-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add GrainLFRS and PrimeField trait to Poseidon #51
Conversation
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.
We need to audit this code at some point...
I can't give good review, but seems... reasonable?
We would like to have a self-contained poseidon module that works natively with arkworks traits, so that round parameters and constants are generated directly from the field characteristic and not hard-coded as now are. This will further enable current and future zerokit modules that use it to access the same Poseidon implementation.
Can you elaborate a bit on a specific example task that becomes easier to do with this? Can't quite picture it right now.
The two main advantages I see are: i) re-use the same implementation across different modules (and if we need to change/improve something we do it in just one place); ii) be able to instantiate Poseidon on different curves/scalar fields (in case we need to increase the security level to >=128 bits). Another minor advantage: don't mess-up in copy/pasting/verifying round constants (especially when using different curves). |
The first point seems orthogonal to the adding of traits (unless I missed something?), but agree with the second point! |
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.
LGTM assuming tested with nwaku e.g.
I think usage gets clearer in #53 and https://github.com/vacp2p/zerokit/blob/e4767328cda90464fcf8ab299d2488c3671895d8/rln/src/poseidon_hash.rs, i.e. when this implementation is moved to a separate module that accepts traits. Then in your module, e.g. rln, it is enough to instantiate a static poseidon by passing the curve scalar field and (only for now) the round parameters. Constants will then be generated accordingly to the field and round parameters and poseidon would then be ready within your module. Without traits this would not be possible. |
Successfully tested with |
Implements the first two steps of #50.