diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 955857962ca..90cf67ac747 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -246,7 +246,6 @@ class GoblinUltra { }; RefVector get_witness() { return WitnessEntities::get_all(); }; - RefVector get_to_be_shifted() { return { this->table_1, this->table_2, this->table_3, this->table_4, this->w_l, this->w_r, diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index ab98bb22fdb..7dbc3bfa503 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -46,7 +46,7 @@ template class GoblinUltraRecursive_ { using FF = typename Curve::ScalarField; using Commitment = typename Curve::Element; using CommitmentHandle = typename Curve::Element; - using NativeFlavor = flavor::GoblinUltra; + using NativeFlavor = typename flavor::GoblinUltra; using NativeVerificationKey = NativeFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index f6e58733ad2..f2f7ea4cde0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -417,44 +417,6 @@ template class UltraRecursive_ { this->z_lookup = commitments.z_lookup; } } - - VerifierCommitments(const std::shared_ptr& verification_key, - const WitnessCommitments& witness_commitments) - { - this->q_m = verification_key->q_m; - this->q_l = verification_key->q_l; - this->q_r = verification_key->q_r; - this->q_o = verification_key->q_o; - this->q_4 = verification_key->q_4; - this->q_c = verification_key->q_c; - this->q_arith = verification_key->q_arith; - this->q_sort = verification_key->q_sort; - this->q_elliptic = verification_key->q_elliptic; - this->q_aux = verification_key->q_aux; - this->q_lookup = verification_key->q_lookup; - this->sigma_1 = verification_key->sigma_1; - this->sigma_2 = verification_key->sigma_2; - this->sigma_3 = verification_key->sigma_3; - this->sigma_4 = verification_key->sigma_4; - this->id_1 = verification_key->id_1; - this->id_2 = verification_key->id_2; - this->id_3 = verification_key->id_3; - this->id_4 = verification_key->id_4; - this->table_1 = verification_key->table_1; - this->table_2 = verification_key->table_2; - this->table_3 = verification_key->table_3; - this->table_4 = verification_key->table_4; - this->lagrange_first = verification_key->lagrange_first; - this->lagrange_last = verification_key->lagrange_last; - - this->w_l = witness_commitments.w_l; - this->w_r = witness_commitments.w_r; - this->w_o = witness_commitments.w_o; - this->sorted_accum = witness_commitments.sorted_accum; - this->w_4 = witness_commitments.w_4; - this->z_perm = witness_commitments.z_perm; - this->z_lookup = witness_commitments.z_lookup; - } }; using Transcript = bb::stdlib::recursion::honk::Transcript; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index d8f29d1f983..ef86acfcb2e 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -103,6 +103,7 @@ template bool DeciderVerifier_::verify_proof(const hon transcript); auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + return sumcheck_verified.value() && verified; } diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 132c3768208..5464480e005 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -307,13 +307,14 @@ FoldingResult ProtoGalaxyProver_get_challenge("delta"); + auto accumulator = get_accumulator(); auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); + auto perturbator = compute_perturbator(accumulator, deltas); for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { transcript->send_to_verifier("perturbator_" + std::to_string(idx), perturbator[idx]); } - auto perturbator_challenge = transcript->get_challenge("perturbator_challenge"); instances.next_gate_challenges = update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas); @@ -321,6 +322,7 @@ FoldingResult ProtoGalaxyProver_(instances.next_gate_challenges); auto combiner = compute_combiner(instances, pow_polynomial); + auto compressed_perturbator = perturbator.evaluate(perturbator_challenge); auto combiner_quotient = compute_combiner_quotient(compressed_perturbator, combiner); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 09872f29b59..bd4be1b8f70 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -112,8 +112,8 @@ void ProtoGalaxyVerifier_::receive_and_finalise_instance(cons // Get permutation challenges and commitment to permutation and lookup grand products auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma"); - // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial if constexpr (IsGoblinFlavor) { + // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial witness_commitments.lookup_inverses = transcript->template receive_from_prover( domain_separator + "_" + commitment_labels.lookup_inverses); } 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 e94e3a0b852..d8c78c278a5 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 @@ -147,6 +147,9 @@ template class ProtoGalaxyRecursiveTests : public tes return inner_folding_proof.accumulator; } + /** + *@brief Create inner circuit and call check_circuit on it + */ static void test_inner_circuit() { InnerBuilder builder; @@ -157,28 +160,37 @@ template class ProtoGalaxyRecursiveTests : public tes EXPECT_EQ(result, true); }; - // static void test_new_evaluate() - // { - // OuterBuilder builder; - // using fr_ct = bn254::ScalarField; - // using fr = bn254::ScalarFieldNative; - - // std::vector coeffs; - // std::vector coeffs_ct; - // for (size_t idx = 0; idx < 8; idx++) { - // auto el = fr::random_element(); - // coeffs.emplace_back(el); - // coeffs_ct.emplace_back(fr_ct(&builder, el)); - // } - // Polynomial poly(coeffs); - // fr point = fr::random_element(); - // fr_ct point_ct(fr_ct(&builder, point)); - // auto res1 = poly.evaluate(point); - - // auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); - // EXPECT_EQ(res1, res2.get_value()); - // }; + /** + * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as + * evaluating in Polynomial class. + * + */ + static void test_new_evaluate() + { + OuterBuilder builder; + using fr_ct = bn254::ScalarField; + using fr = bn254::ScalarFieldNative; + + std::vector coeffs; + std::vector coeffs_ct; + for (size_t idx = 0; idx < 8; idx++) { + auto el = fr::random_element(); + coeffs.emplace_back(el); + coeffs_ct.emplace_back(fr_ct(&builder, el)); + } + Polynomial poly(coeffs); + fr point = fr::random_element(); + fr_ct point_ct(fr_ct(&builder, point)); + auto res1 = poly.evaluate(point); + + auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); + EXPECT_EQ(res1, res2.get_value()); + }; + /** + * @brief Tests a simple recursive fold that is valid works as expected. + * + */ static void test_recursive_folding() { // Create two arbitrary circuits for the first round of folding @@ -197,6 +209,11 @@ template class ProtoGalaxyRecursiveTests : public tes fold_and_verify(instances, inner_composer); }; + /** + * @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof, + * make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native + * verifiers are identical by checking the manifests + */ static void test_full_protogalaxy_recursive() { // Create two arbitrary circuits for the first round of folding @@ -338,38 +355,22 @@ template class ProtoGalaxyRecursiveTests : public tes using FlavorTypes = testing::Types<::bb::honk::flavor::GoblinUltraRecursive_, ::bb::honk::flavor::UltraRecursive_>; TYPED_TEST_SUITE(ProtoGalaxyRecursiveTests, FlavorTypes); -/**@brief Create inner circuit and call check_circuit on it*/ TYPED_TEST(ProtoGalaxyRecursiveTests, InnerCircuit) { TestFixture::test_inner_circuit(); } -/** - * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as - * evaluating in Polynomial class. - * - */ -// TYPED_TEST(ProtoGalaxyRecursiveTests, NewEvaluate) -// { -// TestFixture::test_new_evaluate(); -// } - -/** - * @brief Tests a simple recursive fold that is valid works as expected. - * - */ +TYPED_TEST(ProtoGalaxyRecursiveTests, NewEvaluate) +{ + TestFixture::test_new_evaluate(); +} + TYPED_TEST(ProtoGalaxyRecursiveTests, RecursiveFoldingTest) { TestFixture::test_recursive_folding(); } -/** - * @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof, - * make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native verifiers - * are identical by checking the manifests - - */ TYPED_TEST(ProtoGalaxyRecursiveTests, FullProtogalaxyRecursiveTest) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index ed610d57ada..3a3ee4b4664 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -12,19 +12,19 @@ auto& engine = numeric::get_debug_randomness(); template class ProtoGalaxyTests : public testing::Test { public: using Composer = UltraComposer_; - using VerificationKey = Flavor::VerificationKey; + using VerificationKey = typename Flavor::VerificationKey; using Instance = ProverInstance_; using Instances = ProverInstances_; using ProtoGalaxyProver = ProtoGalaxyProver_; - using FF = Flavor::FF; - using Affine = Flavor::Commitment; - using Projective = Flavor::GroupElement; - using Builder = Flavor::CircuitBuilder; + using FF = typename Flavor::FF; + using Affine = typename Flavor::Commitment; + using Projective = typename Flavor::GroupElement; + using Builder = typename Flavor::CircuitBuilder; using Polynomial = typename Flavor::Polynomial; - using ProverPolynomials = Flavor::ProverPolynomials; + using ProverPolynomials = typename Flavor::ProverPolynomials; using RelationParameters = bb::RelationParameters; using WitnessCommitments = typename Flavor::WitnessCommitments; - using CommitmentKey = Flavor::CommitmentKey; + using CommitmentKey = typename Flavor::CommitmentKey; using PowPolynomial = bb::PowPolynomial; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } @@ -155,7 +155,7 @@ template class ProtoGalaxyTests : public testing::Test { static void test_pertubator_polynomial() { - using RelationSeparator = Flavor::RelationSeparator; + using RelationSeparator = typename Flavor::RelationSeparator; const size_t log_instance_size(3); const size_t instance_size(1 << log_instance_size); std::array, Flavor::NUM_ALL_ENTITIES> random_polynomials;