Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: lookups cleanup/documentation #7002

Merged
merged 6 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ field_t<Builder> keccak<Builder>::normalize_and_rotate(const field_ct& limb, fie
// We need to provide a key/value object for this lookup in order for the Builder
// to compute the plookup sorted list commitment
const auto [input_quotient, input_slice] = input.divmod(divisor);
lookup.key_entries.push_back(
lookup.lookup_entries.push_back(
{ { static_cast<uint64_t>(input_slice), 0 }, { normalized_slice, normalized_msb } });

// reduce the input and output by 11^{bit_slice}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ field_t<Builder> plookup_read<Builder>::read_from_2_to_1_table(const MultiTableI
const field_t<Builder>& key_a,
const field_t<Builder>& key_b)
{
const auto lookup = get_lookup_accumulators(id, key_a, key_b, true);
const auto lookup = get_lookup_accumulators(id, key_a, key_b, /*is_2_to_1_lookup=*/true);

return lookup[ColumnIdx::C3][0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ inline MultiTable get_aes_normalization_table(const MultiTableId id = AES_NORMAL
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(AES_BASE * AES_BASE * AES_BASE * AES_BASE);
table.lookup_ids.emplace_back(AES_SPARSE_NORMALIZE);
table.basic_table_ids.emplace_back(AES_SPARSE_NORMALIZE);
table.get_table_values.emplace_back(&get_aes_sparse_normalization_values_from_key);
}
return table;
Expand All @@ -117,7 +117,7 @@ inline MultiTable get_aes_input_table(const MultiTableId id = AES_INPUT)
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(256);
table.lookup_ids.emplace_back(AES_SPARSE_MAP);
table.basic_table_ids.emplace_back(AES_SPARSE_MAP);
table.get_table_values.emplace_back(&sparse_tables::get_sparse_table_with_rotation_values<AES_BASE, 0>);
}
return table;
Expand Down Expand Up @@ -167,7 +167,7 @@ inline MultiTable get_aes_sbox_table(const MultiTableId id = AES_SBOX)
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(numeric::pow64(AES_BASE, 8));
table.lookup_ids.emplace_back(AES_SBOX_MAP);
table.basic_table_ids.emplace_back(AES_SBOX_MAP);
table.get_table_values.emplace_back(&get_aes_sbox_values_from_key);
}
return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ inline MultiTable get_blake2s_xor_table(const MultiTableId id = BLAKE_XOR)
table.id = id;
for (size_t i = 0; i < num_entries - 1; ++i) {
table.slice_sizes.emplace_back(base);
table.lookup_ids.emplace_back(BLAKE_XOR_ROTATE0);
table.basic_table_ids.emplace_back(BLAKE_XOR_ROTATE0);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
}

table.slice_sizes.emplace_back(SIZE_OF_LAST_SLICE);
table.lookup_ids.emplace_back(BLAKE_XOR_ROTATE0_SLICE5_MOD4);
table.basic_table_ids.emplace_back(BLAKE_XOR_ROTATE0_SLICE5_MOD4);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<BITS_IN_LAST_SLICE, 0, true>);

return table;
Expand Down Expand Up @@ -128,8 +128,8 @@ inline MultiTable get_blake2s_xor_rotate_16_table(const MultiTableId id = BLAKE_

table.id = id;
table.slice_sizes = { base, base, base, base, base, SIZE_OF_LAST_SLICE };
table.lookup_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE4,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };
table.basic_table_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE4,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };

table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
Expand Down Expand Up @@ -163,8 +163,8 @@ inline MultiTable get_blake2s_xor_rotate_8_table(const MultiTableId id = BLAKE_X

table.id = id;
table.slice_sizes = { base, base, base, base, base, SIZE_OF_LAST_SLICE };
table.lookup_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE2, BLAKE_XOR_ROTATE0,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };
table.basic_table_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE2, BLAKE_XOR_ROTATE0,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };

table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 2>);
Expand Down Expand Up @@ -198,8 +198,8 @@ inline MultiTable get_blake2s_xor_rotate_7_table(const MultiTableId id = BLAKE_X

table.id = id;
table.slice_sizes = { base, base, base, base, base, SIZE_OF_LAST_SLICE };
table.lookup_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE1, BLAKE_XOR_ROTATE0,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };
table.basic_table_ids = { BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE1, BLAKE_XOR_ROTATE0,
BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0, BLAKE_XOR_ROTATE0_SLICE5_MOD4 };

table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 1>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ inline MultiTable get_honk_dummy_multitable()
number_of_lookups);
table.id = id;
table.slice_sizes.emplace_back(number_of_elements_in_argument);
table.lookup_ids.emplace_back(HONK_DUMMY_BASIC1);
table.basic_table_ids.emplace_back(HONK_DUMMY_BASIC1);
table.get_table_values.emplace_back(&get_value_from_key<HONK_DUMMY_BASIC1>);
table.slice_sizes.emplace_back(number_of_elements_in_argument);
table.lookup_ids.emplace_back(HONK_DUMMY_BASIC2);
table.basic_table_ids.emplace_back(HONK_DUMMY_BASIC2);
table.get_table_values.emplace_back(&get_value_from_key<HONK_DUMMY_BASIC2>);
return table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ template <size_t multitable_index, size_t num_bits> MultiTable table::get_fixed_
MultiTable table(MAX_TABLE_SIZE, 0, 0, NUM_TABLES);
table.id = id;
table.get_table_values.resize(NUM_TABLES);
table.lookup_ids.resize(NUM_TABLES);
table.basic_table_ids.resize(NUM_TABLES);
for (size_t i = 0; i < NUM_TABLES; ++i) {
table.slice_sizes.emplace_back(MAX_TABLE_SIZE);
table.get_table_values[i] = get_values_from_key_table[multitable_index][i];
static_assert(multitable_index < NUM_FIXED_BASE_MULTI_TABLES);
size_t idx = i + static_cast<size_t>(basic_table_ids[multitable_index]);
table.lookup_ids[i] = static_cast<plookup::BasicTableId>(idx);
table.basic_table_ids[i] = static_cast<plookup::BasicTableId>(idx);
}
return table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Chi {
table.id = id;
for (size_t i = 0; i < num_tables_per_multitable; ++i) {
table.slice_sizes.emplace_back(numeric::pow64(BASE, TABLE_BITS));
table.lookup_ids.emplace_back(KECCAK_CHI);
table.basic_table_ids.emplace_back(KECCAK_CHI);
table.get_table_values.emplace_back(&get_chi_renormalization_values);
}
return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class KeccakInput {
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(1 << 8);
table.lookup_ids.emplace_back(KECCAK_INPUT);
table.basic_table_ids.emplace_back(KECCAK_INPUT);
table.get_table_values.emplace_back(&get_keccak_input_values);
}
return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class KeccakOutput {
table.id = id;
for (size_t i = 0; i < num_tables_per_multitable; ++i) {
table.slice_sizes.emplace_back(numeric::pow64(BASE, TABLE_BITS));
table.lookup_ids.emplace_back(KECCAK_OUTPUT);
table.basic_table_ids.emplace_back(KECCAK_OUTPUT);
table.get_table_values.emplace_back(
&sparse_tables::get_sparse_normalization_values<BASE, OUTPUT_NORMALIZATION_TABLE>);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ template <size_t TABLE_BITS = 0, size_t LANE_INDEX = 0> class Rho {

table.slice_sizes.push_back(scaled_base);
table.get_table_values.emplace_back(&get_rho_renormalization_values);
table.lookup_ids.push_back((BasicTableId)((size_t)KECCAK_RHO_1 + (bit_slice - 1)));
table.basic_table_ids.push_back((BasicTableId)((size_t)KECCAK_RHO_1 + (bit_slice - 1)));
});

// generate table selector values for the 'left' slice
Expand All @@ -284,7 +284,7 @@ template <size_t TABLE_BITS = 0, size_t LANE_INDEX = 0> class Rho {

table.slice_sizes.push_back(scaled_base);
table.get_table_values.emplace_back(&get_rho_renormalization_values);
table.lookup_ids.push_back((BasicTableId)((size_t)KECCAK_RHO_1 + (bit_slice - 1)));
table.basic_table_ids.push_back((BasicTableId)((size_t)KECCAK_RHO_1 + (bit_slice - 1)));
});

return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class Theta {
table.id = id;
for (size_t i = 0; i < num_tables_per_multitable; ++i) {
table.slice_sizes.emplace_back(numeric::pow64(BASE, TABLE_BITS));
table.lookup_ids.emplace_back(KECCAK_THETA);
table.basic_table_ids.emplace_back(KECCAK_THETA);
table.get_table_values.emplace_back(&get_theta_renormalization_values);
}
return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ MultiTable ecc_generator_table<G1>::get_xlo_table(const MultiTableId id, const B
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xlo_values);
}
return table;
Expand All @@ -389,7 +389,7 @@ MultiTable ecc_generator_table<G1>::get_xhi_table(const MultiTableId id, const B
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xhi_values);
}
return table;
Expand All @@ -404,7 +404,7 @@ MultiTable ecc_generator_table<G1>::get_xlo_endo_table(const MultiTableId id, co
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xlo_endo_values);
}
return table;
Expand All @@ -419,7 +419,7 @@ MultiTable ecc_generator_table<G1>::get_xhi_endo_table(const MultiTableId id, co
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xhi_endo_values);
}
return table;
Expand All @@ -434,7 +434,7 @@ MultiTable ecc_generator_table<G1>::get_ylo_table(const MultiTableId id, const B
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_ylo_values);
}
return table;
Expand All @@ -449,7 +449,7 @@ MultiTable ecc_generator_table<G1>::get_yhi_table(const MultiTableId id, const B
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_yhi_values);
}
return table;
Expand All @@ -464,7 +464,7 @@ MultiTable ecc_generator_table<G1>::get_xyprime_table(const MultiTableId id, con
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xyprime_values);
}
return table;
Expand All @@ -479,7 +479,7 @@ MultiTable ecc_generator_table<G1>::get_xyprime_endo_table(const MultiTableId id
table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(512);
table.lookup_ids.emplace_back(basic_id);
table.basic_table_ids.emplace_back(basic_id);
table.get_table_values.emplace_back(&get_xyprime_endo_values);
}
return table;
Expand Down
Loading
Loading