Skip to content

Commit

Permalink
chore: remove usage of slices in pedersen hash (noir-lang/noir#6295)
Browse files Browse the repository at this point in the history
chore: remove dead function (noir-lang/noir#6308)
feat: new formatter (noir-lang/noir#6300)
feat: Sync from aztec-packages (noir-lang/noir#6301)
fix: Allow array map on empty arrays (noir-lang/noir#6305)
fix: Display function name and body when inlining recursion limit hit (noir-lang/noir#6291)
feat(interpreter): Comptime derive generators (noir-lang/noir#6303)
fix: enforce correctness of decompositions performed at compile time (noir-lang/noir#6278)
feat: Warn about private types leaking in public functions and struct fields (noir-lang/noir#6296)
chore(docs): refactoring guides and some other nits (noir-lang/noir#6175)
fix: Do not warn on unused self in traits (noir-lang/noir#6298)
fix: Reject invalid expression with in CLI parser (noir-lang/noir#6287)
  • Loading branch information
AztecBot committed Oct 23, 2024
2 parents bc99f15 + 04de75f commit cbfbd84
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
62404d7ff349ddf7551f2efd865adafc5213a742
8dec84793d200dcb524aa5c397d0a84d38974e7e
29 changes: 0 additions & 29 deletions noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,6 @@ impl Ssa {
}

impl Function {
// TODO(https://github.com/noir-lang/noir/issues/6192): are both this and
// TODO: Ssa::unroll_loops_iteratively needed? Likely able to be combined
pub(crate) fn unroll_loops_iteratively(&mut self) -> Result<(), RuntimeError> {
// Try to unroll loops first:
let mut unroll_errors = vec![];
self.try_to_unroll_loops(&mut unroll_errors);

// Keep unrolling until no more errors are found
while !unroll_errors.is_empty() {
let prev_unroll_err_count = unroll_errors.len();

// Simplify the SSA before retrying

// Do a mem2reg after the last unroll to aid simplify_cfg
self.mem2reg();
self.simplify_function();
// Do another mem2reg after simplify_cfg to aid the next unroll
self.mem2reg();

// Unroll again
self.try_to_unroll_loops(&mut unroll_errors);
// If we didn't manage to unroll any more loops, exit
if unroll_errors.len() >= prev_unroll_err_count {
return Err(unroll_errors.swap_remove(0));
}
}
Ok(())
}

pub(crate) fn try_to_unroll_loops(&mut self, errors: &mut Vec<RuntimeError>) {
// Loop unrolling in brillig can lead to a code explosion currently. This can
// also be true for ACIR, but we have no alternative to unrolling in ACIR.
Expand Down
8 changes: 1 addition & 7 deletions noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,11 @@ pub fn multi_scalar_mul<let N: u32>(
}

#[foreign(multi_scalar_mul)]
fn multi_scalar_mul_array_return<let N: u32>(
pub(crate) fn multi_scalar_mul_array_return<let N: u32>(
points: [EmbeddedCurvePoint; N],
scalars: [EmbeddedCurveScalar; N],
) -> [Field; 3] {}

#[foreign(multi_scalar_mul)]
pub(crate) fn multi_scalar_mul_slice(
points: [EmbeddedCurvePoint],
scalars: [EmbeddedCurveScalar],
) -> [Field; 3] {}

// docs:start:fixed_base_scalar_mul
pub fn fixed_base_scalar_mul(scalar: EmbeddedCurveScalar) -> EmbeddedCurvePoint
// docs:end:fixed_base_scalar_mul
Expand Down
23 changes: 11 additions & 12 deletions noir/noir-repo/noir_stdlib/src/hash/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ pub mod sha512;

use crate::default::Default;
use crate::uint128::U128;
use crate::collections::vec::Vec;
use crate::embedded_curve_ops::{
EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, multi_scalar_mul_slice,
EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, multi_scalar_mul_array_return,
};
use crate::meta::derive_via;

Expand Down Expand Up @@ -57,22 +56,22 @@ pub fn pedersen_hash<let N: u32>(input: [Field; N]) -> Field

#[no_predicates]
pub fn pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u32) -> Field {
let mut scalars: Vec<EmbeddedCurveScalar> =
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 as Field });
let mut scalars: [EmbeddedCurveScalar; N + 1] = [EmbeddedCurveScalar { lo: 0, hi: 0 }; N + 1];
let mut generators: [EmbeddedCurvePoint; N + 1] =
[EmbeddedCurvePoint::point_at_infinity(); N + 1];
let domain_generators: [EmbeddedCurvePoint; N] =
derive_generators("DEFAULT_DOMAIN_SEPARATOR".as_bytes(), separator);
let mut vec_generators = Vec::new();

for i in 0..N {
vec_generators.push(domain_generators[i]);
scalars[i] = from_field_unsafe(input[i]);
generators[i] = domain_generators[i];
}
scalars[N] = EmbeddedCurveScalar { lo: N as Field, hi: 0 as Field };

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]
generators[N] = length_generator[0];
multi_scalar_mul_array_return(generators, scalars)[0]
}

#[field(bn254)]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit cbfbd84

Please sign in to comment.