From a3db97e7f4eed20fdf8e6b4d9a71db7d36c3d6ea Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 21 Aug 2024 00:10:28 +0000 Subject: [PATCH 1/5] decider verifier in ultra verifier builds --- barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.hpp | 2 +- .../cpp/src/barretenberg/client_ivc/client_ivc.hpp | 2 +- .../cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp | 2 +- .../protogalaxy_recursive_verifier.test.cpp | 2 +- .../{protogalaxy => ultra_honk}/decider_verifier.cpp | 1 + .../{protogalaxy => ultra_honk}/decider_verifier.hpp | 0 .../cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp | 7 +++++++ .../cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp | 5 +++++ 8 files changed, 17 insertions(+), 4 deletions(-) rename barretenberg/cpp/src/barretenberg/{protogalaxy => ultra_honk}/decider_verifier.cpp (98%) rename barretenberg/cpp/src/barretenberg/{protogalaxy => ultra_honk}/decider_verifier.hpp (100%) diff --git a/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.hpp b/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.hpp index 89f29976278..c203e6036b7 100644 --- a/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.hpp @@ -3,12 +3,12 @@ #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/plonk_honk_shared/arithmetization/max_block_size_tracker.hpp" -#include "barretenberg/protogalaxy/decider_verifier.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" #include "barretenberg/stdlib/primitives/databus/databus.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" #include "barretenberg/ultra_honk/decider_prover.hpp" +#include "barretenberg/ultra_honk/decider_verifier.hpp" #include namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp index dfa059586ef..5f10e6aead4 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp @@ -3,11 +3,11 @@ #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/plonk_honk_shared/arithmetization/max_block_size_tracker.hpp" -#include "barretenberg/protogalaxy/decider_verifier.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" #include "barretenberg/ultra_honk/decider_prover.hpp" +#include "barretenberg/ultra_honk/decider_verifier.hpp" #include namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp index 1dfda9e7e9a..f4fe51bc251 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp @@ -1,10 +1,10 @@ #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/polynomials/pow.hpp" -#include "barretenberg/protogalaxy/decider_verifier.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/mock_circuits.hpp" #include "barretenberg/ultra_honk/decider_prover.hpp" +#include "barretenberg/ultra_honk/decider_verifier.hpp" #include 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 3ac38a01115..f64f0580f40 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 @@ -1,7 +1,6 @@ #include "barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" -#include "barretenberg/protogalaxy/decider_verifier.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" #include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" @@ -11,6 +10,7 @@ #include "barretenberg/stdlib_circuit_builders/ultra_recursive_flavor.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" #include "barretenberg/ultra_honk/decider_prover.hpp" +#include "barretenberg/ultra_honk/decider_verifier.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp rename to barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp index 080a4f322f0..c349775269c 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp @@ -66,6 +66,7 @@ template bool DeciderVerifier_::verify_proof(const Hon } template class DeciderVerifier_; +template class DeciderVerifier_; template class DeciderVerifier_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp rename to barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 7526a33a115..5ac13f5babf 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -10,6 +10,7 @@ UltraVerifier_::UltraVerifier_(const std::shared_ptr& transc const std::shared_ptr& verifier_key) : key(verifier_key) , transcript(transcript) + , instance(std::make_shared(verifier_key)) {} /** @@ -22,6 +23,7 @@ template UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) : key(verifier_key) , transcript(std::make_shared()) + , instance(std::make_shared(verifier_key)) {} template @@ -51,6 +53,11 @@ template bool UltraVerifier_::verify_proof(const HonkP VerifierCommitments commitments{ key }; OinkVerifier oink_verifier{ key, transcript }; auto [relation_parameters, witness_commitments, public_inputs, alphas] = oink_verifier.verify(); + instance->relation_parameters = relation_parameters; + instance->witness_commitments = witness_commitments; + instance->alphas = alphas; + + [[maybe_unused]] DeciderVerifier decider_verifier{ instance, transcript }; // 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())) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index 727b30482fd..f22b71ea626 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -3,7 +3,9 @@ #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/stdlib_circuit_builders/mega_flavor.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp" +#include "barretenberg/sumcheck/instance//verifier_instance.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" +#include "barretenberg/ultra_honk/decider_verifier.hpp" namespace bb { template class UltraVerifier_ { @@ -12,6 +14,8 @@ template class UltraVerifier_ { using VerificationKey = typename Flavor::VerificationKey; using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; using Transcript = typename Flavor::Transcript; + using Instance = VerifierInstance_; + using DeciderVerifier = DeciderVerifier_; public: explicit UltraVerifier_(const std::shared_ptr& transcript, @@ -27,6 +31,7 @@ template class UltraVerifier_ { std::shared_ptr key; std::shared_ptr transcript; + std::shared_ptr instance; }; using UltraVerifier = UltraVerifier_; From 232853fb03cfa1e3ef49ca48103d9ec41b390c7c Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 21 Aug 2024 16:51:55 +0000 Subject: [PATCH 2/5] tests pass using decider ver in ultra ver --- .../sumcheck/instance/verifier_instance.hpp | 2 +- .../ultra_honk/decider_verifier.cpp | 32 +++++++++--- .../ultra_honk/decider_verifier.hpp | 8 +-- .../ultra_honk/ultra_verifier.cpp | 49 +++---------------- 4 files changed, 39 insertions(+), 52 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp index ba4eb7bc4b2..7f34faf9385 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp @@ -28,7 +28,7 @@ template class VerifierInstance_ { // The folding parameters (\vec{β}, e) which are set for accumulators (i.e. relaxed instances). std::vector gate_challenges; - FF target_sum; + FF target_sum{ 0 }; WitnessCommitments witness_commitments; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp index c349775269c..0ef1de02213 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp @@ -6,6 +6,12 @@ namespace bb { +/** + * @brief Constructor from prover instance and a transcript assumed to be initialized with a full honk proof + * @details Used in the case where an external transcript already exists and has been initialized with a proof, e.g. + * when the decider is being used in the context of the larger honk protocol. + * + */ template DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) @@ -14,26 +20,38 @@ DeciderVerifier_::DeciderVerifier_(const std::shared_ptr -DeciderVerifier_::DeciderVerifier_() - : pcs_verification_key(std::make_unique()) - , transcript(std::make_shared()) +DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator) + : accumulator(accumulator) + , pcs_verification_key(accumulator->verification_key->pcs_verification_key) {} /** - * @brief This function verifies an Ultra Honk proof for a given Flavor, produced for a relaxed instance (ϕ, \vec{β*}, + * @brief This function verifies a decider proof for a given Flavor, produced for a relaxed instance (ϕ, \vec{β*}, * e*). * */ -template bool DeciderVerifier_::verify_proof(const HonkProof& proof) +template bool DeciderVerifier_::verify_proof(const DeciderProof& proof) +{ + transcript = std::make_shared(proof); + return verify(); +} + +/** + * @brief Verify a decider proof that is assumed to be contained in the transcript + * + */ +template bool DeciderVerifier_::verify() { using PCS = typename Flavor::PCS; using Curve = typename Flavor::Curve; using ZeroMorph = ZeroMorphVerifier_; using VerifierCommitments = typename Flavor::VerifierCommitments; - transcript = std::make_shared(proof); - VerifierCommitments commitments{ accumulator->verification_key, accumulator->witness_commitments }; auto sumcheck = SumcheckVerifier( diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp index 55ca8618d02..34bc15c400f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp @@ -14,14 +14,16 @@ template class DeciderVerifier_ { using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; using Transcript = typename Flavor::Transcript; using VerifierInstance = VerifierInstance_; + using DeciderProof = std::vector; public: explicit DeciderVerifier_(); explicit DeciderVerifier_(const std::shared_ptr& accumulator, - const std::shared_ptr& transcript = std::make_shared()); - - bool verify_proof(const HonkProof& proof); + const std::shared_ptr& transcript); + explicit DeciderVerifier_(const std::shared_ptr& accumulator); + bool verify_proof(const DeciderProof&); + bool verify(); std::shared_ptr key; std::map commitments; std::shared_ptr accumulator; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 5ac13f5babf..61d8a4fff02 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -44,56 +44,23 @@ template UltraVerifier_& UltraVerifier_::opera template bool UltraVerifier_::verify_proof(const HonkProof& proof) { using FF = typename Flavor::FF; - using PCS = typename Flavor::PCS; - using Curve = typename Flavor::Curve; - using ZeroMorph = ZeroMorphVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; transcript = std::make_shared(proof); - VerifierCommitments commitments{ key }; OinkVerifier oink_verifier{ key, transcript }; auto [relation_parameters, witness_commitments, public_inputs, alphas] = oink_verifier.verify(); - instance->relation_parameters = relation_parameters; - instance->witness_commitments = witness_commitments; - instance->alphas = alphas; + instance->relation_parameters = std::move(relation_parameters); + instance->witness_commitments = std::move(witness_commitments); + instance->alphas = std::move(alphas); - [[maybe_unused]] DeciderVerifier decider_verifier{ instance, transcript }; - - // 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())) { - wit_comm_1 = wit_comm_2; - } - - // Execute Sumcheck Verifier - const size_t log_circuit_size = static_cast(numeric::get_msb(key->circuit_size)); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - - auto gate_challenges = std::vector(log_circuit_size); + size_t log_circuit_size = numeric::get_msb(key->circuit_size); for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->template get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + instance->gate_challenges.emplace_back( + transcript->template get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx))); } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alphas, gate_challenges); - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - info("Sumcheck verification failed."); - return false; - } + DeciderVerifier decider_verifier{ instance, transcript }; - // Execute ZeroMorph rounds to produce an opening claim and verify it with a univariate PCS. See - // https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. - auto opening_claim = ZeroMorph::verify(key->circuit_size, - commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - Commitment::one(), - transcript); - auto pairing_points = PCS::reduce_verify(opening_claim, transcript); - auto pcs_verified = key->pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - return sumcheck_verified.value() && pcs_verified; + return decider_verifier.verify(); } template class UltraVerifier_; From 30fcbc526cfb68dfdb987b05a1f43814c1e229d6 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 21 Aug 2024 16:57:53 +0000 Subject: [PATCH 3/5] comments --- .../barretenberg/ultra_honk/decider_verifier.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp index 34bc15c400f..1ef0884834f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.hpp @@ -18,12 +18,22 @@ template class DeciderVerifier_ { public: explicit DeciderVerifier_(); + /** + * @brief Constructor from prover instance and a transcript assumed to be initialized with a full honk proof + * @details Used in the case where an external transcript already exists and has been initialized with a proof, e.g. + * when the decider is being used in the context of the larger honk protocol. + * + */ explicit DeciderVerifier_(const std::shared_ptr& accumulator, const std::shared_ptr& transcript); + /** + * @brief Constructor from prover instance + * + */ explicit DeciderVerifier_(const std::shared_ptr& accumulator); - bool verify_proof(const DeciderProof&); - bool verify(); + bool verify_proof(const DeciderProof&); // used when a decider proof is known explicitly + bool verify(); // used when transcript that has been initialized with a proof std::shared_ptr key; std::map commitments; std::shared_ptr accumulator; From bed0f8b59cbd0b4e1e351375a03374f8578b0d46 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 21 Aug 2024 17:07:07 +0000 Subject: [PATCH 4/5] simplify key --- .../ultra_recursive_verifier.test.cpp | 4 ++-- .../ultra_honk/decider_verifier.cpp | 10 -------- .../ultra_honk/ultra_verifier.cpp | 23 ++++--------------- .../ultra_honk/ultra_verifier.hpp | 5 ---- 4 files changed, 6 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.test.cpp index df7716a8f9b..943f1bed60c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.test.cpp @@ -199,8 +199,8 @@ template class RecursiveVerifierTest : public testing auto pcs_verification_key = std::make_shared(); bool result = pcs_verification_key->pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value()); info("input pairing points result: ", result); - auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points.P0.get_value(), - pairing_points.P1.get_value()); + auto recursive_result = native_verifier.instance->verification_key->pcs_verification_key->pairing_check( + pairing_points.P0.get_value(), pairing_points.P1.get_value()); EXPECT_EQ(recursive_result, native_result); // Check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp index 0ef1de02213..2f7f22628bb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp @@ -6,12 +6,6 @@ namespace bb { -/** - * @brief Constructor from prover instance and a transcript assumed to be initialized with a full honk proof - * @details Used in the case where an external transcript already exists and has been initialized with a proof, e.g. - * when the decider is being used in the context of the larger honk protocol. - * - */ template DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) @@ -20,10 +14,6 @@ DeciderVerifier_::DeciderVerifier_(const std::shared_ptr DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator) : accumulator(accumulator) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 61d8a4fff02..ee391ef4a62 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -8,35 +8,20 @@ namespace bb { template UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, const std::shared_ptr& verifier_key) - : key(verifier_key) - , transcript(transcript) + : transcript(transcript) , instance(std::make_shared(verifier_key)) {} /** * @brief Construct an UltraVerifier directly from a verification key * - * @tparam Flavor - * @param verifier_key */ template UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) - : key(verifier_key) - , transcript(std::make_shared()) + : transcript(std::make_shared()) , instance(std::make_shared(verifier_key)) {} -template -UltraVerifier_::UltraVerifier_(UltraVerifier_&& other) - : key(std::move(other.key)) -{} - -template UltraVerifier_& UltraVerifier_::operator=(UltraVerifier_&& other) -{ - key = other.key; - return *this; -} - /** * @brief This function verifies an Ultra Honk proof for a given Flavor. * @@ -46,13 +31,13 @@ template bool UltraVerifier_::verify_proof(const HonkP using FF = typename Flavor::FF; transcript = std::make_shared(proof); - OinkVerifier oink_verifier{ key, transcript }; + OinkVerifier oink_verifier{ instance->verification_key, transcript }; auto [relation_parameters, witness_commitments, public_inputs, alphas] = oink_verifier.verify(); instance->relation_parameters = std::move(relation_parameters); instance->witness_commitments = std::move(witness_commitments); instance->alphas = std::move(alphas); - size_t log_circuit_size = numeric::get_msb(key->circuit_size); + size_t log_circuit_size = numeric::get_msb(instance->verification_key->circuit_size); for (size_t idx = 0; idx < log_circuit_size; idx++) { instance->gate_challenges.emplace_back( transcript->template get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx))); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index f22b71ea626..c61bc652514 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -22,14 +22,9 @@ template class UltraVerifier_ { const std::shared_ptr& verifier_key = nullptr); explicit UltraVerifier_(const std::shared_ptr& verifier_key); - UltraVerifier_(UltraVerifier_&& other); - - UltraVerifier_& operator=(const UltraVerifier_& other) = delete; - UltraVerifier_& operator=(UltraVerifier_&& other); bool verify_proof(const HonkProof& proof); - std::shared_ptr key; std::shared_ptr transcript; std::shared_ptr instance; }; From 130580fc23cbd02bb25287ca216296aec8e7aa12 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 21 Aug 2024 17:12:58 +0000 Subject: [PATCH 5/5] more constructor simplification --- .../barretenberg/ultra_honk/ultra_verifier.cpp | 16 ---------------- .../barretenberg/ultra_honk/ultra_verifier.hpp | 9 ++++----- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index ee391ef4a62..309b0f0264c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -5,22 +5,6 @@ #include "barretenberg/ultra_honk/oink_verifier.hpp" namespace bb { -template -UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& verifier_key) - : transcript(transcript) - , instance(std::make_shared(verifier_key)) -{} - -/** - * @brief Construct an UltraVerifier directly from a verification key - * - */ -template -UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) - : transcript(std::make_shared()) - , instance(std::make_shared(verifier_key)) -{} /** * @brief This function verifies an Ultra Honk proof for a given Flavor. diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index c61bc652514..668d98aeb16 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -18,14 +18,13 @@ template class UltraVerifier_ { using DeciderVerifier = DeciderVerifier_; public: - explicit UltraVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& verifier_key = nullptr); - - explicit UltraVerifier_(const std::shared_ptr& verifier_key); + explicit UltraVerifier_(const std::shared_ptr& verifier_key) + : instance(std::make_shared(verifier_key)) + {} bool verify_proof(const HonkProof& proof); - std::shared_ptr transcript; + std::shared_ptr transcript{ nullptr }; std::shared_ptr instance; };