diff --git a/barretenberg/cpp/scripts/analyze_client_ivc_bench.py b/barretenberg/cpp/scripts/analyze_client_ivc_bench.py index f5da8a48b25..d9b5e047b1f 100644 --- a/barretenberg/cpp/scripts/analyze_client_ivc_bench.py +++ b/barretenberg/cpp/scripts/analyze_client_ivc_bench.py @@ -9,7 +9,7 @@ to_keep = [ "construct_mock_function_circuit(t)", "construct_mock_folding_kernel(t)", - "UltraComposer::create_prover_instance(t)", + "ProverInstance(Circuit&)(t)", "ProtogalaxyProver::fold_instances(t)", "Decider::construct_proof(t)", "ECCVMComposer::create_prover(t)", diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/CMakeLists.txt index 25d49f8ddea..1c090f0bbe1 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(ipa_bench ultra_honk) +barretenberg_module(ipa_bench commitment_schemes) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index 4f1719c141c..e5a86171ad7 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -13,7 +13,7 @@ constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; std::shared_ptr> crs_factory( new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); -auto ck = std::make_shared>(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); +auto ck = std::make_shared>(1 << MAX_POLYNOMIAL_DEGREE_LOG2); auto vk = std::make_shared>(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); std::vector> prover_transcripts(MAX_POLYNOMIAL_DEGREE_LOG2 - diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp index 61525c1cd6d..c37d893e125 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp @@ -8,14 +8,7 @@ namespace bb { template std::shared_ptr> create_commitment_key(const size_t num_points) { std::string srs_path; - if constexpr (std::same_as) { - srs_path = "../srs_db/ignition"; - } else { - static_assert(std::same_as); - srs_path = "../srs_db/grumpkin"; - } - auto crs_factory = std::make_shared>(srs_path, num_points); - return std::make_shared>(num_points, crs_factory); + return std::make_shared>(num_points); } constexpr size_t MAX_LOG_NUM_POINTS = 24; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp index c842e53177e..934b6dae9de 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp @@ -36,6 +36,10 @@ template class CommitmentKey { using Commitment = typename Curve::AffineElement; public: + scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; + std::shared_ptr> crs_factory; + std::shared_ptr> srs; + CommitmentKey() = delete; /** @@ -45,14 +49,14 @@ template class CommitmentKey { * @param path * */ - CommitmentKey(const size_t num_points, - std::shared_ptr> crs_factory = bb::srs::get_crs_factory()) + CommitmentKey(const size_t num_points) : pippenger_runtime_state(num_points) + , crs_factory(srs::get_crs_factory()) , srs(crs_factory->get_prover_crs(num_points)) {} - // Note: This constructor is used only by Plonk; For Honk the srs is extracted by the CommitmentKey - CommitmentKey(const size_t num_points, std::shared_ptr> prover_crs) + // Note: This constructor is to be used only by Plonk; For Honk the srs lives in the CommitmentKey + CommitmentKey(const size_t num_points, std::shared_ptr> prover_crs) : pippenger_runtime_state(num_points) , srs(prover_crs) {} @@ -68,12 +72,9 @@ template class CommitmentKey { BB_OP_COUNT_TIME(); const size_t degree = polynomial.size(); ASSERT(degree <= srs->get_monomial_size()); - return bb::scalar_multiplication::pippenger_unsafe( + return scalar_multiplication::pippenger_unsafe( const_cast(polynomial.data()), srs->get_monomial_points(), degree, pippenger_runtime_state); }; - - bb::scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; - std::shared_ptr> srs; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp index 69d7cdc05dd..4df728ba6b9 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp @@ -6,10 +6,6 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" #include "claim.hpp" -#include -#include -#include -#include #include @@ -19,18 +15,16 @@ template inline std::shared_ptr CreateCommitmentKey(); template <> inline std::shared_ptr> CreateCommitmentKey>() { + srs::init_crs_factory("../srs_db/ignition"); constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new bb::srs::factories::FileCrsFactory("../srs_db/ignition", 4096)); - return std::make_shared>(n, crs_factory); + return std::make_shared>(n); } // For IPA template <> inline std::shared_ptr> CreateCommitmentKey>() { + srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 4096)); - return std::make_shared>(n, crs_factory); + return std::make_shared>(n); } template inline std::shared_ptr CreateCommitmentKey() diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp index c1771ce2ce5..569e72b1492 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp @@ -43,8 +43,9 @@ template <> class VerifierCommitmentKey { * @param num_points * @param srs verifier G2 point */ - VerifierCommitmentKey([[maybe_unused]] size_t num_points, - std::shared_ptr> crs_factory) + VerifierCommitmentKey( + [[maybe_unused]] size_t num_points, // TODO(https://github.com/AztecProtocol/barretenberg/issues/874) + std::shared_ptr> crs_factory) : srs(crs_factory->get_verifier_crs()) {} diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index b3d540b4ddc..07bcd68137a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -77,8 +77,8 @@ std::shared_ptr AcirComposer::init_verification_key void AcirComposer::load_verification_key(bb::plonk::verification_key_data&& data) { - verification_key_ = - std::make_shared(std::move(data), srs::get_crs_factory()->get_verifier_crs()); + verification_key_ = std::make_shared(std::move(data), + srs::get_bn254_crs_factory()->get_verifier_crs()); } bool AcirComposer::verify_proof(std::vector const& proof) diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp index 98f880a3823..03630f5b239 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp @@ -70,7 +70,7 @@ template class ECCVMComposer_ { void compute_commitment_key(size_t circuit_size) { - commitment_key = std::make_shared(circuit_size, crs_factory_); + commitment_key = std::make_shared(circuit_size); }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 5e859cbadbc..2a8d455ecd4 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -310,10 +310,10 @@ template class ECCVMBa * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve * inherit from ProvingKey. */ - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; auto get_to_be_shifted() { return ECCVMBase::get_to_be_shifted(*this); } diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index 20008d3f67c..640a9f68869 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -97,15 +97,17 @@ class PrecomputedEntitiesBase { * @tparam FF The scalar field on which we will encode our polynomial data. When instantiating, this may be extractable * from the other template paramter. */ -template +template class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { public: using Polynomial = typename PrecomputedPolynomials::DataType; using FF = typename Polynomial::FF; + size_t circuit_size; bool contains_recursive_proof; std::vector recursive_proof_public_input_indices; bb::EvaluationDomain evaluation_domain; + std::shared_ptr commitment_key; std::vector get_labels() const { @@ -119,8 +121,9 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { ProvingKey_() = default; ProvingKey_(const size_t circuit_size, const size_t num_public_inputs) { + this->commitment_key = std::make_shared(circuit_size + 1); this->evaluation_domain = bb::EvaluationDomain(circuit_size, circuit_size); - PrecomputedPolynomials::circuit_size = circuit_size; + this->circuit_size = circuit_size; this->log_circuit_size = numeric::get_msb(circuit_size); this->num_public_inputs = num_public_inputs; // Allocate memory for precomputed polynomials @@ -148,6 +151,16 @@ template class VerificationKey_ : public Preco this->log_circuit_size = numeric::get_msb(circuit_size); this->num_public_inputs = num_public_inputs; }; + template VerificationKey_(const ProvingKeyPtr& proving_key) + { + this->circuit_size = proving_key->circuit_size; + this->log_circuit_size = numeric::get_msb(this->circuit_size); + this->num_public_inputs = proving_key->num_public_inputs; + + for (auto [polynomial, commitment] : zip_view(proving_key->get_precomputed_polynomials(), this->get_all())) { + commitment = proving_key->commitment_key->commit(polynomial); + } + } }; // Because of how Gemini is written, is importat to put the polynomials out in this order. diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 89886373557..0f00e1950cf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -8,6 +8,7 @@ using namespace bb; TEST(Flavor, Getters) { + srs::init_crs_factory("../srs_db/ignition"); using Flavor = UltraFlavor; using FF = Flavor::FF; using ProvingKey = typename Flavor::ProvingKey; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/avm_flavor.hpp index 63139cc5991..efb23d6efc5 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/avm_flavor.hpp @@ -504,10 +504,10 @@ class AvmFlavor { }; public: - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; auto get_to_be_shifted() diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/toy_flavor.hpp index cc8896f3392..ac7df4a07e2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/toy_flavor.hpp @@ -200,10 +200,10 @@ class ToyFlavor { }; public: - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; auto get_to_be_shifted() { return RefArray{}; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index cb0163a3b86..5a1d9fb6d41 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -895,14 +895,14 @@ class GoblinTranslatorFlavor { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve * inherit from ProvingKey. */ - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: BF batching_challenge_v = { 0 }; BF evaluation_input_x = { 0 }; ProvingKey() = default; // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; // TODO(https://github.com/AztecProtocol/barretenberg/issues/810): get around this by properly having @@ -919,7 +919,7 @@ class GoblinTranslatorFlavor { } ProvingKey(const size_t circuit_size) - : ProvingKey_, WitnessEntities>(circuit_size, 0) + : ProvingKey_, WitnessEntities, CommitmentKey>(circuit_size, 0) , batching_challenge_v(0) , evaluation_input_x(0) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index c93603f2b78..e1fbb2e7b4d 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -258,10 +258,10 @@ class GoblinUltraFlavor { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve inherit * from ProvingKey. */ - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; std::vector memory_read_records; @@ -285,6 +285,7 @@ class GoblinUltraFlavor { * @note Note the discrepancy with what sort of data is stored here vs in the proving key. We may want to resolve * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our * circuits. + * @todo TODO(https://github.com/AztecProtocol/barretenberg/issues/876) */ using VerificationKey = VerificationKey_>; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index b4f5b055a92..46fe5f4499f 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -264,10 +264,10 @@ class UltraFlavor { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve inherit * from ProvingKey. */ - class ProvingKey : public ProvingKey_, WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities, CommitmentKey> { public: // Expose constructors on the base class - using Base = ProvingKey_, WitnessEntities>; + using Base = ProvingKey_, WitnessEntities, CommitmentKey>; using Base::Base; std::vector memory_read_records; diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index bc14c506539..04ac0636b20 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -134,8 +134,7 @@ class GoblinMockCircuits { op_queue->set_size_data(); // Manually compute the op queue transcript commitments (which would normally be done by the merge prover) - auto crs_factory_ = bb::srs::get_crs_factory(); - auto commitment_key = CommitmentKey(op_queue->get_current_size(), crs_factory_); + auto commitment_key = CommitmentKey(op_queue->get_current_size()); std::array op_queue_commitments; size_t idx = 0; for (auto& entry : op_queue->get_aggregate_transcript()) { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp index da086414e95..687d4c2c7a7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp @@ -47,7 +47,7 @@ void init_verification_key() } verification_key = - bb::plonk::compute_verification_key_common(proving_key, srs::get_crs_factory()->get_verifier_crs()); + bb::plonk::compute_verification_key_common(proving_key, srs::get_bn254_crs_factory()->get_verifier_crs()); } Prover new_join_split_prover(join_split_tx const& tx, bool mock) diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.cpp index 3620fb540c3..4647323de23 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.cpp @@ -35,7 +35,7 @@ std::shared_ptr StandardComposer::compute_proving_key(Circui circuit_constructor.num_gates + circuit_constructor.public_inputs.size() + NUM_RESERVED_GATES; const size_t subgroup_size = circuit_constructor.get_circuit_subgroup_size(total_num_gates); // next power of 2 - auto crs = srs::get_crs_factory()->get_prover_crs(subgroup_size + 1); + auto crs = srs::get_bn254_crs_factory()->get_prover_crs(subgroup_size + 1); // TODO(https://github.com/AztecProtocol/barretenberg/issues/392): Composer type circuit_proving_key = std::make_shared( subgroup_size, circuit_constructor.public_inputs.size(), crs, CircuitType::STANDARD); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp index 63016750973..bf464f79873 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp @@ -30,7 +30,7 @@ class StandardComposer { bool computed_witness = false; - StandardComposer() { crs_factory_ = bb::srs::get_crs_factory(); } + StandardComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } StandardComposer(std::shared_ptr> crs_factory) : crs_factory_(std::move(crs_factory)) {} diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp index 80b0e886c5b..10de6cb1b3b 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp @@ -160,7 +160,7 @@ std::shared_ptr UltraComposer::compute_proving_key(CircuitBuilder& const size_t subgroup_size = compute_dyadic_circuit_size(circuit); - auto crs = srs::get_crs_factory()->get_prover_crs(subgroup_size + 1); + auto crs = srs::get_bn254_crs_factory()->get_prover_crs(subgroup_size + 1); // TODO(https://github.com/AztecProtocol/barretenberg/issues/392): Composer type circuit_proving_key = std::make_shared(subgroup_size, circuit.public_inputs.size(), crs, CircuitType::ULTRA); @@ -209,7 +209,7 @@ std::shared_ptr UltraComposer::compute_verification_key compute_proving_key(circuit_constructor); } circuit_verification_key = - compute_verification_key_common(circuit_proving_key, srs::get_crs_factory()->get_verifier_crs()); + compute_verification_key_common(circuit_proving_key, srs::get_bn254_crs_factory()->get_verifier_crs()); circuit_verification_key->circuit_type = CircuitType::ULTRA; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp index 40767e8e9f0..388029bde02 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp @@ -120,7 +120,7 @@ struct verification_key { void msgpack_unpack(auto obj) { verification_key_data data = obj; - *this = verification_key{ std::move(data), bb::srs::get_crs_factory()->get_verifier_crs() }; + *this = verification_key{ std::move(data), bb::srs::get_bn254_crs_factory()->get_verifier_crs() }; } // Alias verification_key as verification_key_data in the schema void msgpack_schema(auto& packer) const { packer.pack_schema(bb::plonk::verification_key_data{}); } @@ -131,7 +131,7 @@ template inline void read(B& buf, verification_key& key) using serialize::read; verification_key_data vk_data; read(buf, vk_data); - key = verification_key{ std::move(vk_data), bb::srs::get_crs_factory()->get_verifier_crs() }; + key = verification_key{ std::move(vk_data), bb::srs::get_bn254_crs_factory()->get_verifier_crs() }; } template inline void read(B& buf, std::shared_ptr& key) @@ -139,7 +139,7 @@ template inline void read(B& buf, std::shared_ptr using serialize::read; verification_key_data vk_data; read(buf, vk_data); - key = std::make_shared(std::move(vk_data), bb::srs::get_crs_factory()->get_verifier_crs()); + key = std::make_shared(std::move(vk_data), bb::srs::get_bn254_crs_factory()->get_verifier_crs()); } template inline void write(B& buf, verification_key const& key) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/proof_system/CMakeLists.txt index 63d4af708eb..fbfab98569f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/proof_system/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(proof_system relations crypto_pedersen_commitment crypto_pedersen_hash) \ No newline at end of file +barretenberg_module(proof_system relations crypto_pedersen_hash srs) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index a563ca3d534..5754a7ed824 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/ultra.hpp" #include "barretenberg/proof_system/composer/composer_lib.hpp" #include "barretenberg/proof_system/types/circuit_type.hpp" -#include "barretenberg/srs/factories/crs_factory.hpp" +#include "barretenberg/srs/global_crs.hpp" #include #include @@ -14,11 +14,11 @@ class PermutationHelperTests : public ::testing::Test { using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; - srs::factories::CrsFactory crs_factory = srs::factories::CrsFactory(); std::shared_ptr proving_key; virtual void SetUp() { + srs::init_crs_factory("../srs_db/ignition"); circuit_constructor.add_public_variable(1024); circuit_constructor.add_public_variable(1025); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index 502b9ca7cb4..d2699259044 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -13,6 +13,7 @@ template class GrandProductTests : public testing::Test { using Polynomial = bb::Polynomial; public: + void SetUp() { srs::init_crs_factory("../srs_db/ignition"); } /** * @brief Get a random polynomial * diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 1c6601613fb..18a2c949b69 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -14,7 +14,7 @@ DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& tr {} template DeciderVerifier_::DeciderVerifier_() - : pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) + : pcs_verification_key(std::make_unique(0, bb::srs::get_bn254_crs_factory())) , transcript(std::make_shared()) {} diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index 4fd7689471e..d5a142e7433 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -66,10 +66,10 @@ template class ProtoGalaxyProver_ { ProtogalaxyProofConstructionState state; ProtoGalaxyProver_() = default; - ProtoGalaxyProver_(const std::vector>& insts, - const std::shared_ptr& commitment_key) + ProtoGalaxyProver_(const std::vector>& insts) : instances(ProverInstances(insts)) - , commitment_key(std::move(commitment_key)){}; + // TODO(https://github.com/AztecProtocol/barretenberg/issues/878) + , commitment_key(instances[1]->proving_key->commitment_key){}; ~ProtoGalaxyProver_() = default; /** diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp index 6372a06489d..1a704613d96 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp @@ -150,7 +150,7 @@ template class RecursiveCircuit { } static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_bn254_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp index 0d09ee6c2e9..08e18c8a3f4 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp @@ -41,7 +41,7 @@ void init_grumpkin_crs_factory(std::string crs_path) grumpkin_crs_factory = std::make_shared>(crs_path); } -std::shared_ptr> get_crs_factory() +std::shared_ptr> get_bn254_crs_factory() { if (!crs_factory) { throw_or_abort("You need to initalize the global CRS with a call to init_crs_factory(...)!"); @@ -56,4 +56,15 @@ std::shared_ptr> get_grumpkin_crs_factory } return grumpkin_crs_factory; } + +template <> std::shared_ptr> get_crs_factory() +{ + return get_bn254_crs_factory(); +} + +template <> std::shared_ptr> get_crs_factory() +{ + return get_grumpkin_crs_factory(); +} + } // namespace bb::srs \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp index a2aa632b16d..d1bf55bee1b 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp @@ -12,7 +12,9 @@ void init_grumpkin_crs_factory(std::string crs_path); void init_grumpkin_crs_factory(std::vector const& points); void init_crs_factory(std::vector const& points, bb::g2::affine_element const g2_point); -std::shared_ptr> get_crs_factory(); -std::shared_ptr> get_grumpkin_crs_factory(); +std::shared_ptr> get_bn254_crs_factory(); +std::shared_ptr> get_grumpkin_crs_factory(); + +template std::shared_ptr> get_crs_factory(); } // namespace bb::srs \ No newline at end of file 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 8e6595a1b98..bd227b91a67 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 @@ -65,7 +65,7 @@ class RecursiveMergeVerifierTest : public testing::Test { // verifier and check that the result agrees. MergeVerifier native_verifier; bool verified_native = native_verifier.verify_proof(merge_proof); - VerifierCommitmentKey pcs_verification_key(0, srs::get_crs_factory()); + VerifierCommitmentKey pcs_verification_key(0, srs::get_bn254_crs_factory()); auto verified_recursive = pcs_verification_key.pairing_check(pairing_points[0].get_value(), pairing_points[1].get_value()); EXPECT_EQ(verified_native, verified_recursive); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp index 111f308508d..6901e9016f9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp @@ -333,7 +333,7 @@ template class stdlib_verifier : public testing::Test { static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = srs::get_bn254_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); @@ -348,7 +348,7 @@ template class stdlib_verifier : public testing::Test { info("number of gates in recursive verification circuit = ", outer_circuit.get_num_gates()); bool result = outer_circuit.check_circuit(); EXPECT_EQ(result, expected_result); - auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = srs::get_bn254_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); EXPECT_EQ(check_recursive_proof_public_inputs(outer_circuit, g2_lines), true); } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index 5313f7b8304..c6d9d94d1e4 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -64,6 +64,10 @@ template class ProverInstance_ { ProverInstance_(Circuit& circuit) { + BB_OP_COUNT_TIME_NAME("ProverInstance(Circuit&)"); + circuit.add_gates_to_ensure_all_polys_are_non_zero(); + circuit.finalize_circuit(); + dyadic_circuit_size = compute_dyadic_size(circuit); proving_key = std::make_shared(dyadic_circuit_size, circuit.public_inputs.size()); @@ -87,6 +91,8 @@ template class ProverInstance_ { sorted_polynomials = construct_sorted_list_polynomials(circuit, dyadic_circuit_size); populate_memory_read_write_records(circuit, proving_key); + + verification_key = std::make_shared(proving_key); } ProverInstance_() = default; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 1c9e58e5811..2f9d5fa18a4 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -45,6 +45,8 @@ template class InstanceTests : public testing::Test { */ static void test_sorted_list_accumulator_construction() { + srs::init_crs_factory("../srs_db/ignition"); + // Construct a simple circuit of size n = 8 (i.e. the minimum circuit size) Builder builder; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index d8cb79f6bcc..5fa9ba4b246 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -65,7 +65,6 @@ template class SumcheckProver { , round(multivariate_n) , partially_evaluated_polynomials(multivariate_n){}; - // WORKTODO delete this /** * @brief Compute univariate restriction place in transcript, generate challenge, partially evaluate,... repeat * until final round, then compute multivariate evaluations and place in transcript. diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index 4bd084c20af..88b1dc94189 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -40,7 +40,7 @@ class GoblinTranslatorComposer { size_t mini_circuit_dyadic_size = 0; // The size of the small circuit that contains non-range constraint relations // We only need the standard crs factory. GoblinTranslatorFlavor is not supposed to be used with Grumpkin - GoblinTranslatorComposer() { crs_factory_ = bb::srs::get_crs_factory(); } + GoblinTranslatorComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } GoblinTranslatorComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) @@ -67,7 +67,7 @@ class GoblinTranslatorComposer { return commitment_key; } - commitment_key = std::make_shared(circuit_size, crs_factory_); + commitment_key = std::make_shared(circuit_size); return commitment_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 7252076bab7..ddc3cd4bd72 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 @@ -206,8 +206,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) // Compute the commitments to the aggregate op queue directly and check that they match those that were computed // iteratively during transcript aggregation by the provers and stored in the op queue. size_t aggregate_op_queue_size = op_queue->current_ultra_ops_size; - auto crs_factory = std::make_shared>("../srs_db/ignition"); - auto commitment_key = std::make_shared(aggregate_op_queue_size, crs_factory); + auto commitment_key = std::make_shared(aggregate_op_queue_size); size_t idx = 0; for (auto& result : op_queue->ultra_ops_commitments) { auto expected = commitment_key->commit(op_queue->ultra_ops[idx++]); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index e0ade5f34be..1c39e0aecc8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -5,7 +5,7 @@ namespace bb { template MergeVerifier_::MergeVerifier_() : transcript(std::make_shared()) - , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())){}; + , pcs_verification_key(std::make_unique(0, bb::srs::get_bn254_crs_factory())){}; /** * @brief Verify proper construction of the aggregate Goblin ECC op queue polynomials T_i^(j), j = 1,2,3,4. diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index efaa39b9ebc..334f60bf8c6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -6,83 +6,17 @@ namespace bb { -/** - * Compute verification key consisting of selector precommitments. - * - * @return Pointer to the resulting verification key of the Instance. - * */ -template -void UltraComposer_::compute_verification_key(const std::shared_ptr>& instance) -{ - if (instance->verification_key) { - return; - } - - auto& proving_key = instance->proving_key; - - auto verification_key = - std::make_shared(proving_key->circuit_size, proving_key->num_public_inputs); - - // Compute and store commitments to all precomputed polynomials - verification_key->q_m = commitment_key->commit(proving_key->q_m); - verification_key->q_l = commitment_key->commit(proving_key->q_l); - verification_key->q_r = commitment_key->commit(proving_key->q_r); - verification_key->q_o = commitment_key->commit(proving_key->q_o); - verification_key->q_c = commitment_key->commit(proving_key->q_c); - verification_key->sigma_1 = commitment_key->commit(proving_key->sigma_1); - verification_key->sigma_2 = commitment_key->commit(proving_key->sigma_2); - verification_key->sigma_3 = commitment_key->commit(proving_key->sigma_3); - verification_key->id_1 = commitment_key->commit(proving_key->id_1); - verification_key->id_2 = commitment_key->commit(proving_key->id_2); - verification_key->id_3 = commitment_key->commit(proving_key->id_3); - verification_key->lagrange_first = commitment_key->commit(proving_key->lagrange_first); - verification_key->lagrange_last = commitment_key->commit(proving_key->lagrange_last); - - verification_key->q_4 = commitment_key->commit(proving_key->q_4); - verification_key->q_arith = commitment_key->commit(proving_key->q_arith); - verification_key->q_sort = commitment_key->commit(proving_key->q_sort); - verification_key->q_elliptic = commitment_key->commit(proving_key->q_elliptic); - verification_key->q_aux = commitment_key->commit(proving_key->q_aux); - verification_key->q_lookup = commitment_key->commit(proving_key->q_lookup); - verification_key->sigma_4 = commitment_key->commit(proving_key->sigma_4); - verification_key->id_4 = commitment_key->commit(proving_key->id_4); - verification_key->table_1 = commitment_key->commit(proving_key->table_1); - verification_key->table_2 = commitment_key->commit(proving_key->table_2); - verification_key->table_3 = commitment_key->commit(proving_key->table_3); - verification_key->table_4 = commitment_key->commit(proving_key->table_4); - - // TODO(luke): Similar to the lagrange_first/last polynomials, we dont really need to commit to these polynomials - // due to their simple structure. - if constexpr (IsGoblinFlavor) { - verification_key->lagrange_ecc_op = commitment_key->commit(proving_key->lagrange_ecc_op); - verification_key->q_busread = commitment_key->commit(proving_key->q_busread); - verification_key->databus_id = commitment_key->commit(proving_key->databus_id); - verification_key->q_poseidon2_external = commitment_key->commit(proving_key->q_poseidon2_external); - verification_key->q_poseidon2_internal = commitment_key->commit(proving_key->q_poseidon2_internal); - } - - instance->verification_key = std::move(verification_key); -} - template std::shared_ptr> UltraComposer_::create_instance(CircuitBuilder& circuit) { - BB_OP_COUNT_TIME_NAME("UltraComposer::create_prover_instance"); - - circuit.add_gates_to_ensure_all_polys_are_non_zero(); - circuit.finalize_circuit(); - auto instance = std::make_shared(circuit); - commitment_key = compute_commitment_key(instance->proving_key->circuit_size); - - compute_verification_key(instance); - return instance; + return std::make_shared(circuit); } template UltraProver_ UltraComposer_::create_prover(const std::shared_ptr& instance, const std::shared_ptr& transcript) { - UltraProver_ output_state(instance, commitment_key, transcript); + UltraProver_ output_state(instance, transcript); return output_state; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 28a95f03145..dfa23c93349 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -40,7 +40,7 @@ template class UltraComposer_ { // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; - UltraComposer_() { crs_factory_ = bb::srs::get_crs_factory(); } + UltraComposer_() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } explicit UltraComposer_(std::shared_ptr crs_factory) : crs_factory_(std::move(crs_factory)) @@ -84,7 +84,7 @@ template class UltraComposer_ { ProtoGalaxyProver_ create_folding_prover(const std::vector>& instances) { - ProtoGalaxyProver_ output_state(instances, commitment_key); + ProtoGalaxyProver_ output_state(instances); return output_state; }; @@ -96,13 +96,6 @@ template class UltraComposer_ { return output_state; }; - - /** - * @brief Compute the verification key of an Instance, produced from a finalised circuit. - * - * @param inst - */ - void compute_verification_key(const std::shared_ptr&); }; // TODO(#532): this pattern is weird; is this not instantiating the templates? 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 205a67aad24..7acc891f7f9 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -137,7 +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); - auto composer = UltraComposer(bb::srs::get_crs_factory()); + auto composer = UltraComposer(bb::srs::get_bn254_crs_factory()); prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index e4630c377ea..c4f62204066 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -11,12 +11,10 @@ namespace bb { * @tparam a type of UltraFlavor * */ template -UltraProver_::UltraProver_(const std::shared_ptr& inst, - const std::shared_ptr& commitment_key, - const std::shared_ptr& transcript) +UltraProver_::UltraProver_(const std::shared_ptr& inst, const std::shared_ptr& transcript) : instance(std::move(inst)) , transcript(transcript) - , commitment_key(commitment_key) + , 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 e212a38abfa..356f163983b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -24,7 +24,6 @@ template class UltraProver_ { public: explicit UltraProver_(const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); BB_PROFILE void execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 084e711ee71..e9e0a900f97 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -20,7 +20,7 @@ UltraVerifier_::UltraVerifier_(const std::shared_ptr& transc template UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) : key(verifier_key) - , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) + , pcs_verification_key(std::make_unique(0, bb::srs::get_bn254_crs_factory())) , transcript(std::make_shared()) {} diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index 1db659f2797..d00f490fa45 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -37,7 +37,7 @@ class AvmComposer { bool contains_recursive_proof = false; bool computed_witness = false; - AvmComposer() { crs_factory_ = bb::srs::get_crs_factory(); } + AvmComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } AvmComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) @@ -62,7 +62,7 @@ class AvmComposer { void compute_commitment_key(size_t circuit_size) { - commitment_key = std::make_shared(circuit_size, crs_factory_); + commitment_key = std::make_shared(circuit_size); }; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/toy_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/toy_composer.hpp index b65f0b5e5f7..b7c34b2e495 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/toy_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/toy_composer.hpp @@ -37,7 +37,7 @@ class ToyComposer { bool contains_recursive_proof = false; bool computed_witness = false; - ToyComposer() { crs_factory_ = bb::srs::get_crs_factory(); } + ToyComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } ToyComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) @@ -62,7 +62,7 @@ class ToyComposer { void compute_commitment_key(size_t circuit_size) { - commitment_key = std::make_shared(circuit_size, crs_factory_); + commitment_key = std::make_shared(circuit_size); }; };