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: expose derived_generators and pedersen_commitment_with_separator from the stdlib #6154

Merged
merged 3 commits into from
Sep 27, 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
13 changes: 6 additions & 7 deletions noir_stdlib/src/hash/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u3
__pedersen_hash_with_separator(input, separator)
}

fn pedersen_commitment_with_separator<let N: u32>(input: [Field; N], separator: u32) -> EmbeddedCurvePoint {
pub fn pedersen_commitment_with_separator<let N: u32>(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 }
Expand Down Expand Up @@ -88,7 +88,7 @@ fn __pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u32)
fn __pedersen_commitment_with_separator<let N: u32>(input: [Field; N], separator: u32) -> [Field; 2] {}

#[field(bn254)]
fn derive_generators<let N: u32, let M: u32>(domain_separator_bytes: [u8; M], starting_index: u32) -> [EmbeddedCurvePoint; N] {
pub fn derive_generators<let N: u32, let M: u32>(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)
Expand All @@ -102,10 +102,10 @@ fn __derive_generators<let N: u32, let M: u32>(
) -> [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
fn from_field_unsafe(scalar: Field) -> 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)
};
Expand Down Expand Up @@ -419,4 +419,3 @@ fn assert_pedersen() {
}
);
}

Loading