Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

feat!: remove ComputeMerkleRoot opcode #296

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub enum BlackBoxFunc {
RANGE,
SHA256,
Blake2s,
ComputeMerkleRoot,
SchnorrVerify,
Pedersen,
// 128 here specifies that this function
Expand All @@ -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",
Expand All @@ -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),
Expand Down
21 changes: 0 additions & 21 deletions acir/src/circuit/opcodes/black_box_function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ pub enum BlackBoxFuncCall {
inputs: Vec<FunctionInput>,
outputs: Vec<Witness>,
},
ComputeMerkleRoot {
leaf: FunctionInput,
index: FunctionInput,
hash_path: Vec<FunctionInput>,
output: Witness,
},
SchnorrVerify {
public_key_x: FunctionInput,
public_key_y: FunctionInput,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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![],
Expand Down
8 changes: 0 additions & 8 deletions acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ pub trait PartialWitnessGenerator {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError>;
fn compute_merkle_root(
&self,
initial_witness: &mut WitnessMap,
leaf: &FunctionInput,
index: &FunctionInput,
hash_path: &[FunctionInput],
output: &Witness,
) -> Result<OpcodeResolution, OpcodeResolutionError>;
fn schnorr_verify(
&self,
initial_witness: &mut WitnessMap,
Expand Down
13 changes: 3 additions & 10 deletions acvm/src/pwg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,7 @@ mod test {
) -> Result<OpcodeResolution, OpcodeResolutionError> {
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<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}

fn schnorr_verify(
&self,
_initial_witness: &mut WitnessMap,
Expand All @@ -291,6 +282,7 @@ mod test {
) -> Result<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}

fn pedersen(
&self,
_initial_witness: &mut WitnessMap,
Expand All @@ -299,6 +291,7 @@ mod test {
) -> Result<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}

fn fixed_base_scalar_mul(
&self,
_initial_witness: &mut WitnessMap,
Expand Down
3 changes: 0 additions & 3 deletions acvm/src/pwg/blackbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down