Skip to content

Commit

Permalink
chore: address code review comments of PR4398 (#4435)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Related to #4170, this PR address comments in PR #4398 

## Summary\*

Add a comment and a sanity check.

## Additional Context



## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
guipublic authored Feb 27, 2024
1 parent a112b30 commit 97bcae2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion acvm-repo/acvm/src/pwg/blackbox/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,22 @@ pub(crate) fn solve_poseidon2_permutation_opcode(
return Err(OpcodeResolutionError::BlackBoxFunctionFailed(
acir::BlackBoxFunc::Poseidon2Permutation,
format!(
"the number of inputs does not match specified length. {} > {}",
"the number of inputs does not match specified length. {} != {}",
inputs.len(),
len
),
));
}
if len as usize != outputs.len() {
return Err(OpcodeResolutionError::BlackBoxFunctionFailed(
acir::BlackBoxFunc::Poseidon2Permutation,
format!(
"the number of outputs does not match specified length. {} != {}",
outputs.len(),
len
),
));
}

// Read witness assignments
let mut state = Vec::new();
Expand Down
3 changes: 2 additions & 1 deletion noir_stdlib/src/hash/poseidon2.nr
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ impl Poseidon2 {
}

fn hash_internal<N>(input: [Field; N], in_len: u32, is_variable_length: bool) -> Field {
let iv : Field = (in_len as Field) * 18446744073709551616;
let two_pow_64 = 18446744073709551616;
let iv : Field = (in_len as Field) * two_pow_64;
let mut sponge = Poseidon2::new(iv);
for i in 0..input.len() {
if i as u32 < in_len {
Expand Down

0 comments on commit 97bcae2

Please sign in to comment.