From 94c4ecbc1d3d0cc6f602501bdaffa660e5b2f69d Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 19 May 2023 08:34:31 +0100 Subject: [PATCH 1/3] feat!: remove `ComputeMerkleRoot` opcode --- acir/src/circuit/black_box_functions.rs | 3 --- .../opcodes/black_box_function_call.rs | 21 ------------------- acvm/src/pwg/blackbox.rs | 3 --- 3 files changed, 27 deletions(-) diff --git a/acir/src/circuit/black_box_functions.rs b/acir/src/circuit/black_box_functions.rs index 84412624a..0925ec509 100644 --- a/acir/src/circuit/black_box_functions.rs +++ b/acir/src/circuit/black_box_functions.rs @@ -13,7 +13,6 @@ pub enum BlackBoxFunc { RANGE, SHA256, Blake2s, - ComputeMerkleRoot, SchnorrVerify, Pedersen, // 128 here specifies that this function @@ -35,7 +34,6 @@ impl BlackBoxFunc { match self { BlackBoxFunc::AES => "aes", BlackBoxFunc::SHA256 => "sha256", - BlackBoxFunc::ComputeMerkleRoot => "compute_merkle_root", BlackBoxFunc::SchnorrVerify => "schnorr_verify", BlackBoxFunc::Blake2s => "blake2s", BlackBoxFunc::Pedersen => "pedersen", @@ -52,7 +50,6 @@ impl BlackBoxFunc { match op_name { "aes" => Some(BlackBoxFunc::AES), "sha256" => Some(BlackBoxFunc::SHA256), - "compute_merkle_root" => Some(BlackBoxFunc::ComputeMerkleRoot), "schnorr_verify" => Some(BlackBoxFunc::SchnorrVerify), "blake2s" => Some(BlackBoxFunc::Blake2s), "pedersen" => Some(BlackBoxFunc::Pedersen), diff --git a/acir/src/circuit/opcodes/black_box_function_call.rs b/acir/src/circuit/opcodes/black_box_function_call.rs index 2c671eb99..137ba6e0f 100644 --- a/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/acir/src/circuit/opcodes/black_box_function_call.rs @@ -44,12 +44,6 @@ pub enum BlackBoxFuncCall { inputs: Vec, outputs: Vec, }, - ComputeMerkleRoot { - leaf: FunctionInput, - index: FunctionInput, - hash_path: Vec, - output: Witness, - }, SchnorrVerify { public_key_x: FunctionInput, public_key_y: FunctionInput, @@ -101,12 +95,6 @@ impl BlackBoxFuncCall { BlackBoxFunc::RANGE => BlackBoxFuncCall::RANGE { input: FunctionInput::dummy() }, BlackBoxFunc::SHA256 => BlackBoxFuncCall::SHA256 { inputs: vec![], outputs: vec![] }, BlackBoxFunc::Blake2s => BlackBoxFuncCall::Blake2s { inputs: vec![], outputs: vec![] }, - BlackBoxFunc::ComputeMerkleRoot => BlackBoxFuncCall::ComputeMerkleRoot { - leaf: FunctionInput::dummy(), - index: FunctionInput::dummy(), - hash_path: vec![], - output: Witness(0), - }, BlackBoxFunc::SchnorrVerify => BlackBoxFuncCall::SchnorrVerify { public_key_x: FunctionInput::dummy(), public_key_y: FunctionInput::dummy(), @@ -145,7 +133,6 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::RANGE { .. } => BlackBoxFunc::RANGE, BlackBoxFuncCall::SHA256 { .. } => BlackBoxFunc::SHA256, BlackBoxFuncCall::Blake2s { .. } => BlackBoxFunc::Blake2s, - BlackBoxFuncCall::ComputeMerkleRoot { .. } => BlackBoxFunc::ComputeMerkleRoot, BlackBoxFuncCall::SchnorrVerify { .. } => BlackBoxFunc::SchnorrVerify, BlackBoxFuncCall::Pedersen { .. } => BlackBoxFunc::Pedersen, BlackBoxFuncCall::HashToField128Security { .. } => BlackBoxFunc::HashToField128Security, @@ -172,13 +159,6 @@ impl BlackBoxFuncCall { } BlackBoxFuncCall::FixedBaseScalarMul { input, .. } | BlackBoxFuncCall::RANGE { input } => vec![*input], - BlackBoxFuncCall::ComputeMerkleRoot { leaf, index, hash_path, .. } => { - let mut inputs = Vec::with_capacity(2 + hash_path.len()); - inputs.push(*leaf); - inputs.push(*index); - inputs.extend(hash_path.iter().copied()); - inputs - } BlackBoxFuncCall::SchnorrVerify { public_key_x, public_key_y, @@ -226,7 +206,6 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::AND { output, .. } | BlackBoxFuncCall::XOR { output, .. } | BlackBoxFuncCall::HashToField128Security { output, .. } - | BlackBoxFuncCall::ComputeMerkleRoot { output, .. } | BlackBoxFuncCall::SchnorrVerify { output, .. } | BlackBoxFuncCall::EcdsaSecp256k1 { output, .. } => vec![*output], BlackBoxFuncCall::RANGE { .. } => vec![], diff --git a/acvm/src/pwg/blackbox.rs b/acvm/src/pwg/blackbox.rs index 71c26870e..e6f73450a 100644 --- a/acvm/src/pwg/blackbox.rs +++ b/acvm/src/pwg/blackbox.rs @@ -59,9 +59,6 @@ pub(crate) fn solve( BlackBoxFuncCall::Blake2s { inputs, outputs } => { blake2s256(initial_witness, inputs, outputs) } - BlackBoxFuncCall::ComputeMerkleRoot { leaf, index, hash_path, output } => { - backend.compute_merkle_root(initial_witness, leaf, index, hash_path, output) - } BlackBoxFuncCall::SchnorrVerify { public_key_x, public_key_y, From aa051731a7847c4a6ec1291e5863573707402bb5 Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 19 May 2023 09:36:44 +0100 Subject: [PATCH 2/3] chore: remove `compute_merkle_root` from `PartialWitnessGenerator` trait --- acvm/src/lib.rs | 8 -------- acvm/src/pwg.rs | 11 +---------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 8c33f64da..bd88df7ab 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -80,14 +80,6 @@ pub trait PartialWitnessGenerator { inputs: &[FunctionInput], outputs: &[Witness], ) -> Result; - fn compute_merkle_root( - &self, - initial_witness: &mut WitnessMap, - leaf: &FunctionInput, - index: &FunctionInput, - hash_path: &[FunctionInput], - output: &Witness, - ) -> Result; fn schnorr_verify( &self, initial_witness: &mut WitnessMap, diff --git a/acvm/src/pwg.rs b/acvm/src/pwg.rs index dc849b6bd..8f925af2c 100644 --- a/acvm/src/pwg.rs +++ b/acvm/src/pwg.rs @@ -270,16 +270,7 @@ mod test { ) -> Result { panic!("Path not trodden by this test") } - fn compute_merkle_root( - &self, - _initial_witness: &mut WitnessMap, - _leaf: &FunctionInput, - _index: &FunctionInput, - _hash_path: &[FunctionInput], - _output: &Witness, - ) -> Result { - panic!("Path not trodden by this test") - } + fn schnorr_verify( &self, _initial_witness: &mut WitnessMap, From 94d5d20e1eb985cb15eb27556bbe8654172c6a1a Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 19 May 2023 09:37:23 +0100 Subject: [PATCH 3/3] chore: whitespace changes --- acvm/src/pwg.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/acvm/src/pwg.rs b/acvm/src/pwg.rs index 8f925af2c..2b8b63aa2 100644 --- a/acvm/src/pwg.rs +++ b/acvm/src/pwg.rs @@ -282,6 +282,7 @@ mod test { ) -> Result { panic!("Path not trodden by this test") } + fn pedersen( &self, _initial_witness: &mut WitnessMap, @@ -290,6 +291,7 @@ mod test { ) -> Result { panic!("Path not trodden by this test") } + fn fixed_base_scalar_mul( &self, _initial_witness: &mut WitnessMap,