Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a3bdc7e
feat!: Move WitnessMap type into ACVM to avoid leaking BTreeMap type
phated May 1, 2023
cfc8141
update backend and acvm
phated May 2, 2023
de6448d
chore!: Update to acvm 0.11.0
phated May 8, 2023
b780236
chore: Update nargo core to return backend errors
phated May 8, 2023
383e7b8
chore: Make CliError generic over a Backend
phated May 8, 2023
37dd357
update to latest commit
phated May 9, 2023
d3c2eaf
chore: replace long `Backend` type parameters with `B`
TomAFrench May 9, 2023
866f829
fix grep problems
phated May 9, 2023
31c6eb0
remove unneeded import
phated May 9, 2023
98ac822
feat: adapted to heterogeneous bb calls
sirasistant May 10, 2023
48c9bda
chore: update cargo tomls
sirasistant May 10, 2023
eebe426
test: re enabled sort test
sirasistant May 10, 2023
693d53d
fix: improve variable resolution
sirasistant May 10, 2023
a3095ae
latest master
phated May 10, 2023
ec30813
chore: update `acvm-backend-barretenberg` to 0.1.0 commit
TomAFrench May 11, 2023
1b6dfe1
chore: use `try_vecmap` in old `vecmap` locations
TomAFrench May 11, 2023
04a9f85
chore: add missing `?`
TomAFrench May 11, 2023
9de3f2b
feat: use dummy constructor for bb call
sirasistant May 11, 2023
6e3306a
official release of backend
phated May 11, 2023
bb9890e
chore!: Update to ACVM 0.12.0
phated May 11, 2023
091fad1
Merge remote-tracking branch 'origin/arv/acvm-non-homogeneus-bb-call'…
phated May 11, 2023
aeeceda
Merge branch 'phated/acvm-0.12.0' into phated/witness-map
TomAFrench May 12, 2023
c152a7f
chore: remove unwanted changes from merge
TomAFrench May 12, 2023
4dd1cf6
chore: add `FilesystemError::WitnessMapSerialization`
TomAFrench May 12, 2023
1279c96
temp acvm ref to import WitnessMapError
phated May 12, 2023
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
67 changes: 22 additions & 45 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "0.10.3"
acvm = "0.11.0"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand All @@ -50,3 +50,7 @@ toml = "0.7.2"
url = "2.2.0"
wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] }
wasm-bindgen-test = "0.3.33"

[patch.crates-io]
acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "c395c55b7acc84b10dbe6896398ca4df32b2a48a" }
acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "030a7e7b9ba842f3d307dbab178962b63d0dedcf" }
10 changes: 4 additions & 6 deletions crates/nargo/src/ops/codegen_verifier.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use acvm::SmartContract;

use crate::NargoError;

pub fn codegen_verifier(
backend: &impl SmartContract,
pub fn codegen_verifier<B: SmartContract>(
backend: &B,
verification_key: &[u8],
) -> Result<String, NargoError> {
Ok(backend.eth_contract_from_vk(verification_key))
) -> Result<String, B::Error> {
backend.eth_contract_from_vk(verification_key)
}
7 changes: 4 additions & 3 deletions crates/nargo/src/ops/execute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use acvm::acir::native_types::WitnessMap;
use acvm::pwg::{solve, PartialWitnessGeneratorStatus};
use acvm::PartialWitnessGenerator;
use acvm::{acir::circuit::Circuit, pwg::block::Blocks};
use acvm::{PartialWitnessGenerator, PartialWitnessGeneratorStatus};
use noirc_abi::WitnessMap;

use crate::NargoError;

Expand All @@ -10,7 +11,7 @@ pub fn execute_circuit(
mut initial_witness: WitnessMap,
) -> Result<WitnessMap, NargoError> {
let mut blocks = Blocks::default();
let solver_status = backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?;
let solver_status = solve(backend, &mut initial_witness, &mut blocks, circuit.opcodes)?;
if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) {
todo!("Add oracle support to nargo execute")
}
Expand Down
35 changes: 16 additions & 19 deletions crates/nargo/src/ops/preprocess.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use acvm::ProofSystemCompiler;
use iter_extended::vecmap;
use iter_extended::try_vecmap;
use noirc_driver::{CompiledContract, CompiledProgram};

use crate::{
artifacts::{
contract::{PreprocessedContract, PreprocessedContractFunction},
program::PreprocessedProgram,
},
NargoError,
use crate::artifacts::{
contract::{PreprocessedContract, PreprocessedContractFunction},
program::PreprocessedProgram,
};

// TODO: pull this from backend.
const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg";

pub fn preprocess_program(
backend: &impl ProofSystemCompiler,
pub fn preprocess_program<B: ProofSystemCompiler>(
backend: &B,
compiled_program: CompiledProgram,
) -> Result<PreprocessedProgram, NargoError> {
) -> Result<PreprocessedProgram, B::Error> {
// TODO: currently `compiled_program`'s bytecode is already optimized for the backend.
// In future we'll need to apply those optimizations here.
let optimized_bytecode = compiled_program.circuit;
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode);
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?;

Ok(PreprocessedProgram {
backend: String::from(BACKEND_IDENTIFIER),
Expand All @@ -31,26 +28,26 @@ pub fn preprocess_program(
})
}

pub fn preprocess_contract(
backend: &impl ProofSystemCompiler,
pub fn preprocess_contract<B: ProofSystemCompiler>(
backend: &B,
compiled_contract: CompiledContract,
) -> Result<PreprocessedContract, NargoError> {
let preprocessed_contract_functions = vecmap(compiled_contract.functions, |func| {
) -> Result<PreprocessedContract, B::Error> {
let preprocessed_contract_functions = try_vecmap(compiled_contract.functions, |func| {
// TODO: currently `func`'s bytecode is already optimized for the backend.
// In future we'll need to apply those optimizations here.
let optimized_bytecode = func.bytecode;
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode);
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?;

PreprocessedContractFunction {
Ok(PreprocessedContractFunction {
name: func.name,
function_type: func.function_type,
abi: func.abi,

bytecode: optimized_bytecode,
proving_key,
verification_key,
}
});
})
})?;

Ok(PreprocessedContract {
name: compiled_contract.name,
Expand Down
15 changes: 5 additions & 10 deletions crates/nargo/src/ops/prove.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use acvm::acir::circuit::Circuit;
use acvm::acir::{circuit::Circuit, native_types::WitnessMap};
use acvm::ProofSystemCompiler;
use noirc_abi::WitnessMap;

use crate::NargoError;

pub fn prove_execution(
backend: &impl ProofSystemCompiler,
pub fn prove_execution<B: ProofSystemCompiler>(
backend: &B,
circuit: &Circuit,
solved_witness: WitnessMap,
proving_key: &[u8],
) -> Result<Vec<u8>, NargoError> {
let proof = backend.prove_with_pk(circuit, solved_witness, proving_key);

Ok(proof)
) -> Result<Vec<u8>, B::Error> {
backend.prove_with_pk(circuit, solved_witness, proving_key)
}
15 changes: 5 additions & 10 deletions crates/nargo/src/ops/verify.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
use acvm::acir::circuit::Circuit;
use acvm::acir::{circuit::Circuit, native_types::WitnessMap};
use acvm::ProofSystemCompiler;
use noirc_abi::WitnessMap;

use crate::NargoError;

pub fn verify_proof(
backend: &impl ProofSystemCompiler,
pub fn verify_proof<B: ProofSystemCompiler>(
backend: &B,
circuit: &Circuit,
proof: &[u8],
public_inputs: WitnessMap,
verification_key: &[u8],
) -> Result<bool, NargoError> {
let valid_proof = backend.verify_with_vk(proof, public_inputs, circuit, verification_key);

Ok(valid_proof)
) -> Result<bool, B::Error> {
backend.verify_with_vk(proof, public_inputs, circuit, verification_key)
}
2 changes: 1 addition & 1 deletion crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ termcolor = "1.1.2"
color-eyre = "0.6.2"

# Backends
acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "677f10e07011849f8aa0d75fe80390bb3081b1e5", default-features = false }
acvm-backend-barretenberg = { version = "0.1.2", default-features = false }

[dev-dependencies]
tempdir = "0.3.7"
Expand Down
Loading