Skip to content

Commit

Permalink
feat(test): Include the PoseidonHasher in the fuzzing (#6280)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Related to #6141

## Summary\*

Assert that the `PoseidonHasher` calculates the same hash on dynamic
input as the `hash_<lenght>` function we know it has to call.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
aakoshh authored Oct 11, 2024
1 parent 8232bfa commit afb8a7c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tooling/nargo_cli/tests/stdlib-props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ fn fuzz_poseidon_equivalence() {
for len in 1..light_poseidon::MAX_X5_LEN {
let source = format!(
"fn main(input: [Field; {len}]) -> pub Field {{
std::hash::poseidon::bn254::hash_{len}(input)
let h1 = std::hash::poseidon::bn254::hash_{len}(input);
let h2 = {{
let mut hasher = std::hash::poseidon::PoseidonHasher::default();
input.hash(&mut hasher);
hasher.finish()
}};
assert_eq(h1, h2);
h1
}}"
);

Expand Down

0 comments on commit afb8a7c

Please sign in to comment.