Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
chore: update to use new black box solver interface
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 9, 2023
1 parent 7c48986 commit e7b2549
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 71 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"

[dependencies]
#acvm = { version = "0.11.0", features = ["bn254"] }
acvm = { git = "https://github.com/noir-lang/acvm", rev = "84b5d18d29a111a42bfc1c3d122129c8f062c3db", features=["bn254"] }
acvm = { git = "https://github.com/noir-lang/acvm", rev = "d0bb049f2f120d632ea0e55d0d53a2dc8f5cf27e", features=["bn254"] }

thiserror = "1.0.21"

Expand Down
75 changes: 9 additions & 66 deletions src/acvm_interop/pwg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acvm::acir::circuit::opcodes::FunctionInput;
use acvm::acir::native_types::Witness;
use acvm::acir::BlackBoxFunc;
use acvm::acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness};
use acvm::pwg::{hash, logic, range, signature, witness_to_value, OpcodeResolution};
use acvm::FieldElement;
use acvm::{OpcodeResolutionError, PartialWitnessGenerator};
Expand Down Expand Up @@ -32,14 +32,7 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
logic::and(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::AND,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
logic::and(initial_witness, inputs, outputs)
}

fn xor(
Expand All @@ -48,30 +41,15 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
logic::xor(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::XOR,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
logic::xor(initial_witness, inputs, outputs)
}

fn range(
&self,
initial_witness: &mut BTreeMap<Witness, FieldElement>,
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
range::solve_range_opcode(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::RANGE,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
range::solve_range_opcode(initial_witness, inputs)
}

fn sha256(
Expand All @@ -80,14 +58,7 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
hash::sha256(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::SHA256,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
hash::sha256(initial_witness, inputs, outputs)
}

fn blake2s(
Expand All @@ -96,14 +67,7 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
hash::blake2s256(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::Blake2s,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
hash::blake2s256(initial_witness, inputs, outputs)
}

fn compute_merkle_root(
Expand Down Expand Up @@ -244,14 +208,7 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
hash::hash_to_field_128_security(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::HashToField128Security,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
hash::hash_to_field_128_security(initial_witness, inputs, outputs)
}

fn ecdsa_secp256k1(
Expand All @@ -260,14 +217,7 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
signature::ecdsa::secp256k1_prehashed(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::EcdsaSecp256k1,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
signature::ecdsa::secp256k1_prehashed(initial_witness, inputs, outputs)
}

fn fixed_base_scalar_mul(
Expand Down Expand Up @@ -296,13 +246,6 @@ impl PartialWitnessGenerator for Barretenberg {
inputs: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
hash::keccak256(
initial_witness,
&BlackBoxFuncCall {
name: BlackBoxFunc::Keccak256,
inputs: inputs.to_vec(),
outputs: outputs.to_vec(),
},
)
hash::keccak256(initial_witness, inputs, outputs)
}
}

0 comments on commit e7b2549

Please sign in to comment.