Skip to content

Commit

Permalink
git subrepo pull --force noir/noir-repo
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "noir/noir-repo"
  merged:   "f2f8ecc833"
upstream:
  origin:   "https://github.com/noir-lang/noir"
  branch:   "master"
  commit:   "f2f8ecc833"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"
  • Loading branch information
TomAFrench committed Jun 24, 2024
1 parent b77204a commit 64a16e2
Show file tree
Hide file tree
Showing 88 changed files with 1,388 additions and 2,024 deletions.
2 changes: 1 addition & 1 deletion noir/noir-repo/.aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58e15edf7fd3d32267b0aed883fc84f6cee327c9
12af650f0d27c37dca06bb329bf76a5574534d78
7 changes: 1 addition & 6 deletions noir/noir-repo/.github/scripts/cargo-binstall-install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env bash
set -eu

if [ command -v cargo-binstall &> /dev/null ]; then
cargo-binstall cargo-binstall -y
else
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
fi

curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
4 changes: 2 additions & 2 deletions noir/noir-repo/.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 = master
commit = a6016b46abf6da6de4566cf6d35a675d805dd9b5
parent = 6c7062443ae23cc75ac06b7ac1492d12f803d0e5
commit = f2f8ecc833d4725d0829f9c339389c90d1a4fbcd
parent = b77204a75c0bbe0850994e37e6f6ab21c9478446
method = merge
cmdver = 0.4.6
57 changes: 3 additions & 54 deletions noir/noir-repo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions noir/noir-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ members = [
"tooling/noirc_abi",
"tooling/noirc_abi_wasm",
"tooling/acvm_cli",
"tooling/profiler",
# ACVM
"acvm-repo/acir_field",
"acvm-repo/acir",
Expand All @@ -37,7 +36,7 @@ members = [
# Utility crates
"utils/iter-extended",
]
default-members = ["tooling/nargo_cli", "tooling/acvm_cli", "tooling/profiler"]
default-members = ["tooling/nargo_cli", "tooling/acvm_cli"]
resolver = "2"

[workspace.package]
Expand Down Expand Up @@ -85,7 +84,7 @@ acvm_cli = { path = "tooling/acvm_cli" }
# Arkworks
ark-bn254 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = ["curve"] }
grumpkin = { version = "0.1.0", package = "noir_grumpkin", features = ["std"] }
grumpkin = { version = "0.1.0", package = "noir_grumpkin", features = ["std"] }
ark-ec = { version = "^0.4.0", default-features = false }
ark-ff = { version = "^0.4.0", default-features = false }
ark-std = { version = "^0.4.0", default-features = false }
Expand Down Expand Up @@ -144,7 +143,6 @@ similar-asserts = "1.5.0"
tempfile = "3.6.0"
jsonrpc = { version = "0.16.0", features = ["minreq_http"] }
flate2 = "1.0.24"
color-eyre = "0.6.2"
rand = "0.8.5"
proptest = "1.2.0"
proptest-derive = "0.4.0"
Expand Down
12 changes: 6 additions & 6 deletions noir/noir-repo/acvm-repo/acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ pub enum BlackBoxFunc {
///
/// [grumpkin]: https://hackmd.io/@aztec-network/ByzgNxBfd#2-Grumpkin---A-curve-on-top-of-BN-254-for-SNARK-efficient-group-operations
SchnorrVerify,
/// Deprecated. To be removed with a sync from aztec-packages
/// Will be deprecated
PedersenCommitment,
/// Deprecated. To be removed with a sync from aztec-packages
/// Will be deprecated
PedersenHash,
/// Verifies a ECDSA signature over the secp256k1 curve.
/// - inputs:
Expand Down Expand Up @@ -227,8 +227,8 @@ impl BlackBoxFunc {
BlackBoxFunc::BigIntToLeBytes => "bigint_to_le_bytes",
BlackBoxFunc::Poseidon2Permutation => "poseidon2_permutation",
BlackBoxFunc::Sha256Compression => "sha256_compression",
BlackBoxFunc::PedersenCommitment => "deprecated pedersen commitment",
BlackBoxFunc::PedersenHash => "deprecated pedersen hash",
BlackBoxFunc::PedersenCommitment => "pedersen_commitment",
BlackBoxFunc::PedersenHash => "pedersen_hash",
}
}

Expand Down Expand Up @@ -257,8 +257,8 @@ impl BlackBoxFunc {
"bigint_to_le_bytes" => Some(BlackBoxFunc::BigIntToLeBytes),
"poseidon2_permutation" => Some(BlackBoxFunc::Poseidon2Permutation),
"sha256_compression" => Some(BlackBoxFunc::Sha256Compression),
"deprecated pedersen commitment" => Some(BlackBoxFunc::PedersenCommitment),
"deprecated pedersen hash" => Some(BlackBoxFunc::PedersenHash),
"pedersen_commitment" => Some(BlackBoxFunc::PedersenCommitment),
"pedersen_hash" => Some(BlackBoxFunc::PedersenHash),
_ => None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ pub enum BlackBoxFuncCall {
message: Vec<FunctionInput>,
output: Witness,
},
/// Deprecated. To be removed with a sync from aztec-packages
/// Will be deprecated
PedersenCommitment {
inputs: Vec<FunctionInput>,
domain_separator: u32,
outputs: (Witness, Witness),
},
/// Deprecated. To be removed with a sync from aztec-packages
/// Will be deprecated
PedersenHash {
inputs: Vec<FunctionInput>,
domain_separator: u32,
Expand Down Expand Up @@ -222,6 +222,8 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::Blake2s { inputs, .. }
| BlackBoxFuncCall::Blake3 { inputs, .. }
| BlackBoxFuncCall::BigIntFromLeBytes { inputs, .. }
| BlackBoxFuncCall::PedersenCommitment { inputs, .. }
| BlackBoxFuncCall::PedersenHash { inputs, .. }
| BlackBoxFuncCall::Poseidon2Permutation { inputs, .. } => inputs.to_vec(),

BlackBoxFuncCall::Keccakf1600 { inputs, .. } => inputs.to_vec(),
Expand Down Expand Up @@ -318,8 +320,6 @@ impl BlackBoxFuncCall {
inputs.push(*key_hash);
inputs
}
BlackBoxFuncCall::PedersenCommitment { .. } => todo!(),
BlackBoxFuncCall::PedersenHash { .. } => todo!(),
}
}

Expand All @@ -341,7 +341,9 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::XOR { output, .. }
| BlackBoxFuncCall::SchnorrVerify { output, .. }
| BlackBoxFuncCall::EcdsaSecp256k1 { output, .. }
| BlackBoxFuncCall::PedersenHash { output, .. }
| BlackBoxFuncCall::EcdsaSecp256r1 { output, .. } => vec![*output],
BlackBoxFuncCall::PedersenCommitment { outputs, .. } => vec![outputs.0, outputs.1],
BlackBoxFuncCall::MultiScalarMul { outputs, .. }
| BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } => {
vec![outputs.0, outputs.1, outputs.2]
Expand All @@ -356,8 +358,6 @@ impl BlackBoxFuncCall {
vec![]
}
BlackBoxFuncCall::BigIntToLeBytes { outputs, .. } => outputs.to_vec(),
BlackBoxFuncCall::PedersenCommitment { .. } => todo!(),
BlackBoxFuncCall::PedersenHash { .. } => todo!(),
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub(crate) mod bigint;
mod embedded_curve_ops;
mod hash;
mod logic;
mod pedersen;
mod range;
mod signature;
pub(crate) mod utils;
Expand All @@ -26,6 +27,7 @@ use embedded_curve_ops::{embedded_curve_add, multi_scalar_mul};
// Hash functions should eventually be exposed for external consumers.
use hash::{solve_generic_256_hash_opcode, solve_sha_256_permutation_opcode};
use logic::{and, xor};
use pedersen::{pedersen, pedersen_hash};
pub(crate) use range::solve_range_opcode;
use signature::{
ecdsa::{secp256k1_prehashed, secp256r1_prehashed},
Expand Down Expand Up @@ -125,6 +127,12 @@ pub(crate) fn solve<F: AcirField>(
message,
*output,
),
BlackBoxFuncCall::PedersenCommitment { inputs, domain_separator, outputs } => {
pedersen(backend, initial_witness, inputs, *domain_separator, *outputs)
}
BlackBoxFuncCall::PedersenHash { inputs, domain_separator, output } => {
pedersen_hash(backend, initial_witness, inputs, *domain_separator, *output)
}
BlackBoxFuncCall::EcdsaSecp256k1 {
public_key_x,
public_key_y,
Expand Down Expand Up @@ -179,7 +187,5 @@ pub(crate) fn solve<F: AcirField>(
BlackBoxFuncCall::Poseidon2Permutation { inputs, outputs, len } => {
solve_poseidon2_permutation_opcode(backend, initial_witness, inputs, outputs, *len)
}
BlackBoxFuncCall::PedersenCommitment { .. } => todo!("Deprecated BlackBox"),
BlackBoxFuncCall::PedersenHash { .. } => todo!("Deprecated BlackBox"),
}
}
47 changes: 47 additions & 0 deletions noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/pedersen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use acir::{
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField,
};

use crate::{
pwg::{insert_value, witness_to_value, OpcodeResolutionError},
BlackBoxFunctionSolver,
};

pub(super) fn pedersen<F: AcirField>(
backend: &impl BlackBoxFunctionSolver<F>,
initial_witness: &mut WitnessMap<F>,
inputs: &[FunctionInput],
domain_separator: u32,
outputs: (Witness, Witness),
) -> Result<(), OpcodeResolutionError<F>> {
let scalars: Result<Vec<_>, _> =
inputs.iter().map(|input| witness_to_value(initial_witness, input.witness)).collect();
let scalars: Vec<_> = scalars?.into_iter().cloned().collect();

let (res_x, res_y) = backend.pedersen_commitment(&scalars, domain_separator)?;

insert_value(&outputs.0, res_x, initial_witness)?;
insert_value(&outputs.1, res_y, initial_witness)?;

Ok(())
}

pub(super) fn pedersen_hash<F: AcirField>(
backend: &impl BlackBoxFunctionSolver<F>,
initial_witness: &mut WitnessMap<F>,
inputs: &[FunctionInput],
domain_separator: u32,
output: Witness,
) -> Result<(), OpcodeResolutionError<F>> {
let scalars: Result<Vec<_>, _> =
inputs.iter().map(|input| witness_to_value(initial_witness, input.witness)).collect();
let scalars: Vec<_> = scalars?.into_iter().cloned().collect();

let res = backend.pedersen_hash(&scalars, domain_separator)?;

insert_value(&output, res, initial_witness)?;

Ok(())
}
2 changes: 1 addition & 1 deletion noir/noir-repo/acvm-repo/acvm_js/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function run_if_available {
require_command jq
require_command cargo
require_command wasm-bindgen
#require_command wasm-opt
require_command wasm-opt

self_path=$(dirname "$(readlink -f "$0")")
pname=$(cargo read-manifest | jq -r '.name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ pub trait BlackBoxFunctionSolver<F> {
signature: &[u8; 64],
message: &[u8],
) -> Result<bool, BlackBoxResolutionError>;
fn pedersen_commitment(
&self,
inputs: &[F],
domain_separator: u32,
) -> Result<(F, F), BlackBoxResolutionError>;
fn pedersen_hash(
&self,
inputs: &[F],
domain_separator: u32,
) -> Result<F, BlackBoxResolutionError>;
fn multi_scalar_mul(
&self,
points: &[F],
Expand Down Expand Up @@ -57,6 +67,21 @@ impl<F> BlackBoxFunctionSolver<F> for StubbedBlackBoxSolver {
) -> Result<bool, BlackBoxResolutionError> {
Err(Self::fail(BlackBoxFunc::SchnorrVerify))
}
fn pedersen_commitment(
&self,
_inputs: &[F],
_domain_separator: u32,
) -> Result<(F, F), BlackBoxResolutionError> {
Err(Self::fail(BlackBoxFunc::PedersenCommitment))
}
fn pedersen_hash(
&self,
_inputs: &[F],
_domain_separator: u32,
) -> Result<F, BlackBoxResolutionError> {
Err(Self::fail(BlackBoxFunc::PedersenHash))
}

fn multi_scalar_mul(
&self,
_points: &[F],
Expand Down
Loading

0 comments on commit 64a16e2

Please sign in to comment.