From dbfc1f01abef549fc2bdf48c83e3af9e03c874c0 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 12 Sep 2025 11:08:04 +0000 Subject: [PATCH] chore: remove variable flag from poseidon2 hash --- acvm-repo/bn254_blackbox_solver/src/poseidon2.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/acvm-repo/bn254_blackbox_solver/src/poseidon2.rs b/acvm-repo/bn254_blackbox_solver/src/poseidon2.rs index d756f40a236..1b2bcc612b8 100644 --- a/acvm-repo/bn254_blackbox_solver/src/poseidon2.rs +++ b/acvm-repo/bn254_blackbox_solver/src/poseidon2.rs @@ -543,24 +543,14 @@ impl Poseidon2<'_> { } } -/// Performs a poseidon hash with a sponge construction equivalent to the one in poseidon2.nr -/// -/// The `is_variable_length` parameter is there to so we can produce an equivalent hash with -/// the Barretenberg implementation which distinguishes between variable and fixed length inputs. -/// Set it to true if the input length matches the static size expected by the Noir function. -pub fn poseidon_hash( - inputs: &[FieldElement], - is_variable_length: bool, -) -> Result { +/// Performs a poseidon hash with a sponge construction equivalent to the one in the Barretenberg proving system +pub fn poseidon_hash(inputs: &[FieldElement]) -> Result { let two_pow_64 = 18446744073709551616_u128.into(); let iv = FieldElement::from(inputs.len()) * two_pow_64; let mut sponge = Poseidon2Sponge::new(iv, 3); for input in inputs.iter() { sponge.absorb(*input)?; } - if is_variable_length { - sponge.absorb(FieldElement::from(1u32))?; - } sponge.squeeze() } @@ -650,7 +640,7 @@ mod test { FieldElement::from(3u128), FieldElement::from(4u128), ]; - let result = super::poseidon_hash(&fields, false).expect("should hash successfully"); + let result = super::poseidon_hash(&fields).expect("should hash successfully"); assert_eq!( result, field_from_hex("130bf204a32cac1f0ace56c78b731aa3809f06df2731ebcf6b3464a15788b1b9"),