From ff7c87612ffe61bcf855746453d87e6a5d7ab394 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 03:28:39 +0000 Subject: [PATCH 01/17] Remove create_prover_instance --- .../protogalaxy_bench/protogalaxy.bench.cpp | 15 ++++++------- .../protogalaxy_rounds.bench.cpp | 22 +++++++++---------- .../benchmark/ultra_bench/mock_proofs.hpp | 4 ++-- .../barretenberg/client_ivc/client_ivc.cpp | 5 ++--- .../client_ivc/mock_kernel_pinning.test.cpp | 3 +-- .../cpp/src/barretenberg/goblin/goblin.hpp | 6 ++--- .../goblin/goblin_recursion.test.cpp | 3 ++- .../goblin/mock_circuits_pinning.test.cpp | 8 +++---- .../honk/verifier/goblin_verifier.test.cpp | 12 ++++++---- .../honk/verifier/merge_verifier.test.cpp | 3 ++- .../protogalaxy_recursive_verifier.test.cpp | 18 +++++++-------- .../recursion/honk/verifier/verifier.test.cpp | 13 +++++++---- .../ultra_honk/databus_composer.test.cpp | 2 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 2 +- .../goblin_ultra_transcript.test.cpp | 7 +++--- .../ultra_honk/protogalaxy.test.cpp | 21 +++++++++--------- .../ultra_honk/relation_correctness.test.cpp | 6 ++--- .../barretenberg/ultra_honk/sumcheck.test.cpp | 3 +-- .../ultra_honk/ultra_composer.cpp | 6 ----- .../ultra_honk/ultra_composer.hpp | 2 -- .../ultra_honk/ultra_composer.test.cpp | 8 ++++--- .../ultra_honk/ultra_transcript.test.cpp | 7 +++--- 22 files changed, 88 insertions(+), 88 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index 0b5c2403cc5..140de3e486a 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -9,10 +9,10 @@ using namespace benchmark; namespace bb { // Fold one instance into an accumulator. -template void fold_one(State& state) noexcept +template void fold_one(State& state) noexcept { - using Flavor = typename Composer::Flavor; - using Instance = ProverInstance_; + using ProverInstance = ProverInstance_; + using Instance = ProverInstance; using Instances = ProverInstances_; using ProtoGalaxyProver = ProtoGalaxyProver_; using Builder = typename Flavor::CircuitBuilder; @@ -20,7 +20,6 @@ template void fold_one(State& state) noexcept bb::srs::init_crs_factory("../srs_db/ignition"); auto log2_num_gates = static_cast(state.range(0)); - Composer composer; const auto construct_instance = [&]() { Builder builder; @@ -30,21 +29,21 @@ template void fold_one(State& state) noexcept static_assert(std::same_as); bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); } - return composer.create_prover_instance(builder); + return std::make_shared(builder); }; std::shared_ptr instance_1 = construct_instance(); std::shared_ptr instance_2 = construct_instance(); - ProtoGalaxyProver folding_prover = composer.create_folding_prover({ instance_1, instance_2 }); + ProtoGalaxyProver folding_prover({ instance_1, instance_2 }); for (auto _ : state) { auto proof = folding_prover.fold_instances(); } } -BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); -BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); +BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); +BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); } // namespace bb BENCHMARK_MAIN(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp index 5efdccce9ce..ba1ee89f4de 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp @@ -8,16 +8,16 @@ using namespace benchmark; namespace bb { -template -void _bench_round(::benchmark::State& state, - void (*F)(ProtoGalaxyProver_>&)) +template +void _bench_round(::benchmark::State& state, void (*F)(ProtoGalaxyProver_>&)) { - using Flavor = typename Composer::Flavor; using Builder = typename Flavor::CircuitBuilder; + using ProverInstance = ProverInstance_; + using Instances = ProverInstances_; + using ProtoGalaxyProver = ProtoGalaxyProver_; bb::srs::init_crs_factory("../srs_db/ignition"); auto log2_num_gates = static_cast(state.range(0)); - auto composer = Composer(); const auto construct_instance = [&]() { Builder builder; @@ -27,13 +27,13 @@ void _bench_round(::benchmark::State& state, static_assert(std::same_as); bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); } - return composer.create_prover_instance(builder); + return std::make_shared(builder); }; - auto prover_instance_1 = construct_instance(); - auto prover_instance_2 = construct_instance(); + std::shared_ptr prover_instance_1 = construct_instance(); + std::shared_ptr prover_instance_2 = construct_instance(); - auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); + ProtoGalaxyProver folding_prover({ prover_instance_1, prover_instance_2 }); // prepare the prover state folding_prover.state.accumulator = prover_instance_1; @@ -50,13 +50,13 @@ void _bench_round(::benchmark::State& state, void bench_round_ultra(::benchmark::State& state, void (*F)(ProtoGalaxyProver_>&)) { - _bench_round(state, F); + _bench_round(state, F); } void bench_round_goblin_ultra(::benchmark::State& state, void (*F)(ProtoGalaxyProver_>&)) { - _bench_round(state, F); + _bench_round(state, F); } BENCHMARK_CAPTURE(bench_round_ultra, preparation, [](auto& prover) { prover.preparation_round(); }) 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 29ff2fb135e..9b04fe529f3 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -54,7 +54,7 @@ inline UltraProver get_prover(UltraComposer& composer, { UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); return composer.create_prover(instance); } @@ -64,7 +64,7 @@ inline GoblinUltraProver get_prover(GoblinUltraComposer& composer, { GoblinUltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); return composer.create_prover(instance); } diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp index 911c802ebf8..fe7dca70d6e 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp @@ -17,8 +17,7 @@ ClientIVC::ClientIVC() void ClientIVC::initialize(ClientCircuit& circuit) { goblin.merge(circuit); // Construct new merge proof - Composer composer; - prover_fold_output.accumulator = composer.create_prover_instance(circuit); + prover_fold_output.accumulator = std::make_shared(circuit); } /** @@ -32,7 +31,7 @@ ClientIVC::FoldProof ClientIVC::accumulate(ClientCircuit& circuit) { goblin.merge(circuit); // Add recursive merge verifier and construct new merge proof Composer composer; - prover_instance = composer.create_prover_instance(circuit); + prover_instance = std::make_shared(circuit); auto folding_prover = composer.create_folding_prover({ prover_fold_output.accumulator, prover_instance }); prover_fold_output = folding_prover.fold_instances(); return prover_fold_output.folding_data; diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp index 773496dbfb2..3dbbe13ed61 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp @@ -48,7 +48,6 @@ TEST_F(MockKernelTest, PinFoldingKernelSizes) { kernel_fold_proof, ivc.vks.first_kernel_vk }, { func_fold_proof, ivc.vks.func_vk }, kernel_acc); - GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(kernel_circuit); + auto instance = std::make_shared(kernel_circuit); EXPECT_EQ(instance->proving_key->log_circuit_size, 17); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 3b055844b2f..a6ec15ec07c 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -16,7 +16,6 @@ namespace bb { class Goblin { using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; - using Commitment = GoblinUltraFlavor::Commitment; using FF = GoblinUltraFlavor::FF; @@ -24,6 +23,7 @@ class Goblin { using Builder = GoblinUltraCircuitBuilder; using Fr = bb::fr; using Transcript = NativeTranscript; + using GoblinUltraProverInstance = ProverInstance_; using GoblinUltraComposer = bb::UltraComposer_; using GoblinUltraVerifier = bb::UltraVerifier_; using OpQueue = bb::ECCOpQueue; @@ -104,7 +104,7 @@ class Goblin { // Construct a Honk proof for the main circuit GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(circuit_builder); + auto instance = std::make_shared(circuit_builder); auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); @@ -230,7 +230,7 @@ class Goblin { // Construct a Honk proof for the main circuit GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(circuit_builder); + auto instance = std::make_shared(circuit_builder); auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index c731722d755..d5b5288918a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -20,11 +20,12 @@ class GoblinRecursionTests : public ::testing::Test { using FF = Curve::ScalarField; using GoblinUltraBuilder = GoblinUltraCircuitBuilder; using KernelInput = Goblin::AccumulationOutput; + using ProverInstance = ProverInstance_; static Goblin::AccumulationOutput construct_accumulator(GoblinUltraBuilder& builder) { GoblinUltraComposer composer; - auto prover_instance = composer.create_prover_instance(builder); + auto prover_instance = std::make_shared(builder); auto verifier_instance = composer.create_verifier_instance(prover_instance); auto prover = composer.create_prover(prover_instance); auto ultra_proof = prover.construct_proof(); diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp index db0fc69b80d..bdc8abc22e5 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp @@ -13,6 +13,7 @@ using namespace bb; */ class MockCircuits : public ::testing::Test { protected: + using ProverInstance = ProverInstance_; static void SetUpTestSuite() { srs::init_crs_factory("../srs_db/ignition"); } }; @@ -22,8 +23,7 @@ TEST_F(MockCircuits, PinFunctionSizes) Goblin goblin; GoblinUltraCircuitBuilder app_circuit{ goblin.op_queue }; GoblinMockCircuits::construct_mock_function_circuit(app_circuit, large); - GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(app_circuit); + auto instance = std::make_shared(app_circuit); if (large) { EXPECT_EQ(instance->proving_key->log_circuit_size, 19); } else { @@ -46,8 +46,8 @@ TEST_F(MockCircuits, PinRecursionKernelSizes) auto function_accum = goblin.accumulate(app_circuit); GoblinUltraCircuitBuilder kernel_circuit{ goblin.op_queue }; GoblinMockCircuits::construct_mock_recursion_kernel_circuit(kernel_circuit, function_accum, kernel_accum); - GoblinUltraComposer composer; - auto instance = composer.create_prover_instance(kernel_circuit); + + auto instance = std::make_shared(kernel_circuit); if (large) { EXPECT_EQ(instance->proving_key->log_circuit_size, 17); } else { 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 e37b54487cf..b618bc336f6 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,12 +25,16 @@ template class GoblinRecursiveVerifierTest : public testi using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; + using InnerProverInstance = ProverInstance_; using InnerCurve = bn254; using InnerCommitment = InnerFlavor::Commitment; using InnerFF = InnerFlavor::FF; // Types for recursive verifier circuit using OuterBuilder = BuilderType; + using OuterFlavor = + std::conditional_t, GoblinUltraFlavor, UltraFlavor>; + using OuterProverInstance = ProverInstance_; using RecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; using VerificationKey = typename RecursiveVerifier::VerificationKey; @@ -148,7 +152,7 @@ template class GoblinRecursiveVerifierTest : public testi // Compute native verification key InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK auto verification_key = instance->verification_key; // Instantiate the recursive verifier using the native verification key @@ -176,7 +180,7 @@ template class GoblinRecursiveVerifierTest : public testi // Generate a proof over the inner circuit InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_proof(); @@ -208,7 +212,7 @@ template class GoblinRecursiveVerifierTest : public testi // Check 3: Construct and verify a proof of the recursive verifier circuit { auto composer = get_outer_composer(); - auto instance = composer.create_prover_instance(outer_circuit); + auto instance = std::make_shared(outer_circuit); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); @@ -231,7 +235,7 @@ template class GoblinRecursiveVerifierTest : public testi // Generate a proof over the inner circuit InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_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 9b4ee8d37e1..203326a0d1e 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 @@ -22,6 +22,7 @@ class RecursiveMergeVerifierTest : public testing::Test { // Define types relevant for inner circuit using GoblinUltraComposer = UltraComposer_; using InnerFlavor = GoblinUltraFlavor; + using InnerProverInstance = ProverInstance_; using InnerComposer = GoblinUltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; @@ -81,7 +82,7 @@ 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 = composer.create_prover_instance(outer_circuit); + auto instance = std::make_shared(outer_circuit); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_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 55eb6116770..51b968d4890 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 @@ -103,8 +103,8 @@ template class ProtoGalaxyRecursiveTests : public tes builder2.add_public_variable(FF(1)); create_function_circuit(builder2); - auto prover_instance_1 = composer.create_prover_instance(builder1); - auto prover_instance_2 = composer.create_prover_instance(builder2); + auto prover_instance_1 = std::make_shared(builder1); + auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); @@ -169,9 +169,9 @@ template class ProtoGalaxyRecursiveTests : public tes create_function_circuit(builder2); Composer composer = Composer(); - auto prover_instance_1 = composer.create_prover_instance(builder1); + auto prover_instance_1 = std::make_shared(builder1); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); - auto prover_instance_2 = composer.create_prover_instance(builder2); + auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); // Generate a folding proof auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); @@ -203,7 +203,7 @@ template class ProtoGalaxyRecursiveTests : public tes { auto composer = Composer(); - auto instance = composer.create_prover_instance(folding_circuit); + auto instance = std::make_shared(folding_circuit); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); @@ -231,9 +231,9 @@ template class ProtoGalaxyRecursiveTests : public tes create_function_circuit(builder2); Composer composer = Composer(); - auto prover_instance_1 = composer.create_prover_instance(builder1); + auto prover_instance_1 = std::make_shared(builder1); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); - auto prover_instance_2 = composer.create_prover_instance(builder2); + auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); // Generate a folding proof auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); @@ -293,7 +293,7 @@ template class ProtoGalaxyRecursiveTests : public tes // Construct and verify a proof of the recursive decider verifier circuit { auto composer = Composer(); - auto instance = composer.create_prover_instance(decider_circuit); + auto instance = std::make_shared(decider_circuit); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); @@ -335,7 +335,7 @@ template class ProtoGalaxyRecursiveTests : public tes // Create another circuit to do a second round of folding Builder builder; create_function_circuit(builder); - auto prover_inst = composer.create_prover_instance(builder); + auto prover_inst = std::make_shared(builder); auto verifier_inst = composer.create_verifier_instance(prover_inst); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); 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 3dda0156bee..63283006720 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 @@ -23,6 +23,7 @@ template class RecursiveVerifierTest : public testing::Te using GoblinUltraComposer = UltraComposer_; using InnerFlavor = UltraFlavor; + using InnerProverInstance = ProverInstance_; using InnerComposer = UltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerCurve = bn254; @@ -33,6 +34,10 @@ template class RecursiveVerifierTest : public testing::Te using RecursiveFlavor = UltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; using OuterBuilder = BuilderType; + using OuterFlavor = + std::conditional_t, GoblinUltraFlavor, UltraFlavor>; + using OuterProverInstance = ProverInstance_; + using VerificationKey = typename RecursiveVerifier::VerificationKey; // Helper for getting composer for prover/verifier of recursive (outer) circuit @@ -132,7 +137,7 @@ template class RecursiveVerifierTest : public testing::Te // Compute native verification key InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK auto verification_key = instance->verification_key; // Instantiate the recursive verifier using the native verification key @@ -160,7 +165,7 @@ template class RecursiveVerifierTest : public testing::Te // Generate a proof over the inner circuit InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_proof(); @@ -192,7 +197,7 @@ template class RecursiveVerifierTest : public testing::Te // Check 3: Construct and verify a proof of the recursive verifier circuit { auto composer = get_outer_composer(); - auto instance = composer.create_prover_instance(outer_circuit); + auto instance = std::make_shared(outer_circuit); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); @@ -216,7 +221,7 @@ template class RecursiveVerifierTest : public testing::Te // Generate a proof over the inner circuit InnerComposer inner_composer; - auto instance = inner_composer.create_prover_instance(inner_circuit); + auto instance = std::make_shared(inner_circuit); auto inner_prover = inner_composer.create_prover(instance); auto inner_proof = inner_prover.construct_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 6af08ef87f7..cad1e179364 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -84,7 +84,7 @@ TEST_F(DataBusComposerTests, CallDataRead) auto composer = GoblinUltraComposer(); // Construct and verify Honk proof - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared>(builder); // For debugging, use "instance_inspector::print_databus_info(instance)" auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); 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 43ff53ffb0c..fe6b744b032 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 @@ -62,7 +62,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { */ bool construct_and_verify_honk_proof(auto& composer, auto& builder) { - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared>(builder); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_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 12ae627a62f..16a5109adff 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 @@ -13,6 +13,7 @@ class GoblinUltraTranscriptTests : public ::testing::Test { static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Flavor = GoblinUltraFlavor; + using ProverInstance = ProverInstance_; using FF = Flavor::FF; /** @@ -145,7 +146,7 @@ TEST_F(GoblinUltraTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto composer = GoblinUltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); @@ -172,7 +173,7 @@ TEST_F(GoblinUltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto composer = GoblinUltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); @@ -223,7 +224,7 @@ TEST_F(GoblinUltraTranscriptTests, StructureTest) // Automatically generate a transcript manifest by constructing a proof auto composer = GoblinUltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); auto verifier = composer.create_verifier(instance->verification_key); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 3c4370edd94..87494233074 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -114,8 +114,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder = typename Flavor::CircuitBuilder(); construct_circuit(builder); - auto composer = Composer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); instance->initialize_prover_polynomials(); auto eta = FF::random_element(); @@ -299,12 +298,12 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); - auto prover_instance_1 = composer.create_prover_instance(builder_1); + auto prover_instance_1 = std::make_shared(builder_1); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); - auto prover_instance_2 = composer.create_prover_instance(builder_2); + auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); @@ -313,7 +312,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); - auto prover_instance_3 = composer.create_prover_instance(builder_3); + auto prover_instance_3 = std::make_shared(builder_3); auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( @@ -334,12 +333,12 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); - auto prover_instance_1 = composer.create_prover_instance(builder_1); + auto prover_instance_1 = std::make_shared(builder_1); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); - auto prover_instance_2 = composer.create_prover_instance(builder_2); + auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); @@ -348,7 +347,7 @@ template class ProtoGalaxyTests : public testing::Test { verifier_accumulator->witness_commitments.w_l = Projective(Affine::random_element()); auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); - auto prover_instance_3 = composer.create_prover_instance(builder_3); + auto prover_instance_3 = std::make_shared(builder_3); auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( @@ -370,12 +369,12 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); - auto prover_instance_1 = composer.create_prover_instance(builder_1); + auto prover_instance_1 = std::make_shared(builder_1); auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); - auto prover_instance_2 = composer.create_prover_instance(builder_2); + auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); @@ -383,7 +382,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); - auto prover_instance_3 = composer.create_prover_instance(builder_3); + auto prover_instance_3 = std::make_shared(builder_3); auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index e4e9cfee007..777feaee8f0 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -259,8 +259,7 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) create_some_RAM_gates(builder); // Create a prover (it will compute proving key and witness) - auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared>(builder); auto proving_key = instance->proving_key; auto circuit_size = proving_key->circuit_size; @@ -312,8 +311,7 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) create_some_ecc_op_queue_gates(builder); // Goblin! // Create a prover (it will compute proving key and witness) - auto composer = GoblinUltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared>(builder); auto proving_key = instance->proving_key; auto circuit_size = proving_key->circuit_size; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index 34515508931..d0bea39845a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -148,8 +148,7 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) false); // Create a prover (it will compute proving key and witness) - auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared>(builder); // Generate eta, beta and gamma FF eta = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 3cdeefdac7d..6043dc7f00a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -6,12 +6,6 @@ namespace bb { -template -std::shared_ptr> UltraComposer_::create_prover_instance(CircuitBuilder& circuit) -{ - return std::make_shared(circuit); -} - template std::shared_ptr> UltraComposer_::create_verifier_instance( std::shared_ptr>& prover_instance) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index c87071ccb72..742087c11e3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -25,8 +25,6 @@ template class UltraComposer_ { using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - std::shared_ptr create_prover_instance(CircuitBuilder&); - /** * @brief Create a verifier instance object. * 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 1c4d29f3051..3b370b79c7d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -22,6 +22,8 @@ namespace { auto& engine = numeric::get_debug_randomness(); } +using ProverInstance = typename UltraComposer::ProverInstance; + std::vector add_variables(auto& circuit_builder, std::vector variables) { std::vector res; @@ -33,7 +35,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 = composer.create_prover_instance(circuit_builder); + auto instance = std::make_shared(circuit_builder); auto prover = composer.create_prover(instance); auto verifier = composer.create_verifier(instance->verification_key); auto proof = prover.construct_proof(); @@ -67,7 +69,7 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) auto circuit_builder = UltraCircuitBuilder(); auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(circuit_builder); + auto instance = std::make_shared(circuit_builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); auto proving_key = instance->proving_key; @@ -198,7 +200,7 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) } } auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(circuit_builder); + auto instance = std::make_shared(circuit_builder); auto prover = composer.create_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_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index bb05c2588ba..443038c8cdd 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -14,6 +14,7 @@ class UltraTranscriptTests : public ::testing::Test { using Flavor = UltraFlavor; using FF = Flavor::FF; + using ProverInstance = ProverInstance_; /** * @brief Construct a manifest for a Ultra Honk proof @@ -131,7 +132,7 @@ TEST_F(UltraTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); @@ -158,7 +159,7 @@ TEST_F(UltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); @@ -209,7 +210,7 @@ TEST_F(UltraTranscriptTests, StructureTest) // Automatically generate a transcript manifest by constructing a proof auto composer = UltraComposer(); - auto instance = composer.create_prover_instance(builder); + auto instance = std::make_shared(builder); auto prover = composer.create_prover(instance); auto proof = prover.construct_proof(); auto verifier = composer.create_verifier(instance->verification_key); From 9caf8ff4d7be5c38533e674716e382e6cca2254d Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 03:41:19 +0000 Subject: [PATCH 02/17] Remove create_verifier_instance --- .../goblin/goblin_recursion.test.cpp | 3 ++- .../protogalaxy_recursive_verifier.test.cpp | 14 +++++++------- .../ultra_honk/protogalaxy.test.cpp | 18 +++++++++--------- .../barretenberg/ultra_honk/ultra_composer.cpp | 8 -------- .../barretenberg/ultra_honk/ultra_composer.hpp | 7 ------- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index d5b5288918a..4923f879493 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -21,12 +21,13 @@ class GoblinRecursionTests : public ::testing::Test { using GoblinUltraBuilder = GoblinUltraCircuitBuilder; using KernelInput = Goblin::AccumulationOutput; using ProverInstance = ProverInstance_; + using VerifierInstance = VerifierInstance_; static Goblin::AccumulationOutput construct_accumulator(GoblinUltraBuilder& builder) { GoblinUltraComposer composer; auto prover_instance = std::make_shared(builder); - auto verifier_instance = composer.create_verifier_instance(prover_instance); + auto verifier_instance = std::make_shared(prover_instance->verification_key); auto prover = composer.create_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/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index 51b968d4890..7eaee41fffc 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 @@ -105,8 +105,8 @@ template class ProtoGalaxyRecursiveTests : public tes auto prover_instance_1 = std::make_shared(builder1); auto prover_instance_2 = std::make_shared(builder2); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); auto folding_verifier = composer.create_folding_verifier({ verifier_instance_1, verifier_instance_2 }); @@ -170,9 +170,9 @@ template class ProtoGalaxyRecursiveTests : public tes Composer composer = Composer(); auto prover_instance_1 = std::make_shared(builder1); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto prover_instance_2 = std::make_shared(builder2); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); // Generate a folding proof auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); auto folding_proof = folding_prover.fold_instances(); @@ -232,9 +232,9 @@ template class ProtoGalaxyRecursiveTests : public tes Composer composer = Composer(); auto prover_instance_1 = std::make_shared(builder1); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto prover_instance_2 = std::make_shared(builder2); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); // Generate a folding proof auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); auto folding_proof = folding_prover.fold_instances(); @@ -336,7 +336,7 @@ template class ProtoGalaxyRecursiveTests : public tes Builder builder; create_function_circuit(builder); auto prover_inst = std::make_shared(builder); - auto verifier_inst = composer.create_verifier_instance(prover_inst); + auto verifier_inst = std::make_shared(prover_inst->verification_key); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 87494233074..6159440453e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -299,12 +299,12 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); @@ -313,7 +313,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); + auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( { prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }, composer); @@ -334,12 +334,12 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); check_accumulator_target_sum_manual(prover_accumulator, true); @@ -348,7 +348,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); + auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( { prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }, composer); @@ -370,12 +370,12 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = composer.create_verifier_instance(prover_instance_1); + auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = composer.create_verifier_instance(prover_instance_2); + auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); auto [prover_accumulator, verifier_accumulator] = fold_and_verify( { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); check_accumulator_target_sum_manual(prover_accumulator, true); @@ -383,7 +383,7 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = composer.create_verifier_instance(prover_instance_3); + auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 6043dc7f00a..fd3f61923fd 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -6,14 +6,6 @@ namespace bb { -template -std::shared_ptr> UltraComposer_::create_verifier_instance( - std::shared_ptr>& prover_instance) -{ - auto instance = std::make_shared(prover_instance->verification_key); - return instance; -} - template UltraProver_ UltraComposer_::create_prover(const std::shared_ptr& instance, 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 742087c11e3..00bd5497023 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -25,13 +25,6 @@ template class UltraComposer_ { using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - /** - * @brief Create a verifier instance object. - * - * @details Currently use prover instance - */ - std::shared_ptr create_verifier_instance(std::shared_ptr&); - UltraProver_ create_prover(const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); From 727489929f376fe07663d6b599d0c66b6d7bcbaf Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 04:42:33 +0000 Subject: [PATCH 03/17] 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 654ba280c92..50928ccb78b 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 9b04fe529f3..45c1d6e7544 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 a6ec15ec07c..7c7bddba319 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 4923f879493..442a4202716 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 b618bc336f6..d02deff490d 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 203326a0d1e..4b463cabd0f 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 7eaee41fffc..5026e784c4f 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 63283006720..b57efddad10 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 cad1e179364..184a62429b4 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 fe6b744b032..3933b3d8210 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 16a5109adff..1fa6b5e0ebe 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 fd3f61923fd..8e1db484e3b 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 00bd5497023..3797479dfd3 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 3b370b79c7d..80384ba1517 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 c4f62204066..8c8af1bcae2 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 356f163983b..ec5c35f3b5f 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 443038c8cdd..b89e0a3fe2f 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)); From c6e85ead149d0ca75411c4dc819f39199d9b886c Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 15:09:15 +0000 Subject: [PATCH 04/17] 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 d02deff490d..81dab41a878 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 4b463cabd0f..bb0a8058cd3 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 5026e784c4f..35f7546a9a2 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 b57efddad10..7758bda335a 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 184a62429b4..e16356dd7be 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 3933b3d8210..70d281d8ca2 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 1fa6b5e0ebe..62b7dda79d5 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 8e1db484e3b..43423a976be 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 3797479dfd3..2118aa6bd64 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 80384ba1517..da32df9a3e0 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 b89e0a3fe2f..042241335cd 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 From 0bfe8b91a1371324e3108d621b8d717ad3c64694 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 16:12:07 +0000 Subject: [PATCH 05/17] Remove decider prover and verifier construction from composer. --- .../barretenberg/client_ivc/client_ivc.cpp | 5 +- .../barretenberg/client_ivc/client_ivc.hpp | 2 + .../client_ivc/client_ivc.test.cpp | 6 +- .../protogalaxy/decider_prover.hpp | 3 +- .../protogalaxy/decider_verifier.cpp | 8 + .../protogalaxy/decider_verifier.hpp | 5 +- .../protogalaxy_recursive_verifier.test.cpp | 13 +- .../ultra_honk/protogalaxy.test.cpp | 12 +- .../ultra_honk/ultra_composer.cpp | 19 -- .../ultra_honk/ultra_composer.hpp | 11 - barretenberg/cpp/tmp.dot | 213 ++++++++++++++++++ 11 files changed, 249 insertions(+), 48 deletions(-) create mode 100644 barretenberg/cpp/tmp.dot diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp index fe7dca70d6e..9645dcb17f7 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp @@ -63,7 +63,7 @@ bool ClientIVC::verify(Proof& proof, const std::vector& ver auto folding_verifier = composer.create_folding_verifier({ verifier_instances[0], verifier_instances[1] }); auto verifier_accumulator = folding_verifier.verify_folding_proof(proof.fold_proof); - auto decider_verifier = composer.create_decider_verifier(verifier_accumulator); + ClientIVC::DeciderVerifier decider_verifier(verifier_accumulator); bool decision = decider_verifier.verify_proof(proof.decider_proof); return goblin_verified && decision; } @@ -75,8 +75,7 @@ bool ClientIVC::verify(Proof& proof, const std::vector& ver */ HonkProof ClientIVC::decider_prove() const { - Composer composer; - auto decider_prover = composer.create_decider_prover(prover_fold_output.accumulator); + GoblinUltraDeciderProver decider_prover(prover_fold_output.accumulator); return decider_prover.construct_proof(); } diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp index 5c444ac9ec5..0dfb93af348 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp @@ -24,6 +24,8 @@ class ClientIVC { using ProverInstance = ProverInstance_; using VerifierInstance = VerifierInstance_; using ClientCircuit = GoblinUltraCircuitBuilder; // can only be GoblinUltra + using DeciderProver = DeciderProver_; + using DeciderVerifier = DeciderVerifier_; // A full proof for the IVC scheme struct Proof { diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 45e594f47a9..3ce5a93e5d5 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -32,6 +32,8 @@ class ClientIVCTests : public ::testing::Test { using RecursiveVerifierInstances = ::bb::stdlib::recursion::honk::RecursiveVerifierInstances_; using FoldingRecursiveVerifier = bb::stdlib::recursion::honk::ProtoGalaxyRecursiveVerifier_; + using DeciderProver = ClientIVC::DeciderProver; + using DeciderVerifier = ClientIVC::DeciderVerifier; /** * @brief Construct mock circuit with arithmetic gates and goblin ops @@ -89,8 +91,8 @@ class ClientIVCTests : public ::testing::Test { auto verifier_accumulator = folding_verifier.verify_folding_proof(fold_proof); // Run decider - auto decider_prover = composer.create_decider_prover(prover_accumulator); - auto decider_verifier = composer.create_decider_verifier(verifier_accumulator); + DeciderProver decider_prover(prover_accumulator); + DeciderVerifier decider_verifier(verifier_accumulator); auto decider_proof = decider_prover.construct_proof(); bool decision = decider_verifier.verify_proof(decider_proof); EXPECT_TRUE(decision); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp index ef3cd372cee..062d19f96b8 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp @@ -53,6 +53,7 @@ template class DeciderProver_ { HonkProof proof; }; -using DeciderProver = DeciderProver_; +using UltraDeciderProver = DeciderProver_; +using GoblinUltraDeciderProver = DeciderProver_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index d140292bc4b..9d57cbd9f77 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -14,6 +14,14 @@ DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& tr , transcript(transcript) {} +template +DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator, + const std::shared_ptr& transcript) + : accumulator(accumulator) + , pcs_verification_key(accumulator->verification_key->pcs_verification_key) + , transcript(transcript) +{} + template DeciderVerifier_::DeciderVerifier_() : pcs_verification_key(std::make_unique()) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp index 3969b89d96c..fd417e20e4d 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -19,6 +19,8 @@ template class DeciderVerifier_ { explicit DeciderVerifier_(); explicit DeciderVerifier_(const std::shared_ptr& transcript, const std::shared_ptr& accumulator = nullptr); + explicit DeciderVerifier_(const std::shared_ptr& accumulator, + const std::shared_ptr& transcript = std::make_shared()); bool verify_proof(const HonkProof& proof); @@ -29,6 +31,7 @@ template class DeciderVerifier_ { std::shared_ptr transcript; }; -using DeciderVerifier = DeciderVerifier_; +using UltraDeciderVerifier = DeciderVerifier_; +using GoblinUltraDeciderVerifier = DeciderVerifier_; } // namespace bb 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 35f7546a9a2..99772ec0eaa 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 @@ -21,11 +21,12 @@ template class ProtoGalaxyRecursiveTests : public tes using Curve = bn254; using Commitment = typename NativeFlavor::Commitment; using FF = typename NativeFlavor::FF; + using DeciderProver = DeciderProver_; using RecursiveVerifierInstances = ::bb::stdlib::recursion::honk::RecursiveVerifierInstances_; using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; - using DeciderVerifier = DeciderVerifier_; + using NativeDeciderVerifier = DeciderVerifier_; using NativeVerifierInstances = VerifierInstances_; using NativeFoldingVerifier = ProtoGalaxyVerifier_; @@ -265,7 +266,7 @@ template class ProtoGalaxyRecursiveTests : public tes EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]); } - auto decider_prover = composer.create_decider_prover(folding_proof.accumulator); + DeciderProver decider_prover(folding_proof.accumulator); auto decider_proof = decider_prover.construct_proof(); Builder decider_circuit; @@ -275,9 +276,9 @@ template class ProtoGalaxyRecursiveTests : public tes // Check for a failure flag in the recursive verifier circuit EXPECT_EQ(decider_circuit.failed(), false) << decider_circuit.err(); - // Perform native verification then perform the pairing on the outputs of the recursive - // decider verifier and check that the result agrees. - DeciderVerifier native_decider_verifier = composer.create_decider_verifier(verifier_accumulator); + // Perform native verification then perform the pairing on the outputs of the recursive decider verifier and + // 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()); @@ -313,7 +314,7 @@ template class ProtoGalaxyRecursiveTests : public tes verifier_accumulator->target_sum = FF::random_element(); // Create a decider proof for the relaxed instance obtained through folding - auto decider_prover = composer.create_decider_prover(prover_accumulator); + DeciderProver decider_prover(prover_accumulator); auto decider_proof = decider_prover.construct_proof(); // Create a decider verifier circuit for recursively verifying the decider proof diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 6159440453e..82294cc6988 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -29,6 +29,8 @@ template class ProtoGalaxyTests : public testing::Test { using WitnessCommitments = typename Flavor::WitnessCommitments; using CommitmentKey = typename Flavor::CommitmentKey; using PowPolynomial = bb::PowPolynomial; + using DeciderProver = DeciderProver_; + using DeciderVerifier = DeciderVerifier_; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } @@ -93,13 +95,13 @@ template class ProtoGalaxyTests : public testing::Test { static void decide_and_verify(std::shared_ptr& prover_accumulator, std::shared_ptr& verifier_accumulator, - Composer& composer, + [[maybe_unused]] Composer& composer, bool expected_result) { - auto decider_prover = composer.create_decider_prover(prover_accumulator); - auto decider_verifier = composer.create_decider_verifier(verifier_accumulator); - auto decider_proof = decider_prover.construct_proof(); - auto verified = decider_verifier.verify_proof(decider_proof); + DeciderProver decider_prover(prover_accumulator); + DeciderVerifier decider_verifier(verifier_accumulator); + HonkProof decider_proof = decider_prover.construct_proof(); + bool verified = decider_verifier.verify_proof(decider_proof); EXPECT_EQ(verified, expected_result); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 43423a976be..823b3addcc3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -1,25 +1,6 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" -#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/proof_system/composer/composer_lib.hpp" -#include "barretenberg/proof_system/composer/permutation_lib.hpp" -#include "barretenberg/proof_system/library/grand_product_library.hpp" namespace bb { - -template -DeciderProver_ UltraComposer_::create_decider_prover(const std::shared_ptr& accumulator, - const std::shared_ptr& transcript) -{ - return DeciderProver_(accumulator, transcript); -} - -template -DeciderVerifier_ UltraComposer_::create_decider_verifier( - const std::shared_ptr& accumulator, const std::shared_ptr& transcript) -{ - return DeciderVerifier_(transcript, accumulator); -} - template class UltraComposer_; template class UltraComposer_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 2118aa6bd64..673c7c11ab2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -25,17 +25,6 @@ template class UltraComposer_ { using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - DeciderProver_ create_decider_prover( - const std::shared_ptr&, - const std::shared_ptr& transcript = std::make_shared()); - - DeciderVerifier_ create_decider_verifier( - const std::shared_ptr&, - const std::shared_ptr& transcript = std::make_shared()); - UltraVerifier_ create_verifier(CircuitBuilder& circuit); - - UltraVerifier_ create_ultra_with_keccak_verifier(CircuitBuilder& circuit); - ProtoGalaxyProver_ create_folding_prover( const std::vector>& instances) { diff --git a/barretenberg/cpp/tmp.dot b/barretenberg/cpp/tmp.dot new file mode 100644 index 00000000000..51778935908 --- /dev/null +++ b/barretenberg/cpp/tmp.dot @@ -0,0 +1,213 @@ +digraph BarretenbergModules { +basics_bench -> ecc +goblin_bench -> ultra_honk +goblin_bench -> eccvm +goblin_bench -> stdlib_recursion +goblin_bench -> stdlib_sha256 +goblin_bench -> crypto_merkle_tree +goblin_bench -> stdlib_primitives +ipa_bench -> commitment_schemes +plonk_bench -> plonk +plonk_bench -> stdlib_primitives +protogalaxy_bench -> ultra_honk +protogalaxy_bench -> protogalaxy +protogalaxy_bench -> stdlib_primitives +relations_bench -> proof_system +relations_bench -> transcript +ultra_bench -> ultra_honk +ultra_bench -> stdlib_sha256 +ultra_bench -> stdlib_keccak +ultra_bench -> crypto_merkle_tree +ultra_bench -> stdlib_recursion +widgets_bench -> polynomials +widgets_bench -> proof_system +widgets_bench -> transcript +widgets_bench -> stdlib_primitives +append_only_tree_bench -> crypto_poseidon2 +append_only_tree_bench -> crypto_merkle_tree +indexed_tree_bench -> crypto_poseidon2 +indexed_tree_bench -> crypto_merkle_tree +merkle_tree_bench -> crypto_poseidon2 +merkle_tree_bench -> crypto_merkle_tree +poseidon2_bench -> crypto_poseidon2 +protogalaxy_round_bench -> ultra_honk +protogalaxy_round_bench -> protogalaxy +protogalaxy_round_bench -> stdlib_primitives +client_ivc_bench -> client_ivc +client_ivc_bench -> stdlib_recursion +client_ivc_bench -> stdlib_sha256 +client_ivc_bench -> crypto_merkle_tree +client_ivc_bench -> stdlib_primitives +commitment_schemes -> common +commitment_schemes -> transcript +commitment_schemes -> polynomials +commitment_schemes -> ecc +commitment_schemes -> numeric +commitment_schemes -> srs +common -> env +crypto_aes128 +crypto_blake2s +crypto_blake3s +crypto_blake3s_full +crypto_ecdsa -> crypto_blake2s +crypto_ecdsa -> crypto_keccak +crypto_ecdsa -> crypto_sha256 +crypto_ecdsa -> numeric +crypto_hmac -> crypto_blake2s +crypto_hmac -> crypto_keccak +crypto_hmac -> crypto_sha256 +crypto_hmac -> numeric +crypto_keccak +crypto_pedersen_commitment -> ecc +crypto_pedersen_hash -> ecc +crypto_pedersen_hash -> crypto_pedersen_commitment +crypto_poseidon2 -> ecc +crypto_schnorr -> crypto_pedersen_hash +crypto_schnorr -> crypto_blake2s +crypto_schnorr -> crypto_keccak +crypto_schnorr -> crypto_sha256 +crypto_schnorr -> numeric +crypto_sha256 +crypto_merkle_tree -> stdlib_primitives +crypto_merkle_tree -> stdlib_blake3s +crypto_merkle_tree -> stdlib_pedersen_hash +dsl -> plonk +dsl -> stdlib_primitives +dsl -> stdlib_sha256 +dsl -> stdlib_blake2s +dsl -> stdlib_keccak +dsl -> stdlib_pedersen_hash +dsl -> stdlib_poseidon2 +dsl -> crypto_merkle_tree +dsl -> stdlib_schnorr +dsl -> crypto_sha256 +ecc -> numeric +ecc -> crypto_keccak +ecc -> crypto_sha256 +eccvm -> honk +eccvm -> sumcheck +env +examples -> stdlib_pedersen_commitment +flavor -> commitment_schemes +flavor -> ecc +flavor -> polynomials +flavor -> proof_system +goblin -> stdlib_recursion +goblin -> ultra_honk +goblin -> eccvm +goblin -> translator_vm +goblin -> stdlib_sha256 +goblin -> crypto_merkle_tree +goblin -> stdlib_primitives +honk -> polynomials +join_split_example_proofs_inner_proof_data -> numeric +join_split_example_proofs_inner_proof_data -> ecc +join_split_example_proofs_join_split -> join_split_example_proofs_inner_proof_data +join_split_example_proofs_join_split -> join_split_example_proofs_notes +join_split_example_proofs_join_split -> crypto_schnorr +join_split_example_proofs_join_split -> stdlib_blake2s +join_split_example_proofs_join_split -> stdlib_sha256 +join_split_example_proofs_join_split -> stdlib_pedersen_commitment +join_split_example_proofs_join_split -> stdlib_schnorr +join_split_example_proofs_join_split -> stdlib_primitives +join_split_example_proofs_join_split -> crypto_merkle_tree +rollup_proofs_mock -> stdlib_blake2s +rollup_proofs_mock -> stdlib_sha256 +rollup_proofs_mock -> stdlib_pedersen_commitment +rollup_proofs_mock -> stdlib_primitives +join_split_example_proofs_notes -> crypto_schnorr +join_split_example_proofs_notes -> stdlib_blake2s +join_split_example_proofs_notes -> stdlib_sha256 +join_split_example_proofs_notes -> stdlib_pedersen_commitment +join_split_example_proofs_notes -> stdlib_schnorr +join_split_example_proofs_notes -> stdlib_primitives +join_split_example_proofs_notes -> crypto_merkle_tree +numeric -> common +plonk -> proof_system +plonk -> transcript +plonk -> crypto_pedersen_commitment +plonk -> polynomials +plonk -> crypto_sha256 +plonk -> ecc +plonk -> crypto_blake3s +plonk -> srs +plonk -> flavor +polynomials -> numeric +polynomials -> ecc +polynomials -> crypto_sha256 +proof_system -> relations +proof_system -> crypto_pedersen_hash +proof_system -> srs +protogalaxy -> honk +protogalaxy -> flavor +protogalaxy -> relations +protogalaxy -> sumcheck +relations -> polynomials +stdlib_solidity_helpers -> plonk +stdlib_solidity_helpers -> proof_system +stdlib_solidity_helpers -> transcript +stdlib_solidity_helpers -> crypto_pedersen_commitment +stdlib_solidity_helpers -> polynomials +stdlib_solidity_helpers -> crypto_sha256 +stdlib_solidity_helpers -> ecc +stdlib_solidity_helpers -> crypto_blake3s +stdlib_solidity_helpers -> stdlib_primitives +stdlib_solidity_helpers -> stdlib_pedersen_commitment +stdlib_solidity_helpers -> stdlib_blake3s +stdlib_solidity_helpers -> stdlib_blake2s +stdlib_solidity_helpers -> stdlib_sha256 +stdlib_solidity_helpers -> srs +srs -> polynomials +stdlib_pedersen_commitment -> stdlib_primitives +stdlib_pedersen_commitment -> stdlib_pedersen_hash +stdlib_pedersen_commitment -> crypto_pedersen_commitment +stdlib_aes128 -> numeric +stdlib_aes128 -> stdlib_primitives +stdlib_ecdsa -> crypto_sha256 +stdlib_ecdsa -> stdlib_sha256 +stdlib_ecdsa -> stdlib_primitives +stdlib_schnorr -> stdlib_pedersen_commitment +stdlib_schnorr -> stdlib_blake2s +stdlib_schnorr -> stdlib_primitives +hash_benchmarks -> stdlib_primitives +hash_benchmarks -> crypto_sha256 +hash_benchmarks -> stdlib_sha256 +hash_benchmarks -> stdlib_blake3s +stdlib_blake2s -> stdlib_primitives +stdlib_blake2s -> crypto_blake2s +stdlib_blake3s -> stdlib_primitives +stdlib_blake3s -> crypto_blake3s +stdlib_keccak -> stdlib_primitives +stdlib_keccak -> crypto_keccak +stdlib_pedersen_hash -> stdlib_primitives +stdlib_pedersen_hash -> crypto_pedersen_commitment +stdlib_poseidon2 -> stdlib_primitives +stdlib_poseidon2 -> crypto_poseidon2 +stdlib_sha256 -> stdlib_primitives +stdlib_sha256 -> crypto_sha256 +stdlib_primitives -> proof_system +stdlib_primitives -> plonk +stdlib_recursion -> ecc +stdlib_recursion -> proof_system +stdlib_recursion -> stdlib_primitives +stdlib_recursion -> stdlib_pedersen_commitment +stdlib_recursion -> stdlib_blake3s +stdlib_recursion -> ultra_honk +stdlib_recursion -> eccvm +stdlib_recursion -> translator_vm +stdlib_recursion -> stdlib_poseidon2 +sumcheck -> flavor +sumcheck -> srs +sumcheck -> transcript +transcript -> crypto_poseidon2 +translator_vm -> honk +translator_vm -> sumcheck +ultra_honk -> honk +ultra_honk -> sumcheck +ultra_honk -> protogalaxy +vm -> honk +vm -> sumcheck +vm -> protogalaxy +wasi +client_ivc -> goblin +} From b8177c19e46ef29416caf8a5fc3d1d05c5551b5d Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 17:40:23 +0000 Subject: [PATCH 06/17] Composer has no functions. --- .../barretenberg/client_ivc/client_ivc.cpp | 6 ++---- .../barretenberg/client_ivc/client_ivc.hpp | 10 +++++++--- .../client_ivc/client_ivc.test.cpp | 7 +++++-- .../protogalaxy_recursive_verifier.test.cpp | 20 +++++++++---------- .../ultra_honk/protogalaxy.test.cpp | 8 +++++--- .../ultra_honk/ultra_composer.hpp | 16 --------------- 6 files changed, 29 insertions(+), 38 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp index 9645dcb17f7..fb355852294 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp @@ -30,9 +30,8 @@ void ClientIVC::initialize(ClientCircuit& circuit) ClientIVC::FoldProof ClientIVC::accumulate(ClientCircuit& circuit) { goblin.merge(circuit); // Add recursive merge verifier and construct new merge proof - Composer composer; prover_instance = std::make_shared(circuit); - auto folding_prover = composer.create_folding_prover({ prover_fold_output.accumulator, prover_instance }); + FoldingProver folding_prover({ prover_fold_output.accumulator, prover_instance }); prover_fold_output = folding_prover.fold_instances(); return prover_fold_output.folding_data; } @@ -59,8 +58,7 @@ bool ClientIVC::verify(Proof& proof, const std::vector& ver bool goblin_verified = goblin.verify(proof.goblin_proof); // Decider verification - Composer composer; - auto folding_verifier = composer.create_folding_verifier({ verifier_instances[0], verifier_instances[1] }); + ClientIVC::FoldingVerifier folding_verifier({ verifier_instances[0], verifier_instances[1] }); auto verifier_accumulator = folding_verifier.verify_folding_proof(proof.fold_proof); ClientIVC::DeciderVerifier decider_verifier(verifier_accumulator); diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp index 0dfb93af348..011c8710b5a 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp @@ -21,11 +21,15 @@ class ClientIVC { using FoldProof = std::vector; using ProverAccumulator = std::shared_ptr>; using VerifierAccumulator = std::shared_ptr>; - using ProverInstance = ProverInstance_; - using VerifierInstance = VerifierInstance_; + using ProverInstance = ProverInstance_; + using VerifierInstance = VerifierInstance_; using ClientCircuit = GoblinUltraCircuitBuilder; // can only be GoblinUltra using DeciderProver = DeciderProver_; using DeciderVerifier = DeciderVerifier_; + using ProverInstances = ProverInstances_; + using FoldingProver = ProtoGalaxyProver_; + using VerifierInstances = VerifierInstances_; + using FoldingVerifier = ProtoGalaxyVerifier_; // A full proof for the IVC scheme struct Proof { @@ -42,7 +46,7 @@ class ClientIVC { }; private: - using ProverFoldOutput = FoldingResult; + using ProverFoldOutput = FoldingResult; using Composer = GoblinUltraComposer; // Note: We need to save the last instance that was folded in order to compute its verification key, this will not // be needed in the real IVC as they are provided as inputs diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 3ce5a93e5d5..54870a0b4fe 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -34,6 +34,10 @@ class ClientIVCTests : public ::testing::Test { bb::stdlib::recursion::honk::ProtoGalaxyRecursiveVerifier_; using DeciderProver = ClientIVC::DeciderProver; using DeciderVerifier = ClientIVC::DeciderVerifier; + using ProverInstances = ProverInstances_; + using FoldingProver = ProtoGalaxyProver_; + using VerifierInstances = VerifierInstances_; + using FoldingVerifier = ProtoGalaxyVerifier_; /** * @brief Construct mock circuit with arithmetic gates and goblin ops @@ -85,9 +89,8 @@ class ClientIVCTests : public ::testing::Test { const std::shared_ptr& verifier_inst_vk) { // Verify fold proof - Composer composer; auto new_verifier_inst = std::make_shared(verifier_inst_vk); - auto folding_verifier = composer.create_folding_verifier({ prev_verifier_accumulator, new_verifier_inst }); + FoldingVerifier folding_verifier({ prev_verifier_accumulator, new_verifier_inst }); auto verifier_accumulator = folding_verifier.verify_folding_proof(fold_proof); // Run decider 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 99772ec0eaa..fb527e12c16 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 @@ -29,6 +29,8 @@ template class ProtoGalaxyRecursiveTests : public tes using NativeDeciderVerifier = DeciderVerifier_; using NativeVerifierInstances = VerifierInstances_; using NativeFoldingVerifier = ProtoGalaxyVerifier_; + using NativeProverInstances = ProverInstances_; + using NativeFoldingProver = ProtoGalaxyProver_; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } /** @@ -98,7 +100,7 @@ template class ProtoGalaxyRecursiveTests : public tes }; static std::tuple, std::shared_ptr> fold_and_verify_native( - Composer& composer) + [[maybe_unused]] Composer& composer) { Builder builder1; create_function_circuit(builder1); @@ -110,8 +112,8 @@ template class ProtoGalaxyRecursiveTests : public tes auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); - auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); - auto folding_verifier = composer.create_folding_verifier({ verifier_instance_1, verifier_instance_2 }); + NativeFoldingProver folding_prover({ prover_instance_1, prover_instance_2 }); + NativeFoldingVerifier folding_verifier({ verifier_instance_1, verifier_instance_2 }); auto [prover_accumulator, folding_proof] = folding_prover.fold_instances(); auto verifier_accumulator = folding_verifier.verify_folding_proof(folding_proof); @@ -171,13 +173,12 @@ template class ProtoGalaxyRecursiveTests : public tes builder2.add_public_variable(FF(1)); create_function_circuit(builder2); - Composer composer = Composer(); auto prover_instance_1 = std::make_shared(builder1); auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); // Generate a folding proof - auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); + NativeFoldingProver folding_prover({ prover_instance_1, prover_instance_2 }); auto folding_proof = folding_prover.fold_instances(); // Create a recursive folding verifier circuit for the folding proof of the two instances @@ -190,7 +191,7 @@ template class ProtoGalaxyRecursiveTests : public tes // Perform native folding verification and ensure it returns the same result (either true or false) as // calling check_circuit on the recursive folding verifier - auto native_folding_verifier = composer.create_folding_verifier({ verifier_instance_1, verifier_instance_2 }); + NativeFoldingVerifier native_folding_verifier({ verifier_instance_1, verifier_instance_2 }); native_folding_verifier.verify_folding_proof(folding_proof.folding_data); // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring the @@ -232,13 +233,12 @@ template class ProtoGalaxyRecursiveTests : public tes create_function_circuit(builder2); - Composer composer = Composer(); auto prover_instance_1 = std::make_shared(builder1); auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); auto prover_instance_2 = std::make_shared(builder2); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); // Generate a folding proof - auto folding_prover = composer.create_folding_prover({ prover_instance_1, prover_instance_2 }); + NativeFoldingProver folding_prover({ prover_instance_1, prover_instance_2 }); auto folding_proof = folding_prover.fold_instances(); // Create a recursive folding verifier circuit for the folding proof of the two instances @@ -254,7 +254,7 @@ template class ProtoGalaxyRecursiveTests : public tes // Perform native folding verification and ensure it returns the same result (either true or false) as // calling check_circuit on the recursive folding verifier - auto native_folding_verifier = composer.create_folding_verifier({ verifier_instance_1, verifier_instance_2 }); + NativeFoldingVerifier native_folding_verifier({ verifier_instance_1, verifier_instance_2 }); auto verifier_accumulator = native_folding_verifier.verify_folding_proof(folding_proof.folding_data); // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring the @@ -343,7 +343,7 @@ template class ProtoGalaxyRecursiveTests : public tes // Generate a folding proof with the incorrect polynomials which would result in the prover having the wrong // target sum - auto folding_prover = composer.create_folding_prover({ prover_accumulator, prover_inst }); + NativeFoldingProver folding_prover({ prover_accumulator, prover_inst }); auto folding_proof = folding_prover.fold_instances(); // Create a recursive folding verifier circuit for the folding proof of the two instances with the untampered diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 82294cc6988..d0bd67a2bcb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -31,6 +31,8 @@ template class ProtoGalaxyTests : public testing::Test { using PowPolynomial = bb::PowPolynomial; using DeciderProver = DeciderProver_; using DeciderVerifier = DeciderVerifier_; + using FoldingProver = ProtoGalaxyProver_; + using FoldingVerifier = ProtoGalaxyVerifier_; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } @@ -66,10 +68,10 @@ template class ProtoGalaxyTests : public testing::Test { static std::tuple, std::shared_ptr> fold_and_verify( const std::vector>& prover_instances, const std::vector>& verifier_instances, - Composer& composer) + [[maybe_unused]] Composer& composer) { - auto folding_prover = composer.create_folding_prover(prover_instances); - auto folding_verifier = composer.create_folding_verifier(verifier_instances); + FoldingProver folding_prover(prover_instances); + FoldingVerifier folding_verifier(verifier_instances); auto [prover_accumulator, folding_proof] = folding_prover.fold_instances(); auto verifier_accumulator = folding_verifier.verify_folding_proof(folding_proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 673c7c11ab2..9d72bcfd890 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -24,22 +24,6 @@ template class UltraComposer_ { using Transcript = typename Flavor::Transcript; using ProverInstances = ProverInstances_; using VerifierInstances = VerifierInstances_; - - ProtoGalaxyProver_ create_folding_prover( - const std::vector>& instances) - { - ProtoGalaxyProver_ output_state(instances); - - return output_state; - }; - - ProtoGalaxyVerifier_ create_folding_verifier( - const std::vector>& instances) - { - ProtoGalaxyVerifier_ output_state(instances); - - return output_state; - }; }; // TODO(#532): this pattern is weird; is this not instantiating the templates? From 8916fedcaa7b06dfb9645984a9feaa3369108806 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 17:43:28 +0000 Subject: [PATCH 07/17] Remove accidentally added graph file. --- barretenberg/cpp/tmp.dot | 213 --------------------------------------- 1 file changed, 213 deletions(-) delete mode 100644 barretenberg/cpp/tmp.dot diff --git a/barretenberg/cpp/tmp.dot b/barretenberg/cpp/tmp.dot deleted file mode 100644 index 51778935908..00000000000 --- a/barretenberg/cpp/tmp.dot +++ /dev/null @@ -1,213 +0,0 @@ -digraph BarretenbergModules { -basics_bench -> ecc -goblin_bench -> ultra_honk -goblin_bench -> eccvm -goblin_bench -> stdlib_recursion -goblin_bench -> stdlib_sha256 -goblin_bench -> crypto_merkle_tree -goblin_bench -> stdlib_primitives -ipa_bench -> commitment_schemes -plonk_bench -> plonk -plonk_bench -> stdlib_primitives -protogalaxy_bench -> ultra_honk -protogalaxy_bench -> protogalaxy -protogalaxy_bench -> stdlib_primitives -relations_bench -> proof_system -relations_bench -> transcript -ultra_bench -> ultra_honk -ultra_bench -> stdlib_sha256 -ultra_bench -> stdlib_keccak -ultra_bench -> crypto_merkle_tree -ultra_bench -> stdlib_recursion -widgets_bench -> polynomials -widgets_bench -> proof_system -widgets_bench -> transcript -widgets_bench -> stdlib_primitives -append_only_tree_bench -> crypto_poseidon2 -append_only_tree_bench -> crypto_merkle_tree -indexed_tree_bench -> crypto_poseidon2 -indexed_tree_bench -> crypto_merkle_tree -merkle_tree_bench -> crypto_poseidon2 -merkle_tree_bench -> crypto_merkle_tree -poseidon2_bench -> crypto_poseidon2 -protogalaxy_round_bench -> ultra_honk -protogalaxy_round_bench -> protogalaxy -protogalaxy_round_bench -> stdlib_primitives -client_ivc_bench -> client_ivc -client_ivc_bench -> stdlib_recursion -client_ivc_bench -> stdlib_sha256 -client_ivc_bench -> crypto_merkle_tree -client_ivc_bench -> stdlib_primitives -commitment_schemes -> common -commitment_schemes -> transcript -commitment_schemes -> polynomials -commitment_schemes -> ecc -commitment_schemes -> numeric -commitment_schemes -> srs -common -> env -crypto_aes128 -crypto_blake2s -crypto_blake3s -crypto_blake3s_full -crypto_ecdsa -> crypto_blake2s -crypto_ecdsa -> crypto_keccak -crypto_ecdsa -> crypto_sha256 -crypto_ecdsa -> numeric -crypto_hmac -> crypto_blake2s -crypto_hmac -> crypto_keccak -crypto_hmac -> crypto_sha256 -crypto_hmac -> numeric -crypto_keccak -crypto_pedersen_commitment -> ecc -crypto_pedersen_hash -> ecc -crypto_pedersen_hash -> crypto_pedersen_commitment -crypto_poseidon2 -> ecc -crypto_schnorr -> crypto_pedersen_hash -crypto_schnorr -> crypto_blake2s -crypto_schnorr -> crypto_keccak -crypto_schnorr -> crypto_sha256 -crypto_schnorr -> numeric -crypto_sha256 -crypto_merkle_tree -> stdlib_primitives -crypto_merkle_tree -> stdlib_blake3s -crypto_merkle_tree -> stdlib_pedersen_hash -dsl -> plonk -dsl -> stdlib_primitives -dsl -> stdlib_sha256 -dsl -> stdlib_blake2s -dsl -> stdlib_keccak -dsl -> stdlib_pedersen_hash -dsl -> stdlib_poseidon2 -dsl -> crypto_merkle_tree -dsl -> stdlib_schnorr -dsl -> crypto_sha256 -ecc -> numeric -ecc -> crypto_keccak -ecc -> crypto_sha256 -eccvm -> honk -eccvm -> sumcheck -env -examples -> stdlib_pedersen_commitment -flavor -> commitment_schemes -flavor -> ecc -flavor -> polynomials -flavor -> proof_system -goblin -> stdlib_recursion -goblin -> ultra_honk -goblin -> eccvm -goblin -> translator_vm -goblin -> stdlib_sha256 -goblin -> crypto_merkle_tree -goblin -> stdlib_primitives -honk -> polynomials -join_split_example_proofs_inner_proof_data -> numeric -join_split_example_proofs_inner_proof_data -> ecc -join_split_example_proofs_join_split -> join_split_example_proofs_inner_proof_data -join_split_example_proofs_join_split -> join_split_example_proofs_notes -join_split_example_proofs_join_split -> crypto_schnorr -join_split_example_proofs_join_split -> stdlib_blake2s -join_split_example_proofs_join_split -> stdlib_sha256 -join_split_example_proofs_join_split -> stdlib_pedersen_commitment -join_split_example_proofs_join_split -> stdlib_schnorr -join_split_example_proofs_join_split -> stdlib_primitives -join_split_example_proofs_join_split -> crypto_merkle_tree -rollup_proofs_mock -> stdlib_blake2s -rollup_proofs_mock -> stdlib_sha256 -rollup_proofs_mock -> stdlib_pedersen_commitment -rollup_proofs_mock -> stdlib_primitives -join_split_example_proofs_notes -> crypto_schnorr -join_split_example_proofs_notes -> stdlib_blake2s -join_split_example_proofs_notes -> stdlib_sha256 -join_split_example_proofs_notes -> stdlib_pedersen_commitment -join_split_example_proofs_notes -> stdlib_schnorr -join_split_example_proofs_notes -> stdlib_primitives -join_split_example_proofs_notes -> crypto_merkle_tree -numeric -> common -plonk -> proof_system -plonk -> transcript -plonk -> crypto_pedersen_commitment -plonk -> polynomials -plonk -> crypto_sha256 -plonk -> ecc -plonk -> crypto_blake3s -plonk -> srs -plonk -> flavor -polynomials -> numeric -polynomials -> ecc -polynomials -> crypto_sha256 -proof_system -> relations -proof_system -> crypto_pedersen_hash -proof_system -> srs -protogalaxy -> honk -protogalaxy -> flavor -protogalaxy -> relations -protogalaxy -> sumcheck -relations -> polynomials -stdlib_solidity_helpers -> plonk -stdlib_solidity_helpers -> proof_system -stdlib_solidity_helpers -> transcript -stdlib_solidity_helpers -> crypto_pedersen_commitment -stdlib_solidity_helpers -> polynomials -stdlib_solidity_helpers -> crypto_sha256 -stdlib_solidity_helpers -> ecc -stdlib_solidity_helpers -> crypto_blake3s -stdlib_solidity_helpers -> stdlib_primitives -stdlib_solidity_helpers -> stdlib_pedersen_commitment -stdlib_solidity_helpers -> stdlib_blake3s -stdlib_solidity_helpers -> stdlib_blake2s -stdlib_solidity_helpers -> stdlib_sha256 -stdlib_solidity_helpers -> srs -srs -> polynomials -stdlib_pedersen_commitment -> stdlib_primitives -stdlib_pedersen_commitment -> stdlib_pedersen_hash -stdlib_pedersen_commitment -> crypto_pedersen_commitment -stdlib_aes128 -> numeric -stdlib_aes128 -> stdlib_primitives -stdlib_ecdsa -> crypto_sha256 -stdlib_ecdsa -> stdlib_sha256 -stdlib_ecdsa -> stdlib_primitives -stdlib_schnorr -> stdlib_pedersen_commitment -stdlib_schnorr -> stdlib_blake2s -stdlib_schnorr -> stdlib_primitives -hash_benchmarks -> stdlib_primitives -hash_benchmarks -> crypto_sha256 -hash_benchmarks -> stdlib_sha256 -hash_benchmarks -> stdlib_blake3s -stdlib_blake2s -> stdlib_primitives -stdlib_blake2s -> crypto_blake2s -stdlib_blake3s -> stdlib_primitives -stdlib_blake3s -> crypto_blake3s -stdlib_keccak -> stdlib_primitives -stdlib_keccak -> crypto_keccak -stdlib_pedersen_hash -> stdlib_primitives -stdlib_pedersen_hash -> crypto_pedersen_commitment -stdlib_poseidon2 -> stdlib_primitives -stdlib_poseidon2 -> crypto_poseidon2 -stdlib_sha256 -> stdlib_primitives -stdlib_sha256 -> crypto_sha256 -stdlib_primitives -> proof_system -stdlib_primitives -> plonk -stdlib_recursion -> ecc -stdlib_recursion -> proof_system -stdlib_recursion -> stdlib_primitives -stdlib_recursion -> stdlib_pedersen_commitment -stdlib_recursion -> stdlib_blake3s -stdlib_recursion -> ultra_honk -stdlib_recursion -> eccvm -stdlib_recursion -> translator_vm -stdlib_recursion -> stdlib_poseidon2 -sumcheck -> flavor -sumcheck -> srs -sumcheck -> transcript -transcript -> crypto_poseidon2 -translator_vm -> honk -translator_vm -> sumcheck -ultra_honk -> honk -ultra_honk -> sumcheck -ultra_honk -> protogalaxy -vm -> honk -vm -> sumcheck -vm -> protogalaxy -wasi -client_ivc -> goblin -} From d64fe6ec9db5fa5d8cc2cf90000f653862db2457 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 18:40:21 +0000 Subject: [PATCH 08/17] Don't expose honk prover aliases --- .../plonk_bench/standard_plonk.bench.cpp | 2 +- .../ultra_bench/goblin_ultra_honk.bench.cpp | 4 +- .../benchmark/ultra_bench/mock_proofs.hpp | 65 +++++------- .../ultra_bench/ultra_honk.bench.cpp | 4 +- .../ultra_bench/ultra_honk_rounds.bench.cpp | 5 +- .../ultra_bench/ultra_plonk.bench.cpp | 4 +- .../ultra_bench/ultra_plonk_rounds.bench.cpp | 5 +- .../barretenberg/client_ivc/client_ivc.hpp | 1 - .../client_ivc/client_ivc.test.cpp | 1 - .../plonk/proof_system/prover/prover.hpp | 3 + .../proof_system/types/prover_settings.hpp | 2 + .../ultra_honk/goblin_ultra_composer.test.cpp | 14 +-- .../ultra_honk/ultra_composer.hpp | 3 - .../ultra_honk/ultra_composer.test.cpp | 99 +++++++------------ .../barretenberg/ultra_honk/ultra_prover.hpp | 5 +- 15 files changed, 79 insertions(+), 138 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp index c4d85d3fde0..8ddd3d194a4 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp @@ -13,7 +13,7 @@ using StandardPlonk = bb::plonk::StandardComposer; static void construct_proof_standard_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp index 98a42f0bab4..a50c5f6ceca 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp @@ -14,7 +14,7 @@ static void construct_proof_goblinultrahonk(State& state, void (*test_circuit_function)(GoblinUltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -24,7 +24,7 @@ static void construct_proof_goblinultrahonk(State& state, static void construct_proof_goblinultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } 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 45c1d6e7544..89d343cedca 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -47,44 +47,27 @@ template void generate_basic_arithmetic_circuit(Builder& buil } } -// ultrahonk -inline UltraProver get_prover([[maybe_unused]] UltraComposer& composer, - void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) +template +Prover get_prover(void (*test_circuit_function)(typename Prover::Flavor::CircuitBuilder&, size_t), + size_t num_iterations) { - UltraComposer::CircuitBuilder builder; - test_circuit_function(builder, num_iterations); - return UltraProver(builder); -} + using Flavor = typename Prover::Flavor; + using Builder = typename Flavor::CircuitBuilder; -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); - return GoblinUltraProver(builder); -} - -// standard plonk -inline plonk::Prover get_prover(plonk::StandardComposer& composer, - void (*test_circuit_function)(StandardCircuitBuilder&, size_t), - size_t num_iterations) -{ - StandardCircuitBuilder builder; + Builder builder; test_circuit_function(builder, num_iterations); - return composer.create_prover(builder); -} + // This is gross but it's going away soon. + if constexpr (IsPlonkFlavor) { + // If Flavor is Ultra, alias UltraComposer, otherwise alias StandardComposer + using Composer = std:: + conditional_t, plonk::UltraComposer, plonk::StandardComposer>; + Composer composer; + return composer.create_prover(builder); + } else { + return Prover(builder); + } +}; -// ultraplonk -inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, - void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) -{ - plonk::UltraComposer::CircuitBuilder builder; - test_circuit_function(builder, num_iterations); - return composer.create_prover(builder); -} /** * @brief Performs proof constuction for benchmarks based on a provided circuit function * @@ -95,20 +78,18 @@ inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, * @param state * @param test_circuit_function */ -template -void construct_proof_with_specified_num_iterations(benchmark::State& state, - void (*test_circuit_function)(typename Composer::CircuitBuilder&, - size_t), - size_t num_iterations) +template +void construct_proof_with_specified_num_iterations( + benchmark::State& state, + void (*test_circuit_function)(typename Prover::Flavor::CircuitBuilder&, size_t), + size_t num_iterations) { srs::init_crs_factory("../srs_db/ignition"); - Composer composer; - for (auto _ : state) { // Construct circuit and prover; don't include this part in measurement state.PauseTiming(); - auto prover = get_prover(composer, test_circuit_function, num_iterations); + Prover prover = get_prover(test_circuit_function, num_iterations); state.ResumeTiming(); // Construct proof diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp index 29139186659..f91ea3c8dd6 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp @@ -14,7 +14,7 @@ static void construct_proof_ultrahonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -24,7 +24,7 @@ static void construct_proof_ultrahonk(State& state, static void construct_proof_ultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index 619ba60a8c1..a9e0e72f1d5 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -58,10 +58,9 @@ BB_PROFILE static void test_round(State& state, size_t index) noexcept auto log2_num_gates = static_cast(state.range(0)); bb::srs::init_crs_factory("../srs_db/ignition"); - GoblinUltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - GoblinUltraProver prover = bb::mock_proofs::get_prover( - composer, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_num_gates); + auto prover = bb::mock_proofs::get_prover( + &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_num_gates); for (auto _ : state) { test_round_inner(state, prover, index); } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp index 6682aeb5d90..28ef3d8e25e 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp @@ -12,7 +12,7 @@ static void construct_proof_ultraplonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -22,7 +22,7 @@ static void construct_proof_ultraplonk(State& state, static void construct_proof_ultraplonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp index 8fa44c08809..08442500ab0 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp @@ -52,10 +52,9 @@ BB_PROFILE static void test_round(State& state, size_t index) noexcept bb::srs::init_crs_factory("../srs_db/ignition"); for (auto _ : state) { state.PauseTiming(); - plonk::UltraComposer composer; // TODO: https://github.com/AztecProtocol/barretenberg/issues/761 benchmark both sparse and dense circuits - plonk::UltraProver prover = bb::mock_proofs::get_prover( - composer, &bb::stdlib::generate_ecdsa_verification_test_circuit, 10); + auto prover = bb::mock_proofs::get_prover( + &bb::stdlib::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness state.ResumeTiming(); diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp index 011c8710b5a..d1738846503 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp @@ -47,7 +47,6 @@ class ClientIVC { private: using ProverFoldOutput = FoldingResult; - using Composer = GoblinUltraComposer; // Note: We need to save the last instance that was folded in order to compute its verification key, this will not // be needed in the real IVC as they are provided as inputs diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 54870a0b4fe..8fb9c8cc6fd 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -20,7 +20,6 @@ class ClientIVCTests : public ::testing::Test { using Flavor = ClientIVC::Flavor; using FF = typename Flavor::FF; using Builder = ClientIVC::ClientCircuit; - using Composer = GoblinUltraComposer; using ProverAccumulator = ClientIVC::ProverAccumulator; using VerifierAccumulator = ClientIVC::VerifierAccumulator; using VerifierInstance = ClientIVC::VerifierInstance; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp index 9dbe3cd4d49..66c2ad83d9a 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp @@ -12,6 +12,8 @@ namespace bb::plonk { template class ProverBase { public: + using Flavor = typename settings::Flavor; + ProverBase(std::shared_ptr input_key = nullptr, const transcript::Manifest& manifest = transcript::Manifest()); ProverBase(ProverBase&& other); @@ -100,6 +102,7 @@ template class ProverBase { }; typedef ProverBase Prover; +typedef Prover StandardProver; typedef ProverBase UltraProver; // TODO(Mike): maybe just return a templated proverbase so that I don't // need separate cases for ultra vs ultra_to_standard...??? // TODO(Cody): Make this into an issue? diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp index 88dd0d26e89..44469d3c775 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp @@ -13,6 +13,7 @@ class settings_base { class standard_settings : public settings_base { public: using Arithmetization = StandardArith; + using Flavor = plonk::flavor::Standard; static constexpr size_t num_challenge_bytes = 16; static constexpr transcript::HashType hash_type = transcript::HashType::PedersenBlake3s; static constexpr size_t program_width = 3; @@ -26,6 +27,7 @@ class standard_settings : public settings_base { class ultra_settings : public settings_base { public: + using Flavor = plonk::flavor::Ultra; static constexpr size_t num_challenge_bytes = 16; static constexpr transcript::HashType hash_type = transcript::HashType::PedersenBlake3s; static constexpr size_t program_width = 4; 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 70d281d8ca2..6a3419b26c4 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,7 +60,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { * @brief Construct and a verify a Honk proof * */ - bool construct_and_verify_honk_proof([[maybe_unused]] auto& composer, auto& builder) + bool construct_and_verify_honk_proof(auto& builder) { auto instance = std::make_shared>(builder); GoblinUltraProver prover(instance); @@ -105,10 +105,8 @@ TEST_F(GoblinUltraHonkComposerTests, SingleCircuit) generate_test_circuit(builder); - auto composer = GoblinUltraComposer(); - // Construct and verify Honk proof - auto honk_verified = construct_and_verify_honk_proof(composer, builder); + bool honk_verified = construct_and_verify_honk_proof(builder); EXPECT_TRUE(honk_verified); // Construct and verify Goblin ECC op queue Merge proof @@ -162,10 +160,8 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkOnly) generate_test_circuit(builder); - auto composer = GoblinUltraComposer(); - // Construct and verify Honk proof - auto honk_verified = construct_and_verify_honk_proof(composer, builder); + bool honk_verified = construct_and_verify_honk_proof(builder); EXPECT_TRUE(honk_verified); } } @@ -190,10 +186,8 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) generate_test_circuit(builder); - auto composer = GoblinUltraComposer(); - // Construct and verify Honk proof - auto honk_verified = construct_and_verify_honk_proof(composer, builder); + bool honk_verified = construct_and_verify_honk_proof(builder); EXPECT_TRUE(honk_verified); // Construct and verify Goblin ECC op queue Merge proof diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 9d72bcfd890..3edc68a6889 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -26,7 +26,4 @@ template class UltraComposer_ { using VerifierInstances = VerifierInstances_; }; -// TODO(#532): this pattern is weird; is this not instantiating the templates? -using UltraComposer = UltraComposer_; -using GoblinUltraComposer = UltraComposer_; } // namespace bb 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 da32df9a3e0..c300f755f45 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -33,7 +33,7 @@ std::vector add_variables(auto& circuit_builder, std::vector v return res; } -void prove_and_verify(auto& circuit_builder, [[maybe_unused]] auto& composer, bool expected_result) +void prove_and_verify(auto& circuit_builder, bool expected_result) { auto instance = std::make_shared(circuit_builder); UltraProver prover(instance); @@ -110,8 +110,7 @@ TEST_F(UltraHonkComposerTests, PublicInputs) builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); } - auto composer = UltraComposer(); - prove_and_verify(builder, composer, /*expected_result=*/true); + prove_and_verify(builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, XorConstraint) @@ -138,8 +137,7 @@ TEST_F(UltraHonkComposerTests, XorConstraint) circuit_builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::UINT32_XOR, lookup_accumulators, left_witness_index, right_witness_index); - UltraComposer composer; - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) @@ -227,8 +225,7 @@ TEST_F(UltraHonkComposerTests, test_no_lookup_proof) } } - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, test_elliptic_gate) @@ -261,8 +258,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) y3 = circuit_builder.add_variable(p3.y); circuit_builder.create_ecc_add_gate({ x1, y1, x2, y2, x3, y3, -1 }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) @@ -289,8 +285,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) circuit_builder.assign_tag(c_idx, 2); circuit_builder.assign_tag(d_idx, 2); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) @@ -327,8 +322,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) circuit_builder.create_add_gate( { e_idx, f_idx, circuit_builder.zero_idx, fr::one(), -fr::one(), fr::zero(), fr::zero() }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, bad_tag_permutation) @@ -354,8 +348,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) circuit_builder.assign_tag(c_idx, 2); circuit_builder.assign_tag(d_idx, 2); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } // Same as above but without tag creation to check reason of failure is really tag mismatch { @@ -371,9 +364,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) circuit_builder.create_add_gate({ a_idx, b_idx, circuit_builder.zero_idx, 1, 1, 0, 0 }); circuit_builder.create_add_gate({ c_idx, d_idx, circuit_builder.zero_idx, 1, 1, 0, -1 }); - auto composer = UltraComposer(); - - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } } @@ -391,8 +382,7 @@ TEST_F(UltraHonkComposerTests, sort_widget) auto d_idx = circuit_builder.add_variable(d); circuit_builder.create_sort_constraint({ a_idx, b_idx, c_idx, d_idx }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, sort_with_edges_gate) @@ -419,8 +409,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) circuit_builder.create_sort_constraint_with_edges( { a_idx, b_idx, c_idx, d_idx, e_idx, f_idx, g_idx, h_idx }, a, h); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { @@ -436,8 +425,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) circuit_builder.create_sort_constraint_with_edges( { a_idx, b_idx, c_idx, d_idx, e_idx, f_idx, g_idx, h_idx }, a, g); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } { auto circuit_builder = UltraCircuitBuilder(); @@ -452,8 +440,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) circuit_builder.create_sort_constraint_with_edges( { a_idx, b_idx, c_idx, d_idx, e_idx, f_idx, g_idx, h_idx }, b, h); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } { auto circuit_builder = UltraCircuitBuilder(); @@ -468,8 +455,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) circuit_builder.create_sort_constraint_with_edges( { a_idx, b2_idx, c_idx, d_idx, e_idx, f_idx, g_idx, h_idx }, b, h); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } { auto circuit_builder = UltraCircuitBuilder(); @@ -477,8 +463,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 45); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { auto circuit_builder = UltraCircuitBuilder(); @@ -486,8 +471,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 29); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } } @@ -502,8 +486,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) // auto ind = {a_idx,b_idx,c_idx,d_idx,e_idx,f_idx,g_idx,h_idx}; circuit_builder.create_sort_constraint(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { auto circuit_builder = UltraCircuitBuilder(); @@ -514,8 +497,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) // auto ind = {a_idx,b_idx,c_idx,d_idx,e_idx,f_idx,g_idx,h_idx}; circuit_builder.create_dummy_constraints(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { auto circuit_builder = UltraCircuitBuilder(); @@ -525,8 +507,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) } circuit_builder.create_sort_constraint(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } { auto circuit_builder = UltraCircuitBuilder(); @@ -537,8 +518,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) } circuit_builder.create_dummy_constraints(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { auto circuit_builder = UltraCircuitBuilder(); @@ -549,8 +529,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) } circuit_builder.create_dummy_constraints(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } { auto circuit_builder = UltraCircuitBuilder(); @@ -561,8 +540,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) } circuit_builder.create_dummy_constraints(indices); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } } @@ -581,8 +559,7 @@ TEST_F(UltraHonkComposerTests, range_with_gates) circuit_builder.create_add_gate( { idx[6], idx[7], circuit_builder.zero_idx, fr::one(), fr::one(), fr::zero(), -15 }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_two) @@ -600,8 +577,7 @@ TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_tw circuit_builder.create_add_gate( { idx[6], idx[7], circuit_builder.zero_idx, fr::one(), fr::one(), fr::zero(), -15 }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, sort_widget_complex) @@ -615,8 +591,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) ind.emplace_back(circuit_builder.add_variable(a[i])); circuit_builder.create_sort_constraint(ind); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } { @@ -627,8 +602,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) ind.emplace_back(circuit_builder.add_variable(a[i])); circuit_builder.create_sort_constraint(ind); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } } @@ -646,8 +620,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_neg) auto d_idx = circuit_builder.add_variable(d); circuit_builder.create_sort_constraint({ a_idx, b_idx, c_idx, d_idx }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/false); + prove_and_verify(circuit_builder, /*expected_result=*/false); } TEST_F(UltraHonkComposerTests, composed_range_constraint) @@ -660,8 +633,7 @@ TEST_F(UltraHonkComposerTests, composed_range_constraint) circuit_builder.create_add_gate({ a_idx, circuit_builder.zero_idx, circuit_builder.zero_idx, 1, 0, 0, -fr(e) }); circuit_builder.decompose_into_default_range(a_idx, 134); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, non_native_field_multiplication) @@ -717,8 +689,7 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) const auto [lo_1_idx, hi_1_idx] = circuit_builder.evaluate_non_native_field_multiplication(inputs); circuit_builder.range_constrain_two_limbs(lo_1_idx, hi_1_idx, 70, 70); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, rom) @@ -759,8 +730,7 @@ TEST_F(UltraHonkComposerTests, rom) 0, }); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, ram) @@ -823,8 +793,7 @@ TEST_F(UltraHonkComposerTests, ram) }, false); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) @@ -859,8 +828,7 @@ TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) }, false); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } // Ensure copy constraints added on variables smaller than 2^14, which have been previously @@ -883,6 +851,5 @@ TEST_F(UltraHonkComposerTests, range_constraint_small_variable) circuit_builder.create_range_constraint(c_idx, 8, "bad range"); circuit_builder.assert_equal(a_idx, c_idx); - auto composer = UltraComposer(); - prove_and_verify(circuit_builder, composer, /*expected_result=*/true); + prove_and_verify(circuit_builder, /*expected_result=*/true); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index ec5c35f3b5f..26f71d02fba 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -10,7 +10,9 @@ namespace bb { -template class UltraProver_ { +template class UltraProver_ { + public: + using Flavor = Flavor_; using FF = typename Flavor::FF; using Builder = typename Flavor::CircuitBuilder; using Commitment = typename Flavor::Commitment; @@ -24,7 +26,6 @@ template class UltraProver_ { using Transcript = typename Flavor::Transcript; using RelationSeparator = typename Flavor::RelationSeparator; - public: explicit UltraProver_(const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); From 1e4b4b37bdd41c16f5410b0b8a3a4812b26f2ed0 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 19:19:56 +0000 Subject: [PATCH 09/17] Delete composer class. --- .../cpp/src/barretenberg/goblin/goblin.hpp | 2 +- .../honk/verifier/goblin_verifier.test.cpp | 16 +------- .../honk/verifier/merge_verifier.test.cpp | 4 +- .../protogalaxy_recursive_verifier.test.cpp | 10 ++--- .../recursion/honk/verifier/verifier.test.cpp | 16 +------- .../ultra_honk/protogalaxy.test.cpp | 38 ++++++++----------- .../ultra_honk/ultra_composer.cpp | 7 +--- .../ultra_honk/ultra_composer.hpp | 18 --------- 8 files changed, 25 insertions(+), 86 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 7c7bddba319..029059e5f01 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -12,6 +12,7 @@ #include "barretenberg/ultra_honk/merge_verifier.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" namespace bb { @@ -25,7 +26,6 @@ class Goblin { using Fr = bb::fr; using Transcript = NativeTranscript; using GoblinUltraProverInstance = ProverInstance_; - using GoblinUltraComposer = bb::UltraComposer_; using GoblinUltraVerifier = bb::UltraVerifier_; using OpQueue = bb::ECCOpQueue; using ECCVMFlavor = bb::ECCVMFlavor; 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 81dab41a878..09ad36feaa4 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 @@ -18,15 +18,11 @@ namespace bb::stdlib::recursion::honk { */ template class GoblinRecursiveVerifierTest : public testing::Test { - using UltraComposer = UltraComposer_; - using GoblinUltraComposer = UltraComposer_; - // 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 InnerVerifier = GoblinUltraVerifier; - using InnerBuilder = typename InnerComposer::CircuitBuilder; + using InnerBuilder = typename InnerFlavor::CircuitBuilder; using InnerProverInstance = ProverInstance_; using InnerCurve = bn254; using InnerCommitment = InnerFlavor::Commitment; @@ -45,16 +41,6 @@ template class GoblinRecursiveVerifierTest : public testi using RecursiveVerifier = UltraRecursiveVerifier_; using VerificationKey = typename RecursiveVerifier::VerificationKey; - // Helper for getting composer for prover/verifier of recursive (outer) circuit - template static auto get_outer_composer() - { - if constexpr (IsGoblinBuilder) { - return GoblinUltraComposer(); - } else { - return UltraComposer(); - } - } - /** * @brief Create a non-trivial arbitrary inner circuit, the proof of which will be recursively 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 bb0a8058cd3..266cf2be8e9 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 @@ -20,11 +20,9 @@ class RecursiveMergeVerifierTest : public testing::Test { using RecursiveMergeVerifier = MergeRecursiveVerifier_; // Define types relevant for inner circuit - using GoblinUltraComposer = UltraComposer_; using InnerFlavor = GoblinUltraFlavor; using InnerProverInstance = ProverInstance_; - using InnerComposer = GoblinUltraComposer; - using InnerBuilder = typename InnerComposer::CircuitBuilder; + using InnerBuilder = typename InnerFlavor::CircuitBuilder; // Define additional types for testing purposes using Commitment = InnerFlavor::Commitment; 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 fb527e12c16..988a5b77956 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 @@ -11,7 +11,6 @@ namespace bb::stdlib::recursion::honk { template class ProtoGalaxyRecursiveTests : public testing::Test { public: using NativeFlavor = typename RecursiveFlavor::NativeFlavor; - using Composer = ::bb::UltraComposer_; using Builder = typename RecursiveFlavor::CircuitBuilder; using Prover = UltraProver_; using Verifier = UltraVerifier_; @@ -99,8 +98,7 @@ template class ProtoGalaxyRecursiveTests : public tes } }; - static std::tuple, std::shared_ptr> fold_and_verify_native( - [[maybe_unused]] Composer& composer) + static std::tuple, std::shared_ptr> fold_and_verify_native() { Builder builder1; create_function_circuit(builder1); @@ -307,8 +305,7 @@ template class ProtoGalaxyRecursiveTests : public tes static void test_tampered_decider_proof() { // Natively fold two circuits - auto composer = Composer(); - auto [prover_accumulator, verifier_accumulator] = fold_and_verify_native(composer); + auto [prover_accumulator, verifier_accumulator] = fold_and_verify_native(); // Tamper with the accumulator by changing the target sum verifier_accumulator->target_sum = FF::random_element(); @@ -330,8 +327,7 @@ template class ProtoGalaxyRecursiveTests : public tes static void test_tampered_accumulator() { // Fold two circuits natively - auto composer = Composer(); - auto [prover_accumulator, verifier_accumulator] = fold_and_verify_native(composer); + auto [prover_accumulator, verifier_accumulator] = fold_and_verify_native(); // Create another circuit to do a second round of folding Builder builder; 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 7758bda335a..27829bc8b35 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 @@ -5,6 +5,7 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" namespace bb::stdlib::recursion::honk { @@ -19,15 +20,12 @@ namespace bb::stdlib::recursion::honk { template class HonkRecursiveVerifierTest : public testing::Test { // Define types relevant for testing - using UltraComposer = UltraComposer_; - using GoblinUltraComposer = UltraComposer_; using InnerFlavor = UltraFlavor; using InnerProverInstance = ProverInstance_; - using InnerComposer = UltraComposer; using InnerProver = UltraProver; using InnerVerifier = UltraVerifier; - using InnerBuilder = typename InnerComposer::CircuitBuilder; + using InnerBuilder = typename InnerFlavor::CircuitBuilder; using InnerCurve = bn254; using Commitment = InnerFlavor::Commitment; using FF = InnerFlavor::FF; @@ -46,16 +44,6 @@ template class HonkRecursiveVerifierTest : public testing using VerificationKey = typename RecursiveVerifier::VerificationKey; - // Helper for getting composer for prover/verifier of recursive (outer) circuit - template static auto get_outer_composer() - { - if constexpr (IsGoblinBuilder) { - return GoblinUltraComposer(); - } else { - return UltraComposer(); - } - } - /** * @brief Create a non-trivial arbitrary inner circuit, the proof of which will be recursively verified * diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index d0bd67a2bcb..71503f97746 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -12,7 +12,6 @@ auto& engine = numeric::get_debug_randomness(); template class ProtoGalaxyTests : public testing::Test { public: - using Composer = UltraComposer_; using VerificationKey = typename Flavor::VerificationKey; using ProverInstance = ProverInstance_; using ProverInstances = ProverInstances_; @@ -67,8 +66,7 @@ template class ProtoGalaxyTests : public testing::Test { static std::tuple, std::shared_ptr> fold_and_verify( const std::vector>& prover_instances, - const std::vector>& verifier_instances, - [[maybe_unused]] Composer& composer) + const std::vector>& verifier_instances) { FoldingProver folding_prover(prover_instances); FoldingVerifier folding_verifier(verifier_instances); @@ -97,7 +95,6 @@ template class ProtoGalaxyTests : public testing::Test { static void decide_and_verify(std::shared_ptr& prover_accumulator, std::shared_ptr& verifier_accumulator, - [[maybe_unused]] Composer& composer, bool expected_result) { DeciderProver decider_prover(prover_accumulator); @@ -298,7 +295,6 @@ template class ProtoGalaxyTests : public testing::Test { */ static void test_full_protogalaxy() { - auto composer = Composer(); auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); @@ -309,8 +305,8 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); - auto [prover_accumulator, verifier_accumulator] = fold_and_verify( - { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); + auto [prover_accumulator, verifier_accumulator] = + fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); check_accumulator_target_sum_manual(prover_accumulator, true); @@ -319,12 +315,12 @@ template class ProtoGalaxyTests : public testing::Test { auto prover_instance_3 = std::make_shared(builder_3); auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); - auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( - { prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }, composer); + auto [prover_accumulator_2, verifier_accumulator_2] = + fold_and_verify({ prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }); check_accumulator_target_sum_manual(prover_accumulator_2, true); - decide_and_verify(prover_accumulator_2, verifier_accumulator_2, composer, true); + decide_and_verify(prover_accumulator_2, verifier_accumulator_2, true); } /** @@ -333,7 +329,6 @@ template class ProtoGalaxyTests : public testing::Test { */ static void test_tampered_commitment() { - auto composer = Composer(); auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); @@ -344,8 +339,8 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); - auto [prover_accumulator, verifier_accumulator] = fold_and_verify( - { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); + auto [prover_accumulator, verifier_accumulator] = + fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); check_accumulator_target_sum_manual(prover_accumulator, true); verifier_accumulator->witness_commitments.w_l = Projective(Affine::random_element()); @@ -354,12 +349,12 @@ template class ProtoGalaxyTests : public testing::Test { auto prover_instance_3 = std::make_shared(builder_3); auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); - auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( - { prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }, composer); + auto [prover_accumulator_2, verifier_accumulator_2] = + fold_and_verify({ prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }); check_accumulator_target_sum_manual(prover_accumulator_2, true); - decide_and_verify(prover_accumulator_2, verifier_accumulator_2, composer, false); + decide_and_verify(prover_accumulator_2, verifier_accumulator_2, false); } /** @@ -369,7 +364,6 @@ template class ProtoGalaxyTests : public testing::Test { */ static void test_tampered_accumulator_polynomial() { - auto composer = Composer(); auto builder_1 = typename Flavor::CircuitBuilder(); construct_circuit(builder_1); @@ -380,8 +374,8 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); - auto [prover_accumulator, verifier_accumulator] = fold_and_verify( - { prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }, composer); + auto [prover_accumulator, verifier_accumulator] = + fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); check_accumulator_target_sum_manual(prover_accumulator, true); auto builder_3 = typename Flavor::CircuitBuilder(); @@ -390,11 +384,11 @@ template class ProtoGalaxyTests : public testing::Test { auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); - auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify( - { prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }, composer); + auto [prover_accumulator_2, verifier_accumulator_2] = + fold_and_verify({ prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }); EXPECT_EQ(prover_accumulator_2->target_sum == verifier_accumulator_2->target_sum, false); - decide_and_verify(prover_accumulator_2, verifier_accumulator_2, composer, false); + decide_and_verify(prover_accumulator_2, verifier_accumulator_2, false); } }; } // namespace diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 823b3addcc3..c7bdd222985 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -1,6 +1 @@ -#include "barretenberg/ultra_honk/ultra_composer.hpp" - -namespace bb { -template class UltraComposer_; -template class UltraComposer_; -} // namespace bb +#include "barretenberg/ultra_honk/ultra_composer.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 3edc68a6889..b50aaef8604 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -9,21 +9,3 @@ #include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" - -namespace bb { -template class UltraComposer_ { - public: - using Flavor = Flavor_; - using CircuitBuilder = typename Flavor::CircuitBuilder; - using ProvingKey = typename Flavor::ProvingKey; - using VerificationKey = typename Flavor::VerificationKey; - using CommitmentKey = typename Flavor::CommitmentKey; - using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; - using ProverInstance = ProverInstance_; - using VerifierInstance = VerifierInstance_; - using Transcript = typename Flavor::Transcript; - using ProverInstances = ProverInstances_; - using VerifierInstances = VerifierInstances_; -}; - -} // namespace bb From 3ca09094a24fd6b046eb681837a6f299695ff2f8 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 20:10:57 +0000 Subject: [PATCH 10/17] Delete the files, update includes. --- .../benchmark/client_ivc_bench/client_ivc.bench.cpp | 2 +- .../benchmark/goblin_bench/goblin.bench.cpp | 1 - .../barretenberg/benchmark/pippenger_bench/main.cpp | 1 - .../benchmark/protogalaxy_bench/protogalaxy.bench.cpp | 4 +++- .../protogalaxy_rounds.bench.cpp | 3 ++- .../benchmark/ultra_bench/goblin_ultra_honk.bench.cpp | 1 - .../benchmark/ultra_bench/mock_proofs.hpp | 2 +- .../benchmark/ultra_bench/ultra_honk.bench.cpp | 1 - .../benchmark/ultra_bench/ultra_honk_rounds.bench.cpp | 2 +- .../cpp/src/barretenberg/client_ivc/client_ivc.hpp | 6 +++++- .../src/barretenberg/client_ivc/client_ivc.test.cpp | 1 - .../client_ivc/mock_kernel_pinning.test.cpp | 2 +- barretenberg/cpp/src/barretenberg/goblin/goblin.hpp | 2 -- .../src/barretenberg/goblin/goblin_recursion.test.cpp | 1 - .../goblin/mock_circuits_pinning.test.cpp | 2 +- .../cpp/src/barretenberg/join_split_example/types.hpp | 1 - .../recursion/honk/verifier/goblin_verifier.test.cpp | 2 +- .../recursion/honk/verifier/merge_verifier.test.cpp | 1 - .../verifier/protogalaxy_recursive_verifier.test.cpp | 8 +++++++- .../stdlib/recursion/honk/verifier/verifier.test.cpp | 2 +- .../cpp/src/barretenberg/sumcheck/sumcheck.test.cpp | 1 - .../barretenberg/ultra_honk/databus_composer.test.cpp | 2 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 2 +- .../ultra_honk/goblin_ultra_transcript.test.cpp | 5 ++++- .../src/barretenberg/ultra_honk/protogalaxy.test.cpp | 5 ++++- .../ultra_honk/relation_correctness.test.cpp | 5 ++++- .../cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp | 1 - .../src/barretenberg/ultra_honk/ultra_composer.cpp | 1 - .../src/barretenberg/ultra_honk/ultra_composer.hpp | 11 ----------- .../barretenberg/ultra_honk/ultra_composer.test.cpp | 7 ++----- .../barretenberg/ultra_honk/ultra_transcript.test.cpp | 6 +++++- 31 files changed, 45 insertions(+), 46 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp diff --git a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp index 41ff9f8ae75..f65385da92e 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/client_ivc.bench.cpp @@ -5,7 +5,7 @@ #include "barretenberg/common/op_count_google_bench.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" using namespace benchmark; using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp index 8667c739dec..92f36e885f0 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -6,7 +6,6 @@ #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" using namespace benchmark; using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp index cd6adb52b36..0fdf754812b 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp @@ -5,7 +5,6 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include #include diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index 140de3e486a..cd369c29a70 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -2,7 +2,9 @@ #include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/protogalaxy/protogalaxy_prover.hpp" +#include "barretenberg/sumcheck/instance/instances.hpp" +#include "barretenberg/sumcheck/instance/prover_instance.hpp" using namespace benchmark; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp index ba1ee89f4de..14794ebb0a9 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp @@ -2,7 +2,8 @@ #include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/protogalaxy/protogalaxy_prover.hpp" +#include "barretenberg/sumcheck/instance/instances.hpp" using namespace benchmark; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp index a50c5f6ceca..776a4752181 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp @@ -2,7 +2,6 @@ #include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" using namespace benchmark; using namespace bb; 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 89d343cedca..ab24f1b070d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -18,7 +18,7 @@ #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include "barretenberg/ultra_honk/ultra_prover.hpp" namespace bb::mock_proofs { diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp index f91ea3c8dd6..d45ad85ebbe 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp @@ -2,7 +2,6 @@ #include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" using namespace benchmark; using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index a9e0e72f1d5..11ad5e6e15f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -3,7 +3,7 @@ #include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/common/op_count_google_bench.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace benchmark; diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp index d1738846503..1d26519f323 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp @@ -2,7 +2,11 @@ #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/protogalaxy/decider_prover.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" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 8fb9c8cc6fd..6376e6a0e04 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -4,7 +4,6 @@ #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp index 3dbbe13ed61..eebaa2e8185 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/mock_kernel_pinning.test.cpp @@ -1,7 +1,7 @@ #include "barretenberg/client_ivc/client_ivc.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 029059e5f01..5d2fb6aab5a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -10,7 +10,6 @@ #include "barretenberg/translator_vm/goblin_translator_composer.hpp" #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" #include "barretenberg/ultra_honk/ultra_verifier.hpp" @@ -26,7 +25,6 @@ class Goblin { using Fr = bb::fr; using Transcript = NativeTranscript; using GoblinUltraProverInstance = ProverInstance_; - using GoblinUltraVerifier = bb::UltraVerifier_; using OpQueue = bb::ECCOpQueue; using ECCVMFlavor = bb::ECCVMFlavor; using ECCVMBuilder = bb::ECCVMCircuitBuilder; diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index 442a4202716..96252176a8a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -2,7 +2,6 @@ #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp index bdc8abc22e5..0b9e06e0ff8 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp @@ -1,7 +1,7 @@ #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp index fbc2e45f7ca..392fe9d4790 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp @@ -2,7 +2,6 @@ #include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/crypto/merkle_tree/hash_path.hpp" #include "barretenberg/plonk/proof_system/prover/prover.hpp" 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 09ad36feaa4..e197532a654 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 @@ -4,7 +4,7 @@ #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" namespace bb::stdlib::recursion::honk { 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 266cf2be8e9..14857e2be94 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 @@ -2,7 +2,6 @@ #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" namespace bb::stdlib::recursion::goblin { 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 988a5b77956..e212443e63f 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 @@ -1,11 +1,17 @@ #include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" +#include "barretenberg/protogalaxy/decider_prover.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" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/sumcheck/instance/instances.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" namespace bb::stdlib::recursion::honk { template class ProtoGalaxyRecursiveTests : public testing::Test { 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 27829bc8b35..efd4462c0d4 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 @@ -4,7 +4,7 @@ #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 842152c3a14..008cbd01570 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -8,7 +8,6 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include 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 e16356dd7be..318afa7f44c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -7,7 +7,7 @@ #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/proof_system/instance_inspector.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" + #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace bb; 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 6a3419b26c4..bd461958e58 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 @@ -7,8 +7,8 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #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" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" using namespace bb; 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 62b7dda79d5..ac68021638f 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 @@ -2,8 +2,11 @@ #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 71503f97746..b48fd8dc20b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -1,7 +1,10 @@ #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/polynomials/pow.hpp" +#include "barretenberg/protogalaxy/decider_prover.hpp" +#include "barretenberg/protogalaxy/decider_verifier.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 777feaee8f0..848d5144c0e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -1,4 +1,6 @@ #include "barretenberg/flavor/goblin_translator.hpp" +#include "barretenberg/flavor/goblin_ultra.hpp" +#include "barretenberg/flavor/ultra.hpp" #include "barretenberg/honk/proof_system/permutation_library.hpp" #include "barretenberg/proof_system/library/grand_product_library.hpp" #include "barretenberg/relations/auxiliary_relation.hpp" @@ -9,7 +11,8 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/sumcheck/instance/prover_instance.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index d0bea39845a..69b3285d9d6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -10,7 +10,6 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp deleted file mode 100644 index c7bdd222985..00000000000 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "barretenberg/ultra_honk/ultra_composer.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp deleted file mode 100644 index b50aaef8604..00000000000 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "barretenberg/flavor/flavor.hpp" -#include "barretenberg/proof_system/composer/composer_lib.hpp" -#include "barretenberg/protogalaxy/decider_prover.hpp" -#include "barretenberg/protogalaxy/decider_verifier.hpp" -#include "barretenberg/protogalaxy/protogalaxy_prover.hpp" -#include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" -#include "barretenberg/srs/global_crs.hpp" -#include "barretenberg/sumcheck/instance/prover_instance.hpp" -#include "barretenberg/ultra_honk/ultra_prover.hpp" -#include "barretenberg/ultra_honk/ultra_verifier.hpp" 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 c300f755f45..fbcc03121e3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -1,4 +1,3 @@ -#include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" @@ -10,11 +9,9 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_round.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" -#include -#include +#include "barretenberg/ultra_honk/ultra_verifier.hpp" + #include -#include -#include using namespace bb; 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 042241335cd..7089a18f1dc 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -1,9 +1,13 @@ #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/ultra.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" +#include "barretenberg/ultra_honk/ultra_prover.hpp" +#include "barretenberg/ultra_honk/ultra_verifier.hpp" + #include using namespace bb; From c80894ba060b4f5022828345037683d2a3bed36a Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 20:40:23 +0000 Subject: [PATCH 11/17] Remove unused constructor --- .../cpp/src/barretenberg/protogalaxy/decider_verifier.cpp | 8 -------- .../cpp/src/barretenberg/protogalaxy/decider_verifier.hpp | 2 -- 2 files changed, 10 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 9d57cbd9f77..d635c15269f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -6,14 +6,6 @@ namespace bb { -template -DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& accumulator) - : accumulator(accumulator) - , pcs_verification_key(accumulator->verification_key->pcs_verification_key) - , transcript(transcript) -{} - template DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp index fd417e20e4d..eb896654430 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -17,8 +17,6 @@ template class DeciderVerifier_ { public: explicit DeciderVerifier_(); - explicit DeciderVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& accumulator = nullptr); explicit DeciderVerifier_(const std::shared_ptr& accumulator, const std::shared_ptr& transcript = std::make_shared()); From 831fff522ac553e84eed857c7c1b03f876044411 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 20:45:07 +0000 Subject: [PATCH 12/17] Git rid of conditional type. --- .../honk/verifier/goblin_verifier.test.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 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 e197532a654..ab2e5058577 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 @@ -16,7 +16,7 @@ namespace bb::stdlib::recursion::honk { * * @tparam Builder Circuit builder for the recursive verifier circuit */ -template class GoblinRecursiveVerifierTest : public testing::Test { +template class GoblinRecursiveVerifierTest : public testing::Test { // Define types for the inner circuit, i.e. the circuit whose proof will be recursively verified using InnerFlavor = GoblinUltraFlavor; @@ -29,13 +29,9 @@ template class GoblinRecursiveVerifierTest : public testi using InnerFF = InnerFlavor::FF; // Types for recursive verifier circuit - using OuterBuilder = BuilderType; - using OuterFlavor = - std::conditional_t, GoblinUltraFlavor, UltraFlavor>; - using OuterProver = - std::conditional_t, GoblinUltraProver, UltraProver>; - using OuterVerifier = - std::conditional_t, GoblinUltraVerifier, UltraVerifier>; + using OuterBuilder = typename OuterFlavor::CircuitBuilder; + using OuterProver = UltraProver_; + using OuterVerifier = UltraVerifier_; using OuterProverInstance = ProverInstance_; using RecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; @@ -244,9 +240,9 @@ template class GoblinRecursiveVerifierTest : public testi }; // Run the recursive verifier tests with conventional Ultra builder and Goblin builder -using BuilderTypes = testing::Types; +using Flavors = testing::Types; -TYPED_TEST_SUITE(GoblinRecursiveVerifierTest, BuilderTypes); +TYPED_TEST_SUITE(GoblinRecursiveVerifierTest, Flavors); HEAVY_TYPED_TEST(GoblinRecursiveVerifierTest, InnerCircuit) { From 12a810268a19753410ed8487c97cf135d988551f Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 20:48:33 +0000 Subject: [PATCH 13/17] Ditto --- .../recursion/honk/verifier/verifier.test.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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 efd4462c0d4..379236de776 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 @@ -17,7 +17,7 @@ namespace bb::stdlib::recursion::honk { * * @tparam Builder */ -template class HonkRecursiveVerifierTest : public testing::Test { +template class HonkRecursiveVerifierTest : public testing::Test { // Define types relevant for testing @@ -31,15 +31,11 @@ template class HonkRecursiveVerifierTest : public testing using FF = InnerFlavor::FF; // Types for recursive verifier circuit - using RecursiveFlavor = UltraRecursiveFlavor_; + using OuterBuilder = typename OuterFlavor::CircuitBuilder; + using RecursiveFlavor = UltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; - using OuterBuilder = BuilderType; - using OuterFlavor = - std::conditional_t, GoblinUltraFlavor, UltraFlavor>; - using OuterProver = - std::conditional_t, GoblinUltraProver, UltraProver>; - using OuterVerifier = - std::conditional_t, GoblinUltraVerifier, UltraVerifier>; + using OuterProver = UltraProver_; + using OuterVerifier = UltraVerifier_; using OuterProverInstance = ProverInstance_; using VerificationKey = typename RecursiveVerifier::VerificationKey; @@ -232,9 +228,9 @@ template class HonkRecursiveVerifierTest : public testing }; // Run the recursive verifier tests with conventional Ultra builder and Goblin builder -using BuilderTypes = testing::Types; +using Flavors = testing::Types; -TYPED_TEST_SUITE(HonkRecursiveVerifierTest, BuilderTypes); +TYPED_TEST_SUITE(HonkRecursiveVerifierTest, Flavors); HEAVY_TYPED_TEST(HonkRecursiveVerifierTest, InnerCircuit) { From a9f208996fa23657f607d10d08ec11b27fa03e04 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 20:50:45 +0000 Subject: [PATCH 14/17] Improve comment. --- barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 8c8af1bcae2..bfa43d84f9c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -22,7 +22,7 @@ UltraProver_::UltraProver_(const std::shared_ptr& inst, const /** * Create UltraProver_ from a circuit. * - * @param instance Instance whose proof we want to generate. + * @param instance Circuit with witnesses whose validity we'd like to prove. * * @tparam a type of UltraFlavor * */ From 303be779a035a0cecd60cd91e13c8afae25b697b Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 4 Mar 2024 15:48:49 +0000 Subject: [PATCH 15/17] fixed other merge conflicts --- .../goblin/goblin_recursion.test.cpp | 3 ++- .../protogalaxy_recursive_verifier.test.cpp | 9 ++++--- .../ultra_honk/protogalaxy.test.cpp | 27 ++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index 96252176a8a..96463863ebb 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -24,7 +24,8 @@ class GoblinRecursionTests : public ::testing::Test { static Goblin::AccumulationOutput construct_accumulator(GoblinUltraCircuitBuilder& builder) { auto prover_instance = std::make_shared(builder); - auto verifier_instance = std::make_shared(prover_instance->verification_key); + auto verification_key = std::make_shared(prover_instance->proving_key); + auto verifier_instance = std::make_shared(verification_key); 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/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index d839fe7e49e..fbf52ef504b 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 @@ -114,9 +114,11 @@ template class ProtoGalaxyRecursiveTests : public tes create_function_circuit(builder2); auto prover_instance_1 = std::make_shared(builder1); + auto verification_key_1 = std::make_shared(prover_instance_1->proving_key); + auto verifier_instance_1 = std::make_shared(verification_key_1); auto prover_instance_2 = std::make_shared(builder2); - auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); - auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); + auto verification_key_2 = std::make_shared(prover_instance_2->proving_key); + auto verifier_instance_2 = std::make_shared(verification_key_2); NativeFoldingProver folding_prover({ prover_instance_1, prover_instance_2 }); NativeFoldingVerifier folding_verifier({ verifier_instance_1, verifier_instance_2 }); @@ -346,7 +348,8 @@ template class ProtoGalaxyRecursiveTests : public tes Builder builder; create_function_circuit(builder); auto prover_inst = std::make_shared(builder); - auto verifier_inst = std::make_shared(prover_inst->verification_key); + auto verification_key = std::make_shared(prover_inst->proving_key); + auto verifier_inst = std::make_shared(verification_key); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index b48fd8dc20b..4ae0c8e4a3a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -302,12 +302,14 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); + auto verification_key_1 = std::make_shared(prover_instance_1->proving_key); + auto verifier_instance_1 = std::make_shared(verification_key_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); + auto verification_key_2 = std::make_shared(prover_instance_2->proving_key); + auto verifier_instance_2 = std::make_shared(verification_key_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); @@ -316,7 +318,8 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); + auto verification_key_3 = std::make_shared(prover_instance_3->proving_key); + auto verifier_instance_3 = std::make_shared(verification_key_3); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify({ prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }); @@ -336,12 +339,14 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); + auto verification_key_1 = std::make_shared(prover_instance_1->proving_key); + auto verifier_instance_1 = std::make_shared(verification_key_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); + auto verification_key_2 = std::make_shared(prover_instance_2->proving_key); + auto verifier_instance_2 = std::make_shared(verification_key_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); check_accumulator_target_sum_manual(prover_accumulator, true); @@ -350,7 +355,8 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); + auto verification_key_3 = std::make_shared(prover_instance_3->proving_key); + auto verifier_instance_3 = std::make_shared(verification_key_3); auto [prover_accumulator_2, verifier_accumulator_2] = fold_and_verify({ prover_accumulator, prover_instance_3 }, { verifier_accumulator, verifier_instance_3 }); @@ -371,12 +377,14 @@ template class ProtoGalaxyTests : public testing::Test { construct_circuit(builder_1); auto prover_instance_1 = std::make_shared(builder_1); - auto verifier_instance_1 = std::make_shared(prover_instance_1->verification_key); + auto verification_key_1 = std::make_shared(prover_instance_1->proving_key); + auto verifier_instance_1 = std::make_shared(verification_key_1); auto builder_2 = typename Flavor::CircuitBuilder(); construct_circuit(builder_2); auto prover_instance_2 = std::make_shared(builder_2); - auto verifier_instance_2 = std::make_shared(prover_instance_2->verification_key); + auto verification_key_2 = std::make_shared(prover_instance_2->proving_key); + auto verifier_instance_2 = std::make_shared(verification_key_2); auto [prover_accumulator, verifier_accumulator] = fold_and_verify({ prover_instance_1, prover_instance_2 }, { verifier_instance_1, verifier_instance_2 }); check_accumulator_target_sum_manual(prover_accumulator, true); @@ -384,7 +392,8 @@ template class ProtoGalaxyTests : public testing::Test { auto builder_3 = typename Flavor::CircuitBuilder(); construct_circuit(builder_3); auto prover_instance_3 = std::make_shared(builder_3); - auto verifier_instance_3 = std::make_shared(prover_instance_3->verification_key); + auto verification_key_3 = std::make_shared(prover_instance_3->proving_key); + auto verifier_instance_3 = std::make_shared(verification_key_3); prover_accumulator->prover_polynomials.w_l[1] = FF::random_element(); auto [prover_accumulator_2, verifier_accumulator_2] = From ca5fce228a87c02c554ad54e727500806064a481 Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 4 Mar 2024 19:08:47 +0000 Subject: [PATCH 16/17] Remove pointless constructor args. --- barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp | 3 +-- barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index bfa43d84f9c..8b0ef603085 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -27,9 +27,8 @@ UltraProver_::UltraProver_(const std::shared_ptr& inst, const * @tparam a type of UltraFlavor * */ template -UltraProver_::UltraProver_(Builder& circuit, const std::shared_ptr& transcript) +UltraProver_::UltraProver_(Builder& circuit) : instance(std::make_shared(circuit)) - , transcript(transcript) , commitment_key(instance->proving_key->commitment_key) { instance->initialize_prover_polynomials(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index 26f71d02fba..dd822986f11 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -29,7 +29,7 @@ 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()); + explicit UltraProver_(Builder&); BB_PROFILE void execute_preamble_round(); BB_PROFILE void execute_wire_commitments_round(); From 8ea2cbc16cf0cec92300190267167e3cd16a636c Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 4 Mar 2024 19:20:16 +0000 Subject: [PATCH 17/17] Default initialize Prover transcript --- barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 8b0ef603085..7d4325054ee 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -29,6 +29,7 @@ UltraProver_::UltraProver_(const std::shared_ptr& inst, const template UltraProver_::UltraProver_(Builder& circuit) : instance(std::make_shared(circuit)) + , transcript(std::make_shared()) , commitment_key(instance->proving_key->commitment_key) { instance->initialize_prover_polynomials();