Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Frontend Interface #32

Closed

Conversation

yugocabrio
Copy link
Contributor

Implement Frontend Interface and Its Traits for R1CS and CCS Extraction

This pull request introduces the Frontend interface as outlined in Issue #15. The interface defines how circuits are connected to folding-schemes, specifically facilitating the extraction of R1CS and CCS structures. Implementations for this interface have been provided for both the Arkworks and Circom frameworks.

Main Changes:

  • Introduced the Frontend trait with methods extract_r1cs_and_z and extract_ccs_and_z as per the circuit tool.
  • Implemented the Frontend trait for the ConstraintSystem from Arkworks and the CircomWrapper from Circom.
  • Provided tests under the frontend_tests module to validate the trait's functionality across both frameworks.

Usage
Arkworks

let cs = ConstraintSystem::<Fr>::new_ref();
let frontend: &dyn Frontend<Projective, Fr> = &cs;
let (r1cs, z_r1cs) = frontend.extract_r1cs_and_z(&[].as_slice()).unwrap();
let (ccs, z_ccs) = frontend.extract_ccs_and_z(&[].as_slice()).unwrap();

Circom

let frontend = CircomWrapper::<Bn254>::new(r1cs_filepath, wasm_filepath);
let (r1cs, z_r1cs) = frontend.extract_r1cs_and_z(&[("input_name", vec![BigInt::from(3)])]).unwrap();
let (ccs, z_ccs) = frontend.extract_ccs_and_z(&[("input_name", vec![BigInt::from(3)])]).unwrap();

Feedback
I kindly request reviewers to verify that the code meets the requirements. Thanks in advance!

@arnaucube
Copy link
Collaborator

I'm afraid that we don't have yet enough info to define a frontend trait interface.
For example, now that we have Nova's AugmentedFCircuit implemented, it is a bit clearer how the frontend trait interface might look, eg. having a method to generate the constraints of the current step and returning the witness vector (eg. generate_step_constraints) to be used as part of the constraints of the AugmentedFCircuit.

Before doing the part of the AugmentedFCircuit in the code, we didn't had awareness of these needs. This can be covered with the current existing methods of extract_{r1cs/z}, but the trait will not be directly the methods that exist in frontend/arkworks & frontend/circom just exposed as a trait as it is in this PR.

I appreciate your effort, and sorry for the radio silence, but for the moment I would suggest to come back at the frontend trait in some time, once other pieces are more advanced and we have the whole picture to evaluate how the trait should look. If you're still interested into this, once we have the other parts more stable I can ping you in the issue #15 with a more complete definition of the trait so you can work on it.

@arnaucube
Copy link
Collaborator

Hi @yugocabrio , we're now in a stage in which we have more clear view on how the whole frontend interface would look like.
The extract_r1cs, extract_z, extract_w_x, extract_r1cs_and_z methods were actually not needed in the frontend interface, but just internally in the folding scheme code (and only two of them), and the frontend/arkworks implementation was not even needed.

The only needed thing for the frontend is to fulfill the interface of the FCircuit. So a task needed now is to update the frontend/circom (code that you already did in #26 ) and adapt it to fit into the FCircuit trait. This is the issue to track it: #55

Would you like to do it? If so, I can ping you once the latest changes (#54) are merged, so then you can work on it.

@yugocabrio
Copy link
Contributor Author

Absolutely! I will be able to work on it from the end of this month. Thanks for letting me know.

@arnaucube
Copy link
Collaborator

Hi, @yugocabrio , is it fine if we close this PR (#32) since you're working on this in #71 ?

@yugocabrio
Copy link
Contributor Author

Yes, it's fine.

@arnaucube
Copy link
Collaborator

Closing this PR since it's being done at the other PR: #71

@arnaucube arnaucube closed this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants