From 174fc104d68e94b33d4d455f24e38b73a64b534a Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:56:09 +0000 Subject: [PATCH 1/5] fix: depreciated ci image (#4911) --- .circleci/config.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e4c59e004a..e0d02ee2a2c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -114,7 +114,7 @@ jobs: noir-ecr-manifest: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: medium steps: - *checkout @@ -259,7 +259,7 @@ jobs: barretenberg-docs: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -313,7 +313,7 @@ jobs: machine: # NOTE: we usually use alpine build image when making spot images, but # we are not able to upload to S3 with it - image: ubuntu-2204:2023.07.2 + image: default resource_class: medium steps: - *checkout @@ -377,7 +377,7 @@ jobs: bb-js: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -413,7 +413,7 @@ jobs: l1-contracts: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -425,7 +425,7 @@ jobs: noir-projects: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -437,7 +437,7 @@ jobs: boxes-files: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: medium steps: - *checkout @@ -449,7 +449,7 @@ jobs: yarn-project-base: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -461,7 +461,7 @@ jobs: yarn-project: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -473,7 +473,7 @@ jobs: yarn-project-prod: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -509,7 +509,7 @@ jobs: aztec-package: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -521,7 +521,7 @@ jobs: cli: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -533,7 +533,7 @@ jobs: mainnet-fork: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -545,7 +545,7 @@ jobs: aztec-faucet: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -593,7 +593,7 @@ jobs: end-to-end: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -1135,7 +1135,7 @@ jobs: build-docs: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -1165,7 +1165,7 @@ jobs: yellow-paper: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: large steps: - *checkout @@ -1195,7 +1195,7 @@ jobs: bench-summary: machine: - image: ubuntu-2204:2023.07.2 + image: default steps: - *checkout - *setup_env @@ -1206,7 +1206,7 @@ jobs: # Deploy & release jobs. deploy-and-release: machine: - image: ubuntu-2204:2023.07.2 + image: default resource_class: medium steps: - *checkout From e1df28c0e93313ebf267a54517eb4ccc05673499 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Mon, 4 Mar 2024 13:06:13 +0000 Subject: [PATCH 2/5] add some migration notes (#4913) --- docs/docs/misc/migration_notes.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index ff1ca742cd1..29418ce197a 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -6,15 +6,29 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. -## TBD +## 0.25.0 -### Autogenerate `compute_note_hash_and_nullifier` +### [Aztec.nr] No SafeU120 anymore! +Noir now have overflow checks by default. So we don't need SafeU120 like libraries anymore. + +You can replace it with `U128` instead + +Before: +``` +SafeU120::new(0) +``` + +Now: +``` +U128::from_integer(0) +``` +### [Aztec.nr] `compute_note_hash_and_nullifier` is now autogenerated Historically developers have been required to include a `compute_note_hash_and_nullifier` function in each of their contracts. This function is now automatically generated, and all instances of it in contract code can be safely removed. It is possible to provide a user-defined implementation, in which case auto-generation will be skipped (though there are no known use cases for this). -### Updated naming of state variable wrappers +### [Aztec.nr] Updated naming of state variable wrappers We have decided to change the naming of our state variable wrappers because the naming was not clear. The changes are as follows: From 46ee6a88f4c8972bf7c8b60caf14030760590b96 Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 4 Mar 2024 13:25:44 +0000 Subject: [PATCH 3/5] chore(avm-transpiler): minor rust fixes (#4889) * Validate that the catch-all for foreign functions looks like a getter. When I was implementing NOTEHASHEXISTS I was getting a weird assertion failing but what was happening was that I was running the old transpiler on a contract using NOTEHASHEXISTS. The transpiler would go into the catch-all for NOTEHASHEXISTS and then I'd get the assertion that the inputs where not empty. This should make it better. Even better is to have the getter to opcode transformation in the match, but I didn't like the formatting. Using a global Map is not possible in rust. * `&String` is rare. `&str` is better and `&String` autoconverts. --- avm-transpiler/src/transpile.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 82ce26177e6..372a273dbe5 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -233,14 +233,14 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { /// - TODO: support for avm external calls through this function fn handle_foreign_call( avm_instrs: &mut Vec, - function: &String, + function: &str, destinations: &Vec, inputs: &Vec, ) { - match function.as_str() { + match function { "avmOpcodeNoteHashExists" => handle_note_hash_exists(avm_instrs, destinations, inputs), "emitNoteHash" | "emitNullifier" => handle_emit_note_hash_or_nullifier( - function.as_str() == "emitNullifier", + function == "emitNullifier", avm_instrs, destinations, inputs, @@ -252,7 +252,15 @@ fn handle_foreign_call( "poseidon" => { handle_single_field_hash_instruction(avm_instrs, function, destinations, inputs) } - _ => handle_getter_instruction(avm_instrs, function, destinations, inputs), + // Getters. + _ if inputs.len() == 0 && destinations.len() == 1 => { + handle_getter_instruction(avm_instrs, function, destinations, inputs) + } + // Anything else. + _ => panic!( + "Transpiler doesn't know how to process ForeignCall function {}", + function + ), } } @@ -384,7 +392,7 @@ fn handle_nullifier_exists( /// to reason about. In order to decrease user friction we will use two field outputs. fn handle_2_field_hash_instruction( avm_instrs: &mut Vec, - function: &String, + function: &str, destinations: &[ValueOrArray], inputs: &[ValueOrArray], ) { @@ -405,7 +413,7 @@ fn handle_2_field_hash_instruction( _ => panic!("Keccak | Poseidon address destination should be a single value"), }; - let opcode = match function.as_str() { + let opcode = match function { "keccak256" => AvmOpcode::KECCAK, "sha256" => AvmOpcode::SHA256, _ => panic!( @@ -443,7 +451,7 @@ fn handle_2_field_hash_instruction( /// representation. fn handle_single_field_hash_instruction( avm_instrs: &mut Vec, - function: &String, + function: &str, destinations: &[ValueOrArray], inputs: &[ValueOrArray], ) { @@ -461,7 +469,7 @@ fn handle_single_field_hash_instruction( _ => panic!("Poseidon address destination should be a single value"), }; - let opcode = match function.as_str() { + let opcode = match function { "poseidon" => AvmOpcode::POSEIDON, _ => panic!( "Transpiler doesn't know how to process ForeignCall function {:?}", @@ -497,20 +505,21 @@ fn handle_single_field_hash_instruction( /// - ... fn handle_getter_instruction( avm_instrs: &mut Vec, - function: &String, + function: &str, destinations: &Vec, inputs: &Vec, ) { // For the foreign calls we want to handle, we do not want inputs, as they are getters assert!(inputs.is_empty()); assert!(destinations.len() == 1); + let dest_offset_maybe = destinations[0]; let dest_offset = match dest_offset_maybe { ValueOrArray::MemoryAddress(dest_offset) => dest_offset.0, _ => panic!("ForeignCall address destination should be a single value"), }; - let opcode = match function.as_str() { + let opcode = match function { "address" => AvmOpcode::ADDRESS, "storageAddress" => AvmOpcode::STORAGEADDRESS, "origin" => AvmOpcode::ORIGIN, @@ -529,6 +538,7 @@ fn handle_getter_instruction( function ), }; + avm_instrs.push(AvmInstruction { opcode, indirect: Some(ALL_DIRECT), From 8619c084cdfd061f284058b00a96f16fbbca65bf Mon Sep 17 00:00:00 2001 From: maramihali Date: Mon, 4 Mar 2024 13:37:32 +0000 Subject: [PATCH 4/5] fix: Remove the `VerificationKey` from `ProverInstance` (#4908) In PR #4639 I introduced a tiny regression after doing the final master merge: while the VerificationKey wasn't used anymore in the PG prover workflow, as the PR aimed, it remained computed (and retrieved in some places) from the prover instance which nullified the benefits of precomputing verification keys for benchmarks. This PR addresses this. # Benchmark ### Before ``` ninja: no work to do. Benchmarking lock created at ~/BENCHMARK_IN_PROGRESS. client_ivc_bench 100% 16MB 55.4MB/s 00:00 2024-03-04T11:23:39+00:00 Running ./client_ivc_bench Run on (16 X 3606.39 MHz CPU s) CPU Caches: L1 Data 32 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1024 KiB (x8) L3 Unified 36608 KiB (x1) Load Average: 0.13, 0.72, 0.40 ---------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------- ClientIVCBench/Full/6 32647 ms 26672 ms 1 Benchmarking lock deleted. ``` ### After ``` client_ivc_bench 100% 16MB 52.0MB/s 00:00 2024-03-04T11:19:11+00:00 Running ./client_ivc_bench Run on (16 X 3596.99 MHz CPU s) CPU Caches: L1 Data 32 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1024 KiB (x8) L3 Unified 36608 KiB (x1) Load Average: 0.00, 0.00, 0.00 ---------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------- ClientIVCBench/Full/6 29206 ms 24549 ms 1 ``` --- .../barretenberg/client_ivc/client_ivc.cpp | 9 +++++---- .../client_ivc/client_ivc.test.cpp | 8 +++++--- .../cpp/src/barretenberg/goblin/goblin.hpp | 7 +++++-- .../honk/verifier/goblin_verifier.test.cpp | 20 ++++++++++++------- .../honk/verifier/merge_verifier.test.cpp | 4 +++- .../protogalaxy_recursive_verifier.test.cpp | 7 +++++-- .../recursion/honk/verifier/verifier.test.cpp | 17 +++++++++------- .../sumcheck/instance/prover_instance.hpp | 2 -- .../ultra_honk/databus_composer.test.cpp | 3 ++- .../ultra_honk/goblin_ultra_composer.test.cpp | 3 ++- .../goblin_ultra_transcript.test.cpp | 7 +++++-- .../ultra_honk/ultra_composer.cpp | 3 ++- .../ultra_honk/ultra_composer.hpp | 1 - .../ultra_honk/ultra_composer.test.cpp | 8 ++++++-- .../ultra_honk/ultra_transcript.test.cpp | 7 +++++-- 15 files changed, 68 insertions(+), 38 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp index 911c802ebf8..a17021b803c 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp @@ -91,13 +91,14 @@ HonkProof ClientIVC::decider_prove() const void ClientIVC::precompute_folding_verification_keys() { using VerifierInstance = VerifierInstance_; + using VerificationKey = Flavor::VerificationKey; ClientCircuit initial_function_circuit{ goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(initial_function_circuit); // Initialise both the first prover and verifier accumulator from the inital function circuit initialize(initial_function_circuit); - vks.first_func_vk = prover_fold_output.accumulator->verification_key; + vks.first_func_vk = std::make_shared(prover_fold_output.accumulator->proving_key); auto initial_verifier_acc = std::make_shared(vks.first_func_vk); // Accumulate the next function circuit @@ -106,14 +107,14 @@ void ClientIVC::precompute_folding_verification_keys() auto function_fold_proof = accumulate(function_circuit); // Create its verification key (we have called accumulate so it includes the recursive merge verifier) - vks.func_vk = prover_instance->verification_key; + vks.func_vk = std::make_shared(prover_instance->proving_key); // Create the initial kernel iteration and precompute its verification key ClientCircuit kernel_circuit{ goblin.op_queue }; auto kernel_acc = GoblinMockCircuits::construct_mock_folding_kernel( kernel_circuit, { function_fold_proof, vks.func_vk }, {}, initial_verifier_acc); auto kernel_fold_proof = accumulate(kernel_circuit); - vks.first_kernel_vk = prover_instance->verification_key; + vks.first_kernel_vk = std::make_shared(prover_instance->proving_key); // Create another mock function circuit to run the full kernel function_circuit = ClientCircuit{ goblin.op_queue }; @@ -126,7 +127,7 @@ void ClientIVC::precompute_folding_verification_keys() kernel_circuit, { function_fold_proof, vks.func_vk }, { kernel_fold_proof, vks.first_kernel_vk }, kernel_acc); kernel_fold_proof = accumulate(kernel_circuit); - vks.kernel_vk = prover_instance->verification_key; + vks.kernel_vk = std::make_shared(prover_instance->proving_key); // Clean the ivc state goblin.op_queue = std::make_shared(); diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 45e594f47a9..1f985351bbf 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -105,18 +105,20 @@ class ClientIVCTests : public ::testing::Test { */ TEST_F(ClientIVCTests, Full) { + using VerificationKey = Flavor::VerificationKey; + ClientIVC ivc; // Initialize IVC with function circuit Builder function_circuit = create_mock_circuit(ivc); ivc.initialize(function_circuit); - auto function_vk = ivc.prover_fold_output.accumulator->verification_key; + auto function_vk = std::make_shared(ivc.prover_fold_output.accumulator->proving_key); auto foo_verifier_instance = std::make_shared(function_vk); // Accumulate kernel circuit (first kernel mocked as simple circuit since no folding proofs yet) Builder kernel_circuit = create_mock_circuit(ivc); FoldProof kernel_fold_proof = ivc.accumulate(kernel_circuit); // This will have a different verification key because we added the recursive merge verification to the circuit - auto function_vk_with_merge = ivc.prover_instance->verification_key; + auto function_vk_with_merge = std::make_shared(ivc.prover_instance->proving_key); auto kernel_vk = function_vk_with_merge; auto intermediary_acc = update_accumulator_and_decide_native( ivc.prover_fold_output.accumulator, kernel_fold_proof, foo_verifier_instance, kernel_vk); @@ -137,7 +139,7 @@ TEST_F(ClientIVCTests, Full) foo_verifier_instance = construct_mock_folding_kernel( kernel_circuit, kernel_fold_output, function_fold_output, foo_verifier_instance); FoldProof kernel_fold_proof = ivc.accumulate(kernel_circuit); - kernel_vk = ivc.prover_instance->verification_key; + kernel_vk = std::make_shared(ivc.prover_instance->proving_key); intermediary_acc = update_accumulator_and_decide_native( ivc.prover_fold_output.accumulator, kernel_fold_proof, intermediary_acc, kernel_vk); diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 3b055844b2f..1dece4eed0e 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -36,6 +36,7 @@ class Goblin { using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; using MergeProver = bb::MergeProver_; using MergeVerifier = bb::MergeVerifier_; + using VerificationKey = GoblinUltraFlavor::VerificationKey; /** * @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key * @@ -105,6 +106,7 @@ class Goblin { // Construct a Honk proof for the main circuit GoblinUltraComposer composer; auto instance = composer.create_prover_instance(circuit_builder); + auto verification_key = std::make_shared(instance->proving_key); auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); @@ -116,7 +118,7 @@ class Goblin { merge_proof_exists = true; } - return { ultra_proof, instance->verification_key }; + return { ultra_proof, verification_key }; }; /** @@ -231,10 +233,11 @@ class Goblin { // Construct a Honk proof for the main circuit GoblinUltraComposer composer; auto instance = composer.create_prover_instance(circuit_builder); + auto verification_key = std::make_shared(instance->proving_key); auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); - accumulator = { ultra_proof, instance->verification_key }; + accumulator = { ultra_proof, verification_key }; // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now since we're not // mocking the first set of ecc ops diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index e37b54487cf..e4b227e57b8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -149,8 +149,7 @@ template class GoblinRecursiveVerifierTest : public testi // Compute native verification key InnerComposer inner_composer; auto instance = inner_composer.create_prover_instance(inner_circuit); - auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK - auto verification_key = instance->verification_key; + auto verification_key = std::make_shared(instance->proving_key); // Instantiate the recursive verifier using the native verification key RecursiveVerifier verifier{ &outer_circuit, verification_key }; @@ -166,7 +165,8 @@ template class GoblinRecursiveVerifierTest : public testi } /** - * @brief Construct a recursive verification circuit for the proof of an inner circuit then call check_circuit on it + * @brief Construct a recursive verification circuit for the proof of an inner circuit then call check_circuit on + it * */ static void test_recursive_verification() @@ -177,12 +177,13 @@ template class GoblinRecursiveVerifierTest : public testi // Generate a proof over the inner circuit InnerComposer inner_composer; auto instance = inner_composer.create_prover_instance(inner_circuit); + auto verification_key = std::make_shared(instance->proving_key); auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_proof(); // Create a recursive verification circuit for the proof of the inner circuit OuterBuilder outer_circuit; - RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; + RecursiveVerifier verifier{ &outer_circuit, verification_key }; auto pairing_points = verifier.verify_proof(inner_proof); info("Recursive Verifier Goblin: num gates = ", outer_circuit.num_gates); @@ -191,7 +192,7 @@ template class GoblinRecursiveVerifierTest : public testi // Check 1: Perform native verification then perform the pairing on the outputs of the recursive // verifier and check that the result agrees. - auto native_verifier = inner_composer.create_verifier(instance->verification_key); + auto native_verifier = inner_composer.create_verifier(verification_key); auto native_result = native_verifier.verify_proof(inner_proof); auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(), pairing_points[1].get_value()); @@ -210,7 +211,9 @@ template class GoblinRecursiveVerifierTest : public testi auto composer = get_outer_composer(); auto instance = composer.create_prover_instance(outer_circuit); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + TODO: // github.com/AztecProtocol/barretenberg/issues/892 + auto verifier_instance = composer.create_verifier_instance(instance); + auto verifier = composer.create_verifier(verifier_instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -241,9 +244,12 @@ template class GoblinRecursiveVerifierTest : public testi inner_prover.transcript->serialize_full_transcript(); inner_proof = inner_prover.export_proof(); + // Generate the corresponding inner verification key + auto inner_verification_key = std::make_shared(instance->proving_key); + // Create a recursive verification circuit for the proof of the inner circuit OuterBuilder outer_circuit; - RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; + RecursiveVerifier verifier{ &outer_circuit, inner_verification_key }; verifier.verify_proof(inner_proof); // We expect the circuit check to fail due to the bad proof diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 9b4ee8d37e1..ca58db33acc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -83,7 +83,9 @@ class RecursiveMergeVerifierTest : public testing::Test { GoblinUltraComposer composer; auto instance = composer.create_prover_instance(outer_circuit); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + // TODO: github.com/AztecProtocol/barretenberg/issues/892 + auto verifier_instance = composer.create_verifier_instance(instance); + auto verifier = composer.create_verifier(verifier_instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index 55eb6116770..10f05b58fdf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -19,6 +19,7 @@ template class ProtoGalaxyRecursiveTests : public tes using Curve = bn254; using Commitment = typename NativeFlavor::Commitment; using FF = typename NativeFlavor::FF; + using VerificationKey = typename NativeFlavor::VerificationKey; using RecursiveVerifierInstances = ::bb::stdlib::recursion::honk::RecursiveVerifierInstances_; using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; @@ -205,7 +206,8 @@ template class ProtoGalaxyRecursiveTests : public tes auto composer = Composer(); auto instance = composer.create_prover_instance(folding_circuit); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -295,7 +297,8 @@ template class ProtoGalaxyRecursiveTests : public tes auto composer = Composer(); auto instance = composer.create_prover_instance(decider_circuit); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index 3dda0156bee..fd1eddeebe1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -33,7 +33,6 @@ template class RecursiveVerifierTest : public testing::Te using RecursiveFlavor = UltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; using OuterBuilder = BuilderType; - using VerificationKey = typename RecursiveVerifier::VerificationKey; // Helper for getting composer for prover/verifier of recursive (outer) circuit template static auto get_outer_composer() @@ -133,8 +132,7 @@ template class RecursiveVerifierTest : public testing::Te // Compute native verification key InnerComposer inner_composer; auto instance = inner_composer.create_prover_instance(inner_circuit); - auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK - auto verification_key = instance->verification_key; + auto verification_key = std::make_shared(instance->proving_key); // Instantiate the recursive verifier using the native verification key RecursiveVerifier verifier{ &outer_circuit, verification_key }; @@ -164,9 +162,11 @@ template class RecursiveVerifierTest : public testing::Te auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_proof(); + auto verification_key = std::make_shared(instance->proving_key); + // Create a recursive verification circuit for the proof of the inner circuit OuterBuilder outer_circuit; - RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; + RecursiveVerifier verifier{ &outer_circuit, verification_key }; auto pairing_points = verifier.verify_proof(inner_proof); info("Recursive Verifier Ultra: num gates = ", outer_circuit.num_gates); @@ -175,7 +175,7 @@ template class RecursiveVerifierTest : public testing::Te // Check 1: Perform native verification then perform the pairing on the outputs of the recursive // verifier and check that the result agrees. - auto native_verifier = inner_composer.create_verifier(instance->verification_key); + auto native_verifier = inner_composer.create_verifier(verification_key); auto native_result = native_verifier.verify_proof(inner_proof); auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(), pairing_points[1].get_value()); @@ -194,7 +194,8 @@ template class RecursiveVerifierTest : public testing::Te auto composer = get_outer_composer(); auto instance = composer.create_prover_instance(outer_circuit); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verifier_instance = composer.create_verifier_instance(instance); + auto verifier = composer.create_verifier(verifier_instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -226,9 +227,11 @@ template class RecursiveVerifierTest : public testing::Te inner_prover.transcript->serialize_full_transcript(); inner_proof = inner_prover.export_proof(); + auto verification_key = std::make_shared(instance->proving_key); + // Create a recursive verification circuit for the proof of the inner circuit OuterBuilder outer_circuit; - RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; + RecursiveVerifier verifier{ &outer_circuit, verification_key }; verifier.verify_proof(inner_proof); // We expect the circuit check to fail due to the bad proof diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index 6c83c5210d8..c11f3ebb74a 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -36,7 +36,6 @@ template class ProverInstance_ { // currently commitment_key needs to be here, and not accessed through the proving key, since sometimes the proving // key is null during protogalaxy proving (TODO(https://github.com/AztecProtocol/barretenberg/issues/881)?) std::shared_ptr commitment_key; - std::shared_ptr verification_key; ProverPolynomials prover_polynomials; WitnessCommitments witness_commitments; @@ -92,7 +91,6 @@ template class ProverInstance_ { sorted_polynomials = construct_sorted_list_polynomials(circuit, dyadic_circuit_size); - verification_key = std::make_shared(proving_key); commitment_key = proving_key->commitment_key; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index 6af08ef87f7..a073c1f1aba 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -87,7 +87,8 @@ TEST_F(DataBusComposerTests, CallDataRead) auto instance = composer.create_prover_instance(builder); // For debugging, use "instance_inspector::print_databus_info(instance)" auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 43ff53ffb0c..7ac3a91b378 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -64,7 +64,8 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { { auto instance = composer.create_prover_instance(builder); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 12ae627a62f..91c5afbb36a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -14,6 +14,7 @@ class GoblinUltraTranscriptTests : public ::testing::Test { using Flavor = GoblinUltraFlavor; using FF = Flavor::FF; + using VerificationKey = Flavor::VerificationKey; /** * @brief Construct a manifest for a GoblinUltra Honk proof @@ -177,7 +178,8 @@ TEST_F(GoblinUltraTranscriptTests, VerifierManifestConsistency) auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); verifier.verify_proof(proof); // Check consistency between the manifests generated by the prover and verifier @@ -226,7 +228,8 @@ TEST_F(GoblinUltraTranscriptTests, StructureTest) auto instance = composer.create_prover_instance(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); EXPECT_TRUE(verifier.verify_proof(proof)); // try deserializing and serializing with no changes and check proof is still valid diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 3cdeefdac7d..506c0d02b81 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -16,7 +16,8 @@ template std::shared_ptr> UltraComposer_::create_verifier_instance( std::shared_ptr>& prover_instance) { - auto instance = std::make_shared(prover_instance->verification_key); + auto verification_key = std::make_shared(prover_instance->proving_key); + auto instance = std::make_shared(verification_key); return instance; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index c87071ccb72..b8635ed9ae9 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -48,7 +48,6 @@ template class UltraComposer_ { DeciderVerifier_ create_decider_verifier( const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); - UltraVerifier_ create_verifier(CircuitBuilder& circuit); UltraVerifier_ create_ultra_with_keccak_verifier(CircuitBuilder& circuit); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 1c4d29f3051..43fda667d0a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -22,6 +22,8 @@ namespace { auto& engine = numeric::get_debug_randomness(); } +using VerificationKey = UltraFlavor::VerificationKey; + std::vector add_variables(auto& circuit_builder, std::vector variables) { std::vector res; @@ -35,7 +37,8 @@ void prove_and_verify(auto& circuit_builder, auto& composer, bool expected_resul { auto instance = composer.create_prover_instance(circuit_builder); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); EXPECT_EQ(verified, expected_result); @@ -200,7 +203,8 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) auto composer = UltraComposer(); auto instance = composer.create_prover_instance(circuit_builder); auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); auto proof = prover.construct_proof(); bool result = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index bb05c2588ba..14afc28f05b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -13,6 +13,7 @@ class UltraTranscriptTests : public ::testing::Test { static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Flavor = UltraFlavor; + using VerificationKey = Flavor::VerificationKey; using FF = Flavor::FF; /** @@ -163,7 +164,8 @@ TEST_F(UltraTranscriptTests, VerifierManifestConsistency) auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); verifier.verify_proof(proof); // Check consistency between the manifests generated by the prover and verifier @@ -212,7 +214,8 @@ TEST_F(UltraTranscriptTests, StructureTest) auto instance = composer.create_prover_instance(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); - auto verifier = composer.create_verifier(instance->verification_key); + auto verification_key = std::make_shared(instance->proving_key); + auto verifier = composer.create_verifier(verification_key); EXPECT_TRUE(verifier.verify_proof(proof)); // try deserializing and serializing with no changes and check proof is still valid From 15df3c08168611f7f65f5837a937031d81bb3566 Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:26:12 +0000 Subject: [PATCH 5/5] fix: cpp build (#4918) --- .../stdlib/recursion/honk/verifier/goblin_verifier.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index e4b227e57b8..b5615b0d0c3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -211,7 +211,7 @@ template class GoblinRecursiveVerifierTest : public testi auto composer = get_outer_composer(); auto instance = composer.create_prover_instance(outer_circuit); auto prover = composer.create_prover(instance); - TODO: // github.com/AztecProtocol/barretenberg/issues/892 + // TODO: github.com/AztecProtocol/barretenberg/issues/892 auto verifier_instance = composer.create_verifier_instance(instance); auto verifier = composer.create_verifier(verifier_instance->verification_key); auto proof = prover.construct_proof();