From 7c2178d138e7416a6d6eeae5d8b46eb7c94cab22 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 15:09:15 +0000 Subject: [PATCH] REmove create_verifier functionality --- .../recursion/honk/verifier/goblin_verifier.test.cpp | 9 +++++---- .../recursion/honk/verifier/merge_verifier.test.cpp | 3 +-- .../verifier/protogalaxy_recursive_verifier.test.cpp | 7 +++---- .../stdlib/recursion/honk/verifier/verifier.test.cpp | 9 +++++---- .../barretenberg/ultra_honk/databus_composer.test.cpp | 4 +--- .../ultra_honk/goblin_ultra_composer.test.cpp | 4 ++-- .../ultra_honk/goblin_ultra_transcript.test.cpp | 8 +++----- .../cpp/src/barretenberg/ultra_honk/ultra_composer.cpp | 7 ------- .../cpp/src/barretenberg/ultra_honk/ultra_composer.hpp | 4 ---- .../src/barretenberg/ultra_honk/ultra_composer.test.cpp | 9 ++++----- .../barretenberg/ultra_honk/ultra_transcript.test.cpp | 6 ++---- 11 files changed, 26 insertions(+), 44 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index d02deff490db..81dab41a8784 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -25,6 +25,7 @@ template class GoblinRecursiveVerifierTest : public testi using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; using InnerProver = GoblinUltraProver; + using InnerVerifier = GoblinUltraVerifier; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerProverInstance = ProverInstance_; using InnerCurve = bn254; @@ -37,6 +38,8 @@ template class GoblinRecursiveVerifierTest : public testi std::conditional_t, GoblinUltraFlavor, UltraFlavor>; using OuterProver = std::conditional_t, GoblinUltraProver, UltraProver>; + using OuterVerifier = + std::conditional_t, GoblinUltraVerifier, UltraVerifier>; using OuterProverInstance = ProverInstance_; using RecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; @@ -181,7 +184,6 @@ template class GoblinRecursiveVerifierTest : public testi auto inner_circuit = create_inner_circuit(); // Generate a proof over the inner circuit - InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); @@ -197,7 +199,7 @@ template class GoblinRecursiveVerifierTest : public testi // Check 1: Perform native verification then perform the pairing on the outputs of the recursive // verifier and check that the result agrees. - auto native_verifier = inner_composer.create_verifier(instance->verification_key); + InnerVerifier native_verifier(instance->verification_key); auto native_result = native_verifier.verify_proof(inner_proof); auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(), pairing_points[1].get_value()); @@ -213,10 +215,9 @@ template class GoblinRecursiveVerifierTest : public testi // Check 3: Construct and verify a proof of the recursive verifier circuit { - auto composer = get_outer_composer(); auto instance = std::make_shared(outer_circuit); OuterProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + OuterVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 4b463cabd0fc..bb0a8058cd32 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -81,10 +81,9 @@ class RecursiveMergeVerifierTest : public testing::Test { // Check 3: Construct and verify a (goblin) ultra honk proof of the Merge recursive verifier circuit { - GoblinUltraComposer composer; auto instance = std::make_shared(outer_circuit); GoblinUltraProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + GoblinUltraVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); 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 5026e784c4f9..35f7546a9a29 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 @@ -14,6 +14,7 @@ template class ProtoGalaxyRecursiveTests : public tes using Composer = ::bb::UltraComposer_; using Builder = typename RecursiveFlavor::CircuitBuilder; using Prover = UltraProver_; + using Verifier = UltraVerifier_; using ProverInstance = ::bb::ProverInstance_; using VerifierInstance = ::bb::VerifierInstance_; using RecursiveVerifierInstance = ::bb::stdlib::recursion::honk::RecursiveVerifierInstance_; @@ -203,10 +204,9 @@ template class ProtoGalaxyRecursiveTests : public tes // Check for a failure flag in the recursive verifier circuit { - auto composer = Composer(); auto instance = std::make_shared(folding_circuit); Prover prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + Verifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -293,10 +293,9 @@ template class ProtoGalaxyRecursiveTests : public tes // Construct and verify a proof of the recursive decider verifier circuit { - auto composer = Composer(); auto instance = std::make_shared(decider_circuit); Prover prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + Verifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index b57efddad109..7758bda335a6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -26,6 +26,7 @@ template class HonkRecursiveVerifierTest : public testing using InnerProverInstance = ProverInstance_; using InnerComposer = UltraComposer; using InnerProver = UltraProver; + using InnerVerifier = UltraVerifier; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerCurve = bn254; using Commitment = InnerFlavor::Commitment; @@ -39,6 +40,8 @@ template class HonkRecursiveVerifierTest : public testing std::conditional_t, GoblinUltraFlavor, UltraFlavor>; using OuterProver = std::conditional_t, GoblinUltraProver, UltraProver>; + using OuterVerifier = + std::conditional_t, GoblinUltraVerifier, UltraVerifier>; using OuterProverInstance = ProverInstance_; using VerificationKey = typename RecursiveVerifier::VerificationKey; @@ -166,7 +169,6 @@ template class HonkRecursiveVerifierTest : public testing create_inner_circuit(inner_circuit); // Generate a proof over the inner circuit - InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); @@ -182,7 +184,7 @@ template class HonkRecursiveVerifierTest : public testing // Check 1: Perform native verification then perform the pairing on the outputs of the recursive // verifier and check that the result agrees. - auto native_verifier = inner_composer.create_verifier(instance->verification_key); + InnerVerifier native_verifier(instance->verification_key); auto native_result = native_verifier.verify_proof(inner_proof); auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(), pairing_points[1].get_value()); @@ -198,10 +200,9 @@ template class HonkRecursiveVerifierTest : public testing // Check 3: Construct and verify a proof of the recursive verifier circuit { - auto composer = get_outer_composer(); auto instance = std::make_shared(outer_circuit); OuterProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + OuterVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index 184a62429b47..e16356dd7bea 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -81,13 +81,11 @@ TEST_F(DataBusComposerTests, CallDataRead) builder.calldata_read_counts[read_index]++; } - auto composer = GoblinUltraComposer(); - // Construct and verify Honk proof auto instance = std::make_shared>(builder); // For debugging, use "instance_inspector::print_databus_info(instance)" GoblinUltraProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + GoblinUltraVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 3933b3d8210e..70d281d8ca2d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -60,11 +60,11 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { * @brief Construct and a verify a Honk proof * */ - bool construct_and_verify_honk_proof(auto& composer, auto& builder) + bool construct_and_verify_honk_proof([[maybe_unused]] auto& composer, auto& builder) { auto instance = std::make_shared>(builder); GoblinUltraProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + GoblinUltraVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 1fa6b5e0ebed..62b7dda79d5f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -171,13 +171,12 @@ TEST_F(GoblinUltraTranscriptTests, VerifierManifestConsistency) generate_test_circuit(builder); // Automatically generate a transcript manifest in the prover by constructing a proof - auto composer = GoblinUltraComposer(); auto instance = std::make_shared(builder); GoblinUltraProver prover(instance); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof - auto verifier = composer.create_verifier(instance->verification_key); + GoblinUltraVerifier verifier(instance->verification_key); verifier.verify_proof(proof); // Check consistency between the manifests generated by the prover and verifier @@ -218,15 +217,14 @@ TEST_F(GoblinUltraTranscriptTests, ChallengeGenerationTest) TEST_F(GoblinUltraTranscriptTests, StructureTest) { // Construct a simple circuit of size n = 8 (i.e. the minimum circuit size) - auto builder = typename Flavor::CircuitBuilder(); + Flavor::CircuitBuilder builder; generate_test_circuit(builder); // Automatically generate a transcript manifest by constructing a proof - auto composer = GoblinUltraComposer(); auto instance = std::make_shared(builder); GoblinUltraProver prover(instance); auto proof = prover.construct_proof(); - auto verifier = composer.create_verifier(instance->verification_key); + GoblinUltraVerifier verifier(instance->verification_key); EXPECT_TRUE(verifier.verify_proof(proof)); // try deserializing and serializing with no changes and check proof is still valid diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 2a2306990867..817e88d80c01 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -6,13 +6,6 @@ namespace bb { -template -UltraVerifier_ UltraComposer_::create_verifier(const std::shared_ptr& verification_key, - const std::shared_ptr& transcript) -{ - return UltraVerifier_(transcript, verification_key); -} - template DeciderProver_ UltraComposer_::create_decider_prover(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 3797479dfd30..2118aa6bd64b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -25,10 +25,6 @@ template class UltraComposer_ { using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - UltraVerifier_ create_verifier( - const std::shared_ptr&, - const std::shared_ptr& transcript = std::make_shared()); - DeciderProver_ create_decider_prover( const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 80384ba15177..da32df9a3e0d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -33,11 +33,11 @@ std::vector add_variables(auto& circuit_builder, std::vector v return res; } -void prove_and_verify(auto& circuit_builder, auto& composer, bool expected_result) +void prove_and_verify(auto& circuit_builder, [[maybe_unused]] auto& composer, bool expected_result) { auto instance = std::make_shared(circuit_builder); UltraProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + UltraVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); EXPECT_EQ(verified, expected_result); @@ -198,10 +198,9 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) expected_scalar >>= table_bits; } } - auto composer = UltraComposer(); auto instance = std::make_shared(circuit_builder); UltraProver prover(instance); - auto verifier = composer.create_verifier(instance->verification_key); + UltraVerifier verifier(instance->verification_key); auto proof = prover.construct_proof(); bool result = verifier.verify_proof(proof); @@ -886,4 +885,4 @@ TEST_F(UltraHonkComposerTests, range_constraint_small_variable) auto composer = UltraComposer(); prove_and_verify(circuit_builder, composer, /*expected_result=*/true); -} \ No newline at end of file +} diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index b89e0a3fe2f8..042241335cdf 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -157,13 +157,12 @@ TEST_F(UltraTranscriptTests, VerifierManifestConsistency) generate_test_circuit(builder); // Automatically generate a transcript manifest in the prover by constructing a proof - auto composer = UltraComposer(); auto instance = std::make_shared(builder); UltraProver prover(instance); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof - auto verifier = composer.create_verifier(instance->verification_key); + UltraVerifier verifier(instance->verification_key); verifier.verify_proof(proof); // Check consistency between the manifests generated by the prover and verifier @@ -208,11 +207,10 @@ TEST_F(UltraTranscriptTests, StructureTest) generate_test_circuit(builder); // Automatically generate a transcript manifest by constructing a proof - auto composer = UltraComposer(); auto instance = std::make_shared(builder); UltraProver prover(instance); auto proof = prover.construct_proof(); - auto verifier = composer.create_verifier(instance->verification_key); + UltraVerifier verifier(instance->verification_key); EXPECT_TRUE(verifier.verify_proof(proof)); // try deserializing and serializing with no changes and check proof is still valid