diff --git a/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp b/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp index 7d3bdc0950..723532dd7b 100644 --- a/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen_plookup.cpp +++ b/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/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index 6e99674ba9..2c1263baff 100644 --- a/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/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/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp b/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp index 3fad189ef2..48e317b805 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s_plookup.cpp +++ b/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/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp b/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp index fe7650bbb5..258abe3f7f 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp +++ b/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/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp b/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp index 3253483722..411afe83ce 100644 --- a/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s_plookup.cpp +++ b/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/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index c35da9781c..f30231a840 100644 --- a/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/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/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp b/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp index d55161447a..77244ded91 100644 --- a/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen_plookup.cpp +++ b/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/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp b/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp index 04a5632eab..5ca3a1990c 100644 --- a/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp +++ b/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp @@ -2,6 +2,7 @@ #include "barretenberg/plonk/composer/plookup_tables/plookup_tables.hpp" #include "barretenberg/plonk/composer/plookup_tables/sha256.hpp" +#include "barretenberg/plonk/composer/plookup_tables/types.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/stdlib/primitives/bit_array/bit_array.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" @@ -14,6 +15,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/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp index 9fee073888..9eccbc1263 100644 --- a/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_tables.hpp @@ -1,13 +1,14 @@ #pragma once +#include "barretenberg/plonk/composer/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/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp b/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp index ac251c7081..95ad8656ef 100644 --- a/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp +++ b/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp @@ -10,6 +10,8 @@ class UltraComposer; namespace proof_system::plonk { namespace stdlib { +using plookup::ColumnIdx; +using plookup::MultiTableId; using namespace barretenberg; template diff --git a/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp b/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp index b178032b10..e08089b33f 100644 --- a/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.hpp +++ b/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/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp b/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp index db45a6f7c3..b996f4bccf 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp +++ b/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 {