diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 8e3a10f4f50..ec5062277a5 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -41,7 +41,7 @@ template class GoblinUltraRecursiveFlavor_ { using NativeVerificationKey = NativeFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = bb::VerifierCommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = GoblinUltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often @@ -114,6 +114,7 @@ template class GoblinUltraRecursiveFlavor_ { */ VerificationKey(CircuitBuilder* builder, const std::shared_ptr& native_key) { + this->pcs_verification_key = native_key->pcs_verification_key; this->circuit_size = native_key->circuit_size; this->log_circuit_size = numeric::get_msb(this->circuit_size); this->num_public_inputs = native_key->num_public_inputs; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index e7ab769eb6d..0ac2f297ce6 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -56,7 +56,7 @@ template class UltraRecursiveFlavor_ { using NativeVerificationKey = NativeFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = bb::VerifierCommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = UltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often @@ -288,6 +288,7 @@ template class UltraRecursiveFlavor_ { this->circuit_size = native_key->circuit_size; this->log_circuit_size = numeric::get_msb(this->circuit_size); this->num_public_inputs = native_key->num_public_inputs; + this->pcs_verification_key = native_key->pcs_verification_key; this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); this->q_r = Commitment::from_witness(builder, native_key->q_r); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index 3d0b2e4e8ed..4f1fa1eb481 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp @@ -17,7 +17,7 @@ DeciderProver_::DeciderProver_(const std::shared_ptr& inst, const std::shared_ptr& transcript) : accumulator(std::move(inst)) , transcript(transcript) - , commitment_key(inst->commitment_key) + , commitment_key(inst->proving_key->commitment_key) {} /** diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index d635c15269f..ebb0b6c7034 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -54,7 +54,8 @@ template bool DeciderVerifier_::verify_proof(const Hon multivariate_challenge, transcript); - auto verified = accumulator->pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + auto verified = + accumulator->verification_key->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 e7fe59f6644..382dfcddf3f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -134,7 +134,7 @@ std::shared_ptr ProtoGalaxyProver_is_accumulator = true; next_accumulator->instance_size = instances[0]->instance_size; next_accumulator->log_instance_size = instances[0]->log_instance_size; - next_accumulator->commitment_key = instances[0]->commitment_key; + next_accumulator->proving_key = instances[0]->proving_key; // Compute the next target sum and send the next folding parameters to the verifier FF next_target_sum = diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index b56f3da6344..ab406ffcb7e 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -138,10 +138,12 @@ std::shared_ptr ProtoGalaxyVerifier_{ FF(1) - combiner_challenge, combiner_challenge }; - auto next_accumulator = std::make_shared(); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/881): bad pattern + auto next_accumulator = std::make_shared(accumulator->verification_key); next_accumulator->instance_size = accumulator->instance_size; next_accumulator->log_instance_size = accumulator->log_instance_size; next_accumulator->is_accumulator = true; + // Compute next folding parameters next_accumulator->target_sum = perturbator_at_challenge * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; @@ -200,6 +202,7 @@ std::shared_ptr ProtoGalaxyVerifier_verification_key = std::make_shared(instances[0]->instance_size, instances[0]->public_input_size); + next_accumulator->verification_key->pcs_verification_key = accumulator->verification_key->pcs_verification_key; size_t vk_idx = 0; for (auto& expected_vk : next_accumulator->verification_key->get_all()) { size_t inst = 0; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 8063c369db3..38ed52ba00a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -212,6 +212,7 @@ std::shared_ptr ProtoGalaxyRecursiveVerifi next_accumulator->verification_key = std::make_shared(instances[0]->instance_size, instances[0]->public_input_size); + next_accumulator->verification_key->pcs_verification_key = accumulator->verification_key->pcs_verification_key; size_t vk_idx = 0; for (auto& expected_vk : next_accumulator->verification_key->get_all()) { size_t inst = 0; 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 fbf52ef504b..5876c226d46 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 @@ -292,8 +292,9 @@ template class ProtoGalaxyRecursiveTests : public tes // check that the result agrees. NativeDeciderVerifier native_decider_verifier(verifier_accumulator); auto native_result = native_decider_verifier.verify_proof(decider_proof); - auto recursive_result = native_decider_verifier.accumulator->pcs_verification_key->pairing_check( - pairing_points[0].get_value(), pairing_points[1].get_value()); + auto recursive_result = + native_decider_verifier.accumulator->verification_key->pcs_verification_key->pairing_check( + pairing_points[0].get_value(), pairing_points[1].get_value()); EXPECT_EQ(native_result, recursive_result); // Ensure that the underlying native and recursive decider verification algorithms agree by ensuring diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp index d61ee8734fc..cbc2e71ae5e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp @@ -1,4 +1,5 @@ #pragma once +#include "barretenberg/commitment_schemes/verification_key.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/instance/verifier_instance.hpp" @@ -63,6 +64,7 @@ template class RecursiveVerifierInstance_ { public_input_idx++; } verification_key = std::make_shared(instance_size, public_input_size); + verification_key->pcs_verification_key = instance->verification_key->pcs_verification_key; auto other_vks = instance->verification_key->get_all(); size_t vk_idx = 0; for (auto& vk : verification_key->get_all()) { @@ -105,7 +107,13 @@ template class RecursiveVerifierInstance_ { */ VerifierInstance get_value() { - VerifierInstance inst; + auto inst_verification_key = std::make_shared(instance_size, public_input_size); + inst_verification_key->pcs_verification_key = verification_key->pcs_verification_key; + for (auto [vk, inst_vk] : zip_view(verification_key->get_all(), inst_verification_key->get_all())) { + inst_vk = vk.get_value(); + } + + VerifierInstance inst(inst_verification_key); inst.pub_inputs_offset = pub_inputs_offset; inst.public_input_size = public_input_size; inst.log_instance_size = log_instance_size; @@ -117,11 +125,6 @@ template class RecursiveVerifierInstance_ { inst_public_input = public_input.get_value(); } - inst.verification_key = std::make_shared(instance_size, public_input_size); - for (auto [vk, inst_vk] : zip_view(verification_key->get_all(), inst.verification_key->get_all())) { - inst_vk = vk.get_value(); - } - for (auto [alpha, inst_alpha] : zip_view(alphas, inst.alphas)) { inst_alpha = alpha.get_value(); } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index c11f3ebb74a..544e1d5f9f0 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -33,10 +33,6 @@ template class ProverInstance_ { public: std::shared_ptr proving_key; - // 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; - ProverPolynomials prover_polynomials; WitnessCommitments witness_commitments; CommitmentLabels commitment_labels; @@ -90,8 +86,6 @@ template class ProverInstance_ { proving_key->contains_recursive_proof = contains_recursive_proof; sorted_polynomials = construct_sorted_list_polynomials(circuit, dyadic_circuit_size); - - commitment_key = proving_key->commitment_key; } ProverInstance_() = default; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp index 983dc37dd4e..9c6faf879aa 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp @@ -20,9 +20,6 @@ template class VerifierInstance_ { using RelationSeparator = typename Flavor::RelationSeparator; std::shared_ptr verification_key; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/881)?: Access throutgh vk by making sure vk is - // initialized in Protogalaxy? - std::shared_ptr pcs_verification_key; std::vector public_inputs; size_t pub_inputs_offset = 0; size_t public_input_size; @@ -38,11 +35,8 @@ template class VerifierInstance_ { WitnessCommitments witness_commitments; CommitmentLabels commitment_labels; - VerifierInstance_() - : pcs_verification_key(std::make_shared()){}; VerifierInstance_(std::shared_ptr vk) : verification_key(std::move(vk)) - , pcs_verification_key(std::make_shared()) {} }; } // namespace bb \ No newline at end of file