Skip to content

Commit

Permalink
chore: git subrepo commit (merge) noir (AztecProtocol#4321)
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "noir"
  merged:   "ab74cff2b"
upstream:
  origin:   "https://github.com/noir-lang/noir"
  branch:   "aztec-packages"
  commit:   "2badd023e"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"

Please read [contributing guidelines](CONTRIBUTING.md) and remove this
line.
  • Loading branch information
sirasistant authored Jan 31, 2024
1 parent 7cdc186 commit 348d18a
Show file tree
Hide file tree
Showing 81 changed files with 383 additions and 1,426 deletions.
2 changes: 1 addition & 1 deletion noir/.github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Cut a new version
working-directory: ./docs
run: yarn docusaurus docs:version ${{ steps.noir-version.outputs.semver }}
run: yarn version ${{ steps.noir-version.outputs.semver }}

- name: Configure git
run: |
Expand Down
2 changes: 1 addition & 1 deletion noir/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/noir-lang/noir
branch = aztec-packages
commit = ea6aebcc4e190d9dbadaf1dd0f70950651eed615
commit = 2badd023eab159b7892bd507897bedb360bebebe
parent = 3b25737324e45bdfb49233f73065569301282cc0
method = merge
cmdver = 0.4.6
57 changes: 2 additions & 55 deletions noir/acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,61 +99,8 @@ pub(super) fn transform_internal(
}
}
Opcode::BlackBoxFuncCall(ref func) => {
match func {
acir::circuit::opcodes::BlackBoxFuncCall::AND { output, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::XOR { output, .. } => {
transformer.mark_solvable(*output);
}
acir::circuit::opcodes::BlackBoxFuncCall::RANGE { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntFromLeBytes { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntAdd { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntNeg { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntMul { .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntDiv { .. } => (),
acir::circuit::opcodes::BlackBoxFuncCall::SHA256 { outputs, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::Keccak256 { outputs, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::Keccak256VariableLength {
outputs,
..
}
| acir::circuit::opcodes::BlackBoxFuncCall::Keccakf1600 { outputs, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::Blake2s { outputs, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::Blake3 { outputs, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::BigIntToLeBytes {
outputs, ..
}
| acir::circuit::opcodes::BlackBoxFuncCall::Poseidon2Permutation {
outputs,
..
}
| acir::circuit::opcodes::BlackBoxFuncCall::Sha256Compression {
outputs, ..
} => {
for witness in outputs {
transformer.mark_solvable(*witness);
}
}
acir::circuit::opcodes::BlackBoxFuncCall::FixedBaseScalarMul {
outputs,
..
}
| acir::circuit::opcodes::BlackBoxFuncCall::EmbeddedCurveAdd {
outputs, ..
}
| acir::circuit::opcodes::BlackBoxFuncCall::PedersenCommitment {
outputs,
..
} => {
transformer.mark_solvable(outputs.0);
transformer.mark_solvable(outputs.1);
}
acir::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256k1 { output, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256r1 { output, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::SchnorrVerify { output, .. }
| acir::circuit::opcodes::BlackBoxFuncCall::PedersenHash { output, .. } => {
transformer.mark_solvable(*output);
}
for witness in func.get_outputs_vec() {
transformer.mark_solvable(witness);
}

new_acir_opcode_positions.push(acir_opcode_positions[index]);
Expand Down
25 changes: 22 additions & 3 deletions noir/acvm-repo/acvm_js/src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use js_sys::{Error, JsString};
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
use tracing_web::MakeWebConsoleWriter;
Expand All @@ -7,12 +8,15 @@ use wasm_bindgen::prelude::*;
///
/// @param {LogLevel} level - The maximum level of logging to be emitted.
#[wasm_bindgen(js_name = initLogLevel, skip_jsdoc)]
pub fn init_log_level(filter: String) {
pub fn init_log_level(filter: String) -> Result<(), JsLogInitError> {
// Set the static variable from Rust
use std::sync::Once;

let filter: EnvFilter =
filter.parse().expect("Could not parse log filter while initializing logger");
let filter: EnvFilter = filter.parse().map_err(|err| {
JsLogInitError::constructor(
format!("Could not parse log filter while initializing logger: {err}").into(),
)
})?;

static SET_HOOK: Once = Once::new();
SET_HOOK.call_once(|| {
Expand All @@ -23,4 +27,19 @@ pub fn init_log_level(filter: String) {

tracing_subscriber::registry().with(fmt_layer.with_filter(filter)).init();
});

Ok(())
}

/// `LogInitError` is a raw js error.
/// It'd be ideal that `LogInitError` was a subclass of Error, but for that we'd need to use JS snippets or a js module.
/// Currently JS snippets don't work with a nodejs target. And a module would be too much for just a custom error type.
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Error, js_name = "LogInitError", typescript_type = "LogInitError")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type JsLogInitError;

#[wasm_bindgen(constructor, js_class = "Error")]
fn constructor(message: JsString) -> JsLogInitError;
}
10 changes: 5 additions & 5 deletions noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,11 @@ fn make_return_push(push_value: Expression) -> Statement {
/// Make Return push array
///
/// Translates to:
/// `context.return_values.push_array({push_value})`
fn make_return_push_array(push_value: Expression) -> Statement {
/// `context.return_values.extend_from_array({push_value})`
fn make_return_extend_from_array(push_value: Expression) -> Statement {
make_statement(StatementKind::Semi(method_call(
context_return_values(),
"push_array",
"extend_from_array",
vec![push_value],
)))
}
Expand All @@ -859,14 +859,14 @@ fn make_return_push_array(push_value: Expression) -> Statement {
///
/// Translates to:
/// ```noir
/// `context.return_values.push_array({push_value}.serialize())`
/// `context.return_values.extend_from_array({push_value}.serialize())`
fn make_struct_return_type(expression: Expression) -> Statement {
let serialized_call = method_call(
expression, // variable
"serialize", // method name
vec![], // args
);
make_return_push_array(serialized_call)
make_return_extend_from_array(serialized_call)
}

/// Make array return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ impl AcirContext {
// Operands are booleans.
//
// a ^ b == a + b - 2*a*b
let sum = self.add_var(lhs, rhs)?;
let prod = self.mul_var(lhs, rhs)?;
let sum = self.add_var(lhs, rhs)?;
self.add_mul_var(sum, -FieldElement::from(2_i128), prod)
} else {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
Expand Down Expand Up @@ -461,8 +461,8 @@ impl AcirContext {
if bit_size == 1 {
// Operands are booleans
// a + b - ab
let sum = self.add_var(lhs, rhs)?;
let mul = self.mul_var(lhs, rhs)?;
let sum = self.add_var(lhs, rhs)?;
self.sub_var(sum, mul)
} else {
// Implement OR in terms of AND
Expand Down
17 changes: 17 additions & 0 deletions noir/docs/docs/noir/concepts/data_types/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ fn main() {
}
```

### assert_max_bit_size

Adds a constraint to specify that the field can be represented with `bit_size` number of bits

```rust
fn assert_max_bit_size(self, bit_size: u32)
```

example:

```rust
fn main() {
let field = 2
field.assert_max_bit_size(32);
}
```

### sgn0

Parity of (prime) Field element, i.e. sgn0(x mod p) = 0 if x ∈ \{0, ..., p-1\} is even, otherwise sgn0(x mod p) = 1.
Expand Down

This file was deleted.

Loading

0 comments on commit 348d18a

Please sign in to comment.