From 4d6445160bc44ce61db340e5201db523998063c4 Mon Sep 17 00:00:00 2001 From: codygunton Date: Fri, 1 Mar 2024 17:40:23 +0000 Subject: [PATCH] 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 9645dcb17f79..fb355852294b 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 0dfb93af3485..011c8710b5a5 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 3ce5a93e5d56..54870a0b4fe8 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 99772ec0eaa0..fb527e12c16f 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 82294cc69884..d0bd67a2bcb8 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 673c7c11ab27..9d72bcfd8900 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?