-
Notifications
You must be signed in to change notification settings - Fork 219
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(stdlib): Implement Poseidon hash #768
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.
Thank you for this submission, I have added my comments below.
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.
Some quick style suggestions
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.
Looks good, I just have a few comments.
Thanks for the comments. I've incorporated your changes. A couple of things worth noting:
|
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.
It fine for me.
The verification seems to be failing, which could be due to an existing issue.
@ax0 Thank you for the PR and for your patience in getting it merged. It's very much appreciated :) |
Related issue(s)
Resolves #387
Description
This PR implements the Poseidon hash function. It is exposed in the form of a permutation function (
hash::poseidon::permute
) for fixed-length and an absorption function (hash::poseidon::absorb
) for variable-length inputs. Both functions take the usual parameters as inputs in addition to the input state. Instantiations are provided for fixed length inputs of length 2 to 17 ashash::poseidon::bn254::perm::x5_2
, ...,hash::poseidon::bn254::perm::x5_17
for the field size currently used, which are in agreement with those used by Circom. A sponge functionhash::poseidon::bn254::sponge
is provided for variable-length inputs in accordance with a suggested application in §3 of the paper .Summary of changes
Addition of Poseidon hash under
noir_stdlib/src/hash
with corresponding declaration inhash.nr
Dependency additions / changes
Test additions / changes
Two test cases under
nargo/tests/test_data
, separated into permutation tests and a sponge test. The former test agrees with Circom's tests and the latter may be verified in Arkworks using appropriate incantations ofabsorb
andsqueeze_field_elements
. These cases are also listed in theconfig.toml
.Checklist
cargo fmt
with default settings.Additional context