From 28c79aa73fc2aa28d7b4d916d22726ed67c25db1 Mon Sep 17 00:00:00 2001 From: maramihali Date: Tue, 20 Feb 2024 11:43:53 +0000 Subject: [PATCH] typos + make gcc pass --- .../benchmark/ivc_bench/ivc.bench.cpp | 18 ++++++------ .../client_ivc/client_ivc.test.cpp | 15 +++++----- .../client_ivc/mock_kernel_pinning.test.cpp | 28 +++++++++---------- .../src/barretenberg/goblin/mock_circuits.hpp | 14 +++++----- .../protogalaxy/protogalaxy_verifier.cpp | 4 +-- .../protogalaxy/protogalaxy_verifier.hpp | 6 ---- .../protogalaxy_recursive_verifier.test.cpp | 9 +++--- .../ultra_honk/ultra_composer.cpp | 2 +- 8 files changed, 45 insertions(+), 51 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ivc_bench/ivc.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ivc_bench/ivc.bench.cpp index 366fbce42ae0..923b56a80dda 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ivc_bench/ivc.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ivc_bench/ivc.bench.cpp @@ -21,7 +21,7 @@ namespace { class IvcBench : public benchmark::Fixture { public: using Builder = GoblinUltraCircuitBuilder; - using FoldOutput = GoblinMockCircuits::FoldOutput; + using VerifierFoldData = GoblinMockCircuits::VerifierFoldData; // Number of function circuits to accumulate(based on Zacs target numbers) static constexpr size_t NUM_ITERATIONS_MEDIUM_COMPLEXITY = 6; @@ -48,21 +48,21 @@ class IvcBench : public benchmark::Fixture { Builder initial_function_circuit{ ivc.goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(initial_function_circuit); ivc.initialize(initial_function_circuit); - auto kernel_verifeir_accumulator = std::make_shared(); - kernel_verifeir_accumulator->verification_key = ivc.vks.first_func_vk; + auto kernel_verifier_accumulator = std::make_shared(); + kernel_verifier_accumulator->verification_key = ivc.vks.first_func_vk; // Accumulate another function circuit Builder function_circuit{ ivc.goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(function_circuit); auto function_fold_proof = ivc.accumulate(function_circuit); - FoldOutput function_fold_output = { function_fold_proof, ivc.vks.func_vk }; + VerifierFoldData function_fold_output = { function_fold_proof, ivc.vks.func_vk }; // Create and accumulate the first folding kernel which only verifies the accumulation of a function circuit Builder kernel_circuit{ ivc.goblin.op_queue }; - kernel_verifeir_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, {}, kernel_verifeir_accumulator); + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, {}, kernel_verifier_accumulator); auto kernel_fold_proof = ivc.accumulate(kernel_circuit); - FoldOutput kernel_fold_output = { kernel_fold_proof, ivc.vks.first_kernel_vk }; + VerifierFoldData kernel_fold_output = { kernel_fold_proof, ivc.vks.first_kernel_vk }; auto NUM_CIRCUITS = static_cast(state.range(0)); // Subtract one to account for the "initialization" round above @@ -77,8 +77,8 @@ class IvcBench : public benchmark::Fixture { // Create kernel circuit containing the recursive folding verification of a function circuit and a kernel // circuit and accumulate it Builder kernel_circuit{ ivc.goblin.op_queue }; - kernel_verifeir_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifeir_accumulator); + kernel_verifier_accumulator = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, function_fold_output, kernel_fold_output, kernel_verifier_accumulator); kernel_fold_proof = ivc.accumulate(kernel_circuit); kernel_fold_output = { kernel_fold_proof, ivc.vks.kernel_vk }; 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 ebbbb5b52190..9dd76691320c 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -25,7 +25,7 @@ class ClientIVCTests : public ::testing::Test { using VerifierAccumulator = ClientIVC::VerifierAccumulator; using VerifierInstance = ClientIVC::VerifierInstance; using FoldProof = ClientIVC::FoldProof; - using FoldOutput = GoblinMockCircuits::FoldOutput; + using VerifierFoldData = GoblinMockCircuits::VerifierFoldData; using GURecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifierInstance = ::bb::stdlib::recursion::honk::RecursiveVerifierInstance_; using RecursiveVerifierAccumulator = std::shared_ptr; @@ -55,8 +55,8 @@ class ClientIVCTests : public ::testing::Test { * @param kernel_fold_proof */ static VerifierAccumulator construct_mock_folding_kernel(Builder& builder, - FoldOutput& func_accum, - FoldOutput& kernel_accum, + VerifierFoldData& func_accum, + VerifierFoldData& kernel_accum, VerifierAccumulator& prev_kernel_accum) { @@ -90,25 +90,26 @@ TEST_F(ClientIVCTests, Full) FoldProof kernel_fold_proof = ivc.accumulate(kernel_circuit); auto function_vk_2 = composer.compute_verification_key(ivc.prover_instance); auto kernel_vk = function_vk_2; - FoldOutput kernel_fold_output = { kernel_fold_proof, function_vk_2 }; + VerifierFoldData kernel_fold_output = { kernel_fold_proof, function_vk_2 }; size_t NUM_CIRCUITS = 1; for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { // Accumulate function circuit Builder function_circuit = create_mock_circuit(ivc); FoldProof function_fold_proof = ivc.accumulate(function_circuit); - FoldOutput function_fold_output = { function_fold_proof, function_vk_2 }; + VerifierFoldData function_fold_output = { function_fold_proof, function_vk_2 }; // Accumulate kernel circuit Builder kernel_circuit{ ivc.goblin.op_queue }; kernel_acc = construct_mock_folding_kernel(kernel_circuit, kernel_fold_output, function_fold_output, kernel_acc); FoldProof kernel_fold_proof = ivc.accumulate(kernel_circuit); kernel_vk = composer.compute_verification_key(ivc.prover_instance); - FoldOutput kernel_fold_output = { kernel_fold_proof, kernel_vk }; + VerifierFoldData kernel_fold_output = { kernel_fold_proof, kernel_vk }; } // Constuct four proofs: merge, eccvm, translator, decider auto proof = ivc.prove(); - auto inst = std::make_shared(kernel_vk); + auto inst = std::make_shared(); + inst->verification_key = kernel_vk; // Verify all four proofs EXPECT_TRUE(ivc.verify(proof, { kernel_acc, inst })); }; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp index 5011d1753913..d3b322558aee 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp @@ -18,37 +18,37 @@ class MockKernelTest : public ::testing::Test { TEST_F(MockKernelTest, PinFoldingKernelSizes) { - using FoldOutput = GoblinMockCircuits::FoldOutput; ClientIVC ivc; ivc.precompute_folding_verification_keys(); - // Accumulate three circuits to generate two folding proofs for input to foldng kernel + // Accumulate three circuits to generate two folding proofs for input to folding kernel GoblinUltraCircuitBuilder circuit_1{ ivc.goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(circuit_1); ivc.initialize(circuit_1); - auto verifier_acc = std::make_shared(); - verifier_acc->verification_key = ivc.vks.first_func_vk; + auto initial_acc = std::make_shared(); + initial_acc->verification_key = ivc.vks.first_func_vk; GoblinUltraCircuitBuilder circuit_2{ ivc.goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(circuit_2); - auto fold_proof_1 = ivc.accumulate(circuit_2); + auto func_fold_proof = ivc.accumulate(circuit_2); - FoldOutput kernel_accum; // Construct kernel circuit GoblinUltraCircuitBuilder kernel_circuit{ ivc.goblin.op_queue }; - auto new_acc = GoblinMockCircuits::construct_mock_folding_kernel( - kernel_circuit, { fold_proof_1, ivc.vks.func_vk }, {}, verifier_acc); + auto kernel_acc = GoblinMockCircuits::construct_mock_folding_kernel( + kernel_circuit, { func_fold_proof, ivc.vks.func_vk }, {}, initial_acc); - auto fold_proof_3 = ivc.accumulate(kernel_circuit); + auto kernel_fold_proof = ivc.accumulate(kernel_circuit); EXPECT_EQ(ivc.prover_instance->log_instance_size, 17); GoblinUltraCircuitBuilder circuit_4{ ivc.goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(circuit_4); - auto fold_proof_4 = ivc.accumulate(circuit_4); + func_fold_proof = ivc.accumulate(circuit_4); - GoblinUltraCircuitBuilder new_kernel_circuit = GoblinUltraCircuitBuilder{ ivc.goblin.op_queue }; - new_acc = GoblinMockCircuits::construct_mock_folding_kernel( - new_kernel_circuit, { fold_proof_3, ivc.vks.first_kernel_vk }, { fold_proof_4, ivc.vks.func_vk }, new_acc); + kernel_circuit = GoblinUltraCircuitBuilder{ ivc.goblin.op_queue }; + kernel_acc = GoblinMockCircuits::construct_mock_folding_kernel(kernel_circuit, + { kernel_fold_proof, ivc.vks.first_kernel_vk }, + { func_fold_proof, ivc.vks.func_vk }, + kernel_acc); GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(new_kernel_circuit); + auto instance = composer.create_prover_instance(kernel_circuit); EXPECT_EQ(instance->proving_key->log_circuit_size, 17); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index ef009d2cd0f0..8ad82a88973b 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -37,12 +37,12 @@ class GoblinMockCircuits { static constexpr size_t NUM_OP_QUEUE_COLUMNS = Flavor::NUM_WIRES; /** - * @brief - * + * @brief Information required by the verifier to verify a folding round besides the previous accumulator. */ - struct FoldOutput { - std::vector fold_proof; - std::shared_ptr inst_vk; + struct VerifierFoldData { + std::vector fold_proof; // folding proof + std::shared_ptr + inst_vk; // Verification key of the instance to be folded (note: this would be a vector if k > 1 ) }; /** @@ -227,8 +227,8 @@ class GoblinMockCircuits { */ static std::shared_ptr construct_mock_folding_kernel( GoblinUltraBuilder& builder, - const FoldOutput& func, - const FoldOutput& kernel, + const VerifierFoldData& func, + const VerifierFoldData& kernel, std::shared_ptr& prev_kernel_accum) { using GURecursiveFlavor = GoblinUltraRecursiveFlavor_; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 386f326a8d68..ce08bcc400e1 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -142,13 +142,13 @@ std::shared_ptr ProtoGalaxyVerifier_instance_size = accumulator->instance_size; next_accumulator->log_instance_size = accumulator->log_instance_size; next_accumulator->is_accumulator = true; - // Compute next folding parameters and verify against the ones received from the prover + // Compute next folding parameters next_accumulator->target_sum = perturbator_at_challenge * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; next_accumulator->gate_challenges = update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas); - // Compute ϕ and verify against the data received from the prover + // Compute ϕ auto& acc_witness_commitments = next_accumulator->witness_commitments; auto witness_labels = commitment_labels.get_witness(); size_t comm_idx = 0; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp index 05dae2fb4f15..9a39986fe4b9 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp @@ -66,12 +66,6 @@ template class ProtoGalaxyVerifier_ { */ void prepare_for_folding(const std::vector&); - /** - * @brief Instantiatied the accumulator (i.e. the relaxed instance) from the transcript. - * - */ - // void receive_accumulator(const std::shared_ptr&, const std::string&); - /** * @brief Process the public data ϕ for the Instances to be folded. * 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 2b0cce7f9205..d4812bbf2a86 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 @@ -180,14 +180,13 @@ template class ProtoGalaxyRecursiveTests : public tes Builder folding_circuit; auto verifier = FoldingRecursiveVerifier(&folding_circuit, verifier_instance_1, { verifier_instance_2->verification_key }); - auto recursive_verifier_accumulator = verifier.verify_folding_proof(folding_proof.folding_data); - auto acc = std::make_shared(recursive_verifier_accumulator->get_value()); + verifier.verify_folding_proof(folding_proof.folding_data); info("Folding Recursive Verifier: num gates = ", folding_circuit.num_gates); // Perform native folding verification and ensure it returns the same result (either true or false) as // calling check_circuit on the recursive folding verifier auto native_folding_verifier = composer.create_folding_verifier({ verifier_instance_1, verifier_instance_2 }); - auto verifier_accumulator = native_folding_verifier.verify_folding_proof(folding_proof.folding_data); + native_folding_verifier.verify_folding_proof(folding_proof.folding_data); // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring the // manifestsproduced by each agree. @@ -240,7 +239,7 @@ template class ProtoGalaxyRecursiveTests : public tes auto verifier = FoldingRecursiveVerifier(&folding_circuit, verifier_instance_1, { verifier_instance_2->verification_key }); auto recursive_verifier_accumulator = verifier.verify_folding_proof(folding_proof.folding_data); - auto acc = std::make_shared(recursive_verifier_accumulator->get_value()); + auto native_verifier_acc = std::make_shared(recursive_verifier_accumulator->get_value()); info("Folding Recursive Verifier: num gates = ", folding_circuit.num_gates); // Perform native folding verification and ensure it returns the same result (either true or false) as @@ -261,7 +260,7 @@ template class ProtoGalaxyRecursiveTests : public tes auto decider_proof = decider_prover.construct_proof(); Builder decider_circuit; - DeciderRecursiveVerifier decider_verifier{ &decider_circuit, acc }; + DeciderRecursiveVerifier decider_verifier{ &decider_circuit, native_verifier_acc }; auto pairing_points = decider_verifier.verify_proof(decider_proof); info("Decider Recursive Verifier: num gates = ", decider_circuit.num_gates); // Check for a failure flag in the recursive verifier circuit diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index b745f001c5ba..1ed884e8830f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -58,7 +58,7 @@ std::shared_ptr UltraComposer_::comput verification_key->q_poseidon2_internal = commitment_key->commit(proving_key->q_poseidon2_internal); } - return std::move(verification_key); + return verification_key; } template