feat: Add Poseidon-BN254 hash functions #1176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue(s)
Resolves #1162
Description
Following up on the discussion in #1162, this PR adds the more conventional fixed-length Poseidon hash functions in the case of the BN254 field (i.e. using the permutation instances under
std::hash::poseidon::bn254::perm
). These hash functions agree with those used by Circom. These are exposed asstd::hash::poseidon::bn254::hash_1
,std::hash::poseidon::hash_2
, ...,std::hash::poseidon::bn254::hash_16
.Summary of changes
Dependency additions / changes
Test additions / changes
The
poseidonperm_x5_254
test was modified to make use of the appropriate hash functions directly and thus renamed. Both Poseidon tests are still in the wrong place due to thelinear_eval is not 0.
bug (see #1124).Checklist
cargo fmt
with default settings.Documentation needs
Additional context