Skip to content

Commit

Permalink
Merge branch 'standardize-cli' into named-backend
Browse files Browse the repository at this point in the history
* standardize-cli:
  chore: improve types in `acvm-backend-barretenberg` (#2516)
  feat(aztec_noir): abstract kernel return types (#2521)
  chore: remove usage of `expect` in `Backend`
  chore: remove usage of `Backend` trait (#2514)
  chore: delete `ProveAndVerifyCommand` (#2520)
  chore: Remove dead code from `acvm_backend_barretenberg` (#2512)
  chore: only install `tokio-util` dependency on windows (#2425)
  • Loading branch information
TomAFrench committed Sep 1, 2023
2 parents 76de1cc + fb84503 commit dd8a544
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 109 deletions.
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
mod contract;
mod gates;
mod prove;
mod prove_and_verify;
mod verify;
mod write_vk;

Expand Down
68 changes: 0 additions & 68 deletions crates/acvm_backend_barretenberg/src/cli/prove_and_verify.rs

This file was deleted.

15 changes: 0 additions & 15 deletions crates/acvm_backend_barretenberg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,11 @@

use std::path::PathBuf;

// `acvm-backend-barretenberg` can either interact with the Barretenberg backend through a static library
// or through an embedded wasm binary. It does not make sense to include both of these backends at the same time.
// We then throw a compilation error if both flags are set.
#[cfg(all(feature = "native", feature = "wasm"))]
compile_error!("feature \"native\" and feature \"wasm\" cannot be enabled at the same time");

#[cfg(all(feature = "native", target_arch = "wasm32"))]
compile_error!("feature \"native\" cannot be enabled for a \"wasm32\" target");

#[cfg(all(feature = "wasm", target_arch = "wasm32"))]
compile_error!("feature \"wasm\" cannot be enabled for a \"wasm32\" target");

mod bb;
mod cli;
mod proof_system;
mod smart_contract;

/// The number of bytes necessary to store a `FieldElement`.
const FIELD_BYTES: usize = 32;

#[cfg(test)]
fn get_bb() -> Backend {
let bb = Backend::new();
Expand Down
10 changes: 4 additions & 6 deletions crates/acvm_backend_barretenberg/src/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use acvm::Language;
use tempfile::tempdir;

use crate::cli::{GatesCommand, ProveCommand, VerifyCommand, WriteVkCommand};
use crate::{assert_binary_exists, Backend, BackendError, FIELD_BYTES};
use crate::{assert_binary_exists, Backend, BackendError};

impl Backend {
pub fn np_language(&self) -> Language {
Expand Down Expand Up @@ -88,8 +88,7 @@ impl Backend {
witness_path,
proof_path: proof_path.clone(),
}
.run(&binary_path)
.expect("prove command failed");
.run(&binary_path)?;

let proof_with_public_inputs = read_bytes_from_file(&proof_path).unwrap();

Expand Down Expand Up @@ -147,8 +146,7 @@ impl Backend {
bytecode_path,
vk_path_output: vk_path.clone(),
}
.run(&binary_path)
.expect("write vk command failed");
.run(&binary_path)?;

// Verify the proof
let valid_proof = VerifyCommand {
Expand Down Expand Up @@ -195,7 +193,7 @@ pub(super) fn read_bytes_from_file(path: &Path) -> std::io::Result<Vec<u8>> {
fn remove_public_inputs(num_pub_inputs: usize, proof: &[u8]) -> Vec<u8> {
// Barretenberg prepends the public inputs onto the proof so we need to remove
// the first `num_pub_inputs` field elements.
let num_bytes_to_remove = num_pub_inputs * FIELD_BYTES;
let num_bytes_to_remove = num_pub_inputs * (FieldElement::max_num_bytes() as usize);
proof[num_bytes_to_remove..].to_vec()
}

Expand Down
6 changes: 2 additions & 4 deletions crates/acvm_backend_barretenberg/src/smart_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ impl Backend {
bytecode_path,
vk_path_output: vk_path.clone(),
}
.run(&binary_path)
.expect("write vk command failed");
.run(&binary_path)?;

let contract_path = temp_directory_path.join("contract");
ContractCommand {
Expand All @@ -42,8 +41,7 @@ impl Backend {
vk_path,
contract_path: contract_path.clone(),
}
.run(&binary_path)
.expect("contract command failed");
.run(&binary_path)?;

let verification_key_library_bytes = read_bytes_from_file(&contract_path).unwrap();
let verification_key_library = String::from_utf8(verification_key_library_bytes).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ hex = "0.4.2"
termcolor = "1.1.2"
color-eyre = "0.6.2"
tokio = { version = "1.0", features = ["io-std"] }
tokio-util = { version = "0.7.8", features = ["compat"] }

# Backends
acvm-backend-barretenberg = { path = "../acvm_backend_barretenberg" }

[target.'cfg(not(unix))'.dependencies]
tokio-util = { version = "0.7.8", features = ["compat"] }

[dev-dependencies]
tempdir = "0.3.7"
assert_cmd = "2.0.8"
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![forbid(unsafe_code)]
#![warn(unused_extern_crates)]
#![warn(unreachable_pub)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))]

//! Nargo is the package manager for Noir
//! This name was used because it sounds like `cargo` and
Expand Down
Loading

0 comments on commit dd8a544

Please sign in to comment.