Skip to content

Commit

Permalink
feat: expose derived_generators and `pedersen_commitment_with_separ…
Browse files Browse the repository at this point in the history
…ator` from the stdlib (noir-lang/noir#6154)

fix: Pass radix directly to the blackbox (noir-lang/noir#6164)
chore: enable tests on aztec-nr and contracts (noir-lang/noir#6162)
feat(perf): Handle array set optimization across blocks for Brillig functions (noir-lang/noir#6153)
feat: visibility for globals (noir-lang/noir#6161)
feat(perf): Remove useless paired RC instructions within a block during DIE (noir-lang/noir#6160)
chore: deprecate various items in stdlib (noir-lang/noir#6156)
feat: Hoist constant allocation outside of loops (noir-lang/noir#6158)
chore(ci): Update gates diff action to not post Brillig sizes report with no changes (noir-lang/noir#6157)
fix: Do not duplicate constant arrays in brillig (noir-lang/noir#6155)
feat: detect unconstructed structs (noir-lang/noir#6061)
fix: (LSP) make goto and hover work well for attributes (noir-lang/noir#6152)
feat: visibility for type aliases (noir-lang/noir#6058)
feat: Sync from aztec-packages (noir-lang/noir#6151)
feat: allow silencing an unused variable defined via `let` (noir-lang/noir#6149)
feat: simplify sha256 implementation (noir-lang/noir#6142)
  • Loading branch information
AztecBot committed Sep 27, 2024
2 parents b7326d2 + f4826c9 commit 4c6240e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 628 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fd03ea0824835e1d1ae6c1777ae3e1dcfff6ad7d
877b806ee02cb640472c6bb2b1ed7bc76b861a9b
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,7 @@ impl<'block> BrilligBlock<'block> {
let results = dfg.instruction_results(instruction_id);

let source = self.convert_ssa_single_addr_value(arguments[0], dfg);

let radix: u32 = dfg
.get_numeric_constant(arguments[1])
.expect("Radix should be known")
.try_to_u64()
.expect("Radix should fit in u64")
.try_into()
.expect("Radix should be u32");
let radix = self.convert_ssa_single_addr_value(arguments[1], dfg);

let target_array = self
.variables
Expand Down Expand Up @@ -595,13 +588,17 @@ impl<'block> BrilligBlock<'block> {
)
.extract_array();

let two = self.brillig_context.make_usize_constant_instruction(2_usize.into());

self.brillig_context.codegen_to_radix(
source,
target_array,
2,
two,
matches!(endianness, Endian::Big),
true,
);

self.brillig_context.deallocate_single_addr(two);
}

// `Intrinsic::AsWitness` is used to provide hints to acir-gen on optimal expression splitting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,20 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
&mut self,
source_field: SingleAddrVariable,
target_array: BrilligArray,
radix: u32,
radix: SingleAddrVariable,
big_endian: bool,
output_bits: bool, // If true will generate bit limbs, if false will generate byte limbs
) {
assert!(source_field.bit_size == F::max_num_bits());
assert!(radix.bit_size == 32);

self.codegen_initialize_array(target_array);

let heap_array = self.codegen_brillig_array_to_heap_array(target_array);

let radix_var = self.make_constant_instruction(F::from(radix as u128), 32);

self.black_box_op_instruction(BlackBoxOp::ToRadix {
input: source_field.address,
radix: radix_var.address,
radix: radix.address,
output: heap_array,
output_bits,
});
Expand All @@ -93,6 +92,5 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
self.deallocate_single_addr(items_len);
}
self.deallocate_register(heap_array.pointer);
self.deallocate_register(radix_var.address);
}
}
13 changes: 6 additions & 7 deletions noir/noir-repo/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() {
}
);
}

This file was deleted.

Loading

0 comments on commit 4c6240e

Please sign in to comment.