-
Notifications
You must be signed in to change notification settings - Fork 55
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
Feat/Improve frontend (rust-interface) of sonobe #96
base: main
Are you sure you want to change the base?
Feat/Improve frontend (rust-interface) of sonobe #96
Conversation
Convert to daft because we have better idea to cover this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of prints, this test can do assert_eq
with the expected values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_len
when 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.