From 22db0c541ab74abc44b292354eec4da52fda1e23 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 18 Jun 2024 20:16:01 +0000 Subject: [PATCH 1/3] remove pi folding and add a test --- .../protogalaxy/protogalaxy.test.cpp | 33 +++++++++++++++++++ .../protogalaxy/protogalaxy_prover_impl.hpp | 16 --------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp index e8cf235f4aa..6c717c1d126 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp @@ -310,6 +310,34 @@ template class ProtoGalaxyTests : public testing::Test { } } + /** + * @brief Testing one valid round of folding followed by the decider. + * @brief For additional robustness we give one of the circuits more public inputs than the other + * + */ + static void test_full_protogalaxy_simple() + { + // Construct a first circuit with some public inputs + Builder builder1; + construct_circuit(builder1); + bb::MockCircuits::add_arithmetic_gates_with_public_inputs(builder1, /*num_gates=*/4); + + // Construct a second circuit with no public inputs + Builder builder2; + construct_circuit(builder2); + + // Construct the prover/verifier instances for each + TupleOfInstances instances; + construct_prover_and_verifier_instance(instances, builder1); + construct_prover_and_verifier_instance(instances, builder2); + + // Perform prover and verifier folding + auto [prover_accumulator, verifier_accumulator] = fold_and_verify(get<0>(instances), get<1>(instances)); + check_accumulator_target_sum_manual(prover_accumulator, true); + + decide_and_verify(prover_accumulator, verifier_accumulator, true); + } + /** * @brief Testing two valid rounds of folding followed by the decider. * @@ -489,6 +517,11 @@ TYPED_TEST(ProtoGalaxyTests, CombineAlpha) TestFixture::test_combine_alpha(); } +TYPED_TEST(ProtoGalaxyTests, FullProtogalaxySimple) +{ + TestFixture::test_full_protogalaxy_simple(); +} + TYPED_TEST(ProtoGalaxyTests, FullProtogalaxyTest) { TestFixture::test_full_protogalaxy(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_impl.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_impl.hpp index 02fbb08ff15..f38ff10b3e1 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_impl.hpp @@ -104,22 +104,6 @@ std::shared_ptr ProtoGalaxyProver_proving_key.public_inputs) { - el *= lagranges[0]; - size_t inst = 0; - for (size_t inst_idx = 1; inst_idx < ProverInstances::NUM; inst_idx++) { - auto& instance = instances[inst_idx]; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/830) - if (instance->proving_key.num_public_inputs >= next_accumulator->proving_key.num_public_inputs) { - el += instance->proving_key.public_inputs[el_idx] * lagranges[inst]; - inst++; - }; - } - el_idx++; - } - // Evaluate the combined batching α_i univariate at challenge to obtain next α_i and send it to the // verifier, where i ∈ {0,...,NUM_SUBRELATIONS - 1} auto& folded_alphas = next_accumulator->alphas; From b3ac6d60cbd9a143a12de106a38bf40f8c3081bb Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 18 Jun 2024 20:23:21 +0000 Subject: [PATCH 2/3] remove pi folding from verifier as well --- .../protogalaxy/protogalaxy_verifier.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index a16bacd6e3d..9ffce227620 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -115,19 +115,7 @@ std::shared_ptr ProtoGalaxyVerifier_verification_key->num_public_inputs = accumulator->verification_key->num_public_inputs; next_accumulator->public_inputs = std::vector(static_cast(next_accumulator->verification_key->num_public_inputs), 0); - size_t public_input_idx = 0; - for (auto& public_input : next_accumulator->public_inputs) { - size_t inst = 0; - for (auto& instance : instances) { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/830) - if (instance->verification_key->num_public_inputs >= - next_accumulator->verification_key->num_public_inputs) { - public_input += instance->public_inputs[public_input_idx] * lagranges[inst]; - inst++; - } - } - public_input_idx++; - } + next_accumulator->is_accumulator = true; // Compute next folding parameters From 55e28ecc78613d6bde792de9f8bc3b77aa215c2d Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 19 Jun 2024 15:30:14 +0000 Subject: [PATCH 3/3] pub inputs still needed in some places for now --- .../verifier/protogalaxy_recursive_verifier.cpp | 15 --------------- .../barretenberg/ultra_honk/ultra_verifier.cpp | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp index b605840a125..daedb38fd71 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp @@ -177,21 +177,6 @@ std::shared_ptr ProtoGalaxyRecursiveVerifi // Compute ϕ fold_commitments(lagranges, instances, next_accumulator); - next_accumulator->public_inputs = - std::vector(static_cast(next_accumulator->verification_key->num_public_inputs), 0); - size_t public_input_idx = 0; - for (auto& public_input : next_accumulator->public_inputs) { - size_t inst = 0; - for (auto& instance : instances) { - if (instance->verification_key->num_public_inputs >= - next_accumulator->verification_key->num_public_inputs) { - public_input += instance->public_inputs[public_input_idx] * lagranges[inst]; - inst++; - }; - } - public_input_idx++; - } - size_t alpha_idx = 0; for (auto& alpha : next_accumulator->alphas) { alpha = FF(0); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 60e5afd118b..039591d2ba4 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -49,7 +49,7 @@ template bool UltraVerifier_::verify_proof(const HonkP transcript = std::make_shared(proof); VerifierCommitments commitments{ key }; OinkVerifier oink_verifier{ key, transcript }; - auto [relation_parameters, witness_commitments, _, alphas] = oink_verifier.verify(); + auto [relation_parameters, witness_commitments, public_inputs, alphas] = oink_verifier.verify(); // Copy the witness_commitments over to the VerifierCommitments for (auto [wit_comm_1, wit_comm_2] : zip_view(commitments.get_witness(), witness_commitments.get_all())) {