diff --git a/barretenberg/src/aztec/CMakeLists.txt b/barretenberg/src/aztec/CMakeLists.txt index 7b0328961..239a49721 100644 --- a/barretenberg/src/aztec/CMakeLists.txt +++ b/barretenberg/src/aztec/CMakeLists.txt @@ -1,6 +1,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wno-deprecated -Wno-tautological-compare -Wfatal-errors -Wno-unused-but-set-variable) +add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wno-deprecated -Wno-tautological-compare -Wfatal-errors) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-unguarded-availability-new -Wno-c99-extensions -fconstexpr-steps=100000000) diff --git a/barretenberg/src/aztec/bb/bb.cpp b/barretenberg/src/aztec/bb/bb.cpp index 957139984..281ef3702 100644 --- a/barretenberg/src/aztec/bb/bb.cpp +++ b/barretenberg/src/aztec/bb/bb.cpp @@ -3,4 +3,4 @@ #include #include #include -#include \ No newline at end of file +#include diff --git a/barretenberg/src/aztec/bb/bb.hpp b/barretenberg/src/aztec/bb/bb.hpp index a81c62835..fa40b728f 100644 --- a/barretenberg/src/aztec/bb/bb.hpp +++ b/barretenberg/src/aztec/bb/bb.hpp @@ -5,4 +5,4 @@ #include #include #include -#include +#include diff --git a/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.cpp b/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.cpp index 1836445f6..7cfae5f63 100644 --- a/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.cpp +++ b/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.cpp @@ -22,6 +22,12 @@ WASM_EXPORT uint32_t standard_example__get_circuit_size(uint8_t const* constrain return rollup::proofs::standard_example::c_get_circuit_size(constraint_system_buf); } +// Get the exact circuit size for the constraint system. +WASM_EXPORT uint32_t standard_example__get_exact_circuit_size(uint8_t const* constraint_system_buf) +{ + return rollup::proofs::standard_example::c_get_exact_circuit_size(constraint_system_buf); +} + WASM_EXPORT void standard_example__init_proving_key() { auto crs_factory = std::make_unique(); diff --git a/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.h b/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.h index 37b9b7645..7cdadca70 100644 --- a/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.h +++ b/barretenberg/src/aztec/rollup/proofs/standard_example/c_bind.h @@ -18,6 +18,8 @@ WASM_EXPORT void standard_example__delete_prover(void* prover); WASM_EXPORT bool standard_example__verify_proof(uint8_t* proof, uint32_t length); +WASM_EXPORT uint32_t standard_example__get_exact_circuit_size(uint8_t const* constraint_system_buf); + // Backwards compatibility WASM_EXPORT uint32_t composer__get_circuit_size(uint8_t const* constraint_system_buf); WASM_EXPORT uint32_t composer__smart_contract(void* pippenger, diff --git a/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.cpp b/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.cpp index 4b00c3074..e40dbdec9 100644 --- a/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.cpp +++ b/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.cpp @@ -42,6 +42,16 @@ uint32_t c_get_circuit_size(uint8_t const* constraint_system_buf) return static_cast(circuit_size); } +uint32_t c_get_exact_circuit_size(uint8_t const* constraint_system_buf) +{ + auto constraint_system = from_buffer(constraint_system_buf); + auto crs_factory = std::make_unique(); + auto composer = create_circuit(constraint_system, std::move(crs_factory)); + + auto num_gates = composer.get_num_gates(); + return static_cast(num_gates); +} + void init_proving_key(std::unique_ptr&& crs_factory) { auto composer = create_circuit(*constraint_system, std::move(crs_factory)); diff --git a/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.hpp b/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.hpp index dd7568018..ffcd11f7d 100644 --- a/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.hpp +++ b/barretenberg/src/aztec/rollup/proofs/standard_example/standard_example.hpp @@ -32,6 +32,7 @@ bool verify_proof(waffle::plonk_proof const& proof); // and define the C++ method, we want to call in the standard_example.cpp file void c_init_circuit_def(uint8_t const* constraint_system_buf); uint32_t c_get_circuit_size(uint8_t const* constraint_system_buf); +uint32_t c_get_exact_circuit_size(uint8_t const* constraint_system_buf); size_t c_composer__new_proof(void* pippenger, uint8_t const* g2x, uint8_t const* constraint_system_buf, diff --git a/barretenberg_wrapper/build.rs b/barretenberg_wrapper/build.rs index a8b148d6e..0d1164289 100644 --- a/barretenberg_wrapper/build.rs +++ b/barretenberg_wrapper/build.rs @@ -197,6 +197,12 @@ fn main() { println!("cargo:rustc-link-lib=static=stdlib_schnorr"); println!("cargo:rustc-link-lib=static=stdlib_pedersen"); + println!( + "cargo:rustc-link-search={}/build/src/aztec/rollup/proofs/standard_example", + dst.display() + ); + println!("cargo:rustc-link-lib=static=rollup_proofs_standard_example"); + // Generate bindings from a header file and place them in a bindings.rs file let bindings = bindgen::Builder::default() // Clang args so that we can use relative include paths diff --git a/barretenberg_wrapper/src/composer.rs b/barretenberg_wrapper/src/composer.rs index d085a19cd..ffbfdb5e8 100644 --- a/barretenberg_wrapper/src/composer.rs +++ b/barretenberg_wrapper/src/composer.rs @@ -23,6 +23,10 @@ pub unsafe fn get_circuit_size(cs_prt: *const u8) -> u32 { // TODO test with a circuit of size 2^19 cf: https://github.com/noir-lang/noir/issues/12 } +pub unsafe fn get_exact_circuit_size(cs_prt: *const u8) -> u32 { + standard_example__get_exact_circuit_size(cs_prt) +} + /// # Safety /// pippenger must point to a valid Pippenger object pub unsafe fn create_proof( @@ -47,30 +51,16 @@ pub unsafe fn verify( // This is not the case, if you take the proof directly from Barretenberg pippenger: *mut ::std::os::raw::c_void, proof: &[u8], - public_inputs: &[u8], cs_ptr: &[u8], g2_ptr: &[u8], ) -> bool { let proof_ptr = proof.as_ptr() as *const u8; - let verified; - if !public_inputs.is_empty() { - verified = composer__verify_proof_with_public_inputs( - pippenger, - g2_ptr.as_ptr() as *const u8, - cs_ptr.as_ptr() as *const u8, - public_inputs.as_ptr() as *const u8, - proof_ptr as *mut u8, - proof.len() as u32, - ); - } else { - verified = composer__verify_proof( - pippenger, - g2_ptr.as_ptr() as *const u8, - cs_ptr.as_ptr() as *const u8, - proof_ptr as *mut u8, - proof.len() as u32, - ); - } - - verified + + composer__verify_proof( + pippenger, + g2_ptr.as_ptr() as *const u8, + cs_ptr.as_ptr() as *const u8, + proof_ptr as *mut u8, + proof.len() as u32, + ) }