Feat/Improve frontend (rust-interface) of sonobe #96
Feat/Improve frontend (rust-interface) of sonobe #96vuvoth wants to merge 7 commits intoprivacy-ethereum:mainfrom
Conversation
|
Convert to daft because we have better idea to cover this PR. |
arnaucube
left a comment
There was a problem hiding this comment.
This is a good idea! Did a first pass, I will try to check more in deep the macro, because ideally it would be nice to support vectors and nested structs.
| } | ||
| } | ||
|
|
||
| impl #impl_generics From<Vec #ty_generics> for #iden #ty_generics { |
There was a problem hiding this comment.
There are parts of the code that seem to work with vectors, but when I try to use for example
struct State<F: PrimeField> {
a: F,
b: F,
c: Vec<F>, // vector
d: (F, F), // tuple
}it fails with an error for both cases (vector & tuple). Is it expected?
To put an example of usage, this is the Grapevine circuit (Circom, but taking it as a real-world sample), where they use mostly vectors for the external_inputs: https://github.com/Mach-34/grapevine-sonobe/blob/556d570e807d08557d7a2a233e4637b00ab4eafa/circom/grapevine.circom#L21
There was a problem hiding this comment.
I will check it :D and update it soon
| println!("{:?}", State::<Fr>::state_number()); | ||
| println!("{:?}", v); | ||
| println!("{:?}", State::from(v)); |
There was a problem hiding this comment.
Maybe instead of prints, this test can do assert_eq with the expected values?
There was a problem hiding this comment.
This only for compile macro. I added runable test for macro.
|
(Regarding the GithubActions CI complaining, the current errors are due a |
Motivation
In current implement we are using trait FCircuit describe the folding circuit. This trait (interface) is straightforward but have a few limitation:
state_lenwhen we update circuit inputs/outputs.Proposal
Note: This proposal and PR is early proposal. We can discuss and improve it better!
We can build the derive macro help us auto convert vector to State and vice versa. This macro also auto crate Constraint State struct(check example for more details). We also compute number field in State struct and this equal
state_len. We don't support nested data structure yet.After I implemented the idea above. I realized the problem I want to solve is serialize data to vector and deserialize vector to data structure. Maybe serde is elegant solution for this problem.
This PR is prototype.