From 09d1bbbb5d63e8ca6838a769d59a7190124cb757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Wed, 25 Sep 2024 18:39:44 +0000 Subject: [PATCH 1/3] Make some hash functions pub --- noir_stdlib/src/hash/mod.nr | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index 93bce3c20e1..b1420a47f18 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -36,7 +36,7 @@ pub fn pedersen_hash_with_separator(input: [Field; N], separator: u3 __pedersen_hash_with_separator(input, separator) } -fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { +pub fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { let value = __pedersen_commitment_with_separator(input, separator); if (value[0] == 0) & (value[1] == 0) { EmbeddedCurvePoint { x: 0, y: 0, is_infinite: true } @@ -88,7 +88,7 @@ fn __pedersen_hash_with_separator(input: [Field; N], separator: u32) fn __pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> [Field; 2] {} #[field(bn254)] -fn derive_generators(domain_separator_bytes: [u8; M], starting_index: u32) -> [EmbeddedCurvePoint; N] { +pub fn derive_generators(domain_separator_bytes: [u8; M], starting_index: u32) -> [EmbeddedCurvePoint; N] { crate::assert_constant(domain_separator_bytes); // TODO(https://github.com/noir-lang/noir/issues/5672): Add back assert_constant on starting_index __derive_generators(domain_separator_bytes, starting_index) @@ -105,7 +105,7 @@ fn __derive_generators( // Same as from_field but: // does not assert the limbs are 128 bits // does not assert the decomposition does not overflow the EmbeddedCurveScalar - fn from_field_unsafe(scalar: Field) -> EmbeddedCurveScalar { + pub fn from_field_unsafe(scalar: Field) -> EmbeddedCurveScalar { let (xlo, xhi) = unsafe { crate::field::bn254::decompose_hint(scalar) }; @@ -419,4 +419,3 @@ fn assert_pedersen() { } ); } - From 5c2332abaf788537b914e582c681db4e04e88a49 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:21:00 +0100 Subject: [PATCH 2/3] Update noir_stdlib/src/hash/mod.nr --- noir_stdlib/src/hash/mod.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index b1420a47f18..d7f41804288 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -105,7 +105,7 @@ fn __derive_generators( // Same as from_field but: // does not assert the limbs are 128 bits // does not assert the decomposition does not overflow the EmbeddedCurveScalar - pub fn from_field_unsafe(scalar: Field) -> EmbeddedCurveScalar { +fn from_field_unsafe(scalar: Field) -> EmbeddedCurveScalar { let (xlo, xhi) = unsafe { crate::field::bn254::decompose_hint(scalar) }; From 3fc5e1b10e409fa8174bbbe9459b4773064e7c57 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:21:47 +0100 Subject: [PATCH 3/3] Update mod.nr --- noir_stdlib/src/hash/mod.nr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index d7f41804288..c69c3f9c49e 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -102,9 +102,9 @@ fn __derive_generators( ) -> [EmbeddedCurvePoint; N] {} #[field(bn254)] - // Same as from_field but: - // does not assert the limbs are 128 bits - // does not assert the decomposition does not overflow the EmbeddedCurveScalar +// Same as from_field but: +// does not assert the limbs are 128 bits +// does not assert the decomposition does not overflow the EmbeddedCurveScalar fn from_field_unsafe(scalar: Field) -> EmbeddedCurveScalar { let (xlo, xhi) = unsafe { crate::field::bn254::decompose_hint(scalar)