Skip to content
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(test): Include the PoseidonHasher in the fuzzing #6280

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -295,7 +295,7 @@
use light_poseidon::{Poseidon, PoseidonHasher};

let poseidon_hash = |inputs: &[FieldElement]| {
let mut poseidon = Poseidon::<ark_bn254::Fr>::new_circom(inputs.len()).unwrap();

Check warning on line 298 in tooling/nargo_cli/tests/stdlib-props.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (circom)
let frs: Vec<ark_bn254::Fr> = inputs.iter().map(|f| f.into_repr()).collect::<Vec<_>>();
let hash = poseidon.hash(&frs).expect("failed to hash");
FieldElement::from_repr(hash)
Expand All @@ -305,7 +305,14 @@
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
Loading