diff --git a/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index da82622c7a..a10eb40468 100644 --- a/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -1,6 +1,6 @@ #include "acir_format.hpp" -using namespace plonk::stdlib::types; +using namespace proof_system::plonk::stdlib::types; namespace acir_format { diff --git a/cpp/src/barretenberg/dsl/acir_format/logic_constraint.cpp b/cpp/src/barretenberg/dsl/acir_format/logic_constraint.cpp index b25530fa80..ca14b7cbc4 100644 --- a/cpp/src/barretenberg/dsl/acir_format/logic_constraint.cpp +++ b/cpp/src/barretenberg/dsl/acir_format/logic_constraint.cpp @@ -1,7 +1,7 @@ #include "logic_constraint.hpp" #include "barretenberg/stdlib/primitives/logic/logic.hpp" -using namespace plonk::stdlib::types; +using namespace proof_system::plonk::stdlib::types; namespace acir_format { diff --git a/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp b/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp index aa3cb22f75..21585f6df4 100644 --- a/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp +++ b/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp @@ -1,10 +1,10 @@ #include "acir_proofs.hpp" -#include "barretenberg/proof_system/proving_key/serialize.hpp" +#include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/stdlib/types/types.hpp" #include "barretenberg/srs/reference_string/pippenger_reference_string.hpp" -#include "barretenberg/proof_system/verification_key/sol_gen.hpp" +#include "barretenberg/plonk/proof_system/verification_key/sol_gen.hpp" using namespace proof_system::plonk::stdlib::types; @@ -13,9 +13,9 @@ namespace acir_proofs { size_t get_solidity_verifier(uint8_t const* g2x, uint8_t const* vk_buf, uint8_t** output_buf) { auto crs = std::make_shared(g2x); - bonk::verification_key_data vk_data; + proof_system::plonk::verification_key_data vk_data; read(vk_buf, vk_data); - auto verification_key = std::make_shared(std::move(vk_data), crs); + auto verification_key = std::make_shared(std::move(vk_data), crs); std::ostringstream stream; // TODO(blaine): Should we just use "VerificationKey" generically? @@ -42,7 +42,7 @@ uint32_t get_exact_circuit_size(uint8_t const* constraint_system_buf) uint32_t get_total_circuit_size(uint8_t const* constraint_system_buf) { auto constraint_system = from_buffer(constraint_system_buf); - auto crs_factory = std::make_unique(); + auto crs_factory = std::make_unique(); auto composer = create_circuit(constraint_system, std::move(crs_factory)); return static_cast(composer.get_total_circuit_size()); @@ -138,7 +138,7 @@ bool verify_proof( auto crs = std::make_shared(g2x); plonk::verification_key_data vk_data; read(vk_buf, vk_data); - auto verification_key = std::make_shared(std::move(vk_data), crs); + auto verification_key = std::make_shared(std::move(vk_data), crs); Composer composer(nullptr, verification_key); create_circuit(composer, constraint_system); diff --git a/cpp/src/barretenberg/honk/CMakeLists.txt b/cpp/src/barretenberg/honk/CMakeLists.txt index ac0dc30fd0..df60576b16 100644 --- a/cpp/src/barretenberg/honk/CMakeLists.txt +++ b/cpp/src/barretenberg/honk/CMakeLists.txt @@ -1,4 +1,4 @@ -barretenberg_module(honk numeric ecc srs proof_system transcript) +barretenberg_module(honk numeric ecc srs proof_system transcript plonk) if(TESTING) # TODO: Re-enable all these warnings once PoC is finished diff --git a/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.cpp b/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.cpp index d824abc1bf..2bbf1c596d 100644 --- a/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.cpp +++ b/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.cpp @@ -28,11 +28,8 @@ std::shared_ptr StandardHonkComposerHelper StandardHonkComposerHelper std::shared_ptr StandardHonkComposerHelper::compute_verification_key_base( - std::shared_ptr const& proving_key, - std::shared_ptr const& vrs) + std::shared_ptr const& proving_key, std::shared_ptr const& vrs) { auto key = std::make_shared( proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->composer_type); @@ -109,8 +105,7 @@ std::shared_ptr StandardHonkComposerHelper(circuit_constructor, diff --git a/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.hpp b/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.hpp index 266a07769b..613daaf6a1 100644 --- a/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.hpp +++ b/cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.hpp @@ -27,17 +27,17 @@ template class StandardHonkComposerHelper { std::shared_ptr circuit_verification_key; // TODO(#218)(kesha): we need to put this into the commitment key, so that the composer doesn't have to handle srs // at all - std::shared_ptr crs_factory_; + std::shared_ptr crs_factory_; bool computed_witness = false; StandardHonkComposerHelper() - : StandardHonkComposerHelper(std::shared_ptr( + : StandardHonkComposerHelper(std::shared_ptr( new proof_system::FileReferenceStringFactory("../srs_db/ignition"))) {} - StandardHonkComposerHelper(std::shared_ptr crs_factory) + StandardHonkComposerHelper(std::shared_ptr crs_factory) : crs_factory_(std::move(crs_factory)) {} - StandardHonkComposerHelper(std::unique_ptr&& crs_factory) + StandardHonkComposerHelper(std::unique_ptr&& crs_factory) : crs_factory_(std::move(crs_factory)) {} StandardHonkComposerHelper(std::shared_ptr p_key, @@ -67,8 +67,7 @@ template class StandardHonkComposerHelper { // This needs to be static as it may be used only to compute the selector commitments. static std::shared_ptr compute_verification_key_base( - std::shared_ptr const& proving_key, - std::shared_ptr const& vrs); + std::shared_ptr const& proving_key, std::shared_ptr const& vrs); void compute_witness(const CircuitConstructor& circuit_constructor, const size_t minimum_circuit_size = 0); }; diff --git a/cpp/src/barretenberg/honk/composer/standard_honk_composer.hpp b/cpp/src/barretenberg/honk/composer/standard_honk_composer.hpp index 3674576a6c..ab2c344514 100644 --- a/cpp/src/barretenberg/honk/composer/standard_honk_composer.hpp +++ b/cpp/src/barretenberg/honk/composer/standard_honk_composer.hpp @@ -15,7 +15,7 @@ namespace proof_system::honk { */ class StandardHonkComposer { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::STANDARD_HONK; + static constexpr ComposerType type = ComposerType::STANDARD_HONK; static constexpr size_t UINT_LOG2_BASE = 2; // An instantiation of the circuit constructor that only depends on arithmetization, not on the proof system @@ -38,20 +38,18 @@ class StandardHonkComposer { , variables(circuit_constructor.variables){}; StandardHonkComposer(std::string const& crs_path, const size_t size_hint = 0) - : StandardHonkComposer(std::unique_ptr( - new proof_system::FileReferenceStringFactory(crs_path)), - size_hint){}; + : StandardHonkComposer( + std::unique_ptr(new proof_system::FileReferenceStringFactory(crs_path)), + size_hint){}; - StandardHonkComposer(std::shared_ptr const& crs_factory, - const size_t size_hint = 0) + StandardHonkComposer(std::shared_ptr const& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(crs_factory) , num_gates(circuit_constructor.num_gates) , variables(circuit_constructor.variables) {} - StandardHonkComposer(std::unique_ptr&& crs_factory, - const size_t size_hint = 0) + StandardHonkComposer(std::unique_ptr&& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(std::move(crs_factory)) , num_gates(circuit_constructor.num_gates) diff --git a/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp b/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp index 314b26d02c..0902129370 100644 --- a/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp +++ b/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp @@ -47,12 +47,11 @@ template class ProverLibraryTests : public testing::Test { // Define some mock inputs for proving key constructor static const size_t num_gates = 8; static const size_t num_public_inputs = 0; - auto reference_string = - std::make_shared(num_gates + 1, "../srs_db/ignition"); + auto reference_string = std::make_shared(num_gates + 1, "../srs_db/ignition"); // Instatiate a proving_key and make a pointer to it. This will be used to instantiate a Prover. auto proving_key = std::make_shared( - num_gates, num_public_inputs, reference_string, proof_system::ComposerType::STANDARD_HONK); + num_gates, num_public_inputs, reference_string, ComposerType::STANDARD_HONK); // static const size_t program_width = StandardProver::settings_::program_width; @@ -157,12 +156,11 @@ template class ProverLibraryTests : public testing::Test { // Define some mock inputs for proving key constructor static const size_t circuit_size = 8; static const size_t num_public_inputs = 0; - auto reference_string = - std::make_shared(circuit_size + 1, "../srs_db/ignition"); + auto reference_string = std::make_shared(circuit_size + 1, "../srs_db/ignition"); // Instatiate a proving_key and make a pointer to it. This will be used to instantiate a Prover. auto proving_key = std::make_shared( - circuit_size, num_public_inputs, reference_string, proof_system::ComposerType::STANDARD_HONK); + circuit_size, num_public_inputs, reference_string, ComposerType::STANDARD_HONK); // Construct mock wire and permutation polynomials. // Note: for the purpose of checking the consistency between two methods of computing z_perm, these polynomials @@ -287,10 +285,9 @@ template class ProverLibraryTests : public testing::Test { // Construct a proving_key static const size_t circuit_size = 8; static const size_t num_public_inputs = 0; - auto reference_string = - std::make_shared(circuit_size + 1, "../srs_db/ignition"); + auto reference_string = std::make_shared(circuit_size + 1, "../srs_db/ignition"); auto proving_key = std::make_shared( - circuit_size, num_public_inputs, reference_string, proof_system::ComposerType::STANDARD_HONK); + circuit_size, num_public_inputs, reference_string, ComposerType::STANDARD_HONK); // Get random challenge eta auto eta = FF::random_element(); diff --git a/cpp/src/barretenberg/honk/proof_system/verifier.cpp b/cpp/src/barretenberg/honk/proof_system/verifier.cpp index a40054f2c5..26e4b7e033 100644 --- a/cpp/src/barretenberg/honk/proof_system/verifier.cpp +++ b/cpp/src/barretenberg/honk/proof_system/verifier.cpp @@ -83,9 +83,9 @@ template bool Verifier::verify_pro using Gemini = pcs::gemini::MultilinearReductionScheme; using Shplonk = pcs::shplonk::SingleBatchOpeningScheme; using KZG = pcs::kzg::UnivariateOpeningScheme; - const size_t NUM_POLYNOMIALS = proof_system::honk::StandardArithmetization::NUM_POLYNOMIALS; - const size_t NUM_UNSHIFTED = proof_system::honk::StandardArithmetization::NUM_UNSHIFTED_POLYNOMIALS; - const size_t NUM_PRECOMPUTED = proof_system::honk::StandardArithmetization::NUM_PRECOMPUTED_POLYNOMIALS; + const size_t NUM_POLYNOMIALS = honk::StandardArithmetization::NUM_POLYNOMIALS; + const size_t NUM_UNSHIFTED = honk::StandardArithmetization::NUM_UNSHIFTED_POLYNOMIALS; + const size_t NUM_PRECOMPUTED = honk::StandardArithmetization::NUM_PRECOMPUTED_POLYNOMIALS; constexpr auto num_wires = program_settings::num_wires; diff --git a/cpp/src/barretenberg/honk/proof_system/verifier.test.cpp b/cpp/src/barretenberg/honk/proof_system/verifier.test.cpp index 482281ca89..42f559aabf 100644 --- a/cpp/src/barretenberg/honk/proof_system/verifier.test.cpp +++ b/cpp/src/barretenberg/honk/proof_system/verifier.test.cpp @@ -50,7 +50,7 @@ template class VerifierTests : public testing::Test { prover)); } - auto crs = std::make_shared("../srs_db/ignition"); + auto crs = std::make_shared("../srs_db/ignition"); auto circuit_verification_key = std::make_shared(circuit_proving_key->circuit_size, circuit_proving_key->num_public_inputs, @@ -82,9 +82,9 @@ template class VerifierTests : public testing::Test { // Create some constraints that satisfy our arithmetic circuit relation // even indices = mul gates, odd incides = add gates - auto crs = std::make_shared(n + 1, "../srs_db/ignition"); + auto crs = std::make_shared(n + 1, "../srs_db/ignition"); std::shared_ptr proving_key = - std::make_shared(n, 0, crs, proof_system::ComposerType::STANDARD_HONK); + std::make_shared(n, 0, crs, ComposerType::STANDARD_HONK); polynomial w_l(n); polynomial w_r(n); @@ -178,8 +178,8 @@ template class VerifierTests : public testing::Test { proving_key->polynomial_store.put("sigma_2_lagrange", std::move(sigma_2_lagrange_base)); proving_key->polynomial_store.put("sigma_3_lagrange", std::move(sigma_3_lagrange_base)); - proof_system::compute_standard_honk_id_polynomials<3>(proving_key); - proof_system::compute_first_and_last_lagrange_polynomials(proving_key); + compute_standard_honk_id_polynomials<3>(proving_key); + compute_first_and_last_lagrange_polynomials(proving_key); proving_key->polynomial_store.put("w_1_lagrange", std::move(w_l)); proving_key->polynomial_store.put("w_2_lagrange", std::move(w_r)); diff --git a/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp b/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp index d9d792daf8..d30650154a 100644 --- a/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp +++ b/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp @@ -59,7 +59,7 @@ TYPED_TEST(MultivariatesTests, FoldTwoRoundsSpecial) std::array f0 = { v00, v10, v01, v11 }; auto full_polynomials = std::array, 1>({ f0 }); - auto transcript = proof_system::honk::ProverTranscript::init_empty(); + auto transcript = honk::ProverTranscript::init_empty(); auto sumcheck = Sumcheck(multivariate_n, transcript); FF round_challenge_0 = { 0x6c7301b49d85a46c, 0x44311531e39c64f6, 0xb13d66d8d6c1a24c, 0x04410c360230a295 }; @@ -94,7 +94,7 @@ TYPED_TEST(MultivariatesTests, FoldTwoRoundsGeneric) std::array f0 = { v00, v10, v01, v11 }; auto full_polynomials = std::array, 1>({ f0 }); - auto transcript = proof_system::honk::ProverTranscript::init_empty(); + auto transcript = honk::ProverTranscript::init_empty(); auto sumcheck = Sumcheck(multivariate_n, transcript); FF round_challenge_0 = FF::random_element(); @@ -153,7 +153,7 @@ TYPED_TEST(MultivariatesTests, FoldThreeRoundsSpecial) std::array f0 = { v000, v100, v010, v110, v001, v101, v011, v111 }; auto full_polynomials = std::array, 1>({ f0 }); - auto transcript = proof_system::honk::ProverTranscript::init_empty(); + auto transcript = honk::ProverTranscript::init_empty(); auto sumcheck = Sumcheck(multivariate_n, transcript); FF round_challenge_0 = 1; @@ -202,7 +202,7 @@ TYPED_TEST(MultivariatesTests, FoldThreeRoundsGeneric) std::array f0 = { v000, v100, v010, v110, v001, v101, v011, v111 }; auto full_polynomials = std::array, 1>({ f0 }); - auto transcript = proof_system::honk::ProverTranscript::init_empty(); + auto transcript = honk::ProverTranscript::init_empty(); auto sumcheck = Sumcheck(multivariate_n, transcript); FF round_challenge_0 = FF::random_element(); @@ -261,7 +261,7 @@ TYPED_TEST(MultivariatesTests, FoldThreeRoundsGenericMultiplePolys) std::array f2 = { v000[2], v100[2], v010[2], v110[2], v001[2], v101[2], v011[2], v111[2] }; auto full_polynomials = std::array, 3>{ f0, f1, f2 }; - auto transcript = proof_system::honk::ProverTranscript::init_empty(); + auto transcript = honk::ProverTranscript::init_empty(); auto sumcheck = Sumcheck(multivariate_n, transcript); std::array expected_q1; diff --git a/cpp/src/barretenberg/honk/sumcheck/relations/relation.test.cpp b/cpp/src/barretenberg/honk/sumcheck/relations/relation.test.cpp index 89ea8d5444..6b7e1ac521 100644 --- a/cpp/src/barretenberg/honk/sumcheck/relations/relation.test.cpp +++ b/cpp/src/barretenberg/honk/sumcheck/relations/relation.test.cpp @@ -173,7 +173,7 @@ TYPED_TEST_SUITE(SumcheckRelation, FieldTypes); TYPED_TEST(SumcheckRelation, ArithmeticRelation) { SUMCHECK_RELATION_TYPE_ALIASES - using MULTIVARIATE = proof_system::honk::StandardArithmetization::POLYNOMIAL; + using MULTIVARIATE = honk::StandardArithmetization::POLYNOMIAL; const auto relation_parameters = TestFixture::compute_mock_relation_parameters(); auto run_test = [&relation_parameters](bool is_random_input) { std::array, NUM_POLYNOMIALS> extended_edges; @@ -216,7 +216,7 @@ TYPED_TEST(SumcheckRelation, ArithmeticRelation) TYPED_TEST(SumcheckRelation, GrandProductComputationRelation) { SUMCHECK_RELATION_TYPE_ALIASES - using MULTIVARIATE = proof_system::honk::StandardArithmetization::POLYNOMIAL; + using MULTIVARIATE = honk::StandardArithmetization::POLYNOMIAL; const auto relation_parameters = TestFixture::compute_mock_relation_parameters(); auto run_test = [&relation_parameters](bool is_random_input) { std::array, NUM_POLYNOMIALS> extended_edges; @@ -278,7 +278,7 @@ TYPED_TEST(SumcheckRelation, GrandProductComputationRelation) TYPED_TEST(SumcheckRelation, GrandProductInitializationRelation) { SUMCHECK_RELATION_TYPE_ALIASES - using MULTIVARIATE = proof_system::honk::StandardArithmetization::POLYNOMIAL; + using MULTIVARIATE = honk::StandardArithmetization::POLYNOMIAL; const auto relation_parameters = TestFixture::compute_mock_relation_parameters(); auto run_test = [&relation_parameters](bool is_random_input) { std::array, NUM_POLYNOMIALS> extended_edges; diff --git a/cpp/src/barretenberg/join_split_example/proofs/verify.hpp b/cpp/src/barretenberg/join_split_example/proofs/verify.hpp index 4c26b58980..b37b511691 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/verify.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/verify.hpp @@ -26,7 +26,7 @@ template struct verify_result { template inline bool pairing_check(plonk::stdlib::recursion::recursion_output> recursion_output, - std::shared_ptr const& srs) + std::shared_ptr const& srs) { g1::affine_element P[2]; P[0].x = barretenberg::fq(recursion_output.P0.x.get_value().lo); diff --git a/cpp/src/barretenberg/plonk/composer/composer_base.cpp b/cpp/src/barretenberg/plonk/composer/composer_base.cpp index 2874935584..46e404a57e 100644 --- a/cpp/src/barretenberg/plonk/composer/composer_base.cpp +++ b/cpp/src/barretenberg/plonk/composer/composer_base.cpp @@ -231,7 +231,7 @@ template void ComposerBase::compute_sigma * @param num_reserved_gates The number of reserved gates. * @return Pointer to the initialized proving key updated with selector polynomials. * */ -std::shared_ptr ComposerBase::compute_proving_key_base(const proof_system::ComposerType composer_type, +std::shared_ptr ComposerBase::compute_proving_key_base(const ComposerType composer_type, const size_t minimum_circuit_size, const size_t num_reserved_gates) { diff --git a/cpp/src/barretenberg/plonk/composer/composer_base.hpp b/cpp/src/barretenberg/plonk/composer/composer_base.hpp index 4d9c9dd896..6c93da04b1 100644 --- a/cpp/src/barretenberg/plonk/composer/composer_base.hpp +++ b/cpp/src/barretenberg/plonk/composer/composer_base.hpp @@ -110,7 +110,7 @@ class ComposerBase { virtual size_t get_total_circuit_size() const = 0; virtual void print_num_gates() const { std::cout << num_gates << std::endl; } virtual size_t get_num_variables() const { return variables.size(); } - virtual std::shared_ptr compute_proving_key_base(const proof_system::ComposerType type = STANDARD, + virtual std::shared_ptr compute_proving_key_base(const ComposerType type = STANDARD, const size_t minimum_ciricut_size = 0, const size_t num_reserved_gates = NUM_RESERVED_GATES); // This needs to be static as it may be used only to compute the selector commitments. diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.cpp index 7d2a7972b2..4ab16d7434 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.cpp @@ -44,8 +44,7 @@ void compute_monomial_and_coset_selector_forms(plonk::proving_key* circuit_provi * (2) sets the polynomial manifest using the data from proving key. */ std::shared_ptr compute_verification_key_common( - std::shared_ptr const& proving_key, - std::shared_ptr const& vrs) + std::shared_ptr const& proving_key, std::shared_ptr const& vrs) { auto circuit_verification_key = std::make_shared( proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->composer_type); diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp index f8f18cd92a..927174cc0f 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp @@ -24,7 +24,6 @@ void compute_monomial_and_coset_selector_forms(plonk::proving_key* key, * (2) sets the polynomial manifest using the data from proving key. */ std::shared_ptr compute_verification_key_common( - std::shared_ptr const& proving_key, - std::shared_ptr const& vrs); + std::shared_ptr const& proving_key, std::shared_ptr const& vrs); } // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.cpp index 968cf07abd..601de58dac 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.cpp @@ -7,6 +7,7 @@ #include "barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.hpp" #include "barretenberg/proof_system/composer/composer_helper_lib.hpp" #include "barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp" +#include "barretenberg/proof_system/composer/permutation_helper.hpp" #include #include @@ -64,21 +65,18 @@ std::shared_ptr StandardPlonkComposerHelper( - circuit_constructor, circuit_proving_key.get()); + compute_standard_plonk_sigma_permutations(circuit_constructor, + circuit_proving_key.get()); circuit_proving_key->recursive_proof_public_input_indices = std::vector(recursive_proof_public_input_indices.begin(), recursive_proof_public_input_indices.end()); diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.hpp index 2074d91b1d..32085fcb57 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/standard_plonk_composer_helper.hpp @@ -8,7 +8,6 @@ #include "barretenberg/honk/pcs/commitment_key.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/plonk/proof_system/verifier/verifier.hpp" -#include "barretenberg/proof_system/composer/permutation_helper.hpp" #include "barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp" #include @@ -23,22 +22,21 @@ template class StandardPlonkComposerHelper { std::shared_ptr circuit_verification_key; // TODO(#218)(kesha): we need to put this into the commitment key, so that the composer doesn't have to handle srs // at all - std::shared_ptr crs_factory_; + std::shared_ptr crs_factory_; std::vector recursive_proof_public_input_indices; bool contains_recursive_proof = false; bool computed_witness = false; StandardPlonkComposerHelper() - : StandardPlonkComposerHelper(std::shared_ptr( + : StandardPlonkComposerHelper(std::shared_ptr( new proof_system::FileReferenceStringFactory("../srs_db/ignition"))) {} - - StandardPlonkComposerHelper(std::shared_ptr crs_factory) + StandardPlonkComposerHelper(std::shared_ptr crs_factory) : crs_factory_(std::move(crs_factory)) {} - StandardPlonkComposerHelper(std::unique_ptr&& crs_factory) + StandardPlonkComposerHelper(std::unique_ptr&& crs_factory) : crs_factory_(std::move(crs_factory)) {} StandardPlonkComposerHelper(std::shared_ptr p_key, diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.cpp index 04f2b3fbcd..c24524a928 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.cpp @@ -11,6 +11,9 @@ #include "barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp" #include "barretenberg/plonk/proof_system/widgets/transition_widgets/turbo_arithmetic_widget.hpp" #include "barretenberg/proof_system/composer/permutation_helper.hpp" +#include "barretenberg/proof_system/composer/composer_helper_lib.hpp" +#include "barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp" + using namespace barretenberg; namespace proof_system::plonk { @@ -37,21 +40,18 @@ std::shared_ptr TurboPlonkComposerHelper const size_t num_randomized_gates = NUM_RANDOMIZED_GATES; // Initialize circuit_proving_key // TODO(#229)(Kesha): replace composer types. - circuit_proving_key = proof_system::initialize_proving_key(circuit_constructor, - crs_factory_.get(), - minimum_circuit_size, - num_randomized_gates, - proof_system::ComposerType::TURBO); + circuit_proving_key = initialize_proving_key( + circuit_constructor, crs_factory_.get(), minimum_circuit_size, num_randomized_gates, ComposerType::TURBO); - proof_system::construct_lagrange_selector_forms(circuit_constructor, circuit_proving_key.get()); + construct_lagrange_selector_forms(circuit_constructor, circuit_proving_key.get()); - proof_system::enforce_nonzero_polynomial_selectors(circuit_constructor, circuit_proving_key.get()); + enforce_nonzero_polynomial_selectors(circuit_constructor, circuit_proving_key.get()); compute_monomial_and_coset_selector_forms(circuit_proving_key.get(), turbo_selector_properties()); // Compute sigma polynomials (TODO(kesha): we should update that late) - proof_system::compute_standard_plonk_sigma_permutations( - circuit_constructor, circuit_proving_key.get()); + compute_standard_plonk_sigma_permutations(circuit_constructor, + circuit_proving_key.get()); circuit_proving_key->recursive_proof_public_input_indices = std::vector(recursive_proof_public_input_indices.begin(), recursive_proof_public_input_indices.end()); circuit_proving_key->contains_recursive_proof = contains_recursive_proof; diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.hpp index 5153124fd8..2f12901330 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/turbo_plonk_composer_helper.hpp @@ -12,7 +12,7 @@ template class TurboPlonkComposerHelper { public: static constexpr size_t NUM_RANDOMIZED_GATES = 2; // equal to the number of multilinear evaluations leaked static constexpr size_t program_width = CircuitConstructor::program_width; - static constexpr proof_system::ComposerType type = proof_system::ComposerType::TURBO; + static constexpr ComposerType type = ComposerType::TURBO; static constexpr MerkleHashType merkle_hash_type = MerkleHashType::FIXED_BASE_PEDERSEN; static constexpr size_t UINT_LOG2_BASE = 2; std::shared_ptr circuit_proving_key; @@ -20,21 +20,21 @@ template class TurboPlonkComposerHelper { // TODO(#218)(kesha): we need to put this into the commitment key, so that the composer doesn't have to handle srs // at all - std::shared_ptr crs_factory_; + std::shared_ptr crs_factory_; std::vector recursive_proof_public_input_indices; bool contains_recursive_proof = false; bool computed_witness = false; TurboPlonkComposerHelper() - : TurboPlonkComposerHelper(std::shared_ptr( + : TurboPlonkComposerHelper(std::shared_ptr( new proof_system::FileReferenceStringFactory("../srs_db/ignition"))) {} - TurboPlonkComposerHelper(std::shared_ptr crs_factory) + TurboPlonkComposerHelper(std::shared_ptr crs_factory) : crs_factory_(std::move(crs_factory)) {} - TurboPlonkComposerHelper(std::unique_ptr&& crs_factory) + TurboPlonkComposerHelper(std::unique_ptr&& crs_factory) : crs_factory_(std::move(crs_factory)) {} TurboPlonkComposerHelper(std::shared_ptr p_key, std::shared_ptr v_key) diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.cpp index 9049ed0e0b..26e7049443 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.cpp @@ -10,7 +10,7 @@ #include #include -namespace plonk { +namespace proof_system::plonk { /** * @brief Computes `this.witness`, which is basiclly a set of polynomials mapped-to by strings. @@ -228,11 +228,8 @@ std::shared_ptr UltraPlonkComposerHelper::compu const size_t num_randomized_gates = NUM_RANDOMIZED_GATES; // Initialize circuit_proving_key // TODO(#229)(Kesha): replace composer types. - circuit_proving_key = initialize_proving_key(circuit_constructor, - crs_factory_.get(), - minimum_circuit_size, - num_randomized_gates, - plonk::ComposerType::PLOOKUP); + circuit_proving_key = initialize_proving_key( + circuit_constructor, crs_factory_.get(), minimum_circuit_size, num_randomized_gates, ComposerType::PLOOKUP); construct_lagrange_selector_forms(circuit_constructor, circuit_proving_key.get()); @@ -240,8 +237,8 @@ std::shared_ptr UltraPlonkComposerHelper::compu compute_monomial_and_coset_selector_forms(circuit_proving_key.get(), ultra_selector_properties()); - bonk::compute_plonk_generalized_sigma_permutations(circuit_constructor, - circuit_proving_key.get()); + compute_plonk_generalized_sigma_permutations(circuit_constructor, + circuit_proving_key.get()); const size_t subgroup_size = circuit_proving_key->circuit_size; @@ -350,7 +347,7 @@ std::shared_ptr UltraPlonkComposerHelper::compu * @return Pointer to created circuit verification key. * */ template -std::shared_ptr UltraPlonkComposerHelper::compute_verification_key( +std::shared_ptr UltraPlonkComposerHelper::compute_verification_key( const CircuitConstructor& circuit_constructor) { if (circuit_verification_key) { @@ -391,4 +388,4 @@ void UltraPlonkComposerHelper::add_table_column_selector_pol } template class UltraPlonkComposerHelper; -} // namespace plonk +} // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.hpp index 45b218460d..c66ce7eea0 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.hpp @@ -1,15 +1,16 @@ #pragma once #include "barretenberg/proof_system/composer/composer_helper_lib.hpp" +#include "barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp" #include "barretenberg/srs/reference_string/file_reference_string.hpp" -#include "barretenberg/proof_system/proving_key/proving_key.hpp" +#include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" #include "barretenberg/plonk/proof_system/prover/prover.hpp" #include "barretenberg/plonk/proof_system/verifier/verifier.hpp" #include #include -namespace plonk { +namespace proof_system::plonk { // TODO(Kesha): change initializations to specify this parameter // Cody: What does this mean? template class UltraPlonkComposerHelper { @@ -21,11 +22,11 @@ template class UltraPlonkComposerHelper { // simultaneously here and in the other split composers. static constexpr size_t NUM_RANDOMIZED_GATES = 4; // equal to the number of multilinear evaluations leaked static constexpr size_t program_width = CircuitConstructor::program_width; - std::shared_ptr circuit_proving_key; - std::shared_ptr circuit_verification_key; + std::shared_ptr circuit_proving_key; + std::shared_ptr circuit_verification_key; // TODO(#218)(kesha): we need to put this into the commitment key, so that the composer doesn't have to handle srs // at all - std::shared_ptr crs_factory_; + std::shared_ptr crs_factory_; std::vector recursive_proof_public_input_indices; bool contains_recursive_proof = false; @@ -52,7 +53,7 @@ template class UltraPlonkComposerHelper { UltraPlonkComposerHelper& operator=(UltraPlonkComposerHelper const& other) noexcept = default; ~UltraPlonkComposerHelper() = default; - std::vector ultra_selector_properties() + std::vector ultra_selector_properties() { // When reading and writing the proving key from a buffer we must precompute the Lagrange form of certain // selector polynomials. In order to avoid a new selector type and definitions in the polynomial manifest, we @@ -63,7 +64,7 @@ template class UltraPlonkComposerHelper { // { "q_m", true }, { "q_c", true }, { "q_1", true }, { "q_2", true }, // { "q_3", true }, { "q_4", false }, { "q_arith", false }, { "q_sort", false }, // { "q_elliptic", false }, { "q_aux", false }, { "table_type", true }, - std::vector result{ + std::vector result{ { "q_m", true }, { "q_c", true }, { "q_1", true }, { "q_2", true }, { "q_3", true }, { "q_4", true }, { "q_arith", true }, { "q_sort", true }, { "q_elliptic", true }, { "q_aux", true }, { "table_type", true }, @@ -75,8 +76,8 @@ template class UltraPlonkComposerHelper { void finalize_circuit(CircuitConstructor& circuit_constructor) { circuit_constructor.finalize_circuit(); }; - std::shared_ptr compute_proving_key(const CircuitConstructor& circuit_constructor); - std::shared_ptr compute_verification_key(const CircuitConstructor& circuit_constructor); + std::shared_ptr compute_proving_key(const CircuitConstructor& circuit_constructor); + std::shared_ptr compute_verification_key(const CircuitConstructor& circuit_constructor); void compute_witness(CircuitConstructor& circuit_constructor); @@ -208,4 +209,4 @@ template class UltraPlonkComposerHelper { } }; -} // namespace plonk +} // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.hpp index c8571b94ee..34e51f92de 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.hpp @@ -16,7 +16,7 @@ namespace proof_system::plonk { */ class StandardPlonkComposer { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::STANDARD; + static constexpr ComposerType type = ComposerType::STANDARD; static constexpr size_t UINT_LOG2_BASE = 2; // An instantiation of the circuit constructor that only depends on arithmetization, not on the proof system @@ -39,20 +39,18 @@ class StandardPlonkComposer { , variables(circuit_constructor.variables){}; StandardPlonkComposer(std::string const& crs_path, const size_t size_hint = 0) - : StandardPlonkComposer(std::unique_ptr( - new proof_system::FileReferenceStringFactory(crs_path)), - size_hint){}; + : StandardPlonkComposer( + std::unique_ptr(new proof_system::FileReferenceStringFactory(crs_path)), + size_hint){}; - StandardPlonkComposer(std::shared_ptr const& crs_factory, - const size_t size_hint = 0) + StandardPlonkComposer(std::shared_ptr const& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(crs_factory) , num_gates(circuit_constructor.num_gates) , variables(circuit_constructor.variables) {} - StandardPlonkComposer(std::unique_ptr&& crs_factory, - const size_t size_hint = 0) + StandardPlonkComposer(std::unique_ptr&& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(std::move(crs_factory)) , num_gates(circuit_constructor.num_gates) diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.test.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.test.cpp index fb9373f76b..0ff53d40b0 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.test.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/standard_plonk_composer.test.cpp @@ -13,7 +13,7 @@ auto& engine = numeric::random::get_debug_engine(); TEST(standard_plonk_composer_splitting_tmp, base_case) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr a = fr::one(); composer.add_public_variable(a); plonk::Prover prover = composer.create_prover(); @@ -27,7 +27,7 @@ TEST(standard_plonk_composer_splitting_tmp, base_case) TEST(standard_plonk_composer_splitting_tmp, composer_from_serialized_keys) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr a = fr::one(); composer.add_public_variable(a); @@ -36,12 +36,12 @@ TEST(standard_plonk_composer_splitting_tmp, composer_from_serialized_keys) auto pk_data = from_buffer(pk_buf); auto vk_data = from_buffer(vk_buf); - auto crs = std::make_unique("../srs_db/ignition"); + auto crs = std::make_unique("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); auto verification_key = std::make_shared(std::move(vk_data), crs->get_verifier_crs()); - plonk::StandardPlonkComposer composer2 = proof_system::plonk::StandardPlonkComposer(proving_key, verification_key); + plonk::StandardPlonkComposer composer2 = plonk::StandardPlonkComposer(proving_key, verification_key); composer2.add_public_variable(a); plonk::Prover prover = composer2.create_prover(); @@ -55,7 +55,7 @@ TEST(standard_plonk_composer_splitting_tmp, composer_from_serialized_keys) TEST(standard_plonk_composer_splitting_tmp, test_add_gate_proofs) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr a = fr::one(); uint32_t a_idx = composer.add_public_variable(a); fr b = fr::one(); @@ -114,7 +114,7 @@ TEST(standard_plonk_composer_splitting_tmp, test_add_gate_proofs) TEST(standard_plonk_composer_splitting_tmp, test_mul_gate_proofs) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr q[7]{ fr::random_element(), fr::random_element(), fr::random_element(), fr::random_element(), fr::random_element(), fr::random_element(), fr::random_element() }; fr q_inv[7]{ @@ -193,7 +193,7 @@ TEST(standard_plonk_composer_splitting_tmp, test_mul_gate_proofs) TEST(standard_plonk_composer_splitting_tmp, range_constraint) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); for (size_t i = 0; i < 10; ++i) { uint32_t value = engine.get_random_uint32(); @@ -236,7 +236,7 @@ TEST(standard_plonk_composer_splitting_tmp, range_constraint) TEST(standard_plonk_composer_splitting_tmp, range_constraint_fail) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); uint64_t value = 0xffffff; uint32_t witness_index = composer.add_variable(fr(value)); @@ -256,7 +256,7 @@ TEST(standard_plonk_composer_splitting_tmp, range_constraint_fail) TEST(standard_plonk_composer_splitting_tmp, and_constraint) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); for (size_t i = 0; i < /*10*/ 1; ++i) { uint32_t left_value = engine.get_random_uint32(); @@ -327,7 +327,7 @@ TEST(standard_plonk_composer_splitting_tmp, and_constraint) TEST(standard_plonk_composer_splitting_tmp, xor_constraint) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); for (size_t i = 0; i < /*10*/ 1; ++i) { uint32_t left_value = engine.get_random_uint32(); @@ -397,7 +397,7 @@ TEST(standard_plonk_composer_splitting_tmp, xor_constraint) TEST(standard_plonk_composer_splitting_tmp, big_add_gate_with_bit_extract) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); const auto generate_constraints = [&composer](uint32_t quad_value) { uint32_t quad_accumulator_left = @@ -441,7 +441,7 @@ TEST(standard_plonk_composer_splitting_tmp, big_add_gate_with_bit_extract) TEST(standard_plonk_composer_splitting_tmp, test_range_constraint_fail) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); uint32_t witness_index = composer.add_variable(fr::neg_one()); composer.decompose_into_base4_accumulators(witness_index, 32); @@ -458,7 +458,7 @@ TEST(standard_plonk_composer_splitting_tmp, test_range_constraint_fail) TEST(standard_plonk_composer_splitting_tmp, test_check_circuit_correct) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr a = fr::one(); uint32_t a_idx = composer.add_public_variable(a); fr b = fr::one(); @@ -478,7 +478,7 @@ TEST(standard_plonk_composer_splitting_tmp, test_check_circuit_correct) TEST(standard_plonk_composer_splitting_tmp, test_check_circuit_broken) { - plonk::StandardPlonkComposer composer = proof_system::plonk::StandardPlonkComposer(); + plonk::StandardPlonkComposer composer = plonk::StandardPlonkComposer(); fr a = fr::one(); uint32_t a_idx = composer.add_public_variable(a); fr b = fr::one(); diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/turbo_plonk_composer.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/turbo_plonk_composer.hpp index 93b7450c94..6019662bb5 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/turbo_plonk_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/turbo_plonk_composer.hpp @@ -12,7 +12,7 @@ namespace proof_system::plonk { */ class TurboPlonkComposer { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::STANDARD; + static constexpr ComposerType type = ComposerType::STANDARD; static constexpr size_t UINT_LOG2_BASE = 2; @@ -38,18 +38,17 @@ class TurboPlonkComposer { , variables(circuit_constructor.variables){}; TurboPlonkComposer(std::string const& crs_path, const size_t size_hint = 0) - : TurboPlonkComposer(std::unique_ptr( - new proof_system::FileReferenceStringFactory(crs_path)), - size_hint){}; + : TurboPlonkComposer( + std::unique_ptr(new proof_system::FileReferenceStringFactory(crs_path)), + size_hint){}; - TurboPlonkComposer(std::shared_ptr const& crs_factory, - const size_t size_hint = 0) + TurboPlonkComposer(std::shared_ptr const& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(crs_factory) , num_gates(circuit_constructor.num_gates) , variables(circuit_constructor.variables){}; - TurboPlonkComposer(std::unique_ptr&& crs_factory, const size_t size_hint = 0) + TurboPlonkComposer(std::unique_ptr&& crs_factory, const size_t size_hint = 0) : circuit_constructor(size_hint) , composer_helper(std::move(crs_factory)) , num_gates(circuit_constructor.num_gates) diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.hpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.hpp index 4c448818ad..d66c99aa1d 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.hpp @@ -6,9 +6,7 @@ #include "barretenberg/plonk/composer/splitting_tmp/composer_helper/ultra_plonk_composer_helper.hpp" #include -using namespace bonk; - -namespace plonk { +namespace proof_system::plonk { class UltraPlonkComposer { @@ -364,7 +362,7 @@ class UltraPlonkComposer { // std::array decompose_non_native_field_double_width_limb( // const uint32_t limb_idx, const size_t num_limb_bits = (2 * DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)); std::array evaluate_non_native_field_multiplication( - const bonk::non_native_field_witnesses& input, const bool range_constrain_quotient_and_remainder = true) + const non_native_field_witnesses& input, const bool range_constrain_quotient_and_remainder = true) { return circuit_constructor.evaluate_non_native_field_multiplication(input, range_constrain_quotient_and_remainder); @@ -473,4 +471,4 @@ class UltraPlonkComposer { // std::vector recursive_proof_public_input_indices; // bool contains_recursive_proof = false; }; -} // namespace plonk +} // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.test.cpp b/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.test.cpp index 416cee213e..d5c2128e05 100644 --- a/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.test.cpp +++ b/cpp/src/barretenberg/plonk/composer/splitting_tmp/ultra_plonk_composer.test.cpp @@ -9,9 +9,8 @@ #include "barretenberg/numeric/uintx/uintx.hpp" using namespace barretenberg; -using namespace bonk; -namespace plonk { +namespace proof_system::plonk { namespace { auto& engine = numeric::random::get_debug_engine(); @@ -780,7 +779,7 @@ TEST(ultra_plonk_composer_splitting_tmp, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - bonk::non_native_field_witnesses inputs{ + non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = composer.evaluate_non_native_field_multiplication(inputs); @@ -914,4 +913,4 @@ TEST(ultra_plonk_composer_splitting_tmp, ram) EXPECT_EQ(result, true); } -} // namespace plonk +} // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/standard_composer.hpp b/cpp/src/barretenberg/plonk/composer/standard_composer.hpp index a4d3fc4bc7..f8ec645533 100644 --- a/cpp/src/barretenberg/plonk/composer/standard_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/standard_composer.hpp @@ -16,7 +16,7 @@ inline std::vector standard_selector_propertie class StandardComposer : public ComposerBase { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::STANDARD; + static constexpr ComposerType type = ComposerType::STANDARD; static constexpr MerkleHashType merkle_hash_type = MerkleHashType::FIXED_BASE_PEDERSEN; static constexpr size_t UINT_LOG2_BASE = 2; diff --git a/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp b/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp index d593040f21..c4413ce080 100644 --- a/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp +++ b/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp @@ -37,7 +37,7 @@ TEST(standard_composer, composer_from_serialized_keys) auto pk_data = from_buffer(pk_buf); auto vk_data = from_buffer(vk_buf); - auto crs = std::make_unique("../srs_db/ignition"); + auto crs = std::make_unique("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); auto verification_key = std::make_shared(std::move(vk_data), crs->get_verifier_crs()); diff --git a/cpp/src/barretenberg/plonk/composer/turbo_composer.hpp b/cpp/src/barretenberg/plonk/composer/turbo_composer.hpp index 80087bb131..5f4ffda9af 100644 --- a/cpp/src/barretenberg/plonk/composer/turbo_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/turbo_composer.hpp @@ -4,7 +4,7 @@ namespace proof_system::plonk { class TurboComposer : public ComposerBase { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::TURBO; + static constexpr ComposerType type = ComposerType::TURBO; static constexpr MerkleHashType merkle_hash_type = MerkleHashType::FIXED_BASE_PEDERSEN; static constexpr size_t UINT_LOG2_BASE = 2; enum TurboSelectors { QM, QC, Q1, Q2, Q3, Q4, Q5, QARITH, QFIXED, QRANGE, QLOGIC, NUM }; @@ -227,10 +227,8 @@ class CheckGetter { } }; -using TurboArithmeticChecker = - proof_system::plonk::widget::TurboArithmeticKernel; -using TurboRangeChecker = proof_system::plonk::widget::TurboRangeKernel; -using TurboLogicChecker = proof_system::plonk::widget::TurboLogicKernel; -using TurboFixedBaseChecker = - proof_system::plonk::widget::TurboFixedBaseKernel; +using TurboArithmeticChecker = widget::TurboArithmeticKernel; +using TurboRangeChecker = widget::TurboRangeKernel; +using TurboLogicChecker = widget::TurboLogicKernel; +using TurboFixedBaseChecker = widget::TurboFixedBaseKernel; } // namespace proof_system::plonk diff --git a/cpp/src/barretenberg/plonk/composer/ultra_composer.hpp b/cpp/src/barretenberg/plonk/composer/ultra_composer.hpp index 301e7a656c..7fa42ed939 100644 --- a/cpp/src/barretenberg/plonk/composer/ultra_composer.hpp +++ b/cpp/src/barretenberg/plonk/composer/ultra_composer.hpp @@ -8,7 +8,7 @@ namespace proof_system::plonk { class UltraComposer : public ComposerBase { public: - static constexpr proof_system::ComposerType type = proof_system::ComposerType::PLOOKUP; + static constexpr ComposerType type = ComposerType::PLOOKUP; static constexpr MerkleHashType merkle_hash_type = MerkleHashType::LOOKUP_PEDERSEN; static constexpr size_t NUM_RESERVED_GATES = 4; // This must be >= num_roots_cut_out_of_vanishing_polynomial // See the comment in plonk/proof_system/prover/prover.cpp diff --git a/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp b/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp index 51ba344e26..933de8cd5d 100644 --- a/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp @@ -36,9 +36,9 @@ TEST(commitment_scheme, kate_open) plonk::KateCommitmentScheme newKate; // std::shared_ptr crs_factory = (new FileReferenceStringFactory("../srs_db/ignition")); - auto file_crs = std::make_shared("../srs_db/ignition"); + auto file_crs = std::make_shared("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); - auto circuit_proving_key = std::make_shared(n, 0, crs, proof_system::ComposerType::STANDARD); + auto circuit_proving_key = std::make_shared(n, 0, crs, ComposerType::STANDARD); work_queue queue(circuit_proving_key.get(), &inp_tx); newKate.commit(&coeffs[0], "F_COMM", 0, queue); @@ -93,9 +93,9 @@ TEST(commitment_scheme, kate_batch_open) transcript::StandardTranscript inp_tx = transcript::StandardTranscript(transcript::Manifest()); plonk::KateCommitmentScheme newKate; - auto file_crs = std::make_shared("../srs_db/ignition"); + auto file_crs = std::make_shared("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); - auto circuit_proving_key = std::make_shared(n, 0, crs, proof_system::ComposerType::STANDARD); + auto circuit_proving_key = std::make_shared(n, 0, crs, ComposerType::STANDARD); work_queue queue(circuit_proving_key.get(), &inp_tx); // commit to individual polynomials diff --git a/cpp/src/barretenberg/plonk/proof_system/constants.hpp b/cpp/src/barretenberg/plonk/proof_system/constants.hpp index 5c7336d49c..debf064c8f 100644 --- a/cpp/src/barretenberg/plonk/proof_system/constants.hpp +++ b/cpp/src/barretenberg/plonk/proof_system/constants.hpp @@ -9,7 +9,7 @@ namespace proof_system::plonk { #ifdef USE_TURBO static constexpr uint32_t SYSTEM_COMPOSER = ComposerType::TURBO; #else -static constexpr uint32_t SYSTEM_COMPOSER = proof_system::ComposerType::PLOOKUP; +static constexpr uint32_t SYSTEM_COMPOSER = ComposerType::PLOOKUP; #endif enum MerkleHashType { diff --git a/cpp/src/barretenberg/plonk/proof_system/prover/c_bind.cpp b/cpp/src/barretenberg/plonk/proof_system/prover/c_bind.cpp index 100ce79047..6cd4d4c7af 100644 --- a/cpp/src/barretenberg/plonk/proof_system/prover/c_bind.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/prover/c_bind.cpp @@ -48,9 +48,8 @@ WASM_EXPORT void* test_env_load_prover_crs(size_t num_points) { return env_load_prover_crs(num_points); } -typedef std:: - conditional_t - WasmProver; +typedef std::conditional_t + WasmProver; WASM_EXPORT void prover_process_queue(WasmProver* prover) { diff --git a/cpp/src/barretenberg/plonk/proof_system/prover/c_bind_unrolled.cpp b/cpp/src/barretenberg/plonk/proof_system/prover/c_bind_unrolled.cpp index 3de3e3a02e..66cfdc7496 100644 --- a/cpp/src/barretenberg/plonk/proof_system/prover/c_bind_unrolled.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/prover/c_bind_unrolled.cpp @@ -8,9 +8,8 @@ using namespace barretenberg; extern "C" { // TODO(Cody): Removed "unrolled" here when the time comes, if it does. -typedef std:: - conditional_t - WasmUnrolledProver; +typedef std::conditional_t + WasmUnrolledProver; WASM_EXPORT void unrolled_prover_process_queue(WasmUnrolledProver* prover) { diff --git a/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp b/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp index 2f170b1e29..50a535f946 100644 --- a/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp @@ -112,9 +112,8 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates - auto reference_string = std::make_shared(n + 1, "../srs_db/ignition"); - std::shared_ptr key = - std::make_shared(n, 0, reference_string, proof_system::ComposerType::STANDARD); + auto reference_string = std::make_shared(n + 1, "../srs_db/ignition"); + std::shared_ptr key = std::make_shared(n, 0, reference_string, ComposerType::STANDARD); polynomial w_l(n); polynomial w_r(n); @@ -277,7 +276,7 @@ plonk::Prover generate_test_data(const size_t n) std::unique_ptr> kate_commitment_scheme = std::make_unique>(); - plonk::Prover state = proof_system::plonk::Prover(key, create_manifest()); + plonk::Prover state = plonk::Prover(key, create_manifest()); state.random_widgets.emplace_back(std::move(permutation_widget)); state.transition_widgets.emplace_back(std::move(widget)); state.commitment_scheme = std::move(kate_commitment_scheme); diff --git a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp index db4179c306..ea22d7f366 100644 --- a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp @@ -22,11 +22,10 @@ namespace proof_system::plonk { * * Delegates to proving_key::init * */ -proving_key::proving_key( - const size_t num_gates, - const size_t num_inputs, - std::shared_ptr const& crs, - proof_system::ComposerType type = proof_system::ComposerType::STANDARD) // TODO(Cody): Don't use default for Honk +proving_key::proving_key(const size_t num_gates, + const size_t num_inputs, + std::shared_ptr const& crs, + ComposerType type = ComposerType::STANDARD) // TODO(Cody): Don't use default for Honk : composer_type(type) , circuit_size(num_gates) , log_circuit_size(numeric::get_msb(num_gates)) diff --git a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp index 6fef8bb861..f3198a5cbb 100644 --- a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp +++ b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp @@ -20,7 +20,7 @@ struct proving_key_data { std::vector recursive_proof_public_input_indices; std::vector memory_read_records; std::vector memory_write_records; - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; }; struct proving_key { @@ -31,12 +31,12 @@ struct proving_key { RELATIVE_LOOKUP, }; - proving_key(proving_key_data&& data, std::shared_ptr const& crs); + proving_key(proving_key_data&& data, std::shared_ptr const& crs); proving_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr const& crs, - proof_system::ComposerType type); + std::shared_ptr const& crs, + ComposerType type); proving_key(std::ostream& is, std::string const& crs_path); @@ -51,14 +51,14 @@ struct proving_key { std::vector memory_read_records; // Used by UltraComposer only; for ROM, RAM reads. std::vector memory_write_records; // Used by UltraComposer only, for RAM writes. - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; barretenberg::evaluation_domain small_domain; barretenberg::evaluation_domain large_domain; // The reference_string object contains the monomial SRS. We can access it using: // Monomial SRS: reference_string->get_monomial_points() - std::shared_ptr reference_string; + std::shared_ptr reference_string; barretenberg::polynomial quotient_polynomial_parts[plonk::NUM_QUOTIENT_PARTS]; diff --git a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp index 32a28fe96d..c3d2969fbf 100644 --- a/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp @@ -15,14 +15,14 @@ using namespace proof_system; // Test proving key serialization/deserialization to/from buffer TEST(proving_key, proving_key_from_serialized_key) { - plonk::StandardComposer composer = proof_system::plonk::StandardComposer(); + plonk::StandardComposer composer = plonk::StandardComposer(); fr a = fr::one(); composer.add_public_variable(a); plonk::proving_key& p_key = *composer.compute_proving_key(); auto pk_buf = to_buffer(p_key); auto pk_data = from_buffer(pk_buf); - auto crs = std::make_unique("../srs_db/ignition"); + auto crs = std::make_unique("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); @@ -51,14 +51,14 @@ TEST(proving_key, proving_key_from_serialized_key) // Test proving key serialization/deserialization to/from buffer using UltraComposer TEST(proving_key, proving_key_from_serialized_key_ultra) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = plonk::UltraComposer(); fr a = fr::one(); composer.add_public_variable(a); plonk::proving_key& p_key = *composer.compute_proving_key(); auto pk_buf = to_buffer(p_key); auto pk_data = from_buffer(pk_buf); - auto crs = std::make_unique("../srs_db/ignition"); + auto crs = std::make_unique("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); @@ -88,7 +88,7 @@ TEST(proving_key, proving_key_from_serialized_key_ultra) #ifndef __wasm__ TEST(proving_key, proving_key_from_mmaped_key) { - plonk::StandardComposer composer = proof_system::plonk::StandardComposer(); + plonk::StandardComposer composer = plonk::StandardComposer(); fr a = fr::one(); composer.add_public_variable(a); diff --git a/cpp/src/barretenberg/plonk/proof_system/types/polynomial_manifest.hpp b/cpp/src/barretenberg/plonk/proof_system/types/polynomial_manifest.hpp index c55cc9b13a..aefd348ff9 100644 --- a/cpp/src/barretenberg/plonk/proof_system/types/polynomial_manifest.hpp +++ b/cpp/src/barretenberg/plonk/proof_system/types/polynomial_manifest.hpp @@ -4,8 +4,7 @@ #include #include #include "barretenberg/plonk/proof_system/constants.hpp" -// ToDo(Arijit): The below namespace should be plonk once all the honk related stuffs are moved out -// ToDo(Cody): This is now plonk-specific. + namespace proof_system::plonk { enum PolynomialSource { WITNESS, SELECTOR, PERMUTATION, OTHER }; @@ -176,19 +175,19 @@ class PolynomialManifest { PolynomialManifest(uint32_t composer_type) { switch (composer_type) { - case proof_system::ComposerType::STANDARD: { + case ComposerType::STANDARD: { std::copy(standard_polynomial_manifest, standard_polynomial_manifest + STANDARD_MANIFEST_SIZE, std::back_inserter(manifest)); break; }; - case proof_system::ComposerType::TURBO: { + case ComposerType::TURBO: { std::copy(turbo_polynomial_manifest, turbo_polynomial_manifest + TURBO_MANIFEST_SIZE, std::back_inserter(manifest)); break; }; - case proof_system::ComposerType::PLOOKUP: { + case ComposerType::PLOOKUP: { std::copy(ultra_polynomial_manifest, ultra_polynomial_manifest + ULTRA_MANIFEST_SIZE, std::back_inserter(manifest)); @@ -236,7 +235,7 @@ class PrecomputedPolyList { precomputed_poly_ids.emplace_back(label); precomputed_poly_ids.emplace_back(label + "_fft"); // Store all lagrange forms of selector polynomials for ultra - if (composer_type == proof_system::ComposerType::PLOOKUP) { + if (composer_type == ComposerType::PLOOKUP) { precomputed_poly_ids.emplace_back(label + "_lagrange"); } break; diff --git a/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp b/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp index 9e549d212c..6342ea042f 100644 --- a/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp +++ b/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp @@ -5,7 +5,7 @@ namespace proof_system { * Uses StandardPlonk **/ inline void output_vk_sol_standard(std::ostream& os, - std::shared_ptr const& key, + std::shared_ptr const& key, std::string const& class_name) { const auto print_u256 = [&](const std::string& offset, const barretenberg::fr& element, const std::string& name) { @@ -65,7 +65,7 @@ inline void output_vk_sol_standard(std::ostream& os, * Write a solidity file containing the vk params to the given stream. * Uses UltraPlonk **/ -inline void output_vk_sol_ultra(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) +inline void output_vk_sol_ultra(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) { const auto print_u256 = [&](const std::string& offset, const barretenberg::fr& element, const std::string& name) { os << " mstore(add(_vk, " << offset << "), " << element << ") // " << name << std::endl; @@ -141,19 +141,19 @@ inline void output_vk_sol_ultra(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) +inline void output_vk_sol(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) { - proof_system::ComposerType composer_type = static_cast(key->composer_type); + ComposerType composer_type = static_cast(key->composer_type); switch (composer_type) { - case proof_system::ComposerType::STANDARD: { + case ComposerType::STANDARD: { return output_vk_sol_standard(os, key, class_name); break; } - // case proof_system::ComposerType::TURBO: { + // case ComposerType::TURBO: { // return output_vk_sol_turbo(os, key, class_name); // break; // } - case proof_system::ComposerType::PLOOKUP: { + case ComposerType::PLOOKUP: { return output_vk_sol_ultra(os, key, class_name); break; } diff --git a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp index aeccd3f70e..ef6913f184 100644 --- a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp @@ -6,7 +6,7 @@ namespace proof_system::plonk { verification_key::verification_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr const& crs, + std::shared_ptr const& crs, uint32_t composer_type_) : composer_type(composer_type_) , circuit_size(num_gates) @@ -17,8 +17,7 @@ verification_key::verification_key(const size_t num_gates, , polynomial_manifest(composer_type) {} -verification_key::verification_key(verification_key_data&& data, - std::shared_ptr const& crs) +verification_key::verification_key(verification_key_data&& data, std::shared_ptr const& crs) : composer_type(data.composer_type) , circuit_size(data.circuit_size) , log_circuit_size(numeric::get_msb(data.circuit_size)) diff --git a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp index 3b5e2ee36e..3d1a31a67f 100644 --- a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp +++ b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp @@ -45,10 +45,10 @@ inline bool operator==(verification_key_data const& lhs, verification_key_data c } struct verification_key { - verification_key(verification_key_data&& data, std::shared_ptr const& crs); + verification_key(verification_key_data&& data, std::shared_ptr const& crs); verification_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr const& crs, + std::shared_ptr const& crs, uint32_t composer_type); verification_key(const verification_key& other); verification_key(verification_key&& other); @@ -65,7 +65,7 @@ struct verification_key { barretenberg::evaluation_domain domain; - std::shared_ptr reference_string; + std::shared_ptr reference_string; std::map commitments; diff --git a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp index 8f3fff05aa..bb049af011 100644 --- a/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp @@ -10,7 +10,7 @@ namespace proof_system::plonk::test_verification_key { TEST(verification_key, buffer_serialization) { verification_key_data key; - key.composer_type = static_cast(proof_system::ComposerType::STANDARD); + key.composer_type = static_cast(ComposerType::STANDARD); key.circuit_size = 1234; key.num_public_inputs = 10; key.commitments["test1"] = g1::element::random_element(); @@ -27,7 +27,7 @@ TEST(verification_key, buffer_serialization) TEST(verification_key, stream_serialization) { verification_key_data key; - key.composer_type = static_cast(proof_system::ComposerType::STANDARD); + key.composer_type = static_cast(ComposerType::STANDARD); key.circuit_size = 1234; key.num_public_inputs = 10; key.commitments["test1"] = g1::element::random_element(); diff --git a/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp b/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp index 9a5501a328..701a465189 100644 --- a/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp +++ b/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp @@ -40,7 +40,7 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k state)); } - auto crs = std::make_shared("../srs_db/ignition"); + auto crs = std::make_shared("../srs_db/ignition"); std::shared_ptr circuit_verification_key = std::make_shared(circuit_proving_key->circuit_size, circuit_proving_key->num_public_inputs, @@ -76,8 +76,8 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates - auto crs = std::make_shared(n + 1, "../srs_db/ignition"); - std::shared_ptr key = std::make_shared(n, 0, crs, proof_system::ComposerType::STANDARD); + auto crs = std::make_shared(n + 1, "../srs_db/ignition"); + std::shared_ptr key = std::make_shared(n, 0, crs, ComposerType::STANDARD); polynomial w_l(n); polynomial w_r(n); @@ -232,7 +232,7 @@ plonk::Prover generate_test_data(const size_t n) std::unique_ptr> kate_commitment_scheme = std::make_unique>(); - plonk::Prover state = proof_system::plonk::Prover(std::move(key), plonk::StandardComposer::create_manifest(0)); + plonk::Prover state = plonk::Prover(std::move(key), plonk::StandardComposer::create_manifest(0)); state.random_widgets.emplace_back(std::move(permutation_widget)); state.transition_widgets.emplace_back(std::move(widget)); state.commitment_scheme = std::move(kate_commitment_scheme); diff --git a/cpp/src/barretenberg/proof_system/CMakeLists.txt b/cpp/src/barretenberg/proof_system/CMakeLists.txt index 99041b45c2..3cb2621334 100644 --- a/cpp/src/barretenberg/proof_system/CMakeLists.txt +++ b/cpp/src/barretenberg/proof_system/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(proof_system plonk) \ No newline at end of file +barretenberg_module(proof_system polynomials crypto_pedersen) \ No newline at end of file diff --git a/cpp/src/barretenberg/proof_system/circuit_constructors/standard_circuit_constructor.hpp b/cpp/src/barretenberg/proof_system/circuit_constructors/standard_circuit_constructor.hpp index 7479fbadb1..b627b17a9b 100644 --- a/cpp/src/barretenberg/proof_system/circuit_constructors/standard_circuit_constructor.hpp +++ b/cpp/src/barretenberg/proof_system/circuit_constructors/standard_circuit_constructor.hpp @@ -1,8 +1,8 @@ #pragma once #include #include "circuit_constructor_base.hpp" -#include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" +#include "barretenberg/proof_system/types/composer_type.hpp" namespace proof_system { inline std::vector standard_selector_names() @@ -23,8 +23,7 @@ class StandardCircuitConstructor : public CircuitConstructorBase& q_3 = std::get<3>(selectors); std::vector& q_c = std::get<4>(selectors); - static constexpr proof_system::ComposerType type = - proof_system::ComposerType::STANDARD_HONK; // TODO(Cody): Get rid of this. + static constexpr ComposerType type = ComposerType::STANDARD_HONK; // TODO(Cody): Get rid of this. static constexpr size_t UINT_LOG2_BASE = 2; // These are variables that we have used a gate on, to enforce that they are diff --git a/cpp/src/barretenberg/proof_system/circuit_constructors/turbo_circuit_constructor.hpp b/cpp/src/barretenberg/proof_system/circuit_constructors/turbo_circuit_constructor.hpp index aec533fca9..71dcca5c5e 100644 --- a/cpp/src/barretenberg/proof_system/circuit_constructors/turbo_circuit_constructor.hpp +++ b/cpp/src/barretenberg/proof_system/circuit_constructors/turbo_circuit_constructor.hpp @@ -1,8 +1,8 @@ #pragma once #include #include "circuit_constructor_base.hpp" -#include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" +#include "barretenberg/proof_system/types/composer_type.hpp" namespace proof_system { @@ -32,7 +32,7 @@ class TurboCircuitConstructor : public CircuitConstructorBase& q_range = std::get<9>(selectors); std::vector& q_logic = std::get<10>(selectors); - static constexpr proof_system::ComposerType type = proof_system::ComposerType::TURBO; + static constexpr ComposerType type = ComposerType::TURBO; static constexpr size_t UINT_LOG2_BASE = 2; TurboCircuitConstructor(const size_t size_hint = 0); diff --git a/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.cpp b/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.cpp index c26a3380f5..d606ab173d 100644 --- a/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.cpp +++ b/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.cpp @@ -4,7 +4,7 @@ using namespace barretenberg; -namespace bonk { +namespace proof_system { void UltraCircuitConstructor::finalize_circuit() { @@ -2321,4 +2321,4 @@ void UltraCircuitConstructor::process_RAM_arrays(const size_t gate_offset_from_p } } -} // namespace bonk \ No newline at end of file +} // namespace proof_system \ No newline at end of file diff --git a/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.hpp b/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.hpp index fe9d23830f..65f73f724d 100644 --- a/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.hpp +++ b/cpp/src/barretenberg/proof_system/circuit_constructors/ultra_circuit_constructor.hpp @@ -1,6 +1,6 @@ #pragma once #include "barretenberg/proof_system/arithmetization/arithmetization.hpp" -#include "barretenberg/proof_system/types/polynomial_manifest.hpp" +#include "barretenberg/plonk/proof_system/types/polynomial_manifest.hpp" #include "circuit_constructor_base.hpp" #include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" @@ -10,9 +10,9 @@ #include "barretenberg/plonk/proof_system/types/prover_settings.hpp" #include -namespace bonk { +namespace proof_system { -static constexpr plonk::ComposerType type = plonk::ComposerType::PLOOKUP; +static constexpr ComposerType type = ComposerType::PLOOKUP; static constexpr plonk::MerkleHashType merkle_hash_type = plonk::MerkleHashType::LOOKUP_PEDERSEN; static constexpr size_t NUM_RESERVED_GATES = 4; // This must be >= num_roots_cut_out_of_vanishing_polynomial // See the comment in plonk/proof_system/prover/prover.cpp @@ -167,7 +167,7 @@ class UltraCircuitConstructor : public CircuitConstructorBase - */ -template -std::shared_ptr initialize_proving_key(const CircuitConstructor& circuit_constructor, - proof_system::ReferenceStringFactory* crs_factory, - const size_t minimum_circuit_size, - const size_t num_randomized_gates, - proof_system::ComposerType composer_type) -{ - const size_t num_gates = circuit_constructor.num_gates; - std::span public_inputs = circuit_constructor.public_inputs; - - const size_t num_public_inputs = public_inputs.size(); - const size_t num_constraints = num_gates + num_public_inputs; - const size_t total_num_constraints = std::max(minimum_circuit_size, num_constraints); - const size_t subgroup_size = - circuit_constructor.get_circuit_subgroup_size(total_num_constraints + num_randomized_gates); // next power of 2 - - auto crs = crs_factory->get_prover_crs(subgroup_size + 1); - - return std::make_shared(subgroup_size, num_public_inputs, crs, composer_type); -} - -/** - * @brief Construct lagrange selector polynomials from ciruit selector information and put into polynomial cache - * - * @tparam CircuitConstructor The class holding the circuit - * @param circuit_constructor The object holding the circuit - * @param key Pointer to the proving key - */ -template -void construct_lagrange_selector_forms(const CircuitConstructor& circuit_constructor, - plonk::proving_key* circuit_proving_key) -{ - const size_t num_public_inputs = circuit_constructor.public_inputs.size(); - for (size_t j = 0; j < circuit_constructor.num_selectors; ++j) { - std::span selector_values = circuit_constructor.selectors[j]; - ASSERT(circuit_proving_key->circuit_size >= selector_values.size()); - - // Compute selector vector, initialized to 0. - // Copy the selector values for all gates, keeping the rows at which we store public inputs as 0. - // Initializing the polynomials in this way automatically applies 0-padding to the selectors. - barretenberg::polynomial selector_poly_lagrange(circuit_proving_key->circuit_size); - for (size_t i = 0; i < selector_values.size(); ++i) { - selector_poly_lagrange[num_public_inputs + i] = selector_values[i]; - } - // TODO(#217)(Adrian): We may want to add a unique value (e.g. j+1) in the last position of each selector - // polynomial to guard against some edge cases that may occur during the MSM. If we do so, we should ensure that - // this does not clash with any other values we want to place at the end of of the witness vectors. In later - // iterations of the Sumcheck, we will be able to efficiently cancel out any checks in the last 2^k rows, so any - // randomness or unique values should be placed there. - circuit_proving_key->polynomial_store.put(circuit_constructor.selector_names_[j] + "_lagrange", - std::move(selector_poly_lagrange)); - } -} - -/** - * @brief Fill the last index of each selector polynomial in lagrange form with a non-zero value - * - * @tparam CircuitConstructor The class holding the circuit - * @param circuit_constructor The object holding the circuit - * @param key Pointer to the proving key - */ -template -void enforce_nonzero_polynomial_selectors(const CircuitConstructor& circuit_constructor, - plonk::proving_key* circuit_proving_key) -{ - for (size_t j = 0; j < circuit_constructor.num_selectors; ++j) { - auto current_selector = - circuit_proving_key->polynomial_store.get(circuit_constructor.selector_names_[j] + "_lagrange"); - current_selector[current_selector.size() - 1] = j + 1; - circuit_proving_key->polynomial_store.put(circuit_constructor.selector_names_[j] + "_lagrange", - std::move(current_selector)); - } -} - -// /** -// * @brief Retrieve lagrange forms of selector polynomials and compute monomial and coset-monomial forms and put into -// * cache -// * -// * @note This function also deletes the lagrange forms of the selectors from memory since they are not needed -// * for proof construction once the monomial and coset forms have been computed -// * -// * @param key Pointer to the proving key -// * @param selector_properties Names of selectors -// */ -// void compute_monomial_and_coset_selector_forms(plonk::proving_key* circuit_proving_key, -// std::vector selector_properties) -// { -// for (size_t i = 0; i < selector_properties.size(); i++) { -// // Compute monomial form of selector polynomial - -// auto& selector_poly_lagrange = -// circuit_proving_key->polynomial_store.get(selector_properties[i].name + "_lagrange"); -// barretenberg::polynomial selector_poly(circuit_proving_key->circuit_size); -// barretenberg::polynomial_arithmetic::ifft( -// &selector_poly_lagrange[0], &selector_poly[0], circuit_proving_key->small_domain); - -// // Compute coset FFT of selector polynomial -// barretenberg::polynomial selector_poly_fft(selector_poly, circuit_proving_key->circuit_size * 4 + 4); -// selector_poly_fft.coset_fft(circuit_proving_key->large_domain); - -// // Remove the selector lagrange forms since they will not be needed beyond this point -// circuit_proving_key->polynomial_store.remove(selector_properties[i].name + "_lagrange"); -// circuit_proving_key->polynomial_store.put(selector_properties[i].name, std::move(selector_poly)); -// circuit_proving_key->polynomial_store.put(selector_properties[i].name + "_fft", -// std::move(selector_poly_fft)); -// } -// } - -/** - * Compute witness polynomials (w_1, w_2, w_3, w_4) and put them into polynomial cache - * - * @details Fills 3 or 4 witness polynomials w_1, w_2, w_3, w_4 with the values of in-circuit variables. The beginning - * of w_1, w_2 polynomials is filled with public_input values. - * @return Witness with computed witness polynomials. - * - * @tparam Program settings needed to establish if w_4 is being used. - * */ -template -std::vector compute_witness_base(const CircuitConstructor& circuit_constructor, - const size_t minimum_circuit_size, - const size_t number_of_randomized_gates) -{ - const size_t program_width = CircuitConstructor::program_width; - const size_t num_gates = circuit_constructor.num_gates; - std::span public_inputs = circuit_constructor.public_inputs; - const size_t num_public_inputs = public_inputs.size(); - - const size_t num_constraints = std::max(minimum_circuit_size, num_gates + num_public_inputs); - // TODO(#216)(Adrian): Not a fan of specifying NUM_RANDOMIZED_GATES everywhere, - // Each flavor of Honk should have a "fixed" number of random places to add randomness to. - // It should be taken care of in as few places possible. - const size_t subgroup_size = - circuit_constructor.get_circuit_subgroup_size(num_constraints + number_of_randomized_gates); - - // construct a view over all the wire's variable indices - // w[j][i] is the index of the variable in the j-th wire, at gate i - // Each array should be of size `num_gates` - std::array, program_width> w; - w[0] = circuit_constructor.w_l; - w[1] = circuit_constructor.w_r; - w[2] = circuit_constructor.w_o; - if constexpr (program_width > 3) { - w[3] = circuit_constructor.w_4; - } - std::vector wires; - // Note: randomness is added to 3 of the last 4 positions in plonk/proof_system/prover/prover.cpp - // StandardProverBase::execute_preamble_round(). - for (size_t j = 0; j < program_width; ++j) { - // Initialize the polynomial with all the actual copies variable values - // Expect all values to be set to 0 initially - barretenberg::polynomial w_lagrange(subgroup_size); - - // Place all public inputs at the start of w_l and w_r. - // All selectors at these indices are set to 0 so these values are not constrained at all. - if ((j == 0) || (j == 1)) { - for (size_t i = 0; i < num_public_inputs; ++i) { - w_lagrange[i] = circuit_constructor.get_variable(public_inputs[i]); - } - } - - // Assign the variable values (which are pointed-to by the `w_` wires) to the wire witness polynomials - // `poly_w_`, shifted to make room for the public inputs at the beginning. - for (size_t i = 0; i < num_gates; ++i) { - w_lagrange[num_public_inputs + i] = circuit_constructor.get_variable(w[j][i]); - } - wires.push_back(std::move(w_lagrange)); - } - return wires; -} - -// /** -// * @brief Computes the verification key by computing the: -// * (1) commitments to the selector, permutation, and lagrange (first/last) polynomials, -// * (2) sets the polynomial manifest using the data from proving key. -// */ -// std::shared_ptr compute_verification_key_common( -// std::shared_ptr const& proving_key, std::shared_ptr -// const& vrs) -// { -// auto circuit_verification_key = std::make_shared( -// proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->composer_type); -// // TODO(kesha): Dirty hack for now. Need to actually make commitment-agnositc -// auto commitment_key = proof_system::honk::pcs::kzg::CommitmentKey(proving_key->circuit_size, -// "../srs_db/ignition"); - -// for (size_t i = 0; i < proving_key->polynomial_manifest.size(); ++i) { -// const auto& poly_info = proving_key->polynomial_manifest[i]; - -// const std::string poly_label(poly_info.polynomial_label); -// const std::string selector_commitment_label(poly_info.commitment_label); - -// if (poly_info.source == proof_system::PolynomialSource::SELECTOR || -// poly_info.source == proof_system::PolynomialSource::PERMUTATION || -// poly_info.source == proof_system::PolynomialSource::OTHER) { -// // Fetch the polynomial in its vector form. - -// // Commit to the constraint selector polynomial and insert the commitment in the verification key. - -// auto poly_commitment = commitment_key.commit(proving_key->polynomial_store.get(poly_label)); -// circuit_verification_key->commitments.insert({ selector_commitment_label, poly_commitment }); -// } -// } - -// // Set the polynomial manifest in verification key. -// circuit_verification_key->polynomial_manifest = -// proof_system::plonk::PolynomialManifest(proving_key->composer_type); - -// return circuit_verification_key; -// } - -// Ensure we compile all versions so that there are no issues during linkage -#define COMPILE_FOR_CIRCUIT_CONSTRUCTOR(circuit_constructor) \ - template std::shared_ptr initialize_proving_key( \ - const circuit_constructor&, \ - proof_system::ReferenceStringFactory*, \ - const size_t, \ - const size_t, \ - proof_system::ComposerType); \ - template void construct_lagrange_selector_forms(const circuit_constructor&, \ - plonk::proving_key*); \ - template std::vector compute_witness_base( \ - const circuit_constructor&, const size_t, const size_t); \ - template void enforce_nonzero_polynomial_selectors(const circuit_constructor& constructor, \ - plonk::proving_key* circuit_proving_key); - -COMPILE_FOR_CIRCUIT_CONSTRUCTOR(StandardCircuitConstructor) -COMPILE_FOR_CIRCUIT_CONSTRUCTOR(TurboCircuitConstructor) -COMPILE_FOR_CIRCUIT_CONSTRUCTOR(UltraCircuitConstructor) - -} // namespace proof_system diff --git a/cpp/src/barretenberg/proof_system/composer/composer_helper_lib.hpp b/cpp/src/barretenberg/proof_system/composer/composer_helper_lib.hpp index d629fa79f0..c31dfe13b9 100644 --- a/cpp/src/barretenberg/proof_system/composer/composer_helper_lib.hpp +++ b/cpp/src/barretenberg/proof_system/composer/composer_helper_lib.hpp @@ -1,8 +1,6 @@ #pragma once +#include #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" -#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" -#include "barretenberg/polynomials/polynomial_arithmetic.hpp" -#include "barretenberg/polynomials/polynomial.hpp" namespace proof_system { @@ -18,20 +16,57 @@ namespace proof_system { */ template std::shared_ptr initialize_proving_key(const CircuitConstructor& circuit_constructor, - proof_system::ReferenceStringFactory* crs_factory, + ReferenceStringFactory* crs_factory, const size_t minimum_circuit_size, const size_t num_randomized_gates, - proof_system::ComposerType composer_type); + ComposerType composer_type) +{ + const size_t num_gates = circuit_constructor.num_gates; + std::span public_inputs = circuit_constructor.public_inputs; + + const size_t num_public_inputs = public_inputs.size(); + const size_t num_constraints = num_gates + num_public_inputs; + const size_t total_num_constraints = std::max(minimum_circuit_size, num_constraints); + const size_t subgroup_size = + circuit_constructor.get_circuit_subgroup_size(total_num_constraints + num_randomized_gates); // next power of 2 + + auto crs = crs_factory->get_prover_crs(subgroup_size + 1); + + return std::make_shared(subgroup_size, num_public_inputs, crs, composer_type); +} /** - * @brief Construct lagrange selector polynomials from circuit selector information and put into polynomial cache + * @brief Construct lagrange selector polynomials from ciruit selector information and put into polynomial cache * * @tparam CircuitConstructor The class holding the circuit * @param circuit_constructor The object holding the circuit * @param key Pointer to the proving key */ template -void construct_lagrange_selector_forms(const CircuitConstructor& circuit_constructor, plonk::proving_key* key); +void construct_lagrange_selector_forms(const CircuitConstructor& circuit_constructor, + plonk::proving_key* circuit_proving_key) +{ + const size_t num_public_inputs = circuit_constructor.public_inputs.size(); + for (size_t j = 0; j < circuit_constructor.num_selectors; ++j) { + std::span selector_values = circuit_constructor.selectors[j]; + ASSERT(circuit_proving_key->circuit_size >= selector_values.size()); + + // Compute selector vector, initialized to 0. + // Copy the selector values for all gates, keeping the rows at which we store public inputs as 0. + // Initializing the polynomials in this way automatically applies 0-padding to the selectors. + barretenberg::polynomial selector_poly_lagrange(circuit_proving_key->circuit_size); + for (size_t i = 0; i < selector_values.size(); ++i) { + selector_poly_lagrange[num_public_inputs + i] = selector_values[i]; + } + // TODO(#217)(Adrian): We may want to add a unique value (e.g. j+1) in the last position of each selector + // polynomial to guard against some edge cases that may occur during the MSM. If we do so, we should ensure that + // this does not clash with any other values we want to place at the end of of the witness vectors. In later + // iterations of the Sumcheck, we will be able to efficiently cancel out any checks in the last 2^k rows, so any + // randomness or unique values should be placed there. + circuit_proving_key->polynomial_store.put(circuit_constructor.selector_names_[j] + "_lagrange", + std::move(selector_poly_lagrange)); + } +} /** * @brief Fill the last index of each selector polynomial in lagrange form with a non-zero value @@ -41,17 +76,17 @@ void construct_lagrange_selector_forms(const CircuitConstructor& circuit_constru * @param key Pointer to the proving key */ template -void enforce_nonzero_polynomial_selectors(const CircuitConstructor& circuit_constructor, plonk::proving_key* key); - -// /** -// * @brief Retrieve lagrange forms of selector polynomials and compute monomial and coset-monomial forms and put into -// * cache -// * -// * @param key Pointer to the proving key -// * @param selector_properties Names of selectors -// */ -// void compute_monomial_and_coset_selector_forms(plonk::proving_key* key, -// std::vector selector_properties); +void enforce_nonzero_polynomial_selectors(const CircuitConstructor& circuit_constructor, + plonk::proving_key* circuit_proving_key) +{ + for (size_t j = 0; j < circuit_constructor.num_selectors; ++j) { + auto current_selector = + circuit_proving_key->polynomial_store.get(circuit_constructor.selector_names_[j] + "_lagrange"); + current_selector[current_selector.size() - 1] = j + 1; + circuit_proving_key->polynomial_store.put(circuit_constructor.selector_names_[j] + "_lagrange", + std::move(current_selector)); + } +} /** * Compute witness polynomials (w_1, w_2, w_3, w_4) and put them into polynomial cache @@ -65,15 +100,53 @@ void enforce_nonzero_polynomial_selectors(const CircuitConstructor& circuit_cons template std::vector compute_witness_base(const CircuitConstructor& circuit_constructor, const size_t minimum_circuit_size, - const size_t number_of_randomized_gates); + const size_t number_of_randomized_gates) +{ + const size_t program_width = CircuitConstructor::program_width; + const size_t num_gates = circuit_constructor.num_gates; + std::span public_inputs = circuit_constructor.public_inputs; + const size_t num_public_inputs = public_inputs.size(); + + const size_t num_constraints = std::max(minimum_circuit_size, num_gates + num_public_inputs); + // TODO(#216)(Adrian): Not a fan of specifying NUM_RANDOMIZED_GATES everywhere, + // Each flavor of Honk should have a "fixed" number of random places to add randomness to. + // It should be taken care of in as few places possible. + const size_t subgroup_size = + circuit_constructor.get_circuit_subgroup_size(num_constraints + number_of_randomized_gates); + + // construct a view over all the wire's variable indices + // w[j][i] is the index of the variable in the j-th wire, at gate i + // Each array should be of size `num_gates` + std::array, program_width> w; + w[0] = circuit_constructor.w_l; + w[1] = circuit_constructor.w_r; + w[2] = circuit_constructor.w_o; + if constexpr (program_width > 3) { + w[3] = circuit_constructor.w_4; + } + std::vector wires; + // Note: randomness is added to 3 of the last 4 positions in plonk/proof_system/prover/prover.cpp + // StandardProverBase::execute_preamble_round(). + for (size_t j = 0; j < program_width; ++j) { + // Initialize the polynomial with all the actual copies variable values + // Expect all values to be set to 0 initially + barretenberg::polynomial w_lagrange(subgroup_size); -// /** -// * @brief Computes the verification key by computing the: -// * (1) commitments to the selector, permutation, and lagrange (first/last) polynomials, -// * (2) sets the polynomial manifest using the data from proving key. -// */ -// std::shared_ptr compute_verification_key_common( -// std::shared_ptr const& proving_key, std::shared_ptr -// const& vrs); + // Place all public inputs at the start of w_l and w_r. + // All selectors at these indices are set to 0 so these values are not constrained at all. + if ((j == 0) || (j == 1)) { + for (size_t i = 0; i < num_public_inputs; ++i) { + w_lagrange[i] = circuit_constructor.get_variable(public_inputs[i]); + } + } + // Assign the variable values (which are pointed-to by the `w_` wires) to the wire witness polynomials + // `poly_w_`, shifted to make room for the public inputs at the beginning. + for (size_t i = 0; i < num_gates; ++i) { + w_lagrange[num_public_inputs + i] = circuit_constructor.get_variable(w[j][i]); + } + wires.push_back(std::move(w_lagrange)); + } + return wires; +} } // namespace proof_system diff --git a/cpp/src/barretenberg/proof_system/composer/permutation_helper.hpp b/cpp/src/barretenberg/proof_system/composer/permutation_helper.hpp index 6fb9de5540..793204ea11 100644 --- a/cpp/src/barretenberg/proof_system/composer/permutation_helper.hpp +++ b/cpp/src/barretenberg/proof_system/composer/permutation_helper.hpp @@ -453,7 +453,8 @@ inline void compute_first_and_last_lagrange_polynomials(auto key) // proving_key * @return std::array, program_width> */ template -void compute_plonk_generalized_sigma_permutations(const CircuitConstructor& circuit_constructor, bonk::proving_key* key) +void compute_plonk_generalized_sigma_permutations(const CircuitConstructor& circuit_constructor, + plonk::proving_key* key) { // Compute wire copy cycles for public and private variables auto wire_copy_cycles = compute_wire_copy_cycles(circuit_constructor); diff --git a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp index c0221dd22f..a068cce790 100644 --- a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp +++ b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp @@ -13,7 +13,7 @@ using Polynomial = barretenberg::Polynomial; // Test basic put and get functionality TEST(PolynomialStore, PutThenGet) { - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; // Instantiate a polynomial with random coefficients Polynomial poly(1024); @@ -34,7 +34,7 @@ TEST(PolynomialStore, PutThenGet) // Ensure that attempt to access non-existent key throws out_of_range exception TEST(PolynomialStore, NonexistentKey) { - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; polynomial_store.put("id_1", Polynomial(100)); @@ -46,7 +46,7 @@ TEST(PolynomialStore, NonexistentKey) // Ensure correct calculation of volume in bytes TEST(PolynomialStore, Volume) { - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; size_t size1 = 100; size_t size2 = 10; size_t size3 = 5000; @@ -69,7 +69,7 @@ TEST(PolynomialStore, Volume) // Ensure that the remove method erases entry and reduces memory TEST(PolynomialStore, Remove) { - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; size_t size1 = 100; size_t size2 = 500; Polynomial poly1(size1); @@ -93,7 +93,7 @@ TEST(PolynomialStore, Remove) // Check that PolynomialStore supports range based for loop TEST(PolynomialStore, RangeBasedFor) { - proof_system::PolynomialStore polynomial_store; + PolynomialStore polynomial_store; size_t size = 100; Polynomial poly1(size); Polynomial poly2(size); @@ -102,7 +102,7 @@ TEST(PolynomialStore, RangeBasedFor) polynomial_store.put("id_2", std::move(poly2)); // Check that PolynomialStore meets criteria for std::ranges::range - EXPECT_TRUE(std::ranges::range>); + EXPECT_TRUE(std::ranges::range>); // For example ... Polynomial polynomial_sum(size); diff --git a/cpp/src/barretenberg/proof_system/types/composer_type.hpp b/cpp/src/barretenberg/proof_system/types/composer_type.hpp index 6a19c8fe4d..3521715cd4 100644 --- a/cpp/src/barretenberg/proof_system/types/composer_type.hpp +++ b/cpp/src/barretenberg/proof_system/types/composer_type.hpp @@ -2,11 +2,5 @@ namespace proof_system { // This will go away, but we move it here has a temporary measure to make proof_system not depend on honk or plonk. -enum ComposerType { - STANDARD, - TURBO, - PLOOKUP, - STANDARD_HONK, // Todo(Arijit): We should replace STANDARD_HONK outside plonk or the namespace should be - // proof_system -}; +enum ComposerType { STANDARD, TURBO, PLOOKUP, STANDARD_HONK }; } // namespace proof_system \ No newline at end of file diff --git a/cpp/src/barretenberg/proof_system/work_queue/work_queue.hpp b/cpp/src/barretenberg/proof_system/work_queue/work_queue.hpp index ad0176723f..4cbf548149 100644 --- a/cpp/src/barretenberg/proof_system/work_queue/work_queue.hpp +++ b/cpp/src/barretenberg/proof_system/work_queue/work_queue.hpp @@ -4,7 +4,7 @@ #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" namespace proof_system { -// TODO(Cody): Template by flavor +// TODO(Cody): Template by flavor? class work_queue { public: diff --git a/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index bfd5b43d2c..6e99674ba9 100644 --- a/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp @@ -16,8 +16,8 @@ namespace stdlib { namespace aes128 { constexpr uint32_t AES128_BASE = 9; -typedef proof_system::plonk::stdlib::field_t field_t; -typedef proof_system::plonk::stdlib::witness_t witness_t; +typedef stdlib::field_t field_t; +typedef stdlib::witness_t witness_t; typedef std::pair byte_pair; diff --git a/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp b/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp index 1b315039c3..da1fc78a6d 100644 --- a/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp +++ b/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp @@ -11,8 +11,8 @@ using namespace proof_system::plonk; TEST(stdlib_aes128, encrypt_64_bytes) { - typedef proof_system::plonk::stdlib::field_t field_pt; - typedef proof_system::plonk::stdlib::witness_t witness_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::witness_t witness_pt; uint8_t key[16]{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }; uint8_t out[64]{ 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d, @@ -34,7 +34,7 @@ TEST(stdlib_aes128, encrypt_64_bytes) return converted; }; - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); std::vector in_field{ witness_pt(&composer, fr(convert_bytes(in))), @@ -50,7 +50,7 @@ TEST(stdlib_aes128, encrypt_64_bytes) convert_bytes(out), convert_bytes(out + 16), convert_bytes(out + 32), convert_bytes(out + 48) }; - const auto result = proof_system::plonk::stdlib::aes128::encrypt_buffer_cbc(in_field, iv_field, key_field); + const auto result = stdlib::aes128::encrypt_buffer_cbc(in_field, iv_field, key_field); for (size_t i = 0; i < 4; ++i) { EXPECT_EQ(result[i].get_value(), expected[i]); diff --git a/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp b/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp index e0bb6ccb61..12355453d6 100644 --- a/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp +++ b/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp @@ -33,7 +33,7 @@ bool_t verify_signature(const stdlib::byte_array& message, Fr u2 = r / s; G1 result; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { ASSERT(Curve::type == proof_system::CurveType::SECP256K1); public_key.validate_on_curve(); result = G1::secp256k1_ecdsa_mul(public_key, u1, u2); diff --git a/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp b/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp index ac889f2bf9..86f419095c 100644 --- a/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp +++ b/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp @@ -119,12 +119,12 @@ point variable_base_mul(const point& pub_key, const field_t& low_bits, field_t zero_test = (low_bits * high_bits); zero_test.assert_is_not_zero(); - const auto low_wnaf = proof_system::plonk::stdlib::schnorr::convert_field_into_wnaf(context, low_bits); - const auto high_wnaf = proof_system::plonk::stdlib::schnorr::convert_field_into_wnaf(context, high_bits); + const auto low_wnaf = stdlib::schnorr::convert_field_into_wnaf(context, low_bits); + const auto high_wnaf = stdlib::schnorr::convert_field_into_wnaf(context, high_bits); // current_accumulator is pub_key, so init is true, so high_output is [high_wnaf]pub_key - point high_output = proof_system::plonk::stdlib::schnorr::variable_base_mul(pub_key, pub_key, high_wnaf); + point high_output = stdlib::schnorr::variable_base_mul(pub_key, pub_key, high_wnaf); // compute output = [low_wnaf]pub_key + [2^128]high_output. - point output = proof_system::plonk::stdlib::schnorr::variable_base_mul(pub_key, high_output, low_wnaf); + point output = stdlib::schnorr::variable_base_mul(pub_key, high_output, low_wnaf); return output; } diff --git a/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.cpp b/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.cpp index 0197765143..dfbacf2baf 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.cpp +++ b/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.cpp @@ -119,7 +119,7 @@ template void blake2s(blake2s_state& S, byte_array template byte_array blake2s(const byte_array& input) { - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { return blake2s_plookup::blake2s(input); } diff --git a/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp b/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp index 387b42ddf2..b61cbc305d 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp +++ b/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp @@ -39,7 +39,7 @@ TEST(stdlib_blake2s, test_single_block) TEST(stdlib_blake2s, test_single_block_plookup) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); std::string input = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; std::vector input_v(input.begin(), input.end()); @@ -87,7 +87,7 @@ TEST(stdlib_blake2s, test_double_block) TEST(stdlib_blake2s, test_double_block_plookup) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); std::string input = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"; std::vector input_v(input.begin(), input.end()); diff --git a/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.cpp b/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.cpp index a9e85132d0..dad4d64204 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.cpp +++ b/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.cpp @@ -246,7 +246,7 @@ using namespace blake3_internal; template byte_array blake3s(const byte_array& input) { - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { return blake3s_plookup::blake3s(input); } diff --git a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp index 39202840f3..d0ebf02f5a 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp +++ b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp @@ -225,8 +225,8 @@ point pedersen::hash_single(const field_t& in, if (i > 0) { gates.create_fixed_group_add_gate(round_quad); } else { - if constexpr (C::type == proof_system::ComposerType::PLOOKUP && - C::merkle_hash_type == proof_system::plonk::MerkleHashType::FIXED_BASE_PEDERSEN) { + if constexpr (C::type == ComposerType::PLOOKUP && + C::merkle_hash_type == MerkleHashType::FIXED_BASE_PEDERSEN) { /* In TurboComposer, the selector q_5 is used to show that w_1 and w_2 are properly initialized to the * coordinates of P_s = (-s + 4^n)[g]. In UltraPlonK, we have removed q_5 for overall efficiency (it * would only be used here in this gate), but this presents us a cost in the present circuit: we must @@ -463,7 +463,7 @@ template void pedersen::validate_wnaf_is_in_field(C* ctx, const field_t y_lo = (-reconstructed_input).add_two(high_limb_with_skew * shift + (r_lo + shift), is_even); field_t y_overlap; - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { // carve out the 2 high bits from y_lo and instantiate as y_overlap const uint256_t y_lo_value = y_lo.get_value(); const uint256_t y_overlap_value = y_lo_value >> 126; diff --git a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp index d428cd8eab..c2cf7957ef 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp +++ b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp @@ -12,10 +12,10 @@ constexpr uint64_t WNAF_MASK = crypto::pedersen::WNAF_MASK; template class pedersen { private: - typedef proof_system::plonk::stdlib::field_t field_t; - typedef proof_system::plonk::stdlib::point point; - typedef proof_system::plonk::stdlib::byte_array byte_array; - typedef proof_system::plonk::stdlib::bool_t bool_t; + typedef stdlib::field_t field_t; + typedef stdlib::point point; + typedef stdlib::byte_array byte_array; + typedef stdlib::bool_t bool_t; static point hash_single(const field_t& in, const crypto::pedersen::generator_index_t hash_index, diff --git a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp index 1dc5d64192..5450ab5b8f 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp +++ b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp @@ -454,7 +454,7 @@ typedef stdlib::field_t field_ct; typedef stdlib::witness_t witness_ct; TEST(stdlib_pedersen, test_pedersen_plookup) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); fr left_in = fr::random_element(); fr right_in = fr::random_element(); @@ -481,7 +481,7 @@ TEST(stdlib_pedersen, test_pedersen_plookup) TEST(stdlib_pedersen, test_compress_many_plookup) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); std::vector input_values{ fr::random_element(), fr::random_element(), fr::random_element(), @@ -513,7 +513,7 @@ TEST(stdlib_pedersen, test_compress_many_plookup) TEST(stdlib_pedersen, test_merkle_damgard_compress_plookup) { - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); std::vector input_values{ fr::random_element(), fr::random_element(), fr::random_element(), diff --git a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_gates.hpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_gates.hpp index 6f23139529..96a55974df 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_gates.hpp +++ b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_gates.hpp @@ -25,7 +25,7 @@ template class pedersen_gates { using fixed_group_add_quad = proof_system::fixed_group_add_quad; using fixed_group_init_quad = proof_system::fixed_group_init_quad; using add_quad = proof_system::add_quad; - using ComposerType = proof_system::ComposerType; + using ComposerType = ComposerType; Composer* context; fixed_group_add_quad previous_add_quad; @@ -36,7 +36,7 @@ template class pedersen_gates { void create_fixed_group_add_gate(const fixed_group_add_quad& in) { - if constexpr (Composer::type == proof_system::ComposerType::TURBO) { + if constexpr (Composer::type == ComposerType::TURBO) { context->create_fixed_group_add_gate(in); } else { @@ -229,7 +229,7 @@ template class pedersen_gates { void create_fixed_group_add_gate_with_init(const fixed_group_add_quad& in, const fixed_group_init_quad& init) { - if constexpr (Composer::type == proof_system::ComposerType::TURBO) { + if constexpr (Composer::type == ComposerType::TURBO) { context->create_fixed_group_add_gate_with_init(in, init); } else { uint32_t x_0_idx = in.a; @@ -295,7 +295,7 @@ template class pedersen_gates { void create_fixed_group_add_gate_final(const add_quad& in) { - if constexpr (Composer::type == proof_system::ComposerType::TURBO) { + if constexpr (Composer::type == ComposerType::TURBO) { context->create_fixed_group_add_gate_final(in); } else { diff --git a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.hpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.hpp index 5b10abe606..2d14bf73cb 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.hpp +++ b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.hpp @@ -9,10 +9,10 @@ namespace stdlib { template class pedersen_plookup { private: - typedef proof_system::plonk::stdlib::field_t field_t; - typedef proof_system::plonk::stdlib::point point; - typedef proof_system::plonk::stdlib::packed_byte_array packed_byte_array; - typedef proof_system::plonk::stdlib::bool_t bool_t; + typedef stdlib::field_t field_t; + typedef stdlib::point point; + typedef stdlib::packed_byte_array packed_byte_array; + typedef stdlib::bool_t bool_t; enum AddType { LAMBDA, diff --git a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.cpp b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.cpp index 35863d05d2..22bc5ac9de 100644 --- a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.cpp +++ b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.cpp @@ -139,7 +139,7 @@ template byte_array sha256_block(const byte_array< template packed_byte_array sha256(const packed_byte_array& input) { - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { return sha256_plookup::sha256(input); } typedef field_t field_pt; diff --git a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp index fae71f980c..9379e2382a 100644 --- a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp +++ b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp @@ -16,6 +16,7 @@ auto& engine = numeric::random::get_debug_engine(); namespace test_stdlib_sha256 { using namespace barretenberg; +using namespace proof_system::plonk; using namespace proof_system::plonk::stdlib::types; constexpr uint64_t ror(uint64_t val, uint64_t shift) @@ -111,7 +112,7 @@ std::array inner_block(std::array& w) TEST(stdlib_sha256, test_duplicate_proving_key) { - plonk::StandardComposer first_composer = proof_system::plonk::StandardComposer(); + plonk::StandardComposer first_composer = StandardComposer(); stdlib::packed_byte_array input(&first_composer, "An 8 character password? Snow White and the 7 Dwarves.."); plonk::stdlib::sha256(input); auto prover = first_composer.create_prover(); @@ -124,8 +125,7 @@ TEST(stdlib_sha256, test_duplicate_proving_key) auto circuit_size = prover.circuit_size; // Test a second time with same keys and different input. - plonk::StandardComposer second_composer = - proof_system::plonk::StandardComposer(proving_key, verification_key, circuit_size); + plonk::StandardComposer second_composer = StandardComposer(proving_key, verification_key, circuit_size); stdlib::packed_byte_array input2(&second_composer, "An 8 character password? Snow White and the 9 Dwarves.."); plonk::stdlib::sha256(input2); auto second_prover = second_composer.create_prover(); @@ -138,14 +138,14 @@ TEST(stdlib_sha256, test_duplicate_proving_key) // TEST(stdlib_sha256_plookup, test_round) // { -// plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); +// plonk::UltraComposer composer = UltraComposer(); // std::array w_inputs; // std::array, 64> w_elements; // for (size_t i = 0; i < 64; ++i) { // w_inputs[i] = engine.get_random_uint32(); -// w_elements[i] = proof_system::plonk::stdlib::witness_t(&composer, +// w_elements[i] = stdlib::witness_t(&composer, // barretenberg::fr(w_inputs[i])); // } @@ -169,15 +169,15 @@ TEST(stdlib_sha256, test_duplicate_proving_key) TEST(stdlib_sha256, test_plookup_55_bytes) { - typedef proof_system::plonk::stdlib::field_t field_pt; - typedef proof_system::plonk::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; // 55 bytes is the largest number of bytes that can be hashed in a single block, // accounting for the single padding bit, and the 64 size bits required by the SHA-256 standard. - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); packed_byte_array_pt input(&composer, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_pt output_bits = proof_system::plonk::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -208,7 +208,7 @@ TEST(stdlib_sha256, test_55_bytes) Composer composer = Composer(); packed_byte_array_ct input(&composer, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + packed_byte_array_ct output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -234,13 +234,13 @@ TEST(stdlib_sha256, test_55_bytes) TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) { - typedef proof_system::plonk::stdlib::field_t field_pt; - typedef proof_system::plonk::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); packed_byte_array_pt input(&composer, "abc"); - packed_byte_array_pt output_bytes = proof_system::plonk::stdlib::sha256(input); + packed_byte_array_pt output_bytes = stdlib::sha256(input); std::vector output = output_bytes.to_unverified_byte_slices(4); EXPECT_EQ(uint256_t(output[0].get_value()).data[0], (uint64_t)0xBA7816BFU); EXPECT_EQ(uint256_t(output[1].get_value()).data[0], (uint64_t)0x8F01CFEAU); @@ -265,14 +265,14 @@ TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) TEST(stdlib_sha256, test_NIST_vector_one) { - typedef proof_system::plonk::stdlib::field_t field_pt; - typedef proof_system::plonk::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); packed_byte_array_pt input(&composer, "abc"); - packed_byte_array_pt output_bits = proof_system::plonk::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -303,7 +303,7 @@ TEST(stdlib_sha256, test_NIST_vector_two) byte_array_ct input(&composer, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); - byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -335,7 +335,7 @@ TEST(stdlib_sha256, test_NIST_vector_three) // one byte, 0xbd byte_array_ct input(&composer, std::vector{ 0xbd }); - byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -366,7 +366,7 @@ TEST(stdlib_sha256, test_NIST_vector_four) // 4 bytes, 0xc98c8e55 byte_array_ct input(&composer, std::vector{ 0xc9, 0x8c, 0x8e, 0x55 }); - byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -392,10 +392,10 @@ TEST(stdlib_sha256, test_NIST_vector_four) HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) { - typedef proof_system::plonk::stdlib::field_t field_pt; - typedef proof_system::plonk::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - plonk::UltraComposer composer = proof_system::plonk::UltraComposer(); + plonk::UltraComposer composer = UltraComposer(); packed_byte_array_pt input( &composer, @@ -410,7 +410,7 @@ HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" "AAAAAAAAAA"); - packed_byte_array_pt output_bits = proof_system::plonk::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -444,7 +444,7 @@ TEST(stdlib_sha256, test_input_len_multiple) auto input_buf = std::vector(inp, 1); byte_array_ct input(&composer, input_buf); - byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); auto circuit_output = output_bits.get_value(); @@ -488,7 +488,7 @@ TEST(stdlib_sha256, test_input_str_len_multiple) auto input_buf = std::vector(input_str.begin(), input_str.end()); byte_array_ct input(&composer, input_buf); - byte_array_ct output_bits = proof_system::plonk::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); auto circuit_output = output_bits.get_value(); diff --git a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_all.fuzzer.cpp index 1640d10ec4..17c7879e0c 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "bigfield.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp index 33879aa4d1..218576684e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp @@ -56,7 +56,7 @@ bigfield::bigfield(const field_t& low_bits_in, field_t limb_3(context); if (low_bits_in.witness_index != IS_CONSTANT) { std::vector low_accumulator; - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { // MERGE NOTE: this was the if constexpr block introduced in ecebe7643 const auto limb_witnesses = context->decompose_non_native_field_double_width_limb(low_bits_in.normalize().witness_index); @@ -107,7 +107,7 @@ bigfield::bigfield(const field_t& low_bits_in, if (high_bits_in.witness_index != IS_CONSTANT) { std::vector high_accumulator; - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { const auto limb_witnesses = context->decompose_non_native_field_double_width_limb( high_bits_in.normalize().witness_index, (size_t)num_high_limb_bits); limb_2.witness_index = limb_witnesses[0]; @@ -187,7 +187,7 @@ bigfield bigfield::create_from_u512_as_witness(C* ctx, limbs[2] = value.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3).lo; limbs[3] = value.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4).lo; - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { field_t limb_0(ctx); field_t limb_1(ctx); field_t limb_2(ctx); @@ -384,7 +384,7 @@ template bigfield bigfield::operator+(const result.binary_basis_limbs[3].maximum_value = binary_basis_limbs[3].maximum_value + other.binary_basis_limbs[3].maximum_value; - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { if (prime_basis_limb.multiplicative_constant == 1 && other.prime_basis_limb.multiplicative_constant == 1 && !is_constant() && !other.is_constant()) { bool limbconst = binary_basis_limbs[0].element.is_constant(); @@ -592,7 +592,7 @@ template bigfield bigfield::operator-(const result.binary_basis_limbs[2].element = binary_basis_limbs[2].element + barretenberg::fr(to_add_2); result.binary_basis_limbs[3].element = binary_basis_limbs[3].element + barretenberg::fr(to_add_3); - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { if (result.prime_basis_limb.multiplicative_constant == 1 && other.prime_basis_limb.multiplicative_constant == 1 && !result.is_constant() && !other.is_constant()) { bool limbconst = result.binary_basis_limbs[0].element.is_constant(); @@ -1645,7 +1645,7 @@ template void bigfield::assert_is_in_field() cons r1 = r1.normalize(); r2 = r2.normalize(); r3 = r3.normalize(); - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { context->decompose_into_default_range(r0.witness_index, static_cast(NUM_LIMB_BITS)); context->decompose_into_default_range(r1.witness_index, static_cast(NUM_LIMB_BITS)); context->decompose_into_default_range(r2.witness_index, static_cast(NUM_LIMB_BITS)); @@ -1778,7 +1778,7 @@ template void bigfield::self_reduce() const // TODO: implicit assumption here - NUM_LIMB_BITS large enough for all the quotient uint32_t quotient_limb_index = context->add_variable(barretenberg::fr(quotient_value.lo)); field_t quotient_limb = field_t::from_witness_index(context, quotient_limb_index); - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { context->decompose_into_default_range(quotient_limb.witness_index, static_cast(maximum_quotient_bits)); } else { context->decompose_into_base4_accumulators(quotient_limb.witness_index, @@ -1880,7 +1880,7 @@ void bigfield::unsafe_evaluate_multiply_add(const bigfield& input_left, ++max_hi_bits; } - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { // The plookup custom bigfield gate requires inputs are witnesses. // If we're using constant values, instantiate them as circuit variables const auto convert_constant_to_witness = [ctx](const bigfield& input) { @@ -2238,7 +2238,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vector::unsafe_evaluate_multiple_multiply_add(const std::vectordecompose_into_default_range(lo.normalize().witness_index, carry_lo_msb); } /* NOTE TO AUDITOR: An extraneous block - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { carry_lo = carry_lo.normalize(); carry_hi = carry_hi.normalize(); ctx->decompose_into_default_range(carry_lo.witness_index, static_cast(carry_lo_msb)); @@ -2604,7 +2604,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vectordecompose_into_default_range(carry_lo.witness_index, static_cast(carry_lo_msb)); @@ -2643,7 +2643,7 @@ void bigfield::unsafe_evaluate_square_add(const bigfield& left, const bigfield& quotient, const bigfield& remainder) { - if (C::type == proof_system::ComposerType::PLOOKUP) { + if (C::type == ComposerType::PLOOKUP) { unsafe_evaluate_multiply_add(left, left, to_add, quotient, { remainder }); return; } @@ -2764,7 +2764,7 @@ void bigfield::unsafe_evaluate_square_add(const bigfield& left, const uint64_t carry_hi_msb = max_hi_bits - (2 * NUM_LIMB_BITS); const barretenberg::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); - if constexpr (C::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type == ComposerType::PLOOKUP) { carry_lo = carry_lo.normalize(); carry_hi = carry_hi.normalize(); ctx->decompose_into_default_range(carry_lo.witness_index, static_cast(carry_lo_msb)); diff --git a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_standard.fuzzer.cpp index ff5310e283..58cb089452 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "bigfield.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_turbo.fuzzer.cpp index 4b03fdb19b..246321c8f9 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "bigfield.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp index e0c68ce25d..29d8e472c1 100644 --- a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp @@ -393,17 +393,14 @@ template class element { std::array, 5> coordinates; }; - using twin_lookup_table = typename std::conditional, - lookup_table_base<2>>::type; + using twin_lookup_table = typename std:: + conditional, lookup_table_base<2>>::type; - using triple_lookup_table = typename std::conditional, - lookup_table_base<3>>::type; + using triple_lookup_table = typename std:: + conditional, lookup_table_base<3>>::type; - using quad_lookup_table = typename std::conditional, - lookup_table_base<4>>::type; + using quad_lookup_table = typename std:: + conditional, lookup_table_base<4>>::type; /** * Creates a pair of 4-bit lookup tables, the former corresponding to 4 input points, @@ -416,7 +413,7 @@ template class element { quad_lookup_table endo_table; uint256_t beta_val = barretenberg::field::cube_root_of_unity(); Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { for (size_t i = 0; i < 8; ++i) { endo_table.element_table[i + 8].x = base_table[7 - i].x * beta; endo_table.element_table[i + 8].y = base_table[7 - i].y; @@ -449,7 +446,7 @@ template class element { lookup_table_plookup<5> endo_table; uint256_t beta_val = barretenberg::field::cube_root_of_unity(); Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { for (size_t i = 0; i < 16; ++i) { endo_table.element_table[i + 16].x = base_table[15 - i].x * beta; endo_table.element_table[i + 16].y = base_table[15 - i].y; @@ -938,7 +935,7 @@ template class element { bool has_singleton; }; - using batch_lookup_table = typename std::conditional, batch_lookup_table_base>::type; }; diff --git a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp index 3ea4326238..32eb7d5b80 100644 --- a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp @@ -900,7 +900,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, double_montgomery_ladder) HEAVY_TYPED_TEST(stdlib_biggroup, compute_naf) { // ULTRATODO: make this work for secp curves - if constexpr (TypeParam::Curve::type == proof_system::CurveType::BN254) { + if constexpr (TypeParam::Curve::type == CurveType::BN254) { size_t num_repetitions = 1; for (size_t i = 0; i < num_repetitions; i++) { TestFixture::test_compute_naf(); @@ -913,7 +913,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, compute_naf) /* These tests only work for UltraComposer */ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_batch_mul) { - if constexpr (TypeParam::Curve::Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (TypeParam::Curve::Composer::type == ComposerType::PLOOKUP) { TestFixture::test_compute_wnaf(); } else { GTEST_SKIP(); @@ -924,8 +924,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_batch_mul) Fr is a bigfield. */ HEAVY_TYPED_TEST(stdlib_biggroup, compute_wnaf) { - if constexpr (TypeParam::Curve::Composer::type != proof_system::plonk::UltraComposer::type && - TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::Composer::type != UltraComposer::type && TypeParam::use_bigfield) { GTEST_SKIP(); } else { TestFixture::test_compute_wnaf(); @@ -962,7 +961,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_batch_4) /* The following tests are specific to BN254 and don't work when Fr is a bigfield */ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) { - if constexpr (TypeParam::Curve::type == proof_system::CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { TestFixture::test_bn254_endo_batch_mul(); } else { GTEST_SKIP(); @@ -970,7 +969,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) } HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) { - if constexpr (TypeParam::Curve::type == proof_system::CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { TestFixture::test_mixed_mul_bn254_endo(); } else { GTEST_SKIP(); @@ -980,7 +979,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) /* The following tests are specific to SECP256k1 */ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) { - if constexpr (TypeParam::Curve::type == proof_system::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_wnaf_secp256k1(); } else { GTEST_SKIP(); @@ -988,7 +987,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) { - if constexpr (TypeParam::Curve::type == proof_system::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_wnaf_8bit_secp256k1(); } else { GTEST_SKIP(); @@ -996,7 +995,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, ecdsa_mul_secp256k1) { - if constexpr (TypeParam::Curve::type == proof_system::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_ecdsa_mul_secp256k1(); } else { GTEST_SKIP(); diff --git a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_batch_mul.hpp b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_batch_mul.hpp index e0787df4b9..c237d0dfbb 100644 --- a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_batch_mul.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_batch_mul.hpp @@ -15,7 +15,7 @@ element element::wnaf_batch_mul(const std::vector element::bn254_endo_batch_mul_with_generator break; } } - if constexpr (C::type != proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type != ComposerType::PLOOKUP) { // MERGENOTE: these four lines don't have an equivalent in d-b-p std::vector modified_big_points = big_points; std::vector modified_big_scalars = big_scalars; diff --git a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_secp256k1.hpp b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_secp256k1.hpp index a003cc18d2..7d510e2794 100644 --- a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_secp256k1.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_secp256k1.hpp @@ -12,7 +12,7 @@ template template element element::secp256k1_ecdsa_mul(const element& pubkey, const Fr& u1, const Fr& u2) { - if constexpr (C::type != proof_system::ComposerType::PLOOKUP) { + if constexpr (C::type != ComposerType::PLOOKUP) { C* ctx = pubkey.get_context(); return batch_mul({ element::one(ctx), pubkey }, { u1, u2 }); } diff --git a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_all.fuzzer.cpp index 3a86b2c975..b0c2dea8de 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "bit_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_standard.fuzzer.cpp index c5bfb25570..ff0629b20c 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "bit_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_turbo.fuzzer.cpp index c79b7a7c64..a2bb62031e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "bit_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp b/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp index bd0d877e45..d080f06f10 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp @@ -26,7 +26,7 @@ TEST(stdlib_bool, test_basic_operations) bool_t f = e ^ b; // f = 0 d = (!f) & a; // d = 1 auto prover = composer.create_prover(); - // if constexpr (Composer::type == proof_system::ComposerType::STANDARD_HONK) { + // if constexpr (Composer::type == ComposerType::STANDARD_HONK) { EXPECT_EQ(prover.wire_polynomials[0][3], fr(1)); EXPECT_EQ(prover.wire_polynomials[1][3], fr(1)); EXPECT_EQ(prover.wire_polynomials[2][3], fr(1)); diff --git a/cpp/src/barretenberg/stdlib/primitives/bool/bool_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bool/bool_all.fuzzer.cpp index 252abe30ce..a4f7758fe3 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bool/bool_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bool/bool_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "bool.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bool/bool_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bool/bool_standard.fuzzer.cpp index 718e749aaf..98c247431f 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bool/bool_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bool/bool_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "bool.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/bool/bool_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/bool/bool_turbo.fuzzer.cpp index a63b35aec6..800fd1059c 100644 --- a/cpp/src/barretenberg/stdlib/primitives/bool/bool_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/bool/bool_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "bool.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp index 5c5abda2c1..d63356bc19 100644 --- a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp @@ -129,7 +129,7 @@ template byte_array::byte_array(const field_t y_lo = (-validator) + (s_lo + shift); field_t y_overlap; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { // carve out the 2 high bits from (y_lo + shifted_high_limb) and instantiate as y_overlap const uint256_t y_lo_value = y_lo.get_value() + shifted_high_limb.get_value(); const uint256_t y_overlap_value = y_lo_value >> 128; diff --git a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_all.fuzzer.cpp index a0cb861f86..6795867726 100644 --- a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "byte_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_standard.fuzzer.cpp index 2d82c10698..c0e04755bc 100644 --- a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "byte_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_turbo.fuzzer.cpp index 1eca2596fb..b24568ea12 100644 --- a/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "byte_array.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/field/field.cpp b/cpp/src/barretenberg/stdlib/primitives/field/field.cpp index 3debcc1824..2a76d24872 100644 --- a/cpp/src/barretenberg/stdlib/primitives/field/field.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/field/field.cpp @@ -739,7 +739,7 @@ void field_t::create_range_constraint(const size_t num_bits, st if (is_constant()) { ASSERT(uint256_t(get_value()).get_msb() < num_bits); } else { - if constexpr (ComposerContext::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (ComposerContext::type == ComposerType::PLOOKUP) { context->decompose_into_default_range( normalize().get_witness_index(), num_bits, plonk::UltraComposer::DEFAULT_PLOOKUP_RANGE_BITNUM, msg); } else { @@ -981,7 +981,7 @@ field_t field_t::accumulate(const std::vector< * * If num elements is not a multiple of 3, the final gate will be padded with zero_idx wires **/ - if constexpr (ComposerContext::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (ComposerContext::type == ComposerType::PLOOKUP) { ComposerContext* ctx = nullptr; std::vector accumulator; field_t constant_term = 0; @@ -1039,7 +1039,7 @@ field_t field_t::accumulate(const std::vector< accumulating_total = witness_t(ctx, new_total); } return total.normalize(); - } else if constexpr (ComposerContext::type == proof_system::ComposerType::TURBO) { + } else if constexpr (ComposerContext::type == ComposerType::TURBO) { field_t total(0); bool odd_number = (input.size() & 0x01UL) == 0x01ULL; diff --git a/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp b/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp index 5a71f5e7ef..b78f492e3e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp @@ -192,7 +192,7 @@ template class stdlib_field : public testing::Test { uint64_t expected = fidget(composer); auto prover = composer.create_prover(); - if constexpr (Composer::type == proof_system::ComposerType::STANDARD_HONK) { + if constexpr (Composer::type == ComposerType::STANDARD_HONK) { EXPECT_EQ(prover.wire_polynomials[2][20], fr(expected)); } else { EXPECT_EQ(prover.key->polynomial_store.get("w_3_lagrange")[18], fr(expected)); @@ -249,7 +249,7 @@ template class stdlib_field : public testing::Test { auto prover = composer.create_prover(); - if constexpr (Composer::type == proof_system::ComposerType::STANDARD_HONK) { + if constexpr (Composer::type == ComposerType::STANDARD_HONK) { EXPECT_EQ(prover.wire_polynomials[2][19], fr(4181)); } else { EXPECT_EQ(prover.key->polynomial_store.get("w_3_lagrange")[17], fr(4181)); diff --git a/cpp/src/barretenberg/stdlib/primitives/field/field_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/field/field_all.fuzzer.cpp index 28ef5e5131..e38059c90e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/field/field_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/field/field_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "field.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/field/field_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/field/field_standard.fuzzer.cpp index fc72bfffdc..16c0b9a117 100644 --- a/cpp/src/barretenberg/stdlib/primitives/field/field_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/field/field_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "field.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/field/field_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/field/field_turbo.fuzzer.cpp index 75cc1ab00e..47952895f8 100644 --- a/cpp/src/barretenberg/stdlib/primitives/field/field_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/field/field_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "field.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp b/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp index d3ae520aa8..47d1d848f0 100644 --- a/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp @@ -3,8 +3,7 @@ #include "../composers/composers.hpp" #include "../plookup/plookup.hpp" -namespace plonk { -namespace stdlib { +namespace proof_system::plonk::stdlib { /** * @brief A logical AND or XOR over a variable number of bits. @@ -90,5 +89,4 @@ field_t logic::create_logic_constraint(field_pt& a, field_pt } } INSTANTIATE_STDLIB_TYPE(logic); -} // namespace stdlib -} // namespace plonk +} // namespace proof_system::plonk::stdlib diff --git a/cpp/src/barretenberg/stdlib/primitives/logic/logic.hpp b/cpp/src/barretenberg/stdlib/primitives/logic/logic.hpp index 16423d3188..2b8b99d560 100644 --- a/cpp/src/barretenberg/stdlib/primitives/logic/logic.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/logic/logic.hpp @@ -1,14 +1,14 @@ #pragma once -#include "../composers/composers_fwd.hpp" -#include "../field/field.hpp" +#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" -namespace plonk { -namespace stdlib { +namespace proof_system::plonk::stdlib { template class logic { private: - typedef field_t field_pt; - typedef witness_t witness_pt; + using field_pt = field_t; + using witness_pt = witness_t; public: static field_pt create_logic_constraint(field_pt& a, field_pt& b, size_t num_bits, bool is_xor_gate); @@ -16,5 +16,4 @@ template class logic { EXTERN_STDLIB_TYPE(logic); -} // namespace stdlib -} // namespace plonk \ No newline at end of file +} // namespace proof_system::plonk::stdlib \ No newline at end of file diff --git a/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp b/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp index 36f0384d2d..bf1dd73e5f 100644 --- a/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp @@ -8,8 +8,6 @@ #include "barretenberg/plonk/composer/turbo_composer.hpp" #include "barretenberg/numeric/random/engine.hpp" -using namespace bonk; - namespace test_stdlib_logic { namespace { @@ -19,7 +17,7 @@ auto& engine = numeric::random::get_debug_engine(); template void ignore_unused(T&) {} // use to ignore unused variables in lambdas using namespace barretenberg; -using namespace plonk; +using namespace proof_system::plonk; template class stdlib_logic : public testing::Test { typedef stdlib::bool_t bool_ct; diff --git a/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.cpp b/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.cpp index af7111f8ff..66937a23ba 100644 --- a/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.cpp @@ -25,7 +25,7 @@ DynamicArray::DynamicArray(Composer* composer, const size_t maximum_si , _max_size(maximum_size) , _length(0) { - static_assert(Composer::type == proof_system::ComposerType::PLOOKUP); + static_assert(Composer::type == ComposerType::PLOOKUP); ASSERT(_context != nullptr); _inner_table = ram_table(_context, maximum_size); // Initialize the ram table with all zeroes diff --git a/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.cpp b/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.cpp index df8237b0cd..f68089e229 100644 --- a/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.cpp @@ -13,7 +13,7 @@ namespace stdlib { */ template ram_table::ram_table(Composer* composer, const size_t table_size) { - static_assert(Composer::type == proof_system::ComposerType::PLOOKUP); + static_assert(Composer::type == ComposerType::PLOOKUP); _context = composer; _length = table_size; _index_initialized.resize(table_size); @@ -35,7 +35,7 @@ template ram_table::ram_table(Composer* composer, */ template ram_table::ram_table(const std::vector& table_entries) { - static_assert(Composer::type == proof_system::ComposerType::PLOOKUP); + static_assert(Composer::type == ComposerType::PLOOKUP); // get the composer _context for (const auto& entry : table_entries) { if (entry.get_context() != nullptr) { diff --git a/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp b/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp index 3d978b23dd..53ed2a80f4 100644 --- a/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp @@ -9,7 +9,7 @@ namespace stdlib { template rom_table::rom_table(const std::vector& table_entries) { - static_assert(Composer::type == proof_system::ComposerType::PLOOKUP); + static_assert(Composer::type == ComposerType::PLOOKUP); // get the composer context for (const auto& entry : table_entries) { if (entry.get_context() != nullptr) { diff --git a/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp b/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp index a890496e9d..e8aaff2af4 100644 --- a/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp @@ -10,7 +10,7 @@ namespace stdlib { template twin_rom_table::twin_rom_table(const std::vector>& table_entries) { - static_assert(Composer::type == proof_system::ComposerType::PLOOKUP); + static_assert(Composer::type == ComposerType::PLOOKUP); // get the composer context for (const auto& entry : table_entries) { if (entry[0].get_context() != nullptr) { diff --git a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_all.fuzzer.cpp index d24c0f897a..d2f2ece246 100644 --- a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "safe_uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_standard.fuzzer.cpp index 085c24f0a0..8e1bd615f6 100644 --- a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "safe_uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_turbo.fuzzer.cpp index f8b22f5540..1ff91bdcee 100644 --- a/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "safe_uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp index 196c9a5753..c471804804 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp @@ -16,7 +16,7 @@ std::vector uint::constrain_accumulators(Composer* c const size_t num_bits, std::string const& msg) const { - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { // TODO: manage higher bit ranges const auto sequence = plookup_read::get_lookup_accumulators(plookup::MultiTableId::UINT32_XOR, @@ -317,7 +317,7 @@ template bool_t uintget_variable(right_idx)) - uint256_t(context->get_variable(left_idx)) * uint256_t(4); - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { uint256_t lo_bit = quad & 1; uint256_t hi_bit = (quad & 2) >> 1; // difference in quads = 0, 1, 2, 3 = delta diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp index 3b61778464..44f82f8b7b 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp @@ -194,19 +194,19 @@ template inline std::ostream& operator<<(std::ostream& } template -using uint8 = typename std::conditional, uint>::type; template -using uint16 = typename std::conditional, uint>::type; template -using uint32 = typename std::conditional, uint>::type; template -using uint64 = typename std::conditional, uint>::type; diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp index 2c4b8b29b0..5b098ba4e5 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp @@ -76,7 +76,7 @@ uint_native rotate(uint_native value, size_t rotation) : value; } template class stdlib_uint : public testing::Test { - typedef typename std::conditional, stdlib::uint>::type uint_ct; typedef stdlib::bool_t bool_ct; diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint_all.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint_all.fuzzer.cpp index 8d7ed88eba..4c8f6a70bc 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint_all.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint_all.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard | proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard | ComposerType::Turbo; #include "uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint_standard.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint_standard.fuzzer.cpp index 42e8262e67..2326494030 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint_standard.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint_standard.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Standard; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Standard; #include "uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint_turbo.fuzzer.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint_turbo.fuzzer.cpp index 4f4b2100d3..c5a59d827e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint_turbo.fuzzer.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint_turbo.fuzzer.cpp @@ -1,3 +1,3 @@ #include "barretenberg/common/fuzzer_constants.hpp" -constexpr uint64_t FuzzerComposerTypes = proof_system::ComposerType::Turbo; +constexpr uint64_t FuzzerComposerTypes = ComposerType::Turbo; #include "uint.fuzzer.hpp" diff --git a/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp b/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp index 649415cd10..def7ead90a 100644 --- a/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp +++ b/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp @@ -246,7 +246,7 @@ template class Transcript { } field_pt T0; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { T0 = stdlib::pedersen_plookup::compress(compression_buffer); } else { T0 = stdlib::pedersen::compress(compression_buffer); diff --git a/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp b/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp index bc245ae699..4d6dc477c4 100644 --- a/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp +++ b/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp @@ -54,7 +54,7 @@ template struct evaluation_domain { field_t compress() const { - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { field_t out = pedersen_plookup::compress({ root, domain, @@ -74,7 +74,7 @@ template struct evaluation_domain { static barretenberg::fr compress_native(const barretenberg::evaluation_domain& input) { barretenberg::fr out; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { out = crypto::pedersen::lookup::compress_native({ input.root, input.domain, @@ -155,7 +155,7 @@ template struct verification_key { const auto circuit_key_compressed = compress(); bool found = false; // if we're using Plookup, use a ROM table to index the keys - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { field_t key_index(witness_t(context, 0)); std::vector> compressed_keys; for (size_t i = 0; i < keys_in_set.size(); ++i) { @@ -205,7 +205,7 @@ template struct verification_key { } field_t compressed_key; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { compressed_key = pedersen_plookup::compress(key_witnesses); } else { compressed_key = pedersen::compress(key_witnesses); @@ -245,7 +245,7 @@ template struct verification_key { key_witnesses.push_back(y_limbs[3]); } barretenberg::fr compressed_key; - if constexpr (Composer::type == proof_system::ComposerType::PLOOKUP) { + if constexpr (Composer::type == ComposerType::PLOOKUP) { compressed_key = crypto::pedersen::lookup::compress_native(key_witnesses); } else { compressed_key = crypto::pedersen::compress_native(key_witnesses); @@ -265,7 +265,7 @@ template struct verification_key { // Native data: - std::shared_ptr reference_string; + std::shared_ptr reference_string; PolynomialManifest polynomial_manifest;