diff --git a/crates/acvm_backend_barretenberg/src/bb/mod.rs b/crates/acvm_backend_barretenberg/src/bb/mod.rs index 3f80c538bf5..7eed61154d7 100644 --- a/crates/acvm_backend_barretenberg/src/bb/mod.rs +++ b/crates/acvm_backend_barretenberg/src/bb/mod.rs @@ -3,7 +3,6 @@ mod contract; mod gates; mod prove; -mod prove_and_verify; mod verify; mod write_vk; diff --git a/crates/acvm_backend_barretenberg/src/bb/prove_and_verify.rs b/crates/acvm_backend_barretenberg/src/bb/prove_and_verify.rs deleted file mode 100644 index c5d3e6e64de..00000000000 --- a/crates/acvm_backend_barretenberg/src/bb/prove_and_verify.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::path::PathBuf; - -use super::{assert_binary_exists, get_binary_path}; - -/// ProveAndVerifyCommand will call the barretenberg binary -/// to create a proof and then verify the proof once created. -/// -/// Note: Functions like this are useful for testing. In a real workflow, -/// ProveCommand and VerifyCommand will be used separately. -#[allow(dead_code)] -struct ProveAndVerifyCommand { - verbose: bool, - crs_path: PathBuf, - is_recursive: bool, - bytecode_path: PathBuf, - witness_path: PathBuf, -} - -#[allow(dead_code)] -impl ProveAndVerifyCommand { - fn run(self) -> bool { - assert_binary_exists(); - let mut command = std::process::Command::new(get_binary_path()); - - command - .arg("prove_and_verify") - .arg("-c") - .arg(self.crs_path) - .arg("-b") - .arg(self.bytecode_path) - .arg("-w") - .arg(self.witness_path); - if self.verbose { - command.arg("-v"); - } - if self.is_recursive { - command.arg("-r"); - } - - command.output().expect("Failed to execute command").status.success() - } -} - -#[test] -#[serial_test::serial] -fn prove_and_verify_command() { - use tempfile::tempdir; - - let bytecode_path = PathBuf::from("./src/1_mul.bytecode"); - let witness_path = PathBuf::from("./src/witness.tr"); - - let temp_directory = tempdir().expect("could not create a temporary directory"); - let temp_directory_path = temp_directory.path(); - let crs_path = temp_directory_path.join("crs"); - - let prove_and_verify_command = ProveAndVerifyCommand { - verbose: true, - crs_path, - is_recursive: false, - bytecode_path, - witness_path, - }; - - let output = prove_and_verify_command.run(); - assert!(output); - drop(temp_directory); -} diff --git a/crates/acvm_backend_barretenberg/src/lib.rs b/crates/acvm_backend_barretenberg/src/lib.rs index 4c71302ac4a..e5da8577406 100644 --- a/crates/acvm_backend_barretenberg/src/lib.rs +++ b/crates/acvm_backend_barretenberg/src/lib.rs @@ -1,25 +1,10 @@ #![warn(unused_crate_dependencies, unused_extern_crates)] #![warn(unreachable_pub)] -// `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 proof_system; mod smart_contract; -/// The number of bytes necessary to store a `FieldElement`. -const FIELD_BYTES: usize = 32; - #[derive(Debug, Default)] pub struct Backend {} diff --git a/crates/acvm_backend_barretenberg/src/proof_system.rs b/crates/acvm_backend_barretenberg/src/proof_system.rs index 7a4eaf6feba..fa6952b947f 100644 --- a/crates/acvm_backend_barretenberg/src/proof_system.rs +++ b/crates/acvm_backend_barretenberg/src/proof_system.rs @@ -9,7 +9,7 @@ use acvm::Language; use tempfile::tempdir; use crate::bb::{GatesCommand, ProveCommand, VerifyCommand, WriteVkCommand}; -use crate::{Backend, BackendError, FIELD_BYTES}; +use crate::{Backend, BackendError}; impl Backend { pub fn np_language(&self) -> Language { @@ -191,7 +191,7 @@ pub(super) fn read_bytes_from_file(path: &Path) -> std::io::Result> { fn remove_public_inputs(num_pub_inputs: usize, proof: &[u8]) -> Vec { // 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() } diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index da3eac653c5..e10fde13d7b 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -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" diff --git a/crates/nargo_cli/src/main.rs b/crates/nargo_cli/src/main.rs index 734dbdca2e7..f4d1e1862fc 100644 --- a/crates/nargo_cli/src/main.rs +++ b/crates/nargo_cli/src/main.rs @@ -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