diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index 320b89353d9..8e9fe75d982 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -46,6 +46,7 @@ fn pedersen_commitment_with_separator(input: [Field; N], separator: } } +#[no_predicates] fn pedersen_commitment_with_separator_noir(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { let mut points = [EmbeddedCurveScalar { lo: 0, hi: 0 }; N]; for i in 0..N { @@ -56,15 +57,19 @@ fn pedersen_commitment_with_separator_noir(input: [Field; N], separa multi_scalar_mul(generators, points) } +#[no_predicates] fn pedersen_hash_with_separator_noir(input: [Field; N], separator: u32) -> Field { let mut scalars: Vec = Vec::from_slice([EmbeddedCurveScalar { lo: 0, hi: 0 }; N].as_slice()); //Vec::new(); for i in 0..N { scalars.set(i, from_field_unsafe(input[i])); } - scalars.push(EmbeddedCurveScalar { lo: N as Field, hi: 0 }); + scalars.push(EmbeddedCurveScalar { lo: N as Field, hi: 0 as Field }); let domain_generators :[EmbeddedCurvePoint; N]= derive_generators("DEFAULT_DOMAIN_SEPARATOR".as_bytes(), separator); - let mut vec_generators = Vec::from_slice(domain_generators.as_slice()); + let mut vec_generators = Vec::new(); + for i in 0..N { + vec_generators.push(domain_generators[i]); + } let length_generator : [EmbeddedCurvePoint; 1] = derive_generators("pedersen_hash_length".as_bytes(), 0); vec_generators.push(length_generator[0]); multi_scalar_mul_slice(vec_generators.slice, scalars.slice)[0] @@ -86,7 +91,7 @@ fn __pedersen_commitment_with_separator(input: [Field; N], separator #[field(bn254)] fn derive_generators(domain_separator_bytes: [u8; M], starting_index: u32) -> [EmbeddedCurvePoint; N] { crate::assert_constant(domain_separator_bytes); - crate::assert_constant(starting_index); + // TODO(https://github.com/noir-lang/noir/issues/5672): Add back assert_constant on starting_index __derive_generators(domain_separator_bytes, starting_index) }