From f258cc4bc9399f0ba16a68a0585dc27879b6ba5a Mon Sep 17 00:00:00 2001 From: maramihali Date: Fri, 5 May 2023 17:45:37 +0100 Subject: [PATCH] Reduce occurence of using namespace syntax in header files (https://github.com/AztecProtocol/barretenberg/pull/387) Co-authored-by: maramihali --- .../crypto/pedersen_commitment/pedersen.cpp | 2 +- .../crypto/pedersen_commitment/pedersen.hpp | 9 ++++---- .../crypto/pedersen_hash/pedersen.cpp | 4 +++- .../crypto/pedersen_hash/pedersen.hpp | 4 +--- .../proofs/compute_circuit_data.hpp | 2 +- .../inner_proof_data/inner_proof_data.cpp | 2 ++ .../inner_proof_data/inner_proof_data.hpp | 2 -- .../proofs/join_split/join_split.hpp | 2 -- .../proofs/join_split/join_split.test.cpp | 2 ++ .../proofs/join_split/join_split_circuit.cpp | 1 + .../proofs/join_split/sign_join_split_tx.cpp | 2 ++ .../proofs/join_split/sign_join_split_tx.hpp | 6 ++--- .../proofs/mock/mock_circuit.hpp | 1 - .../proofs/notes/circuit/account/commit.hpp | 2 -- .../claim/create_partial_commitment.hpp | 2 -- .../value/complete_partial_commitment.hpp | 2 -- .../compute_account_alias_hash_nullifier.hpp | 2 +- .../notes/native/claim/compute_nullifier.hpp | 2 -- .../plonk/composer/turbo_composer.test.cpp | 1 + .../commitment_scheme/commitment_scheme.hpp | 4 +--- .../reference_string/env_reference_string.hpp | 2 -- .../stdlib/commitment/pedersen/pedersen.cpp | 1 + .../stdlib/commitment/pedersen/pedersen.hpp | 10 ++++----- .../commitment/pedersen/pedersen_plookup.cpp | 1 + .../stdlib/encryption/aes128/aes128.cpp | 22 ++++++++++--------- .../stdlib/hash/blake2s/blake2s_plookup.cpp | 1 + .../stdlib/hash/blake2s/blake_util.hpp | 2 ++ .../stdlib/hash/blake3s/blake3s_plookup.cpp | 2 ++ .../stdlib/hash/keccak/keccak.cpp | 2 ++ .../stdlib/hash/pedersen/pedersen.cpp | 1 + .../stdlib/hash/pedersen/pedersen.hpp | 2 -- .../stdlib/hash/pedersen/pedersen_plookup.cpp | 1 + .../stdlib/hash/sha256/sha256_plookup.cpp | 2 ++ .../primitives/biggroup/biggroup_tables.hpp | 3 ++- .../stdlib/primitives/group/group.hpp | 6 ++--- .../stdlib/primitives/logic/logic.cpp | 2 +- .../stdlib/primitives/plookup/plookup.cpp | 2 ++ .../stdlib/primitives/plookup/plookup.hpp | 18 +++++++-------- .../stdlib/primitives/uint/plookup/logic.cpp | 2 ++ 39 files changed, 69 insertions(+), 67 deletions(-) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp index 060446ff55a..639dfa2440d 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp @@ -6,7 +6,7 @@ #include #endif -// using namespace crypto::generators; +using namespace crypto::generators; namespace crypto { namespace pedersen_commitment { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp index 231ea1b25d0..d7275aa6ac7 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp @@ -4,16 +4,15 @@ #include "../generators/generator_data.hpp" #include "../generators/fixed_base_scalar_mul.hpp" -using namespace crypto::generators; - namespace crypto { namespace pedersen_commitment { -grumpkin::g1::element commit_single(const barretenberg::fr& in, generator_index_t const& index); +grumpkin::g1::element commit_single(const barretenberg::fr& in, generators::generator_index_t const& index); grumpkin::g1::affine_element commit_native(const std::vector& inputs, const size_t hash_index = 0); -grumpkin::g1::affine_element commit_native(const std::vector>& input_pairs); +grumpkin::g1::affine_element commit_native( + const std::vector>& input_pairs); grumpkin::fq compress_native(const std::vector& inputs, const size_t hash_index = 0); @@ -25,7 +24,7 @@ template grumpkin::fq compress_native(const std::array& input); -grumpkin::fq compress_native(const std::vector>& input_pairs); +grumpkin::fq compress_native(const std::vector>& input_pairs); } // namespace pedersen_commitment } // namespace crypto diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp index 06ffc6cce91..e8a734eece8 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp @@ -8,6 +8,8 @@ namespace crypto { namespace pedersen_hash { +using namespace generators; + grumpkin::g1::element hash_single(const barretenberg::fr& in, generator_index_t const& index) { auto gen_data = get_generator_data(index); @@ -18,7 +20,7 @@ grumpkin::g1::element hash_single(const barretenberg::fr& in, generator_index_t constexpr size_t num_quads = ((num_quads_base << 1) + 1 < num_bits) ? num_quads_base + 1 : num_quads_base; constexpr size_t num_wnaf_bits = (num_quads << 1) + 1; - const crypto::generators::fixed_base_ladder* ladder = gen_data.get_hash_ladder(num_bits); + const fixed_base_ladder* ladder = gen_data.get_hash_ladder(num_bits); uint64_t wnaf_entries[num_quads + 2] = { 0 }; bool skew = false; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp index b6cad2ad2b7..16665adfa7e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp @@ -4,12 +4,10 @@ #include "../generators/generator_data.hpp" #include "../generators/fixed_base_scalar_mul.hpp" -using namespace crypto::generators; - namespace crypto { namespace pedersen_hash { -grumpkin::g1::element hash_single(const barretenberg::fr& in, generator_index_t const& index); +grumpkin::g1::element hash_single(const barretenberg::fr& in, generators::generator_index_t const& index); grumpkin::fq hash_multiple(const std::vector& inputs, const size_t hash_index = 0); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp index e5371b8bd0f..48d4d749fb0 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp @@ -84,7 +84,7 @@ circuit_data get_circuit_data(std::string const& name, info(name, ": Circuit size: ", composer.get_num_gates()); if (mock) { auto public_inputs = composer.get_public_inputs(); - mock::mock_circuit(mock_proof_composer, public_inputs); + ::join_split_example::proofs::mock::mock_circuit(mock_proof_composer, public_inputs); info(name, ": Mock circuit size: ", mock_proof_composer.get_num_gates()); benchmark_collator.benchmark_info_deferred(GET_COMPOSER_NAME_STRING(proof_system::ComposerType), "Core", diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp index 648847373e8..8e1c81dc54e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp @@ -3,6 +3,8 @@ namespace join_split_example { namespace proofs { +using namespace barretenberg; + inner_proof_data::inner_proof_data(std::vector const& proof_data) { proof_id = from_buffer(proof_data, InnerProofOffsets::PROOF_ID); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp index 432a610188a..db2be3f7181 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp @@ -8,8 +8,6 @@ namespace join_split_example { namespace proofs { -using namespace barretenberg; - namespace InnerProofFields { enum { PROOF_ID, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp index a6c103a4a0a..c9f5e22d29f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp @@ -7,8 +7,6 @@ namespace join_split_example { namespace proofs { namespace join_split { -using namespace proof_system::plonk::stdlib::merkle_tree; - void init_proving_key(std::shared_ptr const& crs_factory, bool mock); void init_proving_key(std::shared_ptr const& crs, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp index 25b802cd625..aa7e516609e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp @@ -13,6 +13,8 @@ namespace join_split_example::proofs::join_split { +using namespace proof_system::plonk::stdlib::merkle_tree; + template class join_split : public testing::Test { protected: diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp index c1ea2af1da1..c93f887947c 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp @@ -15,6 +15,7 @@ namespace join_split { using namespace proof_system::plonk; using namespace notes::circuit; using namespace proof_system::plonk::stdlib::merkle_tree; +using namespace crypto::schnorr; /** * Check that the input note data, follows the given hash paths, to the publically given merkle root. diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp index f5785412722..df20aeab5d5 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp @@ -6,6 +6,8 @@ namespace join_split_example { namespace proofs { namespace join_split { +using namespace crypto::schnorr; + signature sign_join_split_tx(join_split_tx const& tx, key_pair const& keys) { fr compressed = compute_signing_data(tx); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp index 6f4319f927a..1942a460459 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp @@ -7,10 +7,8 @@ namespace join_split_example { namespace proofs { namespace join_split { -using namespace crypto::schnorr; - -signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, - key_pair const& keys); +crypto::schnorr::signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, + crypto::schnorr::key_pair const& keys); } // namespace join_split } // namespace proofs diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp index d1585909c80..05e99f612ab 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp @@ -2,7 +2,6 @@ #include "barretenberg/common/map.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" - namespace join_split_example { namespace proofs { namespace mock { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp index dbe568197ab..4dc66235806 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp @@ -10,8 +10,6 @@ namespace notes { namespace circuit { namespace account { -using namespace proof_system::plonk::stdlib; - inline auto commit(field_ct const& account_alias_hash, point_ct const& account_public_key, point_ct const& signing_pub_key) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp index 36c37a8e78c..66583b1f2d2 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp @@ -9,8 +9,6 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib; - inline auto create_partial_commitment(field_ct const& deposit_value, field_ct const& bridge_call_data, field_ct const& value_note_partial_commitment, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp index 1ec344d17a5..b3a6f22a72f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp @@ -9,8 +9,6 @@ namespace notes { namespace circuit { namespace value { -using namespace proof_system::plonk::stdlib; - inline auto complete_partial_commitment(field_ct const& value_note_partial_commitment, suint_ct const& value, suint_ct const& asset_id, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp index 44801e10790..e7eaa29700e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp @@ -9,7 +9,7 @@ namespace notes { namespace native { namespace account { -using namespace barretenberg; +using fr = barretenberg::fr; inline fr compute_account_alias_hash_nullifier(fr const& alias_hash) { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp index 8503c35d2ab..513b8bfe2eb 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp @@ -10,8 +10,6 @@ namespace notes { namespace native { namespace claim { -using namespace barretenberg; - inline auto compute_nullifier(grumpkin::fq const& note_commitment) { return crypto::pedersen_commitment::compress_native({ note_commitment }, GeneratorIndex::CLAIM_NOTE_NULLIFIER); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/composer/turbo_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/composer/turbo_composer.test.cpp index a329384b195..6034b92d8f4 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/composer/turbo_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/composer/turbo_composer.test.cpp @@ -6,6 +6,7 @@ using namespace barretenberg; using namespace proof_system; using namespace crypto::pedersen_commitment; +using namespace crypto::generators; namespace { auto& engine = numeric::random::get_debug_engine(); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp index 8dc934984fb..68f023fb698 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp @@ -5,13 +5,11 @@ #include "../types/commitment_open_proof.hpp" #include "../types/program_settings.hpp" -using namespace barretenberg; - namespace proof_system::plonk { class CommitmentScheme { public: - typedef barretenberg::fr fr; + using fr = barretenberg::fr; // Constructors for CommitmentScheme CommitmentScheme() {} diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/srs/reference_string/env_reference_string.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/srs/reference_string/env_reference_string.hpp index e4eebec39f2..cceb6eef82c 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/srs/reference_string/env_reference_string.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/srs/reference_string/env_reference_string.hpp @@ -19,8 +19,6 @@ #include namespace proof_system { -using namespace barretenberg; - class EnvReferenceString : public ProverReferenceString { public: EnvReferenceString(const size_t num_points) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.cpp index 57dbc02e621..c6212093c24 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.cpp @@ -9,6 +9,7 @@ namespace proof_system::plonk { namespace stdlib { +using namespace crypto::generators; using namespace barretenberg; using namespace crypto::pedersen_commitment; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.hpp index 36ba3cab499..b33b6a2217f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.hpp @@ -5,8 +5,6 @@ #include "../../primitives/point/point.hpp" #include "../../primitives/byte_array/byte_array.hpp" -using namespace crypto::generators; - namespace proof_system::plonk { namespace stdlib { @@ -23,9 +21,9 @@ template class pedersen_commitment { static point commit(const std::vector& inputs, const size_t hash_index = 0); static point commit(const std::vector& inputs, - const std::vector& hash_generator_indices); + const std::vector& hash_generator_indices); - static point commit(const std::vector>& input_pairs); + static point commit(const std::vector>& input_pairs); static field_t compress_unsafe(const field_t& left, const field_t& right, @@ -40,9 +38,9 @@ template class pedersen_commitment { static field_t compress(const std::vector& inputs, const size_t hash_index = 0); static field_t compress(const std::vector& inputs, - const std::vector& hash_generator_indices); + const std::vector& hash_generator_indices); - static field_t compress(const std::vector>& input_pairs); + static field_t compress(const std::vector>& input_pairs); template static field_t compress(const std::array& inputs) { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp index 70b84e515e5..6dbc70e5d17 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp @@ -10,6 +10,7 @@ namespace proof_system::plonk { namespace stdlib { +using namespace plookup; using namespace barretenberg; template diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index 6e99674ba94..2c1263baff7 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp @@ -15,24 +15,26 @@ namespace proof_system::plonk { namespace stdlib { namespace aes128 { +using namespace plookup; + constexpr uint32_t AES128_BASE = 9; -typedef stdlib::field_t field_t; -typedef stdlib::witness_t witness_t; +typedef stdlib::field_t field_t; +typedef stdlib::witness_t witness_t; typedef std::pair byte_pair; -field_t normalize_sparse_form(plonk::UltraComposer*, field_t& byte) +field_t normalize_sparse_form(UltraComposer*, field_t& byte) { auto result = plookup_read::read_from_1_to_2_table(AES_NORMALIZE, byte); return result; } -byte_pair apply_aes_sbox_map(plonk::UltraComposer*, field_t& input) +byte_pair apply_aes_sbox_map(UltraComposer*, field_t& input) { return plookup_read::read_pair_from_table(AES_SBOX, input); } -std::array convert_into_sparse_bytes(plonk::UltraComposer*, const field_t& block_data) +std::array convert_into_sparse_bytes(UltraComposer*, const field_t& block_data) { // `block_data` must be a 128 bit variable std::array sparse_bytes; @@ -46,7 +48,7 @@ std::array convert_into_sparse_bytes(plonk::UltraComposer*, const f return sparse_bytes; } -field_t convert_from_sparse_bytes(plonk::UltraComposer* ctx, field_t* sparse_bytes) +field_t convert_from_sparse_bytes(UltraComposer* ctx, field_t* sparse_bytes) { std::array bytes; @@ -69,7 +71,7 @@ field_t convert_from_sparse_bytes(plonk::UltraComposer* ctx, field_t* sparse_byt return result; } -std::array expand_key(plonk::UltraComposer* ctx, const field_t& key) +std::array expand_key(UltraComposer* ctx, const field_t& key) { constexpr uint8_t round_constants[11] = { 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 }; std::array sparse_round_constants{ @@ -210,7 +212,7 @@ void mix_columns_and_add_round_key(byte_pair* state_pairs, field_t* round_key, u mix_column_and_add_round_key(state_pairs + 12, round_key + 12, round); } -void sub_bytes(plonk::UltraComposer* ctx, byte_pair* state_pairs) +void sub_bytes(UltraComposer* ctx, byte_pair* state_pairs) { for (size_t i = 0; i < 16; ++i) { state_pairs[i] = apply_aes_sbox_map(ctx, state_pairs[i].first); @@ -233,7 +235,7 @@ void xor_with_iv(byte_pair* state, field_t* iv) } } -void aes128_cipher(plonk::UltraComposer* ctx, byte_pair* state, field_t* sparse_round_key) +void aes128_cipher(UltraComposer* ctx, byte_pair* state, field_t* sparse_round_key) { add_round_key(state, sparse_round_key, 0); for (size_t i = 0; i < 16; ++i) { @@ -256,7 +258,7 @@ void aes128_cipher(plonk::UltraComposer* ctx, byte_pair* state, field_t* sparse_ std::vector encrypt_buffer_cbc(const std::vector& input, const field_t& iv, const field_t& key) { - plonk::UltraComposer* ctx = key.get_context(); + UltraComposer* ctx = key.get_context(); auto round_key = expand_key(ctx, key); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp index d7f4176f7de..43074362a6b 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp @@ -22,6 +22,7 @@ namespace stdlib { namespace blake2s_plookup { using plookup::ColumnIdx; +using namespace blake_util; constexpr uint32_t blake2s_IV[8] = { 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp index 884387bedf1..6ed61e3edf3 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp @@ -11,6 +11,8 @@ namespace stdlib { namespace blake_util { +using namespace plookup; + // constants enum blake_constant { BLAKE3_STATE_SIZE = 16 }; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp index ffa904e3ce2..6427c3d9d38 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp @@ -13,6 +13,8 @@ namespace stdlib { namespace blake3s_plookup { +using namespace blake_util; + /* * Constants and more. */ diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index c35da9781c7..f30231a8409 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp @@ -6,6 +6,8 @@ namespace proof_system::plonk { namespace stdlib { +using namespace plookup; + /** * @brief Normalize a base-11 limb and left-rotate by keccak::ROTATIONS[lane_index] bits. * This method also extracts the most significant bit of the normalised rotated limb. diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp index 719e0e38885..65ab7a52818 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp @@ -9,6 +9,7 @@ namespace stdlib { using namespace barretenberg; using namespace crypto::pedersen_hash; +using namespace crypto::generators; using namespace proof_system; /** diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp index 9a46b85a548..460443078b0 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp @@ -8,8 +8,6 @@ namespace proof_system::plonk { namespace stdlib { using namespace barretenberg; -using namespace crypto::pedersen_hash; - template class pedersen_hash { private: diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp index f451a2b5731..2801648f540 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp @@ -12,6 +12,7 @@ namespace proof_system::plonk { namespace stdlib { using namespace barretenberg; +using namespace plookup; /** * Add two curve points in one of the following ways: diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp index 7b611e8ee68..831d5911644 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp @@ -14,6 +14,8 @@ namespace proof_system::plonk { namespace stdlib { namespace sha256_plookup { +using namespace plookup; + namespace internal { constexpr size_t get_num_blocks(const size_t num_bits) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp index 9fee0738886..9098799a7b1 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp @@ -1,13 +1,14 @@ #pragma once +#include "barretenberg/proof_system/plookup_tables/types.hpp" namespace proof_system::plonk { namespace stdlib { +using plookup::MultiTableId; template template std::array, 5> element::create_group_element_rom_tables( const std::array& rom_data) { - std::vector, 2>> x_lo_limbs; std::vector, 2>> x_hi_limbs; std::vector, 2>> y_lo_limbs; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/group.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/group.hpp index 071056d16e2..8f486e9cc29 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/group.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/group.hpp @@ -8,13 +8,11 @@ #include "../../hash/pedersen/pedersen.hpp" #include "../../hash/pedersen/pedersen_gates.hpp" -using namespace proof_system; - namespace proof_system::plonk { namespace stdlib { using namespace barretenberg; -using namespace crypto::pedersen_hash; +using namespace crypto::generators; template class group { public: @@ -137,7 +135,7 @@ auto group::fixed_base_scalar_mul_internal(const field_t diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp index 8e14806b4c0..0e935cc4260 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp @@ -9,21 +9,21 @@ namespace proof_system::plonk { namespace stdlib { -using namespace plookup; - template class plookup_ { typedef field_t field_pt; public: - static std::pair read_pair_from_table(const MultiTableId id, const field_pt& key); + static std::pair read_pair_from_table(const plookup::MultiTableId id, const field_pt& key); - static field_pt read_from_2_to_1_table(const MultiTableId id, const field_pt& key_a, const field_pt& key_b); - static field_pt read_from_1_to_2_table(const MultiTableId id, const field_pt& key_a); + static field_pt read_from_2_to_1_table(const plookup::MultiTableId id, + const field_pt& key_a, + const field_pt& key_b); + static field_pt read_from_1_to_2_table(const plookup::MultiTableId id, const field_pt& key_a); - static ReadData get_lookup_accumulators(const MultiTableId id, - const field_pt& key_a, - const field_pt& key_b = 0, - const bool is_2_to_1_lookup = false); + static plookup::ReadData get_lookup_accumulators(const plookup::MultiTableId id, + const field_pt& key_a, + const field_pt& key_b = 0, + const bool is_2_to_1_lookup = false); }; extern template class plookup_; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp index db45a6f7c38..b996f4bccf5 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp @@ -6,6 +6,8 @@ using namespace barretenberg; namespace proof_system::plonk { namespace stdlib { +using namespace plookup; + template uint_plookup uint_plookup::operator&(const uint_plookup& other) const {