From 3bae7339615c34c249cb7e70df081c99f528a33a Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 11 Sep 2024 18:20:20 +0000 Subject: [PATCH 1/8] Add test to check size of two folding verifiers. Result: ``` Running main() from /mnt/user-data/cody/aztec-packages/barretenberg/cpp/build/_deps/gtest-src/googletest/src/gtest_main.cc Note: Google Test filter = ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from ProtogalaxyRecursiveTests/0, where TypeParam = bb::MegaRecursiveFlavor_ > > [ RUN ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest Folding Recursive Verifier: num gates unfinalized = 37272 Folding Recursive Verifier: num gates finalized = 44041 WARNING: Redundant call to finalize_circuit(). Is this intentional? Dyadic size of verifier circuit: 65536 [ OK ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest (1854 ms) [----------] 1 test from ProtogalaxyRecursiveTests/0 (1854 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (1854 ms total) [ PASSED ] 1 test. ``` --- .../protogalaxy_recursive_verifier.test.cpp | 18 ++++++++++++++---- .../mega_circuit_builder.cpp | 12 +++++++----- .../mega_circuit_builder.hpp | 2 +- .../ultra_circuit_builder.cpp | 6 +++++- .../ultra_circuit_builder.hpp | 2 +- .../ultra_honk/decider_proving_key.hpp | 3 +-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp index dfcc4690a34..1ef85425610 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp @@ -175,7 +175,7 @@ template class ProtogalaxyRecursiveTests : public tes * @brief Tests that a valid recursive fold works as expected. * */ - static void test_recursive_folding() + static void test_recursive_folding(const size_t num_verifiers = 1) { // Create two arbitrary circuits for the first round of folding InnerBuilder builder1; @@ -204,10 +204,11 @@ template class ProtogalaxyRecursiveTests : public tes auto verifier = FoldingRecursiveVerifier{ &folding_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } }; - verifier.verify_folding_proof(stdlib_proof); - info("Folding Recursive Verifier: num gates = ", folding_circuit.num_gates); + for (size_t idx = 0; idx < num_verifiers; idx++) { + verifier.verify_folding_proof(stdlib_proof); + } + info("Folding Recursive Verifier: num gates unfinalized = ", folding_circuit.num_gates); EXPECT_EQ(folding_circuit.failed(), false) << folding_circuit.err(); - // Perform native folding verification and ensure it returns the same result (either true or false) as // calling check_circuit on the recursive folding verifier InnerFoldingVerifier native_folding_verifier({ decider_vk_1, decider_vk_2 }); @@ -226,7 +227,11 @@ template class ProtogalaxyRecursiveTests : public tes // Check for a failure flag in the recursive verifier circuit if constexpr (!IsSimulator) { + // inefficiently check finalized size + folding_circuit.finalize_circuit(); + info("Folding Recursive Verifier: num gates finalized = ", folding_circuit.num_gates); auto decider_pk = std::make_shared(folding_circuit); + info("Dyadic size of verifier circuit: ", decider_pk->proving_key.circuit_size); OuterProver prover(decider_pk); auto honk_vk = std::make_shared(decider_pk->proving_key); OuterVerifier verifier(honk_vk); @@ -405,6 +410,11 @@ TYPED_TEST(ProtogalaxyRecursiveTests, RecursiveFoldingTest) TestFixture::test_recursive_folding(); } +TYPED_TEST(ProtogalaxyRecursiveTests, RecursiveFoldingTwiceTest) +{ + TestFixture::test_recursive_folding(/* num_verifiers= */ 2); +} + TYPED_TEST(ProtogalaxyRecursiveTests, FullProtogalaxyRecursiveTest) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp index 3b547ae0fed..5cf429ddf2d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp @@ -10,10 +10,15 @@ using namespace bb::crypto; namespace bb { -template void MegaCircuitBuilder_::finalize_circuit() +template void MegaCircuitBuilder_::finalize_circuit(const bool ensure_nonzero) { + if (ensure_nonzero && !this->circuit_finalized) { + // do the mega part of ensuring all polynomials are nonzero; ultra part will be done inside of + // Ultra::finalize_circuit + add_gates_to_ensure_all_polys_are_non_zero(); + } // All of the gates involved in finalization are part of the Ultra arithmetization - UltraCircuitBuilder_>::finalize_circuit(); + UltraCircuitBuilder_>::finalize_circuit(ensure_nonzero); } /** @@ -28,9 +33,6 @@ template void MegaCircuitBuilder_::finalize_circuit() // coefficient of the wire polynomials is zero, which is required for them to be shiftable. template void MegaCircuitBuilder_::add_gates_to_ensure_all_polys_are_non_zero() { - // Most polynomials are handled via the conventional Ultra method - UltraCircuitBuilder_>::add_gates_to_ensure_all_polys_are_non_zero(); - // All that remains is to handle databus related and poseidon2 related polynomials. In what follows we populate the // calldata with some mock data then constuct a single calldata read gate diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp index 37fe7724153..06e421fc070 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp @@ -109,7 +109,7 @@ template class MegaCircuitBuilder_ : public UltraCircuitBuilder_ void UltraCircuitBuilder_::finalize_circuit() +template +void UltraCircuitBuilder_::finalize_circuit(const bool ensure_nonzero) { /** * First of all, add the gates related to ROM arrays and range lists. @@ -41,6 +42,9 @@ template void UltraCircuitBuilder_:: * our circuit is finalized, and we must not to execute these functions again. */ if (!circuit_finalized) { + if (ensure_nonzero) { + add_gates_to_ensure_all_polys_are_non_zero(); + } process_non_native_field_multiplications(); process_ROM_arrays(); process_RAM_arrays(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp index 567268caf16..ed3f12aae53 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp @@ -421,7 +421,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase class DeciderProvingKey_ { std::shared_ptr commitment_key = nullptr) { BB_OP_COUNT_TIME_NAME("DeciderProvingKey(Circuit&)"); - circuit.add_gates_to_ensure_all_polys_are_non_zero(); - circuit.finalize_circuit(); + circuit.finalize_circuit(/* ensure_nonzero = */ true); // Set flag indicating whether the polynomials will be constructed with fixed block sizes for each gate type const bool is_structured = (trace_structure != TraceStructure::NONE); From 52c7bf236d499a59f436efb921603f1afa85b895 Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 11 Sep 2024 19:14:55 +0000 Subject: [PATCH 2/8] Fix typo in error --- .../src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp index 3dff9aec750..ed9ab38739f 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp @@ -60,7 +60,7 @@ MemBn254CrsFactory::MemBn254CrsFactory(std::vector const& po std::shared_ptr> MemBn254CrsFactory::get_prover_crs(size_t degree) { if (prover_crs_->get_monomial_size() < degree) { - throw_or_abort(format("prover trying to get too many points in MemGrumpkinCrsFactory! ", + throw_or_abort(format("prover trying to get too many points in MemBn254CrsFactory! ", prover_crs_->get_monomial_size(), " vs ", degree)); @@ -72,7 +72,7 @@ std::shared_ptr> MemBn254CrsFactor { if (prover_crs_->get_monomial_size() < degree) { - throw_or_abort(format("verifier trying to get too many points in MemGrumpkinCrsFactory! ", + throw_or_abort(format("verifier trying to get too many points in MemBn254CrsFactory! ", prover_crs_->get_monomial_size(), " vs ", degree)); From 90d28b34288e98fa32a54165b514b027e59b2095 Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 11 Sep 2024 20:56:11 +0000 Subject: [PATCH 3/8] Fix typo --- .../stdlib_circuit_builders/mega_circuit_builder.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp index 06e421fc070..9d69fefffd9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp @@ -109,7 +109,7 @@ template class MegaCircuitBuilder_ : public UltraCircuitBuilder_ Date: Wed, 11 Sep 2024 20:56:19 +0000 Subject: [PATCH 4/8] hacky fix --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index d318d9e337a..a175eccabdd 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -47,10 +47,15 @@ std::string getHomeDir() } std::string CRS_PATH = getHomeDir() + "/.bb-crs"; - const std::filesystem::path current_path = std::filesystem::current_path(); const auto current_dir = current_path.filename().string(); +static constexpr size_t CRS_MINIMUM_SIZE = 128; +size_t size_or_min(const size_t in) +{ + return in > CRS_MINIMUM_SIZE ? in : CRS_MINIMUM_SIZE; +} + /** * @brief Initialize the global crs_factory for bn254 based on a known dyadic circuit size * @@ -195,7 +200,7 @@ bool proveAndVerifyHonkAcirFormat(acir_format::AcirFormat constraint_system, aci auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(srs_size); + init_bn254_crs(size_or_min(srs_size)); // Construct Honk proof Prover prover{ builder }; @@ -1059,7 +1064,7 @@ UltraProver_ compute_valid_prover(const std::string& bytecodePath, const auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(srs_size); + init_bn254_crs(size_or_min(srs_size)); Prover prover{ builder }; return prover; @@ -1296,7 +1301,7 @@ void prove_honk_output_all(const std::string& bytecodePath, auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(srs_size); + init_bn254_crs(size_or_min(srs_size)); // Construct Honk proof Prover prover{ builder }; From 01930039d828dc20004a5e347c911b43a7465855 Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 11 Sep 2024 21:05:19 +0000 Subject: [PATCH 5/8] Fix `ensure` count --- .../mega_circuit_builder.cpp | 21 +++++++++++++++++-- .../mega_circuit_builder.hpp | 5 +++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp index 5cf429ddf2d..3accdd2b758 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp @@ -15,7 +15,7 @@ template void MegaCircuitBuilder_::finalize_circuit(const bool if (ensure_nonzero && !this->circuit_finalized) { // do the mega part of ensuring all polynomials are nonzero; ultra part will be done inside of // Ultra::finalize_circuit - add_gates_to_ensure_all_polys_are_non_zero(); + add_mega_gates_to_ensure_all_polys_are_non_zero(); } // All of the gates involved in finalization are part of the Ultra arithmetization UltraCircuitBuilder_>::finalize_circuit(ensure_nonzero); @@ -31,7 +31,7 @@ template void MegaCircuitBuilder_::finalize_circuit(const bool // TODO(https://github.com/AztecProtocol/barretenberg/issues/1066): This function adds valid (but arbitrary) gates to // ensure that the circuit which includes them will not result in any zero-polynomials. It also ensures that the first // coefficient of the wire polynomials is zero, which is required for them to be shiftable. -template void MegaCircuitBuilder_::add_gates_to_ensure_all_polys_are_non_zero() +template void MegaCircuitBuilder_::add_mega_gates_to_ensure_all_polys_are_non_zero() { // All that remains is to handle databus related and poseidon2 related polynomials. In what follows we populate the // calldata with some mock data then constuct a single calldata read gate @@ -64,6 +64,23 @@ template void MegaCircuitBuilder_::add_gates_to_ensure_all_pol this->queue_ecc_eq(); } +/** + * @brief Ensure all polynomials have at least one non-zero coefficient to avoid commiting to the zero-polynomial. + * This only adds gates for the Goblin polynomials. Most polynomials are handled via the Ultra method, + * which should be done by a separate call to the Ultra builder's non zero polynomial gates method. + * + * @param in Structure containing variables and witness selectors + */ +// TODO(https://github.com/AztecProtocol/barretenberg/issues/1066): This function adds valid (but arbitrary) gates to +// ensure that the circuit which includes them will not result in any zero-polynomials. It also ensures that the first +// coefficient of the wire polynomials is zero, which is required for them to be shiftable. +template void MegaCircuitBuilder_::add_ultra_and_mega_gates_to_ensure_all_polys_are_non_zero() +{ + // Most polynomials are handled via the conventional Ultra method + UltraCircuitBuilder_>::add_gates_to_ensure_all_polys_are_non_zero(); + add_mega_gates_to_ensure_all_polys_are_non_zero(); +} + /** * @brief Add simple point addition operation to the op queue and add corresponding gates * diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp index 9d69fefffd9..3663dcb1599 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp @@ -110,7 +110,8 @@ template class MegaCircuitBuilder_ : public UltraCircuitBuilder_ class MegaCircuitBuilder_ : public UltraCircuitBuilder_ builder; // instantiate new builder size_t num_gates_prior = builder.get_num_gates(); - builder.add_gates_to_ensure_all_polys_are_non_zero(); + builder.add_ultra_and_mega_gates_to_ensure_all_polys_are_non_zero(); size_t num_gates_post = builder.get_num_gates(); // accounts for finalization gates return num_gates_post - num_gates_prior; From 82d5b3dfaf18790a4dbb91c7d64fc65f6ddba3ff Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 11 Sep 2024 21:23:40 +0000 Subject: [PATCH 6/8] Revert "hacky fix" This reverts commit 6998193981731301a598c43d3224e29a251373ff. --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index a175eccabdd..d318d9e337a 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -47,15 +47,10 @@ std::string getHomeDir() } std::string CRS_PATH = getHomeDir() + "/.bb-crs"; + const std::filesystem::path current_path = std::filesystem::current_path(); const auto current_dir = current_path.filename().string(); -static constexpr size_t CRS_MINIMUM_SIZE = 128; -size_t size_or_min(const size_t in) -{ - return in > CRS_MINIMUM_SIZE ? in : CRS_MINIMUM_SIZE; -} - /** * @brief Initialize the global crs_factory for bn254 based on a known dyadic circuit size * @@ -200,7 +195,7 @@ bool proveAndVerifyHonkAcirFormat(acir_format::AcirFormat constraint_system, aci auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(size_or_min(srs_size)); + init_bn254_crs(srs_size); // Construct Honk proof Prover prover{ builder }; @@ -1064,7 +1059,7 @@ UltraProver_ compute_valid_prover(const std::string& bytecodePath, const auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(size_or_min(srs_size)); + init_bn254_crs(srs_size); Prover prover{ builder }; return prover; @@ -1301,7 +1296,7 @@ void prove_honk_output_all(const std::string& bytecodePath, auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); - init_bn254_crs(size_or_min(srs_size)); + init_bn254_crs(srs_size); // Construct Honk proof Prover prover{ builder }; From de9df0af545e91717818e81b459c03d797cd8089 Mon Sep 17 00:00:00 2001 From: codygunton Date: Thu, 12 Sep 2024 02:47:42 +0000 Subject: [PATCH 7/8] Make test more idiomatic so it doesn't re-oink the accumulator. Result: Console is in 'commands' mode, prefix expressions with '?'. Launching: /mnt/user-data/cody/aztec-packages/barretenberg/cpp/build-debug/bin/stdlib_protogalaxy_verifier_tests --gtest_color=no --gtest_filter=ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest --gtest_also_run_disabled_tests --gtest_break_on_failure Launched process 2317410 Running main() from /mnt/user-data/cody/aztec-packages/barretenberg/cpp/build-debug/_deps/gtest-src/googletest/src/gtest_main.cc Note: Google Test filter = ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from ProtogalaxyRecursiveTests/0, where TypeParam = bb::MegaRecursiveFlavor_ > > [ RUN ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest Folding Recursive Verifier: num gates unfinalized = 18085 Folding Recursive Verifier: num gates finalized = 20194 WARNING: Redundant call to finalize_circuit(). Is this intentional? Dyadic size of verifier circuit: 32768 [ OK ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest (13082 ms) [----------] 1 test from ProtogalaxyRecursiveTests/0 (13082 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (13082 ms total) [ PASSED ] 1 test. Process exited with code 0. --- .../protogalaxy_recursive_verifier.test.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp index e03379fc4f3..4059866c423 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp @@ -204,15 +204,30 @@ template class ProtogalaxyRecursiveTests : public tes auto verifier = FoldingRecursiveVerifier{ &folding_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } }; + std::shared_ptr accumulator; for (size_t idx = 0; idx < num_verifiers; idx++) { - verifier.verify_folding_proof(stdlib_proof); + accumulator = verifier.verify_folding_proof(stdlib_proof); + if (idx < num_verifiers - 1) { // else the transcript is null in the test below + verifier = FoldingRecursiveVerifier{ &folding_circuit, + accumulator, + { std::make_shared( + &folding_circuit, decider_vk_1->verification_key) } }; + } } info("Folding Recursive Verifier: num gates unfinalized = ", folding_circuit.num_gates); EXPECT_EQ(folding_circuit.failed(), false) << folding_circuit.err(); + // Perform native folding verification and ensure it returns the same result (either true or false) as // calling check_circuit on the recursive folding verifier InnerFoldingVerifier native_folding_verifier({ decider_vk_1, decider_vk_2 }); + std::shared_ptr native_accumulator; native_folding_verifier.verify_folding_proof(folding_proof.proof); + for (size_t idx = 0; idx < num_verifiers; idx++) { + native_accumulator = native_folding_verifier.verify_folding_proof(folding_proof.proof); + if (idx < num_verifiers - 1) { // else the transcript is null in the test below + native_folding_verifier = InnerFoldingVerifier{ { native_accumulator, decider_vk_1 } }; + } + } // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring the // manifestsproduced by each agree. From b1259460c8636f9db81db825992c61d8f8dd4f3b Mon Sep 17 00:00:00 2001 From: codygunton Date: Thu, 12 Sep 2024 03:03:33 +0000 Subject: [PATCH 8/8] Fix typo to count gates with ensuring nonzero. Result: ``` Console is in 'commands' mode, prefix expressions with '?'. Launching: /mnt/user-data/cody/aztec-packages/barretenberg/cpp/build-debug/bin/stdlib_protogalaxy_verifier_tests --gtest_color=no --gtest_filter=ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest --gtest_also_run_disabled_tests --gtest_break_on_failure Launched process 2323108 Running main() from /mnt/user-data/cody/aztec-packages/barretenberg/cpp/build-debug/_deps/gtest-src/googletest/src/gtest_main.cc Note: Google Test filter = ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from ProtogalaxyRecursiveTests/0, where TypeParam = bb::MegaRecursiveFlavor_ > > [ RUN ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest Folding Recursive Verifier: num gates unfinalized = 18085 Folding Recursive Verifier: num gates finalized = 20211 WARNING: Redundant call to finalize_circuit(). Is this intentional? Dyadic size of verifier circuit: 32768 [ OK ] ProtogalaxyRecursiveTests/0.RecursiveFoldingTwiceTest (6768 ms) [----------] 1 test from ProtogalaxyRecursiveTests/0 (6768 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (6768 ms total) [ PASSED ] 1 test. Process exited with code 0. ``` --- .../protogalaxy_recursive_verifier.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp index 4059866c423..3c5a432d248 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp @@ -243,7 +243,7 @@ template class ProtogalaxyRecursiveTests : public tes if constexpr (!IsSimulator) { // inefficiently check finalized size - folding_circuit.finalize_circuit(); + folding_circuit.finalize_circuit(/* ensure_nonzero= */ true); info("Folding Recursive Verifier: num gates finalized = ", folding_circuit.num_gates); auto decider_pk = std::make_shared(folding_circuit); info("Dyadic size of verifier circuit: ", decider_pk->proving_key.circuit_size);