From 791a6d8ec9b3b140cefbab743f8adfa81a1b13ed Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 04:42:33 +0000 Subject: [PATCH] Remove create_prover. --- barretenberg/cpp/scripts/ultra_honk_tests.sh | 5 +++- .../benchmark/ultra_bench/mock_proofs.hpp | 10 +++----- .../cpp/src/barretenberg/goblin/goblin.hpp | 7 +++--- .../goblin/goblin_recursion.test.cpp | 6 ++--- .../honk/verifier/goblin_verifier.test.cpp | 13 +++++----- .../honk/verifier/merge_verifier.test.cpp | 2 +- .../protogalaxy_recursive_verifier.test.cpp | 5 ++-- .../recursion/honk/verifier/verifier.test.cpp | 25 ++++++++++--------- .../ultra_honk/databus_composer.test.cpp | 2 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 2 +- .../goblin_ultra_transcript.test.cpp | 7 +++--- .../ultra_honk/ultra_composer.cpp | 9 ------- .../ultra_honk/ultra_composer.hpp | 3 --- .../ultra_honk/ultra_composer.test.cpp | 9 +++---- .../barretenberg/ultra_honk/ultra_prover.cpp | 16 ++++++++++++ .../barretenberg/ultra_honk/ultra_prover.hpp | 6 ++++- .../ultra_honk/ultra_transcript.test.cpp | 7 +++--- 17 files changed, 70 insertions(+), 64 deletions(-) diff --git a/barretenberg/cpp/scripts/ultra_honk_tests.sh b/barretenberg/cpp/scripts/ultra_honk_tests.sh index 654ba280c92b..50928ccb78bb 100755 --- a/barretenberg/cpp/scripts/ultra_honk_tests.sh +++ b/barretenberg/cpp/scripts/ultra_honk_tests.sh @@ -19,4 +19,7 @@ cd build/ ./bin/ultra_honk_tests ./bin/goblin_tests ./bin/client_ivc_tests -./bin/stdlib_recursion_tests \ No newline at end of file +./bin/stdlib_recursion_tests --gtest_filter=Goblin* +./bin/stdlib_recursion_tests --gtest_filter=Honk* +./bin/stdlib_recursion_tests --gtest_filter=Proto* +./bin/stdlib_recursion_tests --gtest_filter=RecursiveMerge* \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp index 9b04fe529f3f..45c1d6e7544d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -48,24 +48,22 @@ template void generate_basic_arithmetic_circuit(Builder& buil } // ultrahonk -inline UltraProver get_prover(UltraComposer& composer, +inline UltraProver get_prover([[maybe_unused]] UltraComposer& composer, void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), size_t num_iterations) { UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - auto instance = std::make_shared(builder); - return composer.create_prover(instance); + return UltraProver(builder); } -inline GoblinUltraProver get_prover(GoblinUltraComposer& composer, +inline GoblinUltraProver get_prover([[maybe_unused]] GoblinUltraComposer& composer, void (*test_circuit_function)(GoblinUltraComposer::CircuitBuilder&, size_t), size_t num_iterations) { GoblinUltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - auto instance = std::make_shared(builder); - return composer.create_prover(instance); + return GoblinUltraProver(builder); } // standard plonk diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 434af456c9e9..e7a220f81cb2 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -11,6 +11,7 @@ #include "barretenberg/ultra_honk/merge_prover.hpp" #include "barretenberg/ultra_honk/merge_verifier.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" namespace bb { @@ -103,9 +104,8 @@ class Goblin { } // Construct a Honk proof for the main circuit - GoblinUltraComposer composer; auto instance = std::make_shared(circuit_builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto ultra_proof = prover.construct_proof(); // Construct and store the merge proof to be recursively verified on the next call to accumulate @@ -229,9 +229,8 @@ class Goblin { // } // Construct a Honk proof for the main circuit - GoblinUltraComposer composer; auto instance = std::make_shared(circuit_builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto ultra_proof = prover.construct_proof(); accumulator = { ultra_proof, instance->verification_key }; diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index 4923f8794930..442a42027163 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -18,17 +18,15 @@ class GoblinRecursionTests : public ::testing::Test { using Curve = curve::BN254; using FF = Curve::ScalarField; - using GoblinUltraBuilder = GoblinUltraCircuitBuilder; using KernelInput = Goblin::AccumulationOutput; using ProverInstance = ProverInstance_; using VerifierInstance = VerifierInstance_; - static Goblin::AccumulationOutput construct_accumulator(GoblinUltraBuilder& builder) + static Goblin::AccumulationOutput construct_accumulator(GoblinUltraCircuitBuilder& builder) { - GoblinUltraComposer composer; auto prover_instance = std::make_shared(builder); auto verifier_instance = std::make_shared(prover_instance->verification_key); - auto prover = composer.create_prover(prover_instance); + GoblinUltraProver prover(prover_instance); auto ultra_proof = prover.construct_proof(); return { ultra_proof, verifier_instance->verification_key }; } 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 b618bc336f6d..d02deff490db 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 @@ -24,6 +24,7 @@ template class GoblinRecursiveVerifierTest : public testi // Define types for the inner circuit, i.e. the circuit whose proof will be recursively verified using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; + using InnerProver = GoblinUltraProver; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerProverInstance = ProverInstance_; using InnerCurve = bn254; @@ -34,6 +35,8 @@ template class GoblinRecursiveVerifierTest : public testi using OuterBuilder = BuilderType; using OuterFlavor = std::conditional_t, GoblinUltraFlavor, UltraFlavor>; + using OuterProver = + std::conditional_t, GoblinUltraProver, UltraProver>; using OuterProverInstance = ProverInstance_; using RecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; @@ -151,9 +154,8 @@ template class GoblinRecursiveVerifierTest : public testi OuterBuilder outer_circuit; // Compute native verification key - InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); - auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK + InnerProver prover(instance); // A prerequisite for computing VK auto verification_key = instance->verification_key; // Instantiate the recursive verifier using the native verification key RecursiveVerifier verifier{ &outer_circuit, verification_key }; @@ -181,7 +183,7 @@ template class GoblinRecursiveVerifierTest : public testi // Generate a proof over the inner circuit InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); - auto inner_prover = inner_composer.create_prover(instance); + InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); // Create a recursive verification circuit for the proof of the inner circuit @@ -213,7 +215,7 @@ template class GoblinRecursiveVerifierTest : public testi { auto composer = get_outer_composer(); auto instance = std::make_shared(outer_circuit); - auto prover = composer.create_prover(instance); + OuterProver prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -234,9 +236,8 @@ 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); - auto inner_prover = inner_composer.create_prover(instance); + InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); // Arbitrarily tamper with the proof to be verified 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 203326a0d1ed..4b463cabd0fc 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 @@ -83,7 +83,7 @@ class RecursiveMergeVerifierTest : public testing::Test { { GoblinUltraComposer composer; auto instance = std::make_shared(outer_circuit); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto verifier = composer.create_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 7eaee41fffc2..5026e784c4f9 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 @@ -13,6 +13,7 @@ template class ProtoGalaxyRecursiveTests : public tes using NativeFlavor = typename RecursiveFlavor::NativeFlavor; using Composer = ::bb::UltraComposer_; using Builder = typename RecursiveFlavor::CircuitBuilder; + using Prover = UltraProver_; using ProverInstance = ::bb::ProverInstance_; using VerifierInstance = ::bb::VerifierInstance_; using RecursiveVerifierInstance = ::bb::stdlib::recursion::honk::RecursiveVerifierInstance_; @@ -204,7 +205,7 @@ template class ProtoGalaxyRecursiveTests : public tes { auto composer = Composer(); auto instance = std::make_shared(folding_circuit); - auto prover = composer.create_prover(instance); + Prover prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -294,7 +295,7 @@ template class ProtoGalaxyRecursiveTests : public tes { auto composer = Composer(); auto instance = std::make_shared(decider_circuit); - auto prover = composer.create_prover(instance); + Prover prover(instance); auto verifier = composer.create_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 632830067203..b57efddad109 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 @@ -16,7 +16,7 @@ namespace bb::stdlib::recursion::honk { * * @tparam Builder */ -template class RecursiveVerifierTest : public testing::Test { +template class HonkRecursiveVerifierTest : public testing::Test { // Define types relevant for testing using UltraComposer = UltraComposer_; @@ -25,6 +25,7 @@ template class RecursiveVerifierTest : public testing::Te using InnerFlavor = UltraFlavor; using InnerProverInstance = ProverInstance_; using InnerComposer = UltraComposer; + using InnerProver = UltraProver; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerCurve = bn254; using Commitment = InnerFlavor::Commitment; @@ -36,6 +37,8 @@ template class RecursiveVerifierTest : public testing::Te using OuterBuilder = BuilderType; using OuterFlavor = std::conditional_t, GoblinUltraFlavor, UltraFlavor>; + using OuterProver = + std::conditional_t, GoblinUltraProver, UltraProver>; using OuterProverInstance = ProverInstance_; using VerificationKey = typename RecursiveVerifier::VerificationKey; @@ -136,9 +139,8 @@ template class RecursiveVerifierTest : public testing::Te create_inner_circuit(inner_circuit); // Compute native verification key - InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); - auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK + InnerProver prover(instance); // A prerequisite for computing VK auto verification_key = instance->verification_key; // Instantiate the recursive verifier using the native verification key RecursiveVerifier verifier{ &outer_circuit, verification_key }; @@ -166,7 +168,7 @@ template class RecursiveVerifierTest : public testing::Te // Generate a proof over the inner circuit InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); - auto inner_prover = inner_composer.create_prover(instance); + InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); // Create a recursive verification circuit for the proof of the inner circuit @@ -198,7 +200,7 @@ template class RecursiveVerifierTest : public testing::Te { auto composer = get_outer_composer(); auto instance = std::make_shared(outer_circuit); - auto prover = composer.create_prover(instance); + OuterProver prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -220,9 +222,8 @@ template class RecursiveVerifierTest : public testing::Te create_inner_circuit(inner_circuit); // Generate a proof over the inner circuit - InnerComposer inner_composer; auto instance = std::make_shared(inner_circuit); - auto inner_prover = inner_composer.create_prover(instance); + InnerProver inner_prover(instance); auto inner_proof = inner_prover.construct_proof(); // Arbitrarily tamper with the proof to be verified @@ -244,24 +245,24 @@ template class RecursiveVerifierTest : public testing::Te // Run the recursive verifier tests with conventional Ultra builder and Goblin builder using BuilderTypes = testing::Types; -TYPED_TEST_SUITE(RecursiveVerifierTest, BuilderTypes); +TYPED_TEST_SUITE(HonkRecursiveVerifierTest, BuilderTypes); -HEAVY_TYPED_TEST(RecursiveVerifierTest, InnerCircuit) +HEAVY_TYPED_TEST(HonkRecursiveVerifierTest, InnerCircuit) { TestFixture::test_inner_circuit(); } -HEAVY_TYPED_TEST(RecursiveVerifierTest, RecursiveVerificationKey) +HEAVY_TYPED_TEST(HonkRecursiveVerifierTest, RecursiveVerificationKey) { TestFixture::test_recursive_verification_key_creation(); } -HEAVY_TYPED_TEST(RecursiveVerifierTest, SingleRecursiveVerification) +HEAVY_TYPED_TEST(HonkRecursiveVerifierTest, SingleRecursiveVerification) { TestFixture::test_recursive_verification(); }; -HEAVY_TYPED_TEST(RecursiveVerifierTest, SingleRecursiveVerificationFailure) +HEAVY_TYPED_TEST(HonkRecursiveVerifierTest, SingleRecursiveVerificationFailure) { TestFixture::test_recursive_verification_fails(); }; 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 cad1e179364d..184a62429b47 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -86,7 +86,7 @@ TEST_F(DataBusComposerTests, CallDataRead) // Construct and verify Honk proof auto instance = std::make_shared>(builder); // For debugging, use "instance_inspector::print_databus_info(instance)" - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto verifier = composer.create_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_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index fe6b744b0326..3933b3d8210e 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 @@ -63,7 +63,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { bool construct_and_verify_honk_proof(auto& composer, auto& builder) { auto instance = std::make_shared>(builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto verifier = composer.create_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 16a5109adff0..1fa6b5e0ebed 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 @@ -145,9 +145,8 @@ TEST_F(GoblinUltraTranscriptTests, ProverManifestConsistency) generate_test_circuit(builder); // Automatically generate a transcript manifest by constructing a proof - auto composer = GoblinUltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -174,7 +173,7 @@ TEST_F(GoblinUltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto composer = GoblinUltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -225,7 +224,7 @@ TEST_F(GoblinUltraTranscriptTests, StructureTest) // Automatically generate a transcript manifest by constructing a proof auto composer = GoblinUltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + GoblinUltraProver prover(instance); auto proof = prover.construct_proof(); auto verifier = composer.create_verifier(instance->verification_key); EXPECT_TRUE(verifier.verify_proof(proof)); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index d91fcad5575a..2a2306990867 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -6,15 +6,6 @@ namespace bb { -template -UltraProver_ UltraComposer_::create_prover(const std::shared_ptr& instance, - const std::shared_ptr& transcript) -{ - UltraProver_ output_state(instance, transcript); - - return output_state; -} - template UltraVerifier_ UltraComposer_::create_verifier(const std::shared_ptr& verification_key, 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 00bd54970238..3797479dfd30 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -25,9 +25,6 @@ template class UltraComposer_ { using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - UltraProver_ create_prover(const std::shared_ptr&, - const std::shared_ptr& transcript = std::make_shared()); - UltraVerifier_ create_verifier( 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 3b370b79c7dd..80384ba15177 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -22,7 +22,7 @@ namespace { auto& engine = numeric::get_debug_randomness(); } -using ProverInstance = typename UltraComposer::ProverInstance; +using ProverInstance = ProverInstance_; std::vector add_variables(auto& circuit_builder, std::vector variables) { @@ -36,7 +36,7 @@ std::vector add_variables(auto& circuit_builder, std::vector v void prove_and_verify(auto& circuit_builder, auto& composer, bool expected_result) { auto instance = std::make_shared(circuit_builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); bool verified = verifier.verify_proof(proof); @@ -68,9 +68,8 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) { auto circuit_builder = UltraCircuitBuilder(); - auto composer = UltraComposer(); auto instance = std::make_shared(circuit_builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto proof = prover.construct_proof(); auto proving_key = instance->proving_key; @@ -201,7 +200,7 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) } auto composer = UltraComposer(); auto instance = std::make_shared(circuit_builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index c4f62204066f..8c8af1bcae29 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -19,6 +19,22 @@ UltraProver_::UltraProver_(const std::shared_ptr& inst, const instance->initialize_prover_polynomials(); } +/** + * Create UltraProver_ from a circuit. + * + * @param instance Instance whose proof we want to generate. + * + * @tparam a type of UltraFlavor + * */ +template +UltraProver_::UltraProver_(Builder& circuit, const std::shared_ptr& transcript) + : instance(std::make_shared(circuit)) + , transcript(transcript) + , commitment_key(instance->proving_key->commitment_key) +{ + instance->initialize_prover_polynomials(); +} + /** * @brief Add circuit size, public input size, and public inputs to transcript * diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index 356f163983b7..ec5c35f3b5f2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -12,13 +12,15 @@ namespace bb { template class UltraProver_ { using FF = typename Flavor::FF; + using Builder = typename Flavor::CircuitBuilder; using Commitment = typename Flavor::Commitment; using CommitmentKey = typename Flavor::CommitmentKey; using Polynomial = typename Flavor::Polynomial; using ProverPolynomials = typename Flavor::ProverPolynomials; using CommitmentLabels = typename Flavor::CommitmentLabels; using Curve = typename Flavor::Curve; - using Instance = ProverInstance_; + using ProverInstance = ProverInstance_; + using Instance = ProverInstance; using Transcript = typename Flavor::Transcript; using RelationSeparator = typename Flavor::RelationSeparator; @@ -26,6 +28,8 @@ template class UltraProver_ { explicit UltraProver_(const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); + explicit UltraProver_(Builder&, const std::shared_ptr& transcript = std::make_shared()); + BB_PROFILE void execute_preamble_round(); BB_PROFILE void execute_wire_commitments_round(); BB_PROFILE void execute_sorted_list_accumulator_round(); 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 443038c8cdde..b89e0a3fe2f8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -131,9 +131,8 @@ TEST_F(UltraTranscriptTests, ProverManifestConsistency) generate_test_circuit(builder); // Automatically generate a transcript manifest by constructing a proof - auto composer = UltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -160,7 +159,7 @@ TEST_F(UltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto composer = UltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -211,7 +210,7 @@ TEST_F(UltraTranscriptTests, StructureTest) // Automatically generate a transcript manifest by constructing a proof auto composer = UltraComposer(); auto instance = std::make_shared(builder); - auto prover = composer.create_prover(instance); + UltraProver prover(instance); auto proof = prover.construct_proof(); auto verifier = composer.create_verifier(instance->verification_key); EXPECT_TRUE(verifier.verify_proof(proof));