diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp index fe7dca70d6e4..9645dcb17f79 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 5c444ac9ec57..0dfb93af3485 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 45e594f47a99..3ce5a93e5d56 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 ef3cd372cee5..062d19f96b88 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 d140292bc4b3..9d57cbd9f77c 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 a7882e9f2516..e960d7274831 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -20,6 +20,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); @@ -30,6 +32,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 35f7546a9a29..99772ec0eaa0 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 6159440453e2..82294cc69884 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 817e88d80c01..823b3addcc3a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -1,26 +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 2118aa6bd64b..673c7c11ab27 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 000000000000..517789359081 --- /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 +}