54static constexpr uint64_t CHOOSE_BASE = 28;
55static constexpr uint64_t MAJORITY_BASE = 16;
56static constexpr uint64_t WITNESS_EXTENSION_BASE = 16;
59static constexpr uint64_t CHOOSE_BITS_PER_LOOKUP = 2;
60static constexpr uint64_t MAJORITY_BITS_PER_LOOKUP = 3;
61static constexpr uint64_t WITNESS_EXTENSION_BITS_PER_LOOKUP = 3;
81static constexpr uint64_t choose_normalization_table[CHOOSE_BASE]{
134static constexpr uint64_t majority_normalization_table[MAJORITY_BASE]{
175static constexpr uint64_t witness_extension_normalization_table[WITNESS_EXTENSION_BASE]{
208static constexpr bb::fr choose_base{ CHOOSE_BASE };
210static constexpr bb::fr HANDLED_VIA_TABLE{ 0 };
214 choose_base.
pow(11 - 6),
215 choose_base.
pow(22 - 6),
219 choose_base.
pow(32 - 11),
221 choose_base.
pow(22 - 11),
225 choose_base.
pow(32 - 25),
226 choose_base.
pow(32 - 25 + 11),
232 choose_rot6_coefficients[0] + choose_rot11_coefficients[0] + choose_rot25_coefficients[0],
233 choose_rot6_coefficients[1] + choose_rot11_coefficients[1] + choose_rot25_coefficients[1],
234 choose_rot6_coefficients[2] + choose_rot11_coefficients[2] + choose_rot25_coefficients[2],
247static constexpr bb::fr majority_base{ MAJORITY_BASE };
251 majority_base.
pow(11 - 2),
252 majority_base.
pow(22 - 2),
256 majority_base.
pow(32 - 13),
258 majority_base.
pow(22 - 13),
262 majority_base.
pow(32 - 22),
263 majority_base.
pow(32 - 22 + 11),
269 majority_rot2_coefficients[0] + majority_rot13_coefficients[0] + majority_rot22_coefficients[0],
270 majority_rot2_coefficients[1] + majority_rot13_coefficients[1] + majority_rot22_coefficients[1],
271 majority_rot2_coefficients[2] + majority_rot13_coefficients[2] + majority_rot22_coefficients[2],
284 WITNESS_EXTENSION_BITS_PER_LOOKUP,
285 witness_extension_normalization_table>(id, table_index);
298 CHOOSE_BITS_PER_LOOKUP,
299 choose_normalization_table>(id, table_index);
312 MAJORITY_BITS_PER_LOOKUP,
313 majority_normalization_table>(id, table_index);
323 const size_t num_entries = 11;
324 const auto slice_size =
numeric::pow64(WITNESS_EXTENSION_BASE, WITNESS_EXTENSION_BITS_PER_LOOKUP);
326 MultiTable table(slice_size, 1ULL << WITNESS_EXTENSION_BITS_PER_LOOKUP, 0, num_entries);
329 for (
size_t i = 0; i < num_entries; ++i) {
334 witness_extension_normalization_table>);
346 const size_t num_entries = 16;
347 const auto slice_size =
numeric::pow64(CHOOSE_BASE, CHOOSE_BITS_PER_LOOKUP);
349 MultiTable table(slice_size, 1ULL << CHOOSE_BITS_PER_LOOKUP, 0, num_entries);
352 for (
size_t i = 0; i < num_entries; ++i) {
356 &sparse_tables::get_sparse_normalization_values<CHOOSE_BASE, choose_normalization_table>);
368 const size_t num_entries = 11;
369 const auto slice_size =
numeric::pow64(MAJORITY_BASE, MAJORITY_BITS_PER_LOOKUP);
371 MultiTable table(slice_size, 1ULL << MAJORITY_BITS_PER_LOOKUP, 0, num_entries);
374 for (
size_t i = 0; i < num_entries; ++i) {
378 &sparse_tables::get_sparse_normalization_values<MAJORITY_BASE, majority_normalization_table>);
395 majority_rotation_coefficients[1] - majority_base.
pow(11) * majority_rotation_coefficients[0];
397 return { majority_rotation_coefficients[0], limb1_correction,
bb::fr(0) };
411 bb::fr limb2_correction = choose_rotation_coefficients[2] - choose_base.
pow(22) * choose_rotation_coefficients[0];
413 return { choose_rotation_coefficients[0],
bb::fr(0), limb2_correction };
447 std::vector<bb::fr> column_1_coefficients{ 1, 1 << 3, 1 << 10, 1 << 18 };
448 std::vector<bb::fr> column_2_coefficients{ 0, 0, 0, 0 };
449 std::vector<bb::fr> column_3_coefficients{ 0, 0, 0, 0 };
450 MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients);
452 table.
slice_sizes = { (1 << 3), (1 << 7), (1 << 8), (1 << 14) };
474 &sparse_tables::get_sparse_table_with_rotation_values<WITNESS_EXTENSION_BASE, 0>,
475 &sparse_tables::get_sparse_table_with_rotation_values<WITNESS_EXTENSION_BASE, 4>,
476 &sparse_tables::get_sparse_table_with_rotation_values<WITNESS_EXTENSION_BASE, 7>,
477 &sparse_tables::get_sparse_table_with_rotation_values<WITNESS_EXTENSION_BASE, 1>,
530 bb::fr limb1_table_correction =
531 choose_rotation_coefficients[1] - choose_base.
pow(11) * choose_rotation_coefficients[0];
533 std::vector<bb::fr> column_1_coefficients{
bb::fr(1),
bb::fr(1 << 11),
bb::fr(1 << 22) };
534 std::vector<bb::fr> column_2_coefficients{
bb::fr(1), choose_base.
pow(11), choose_base.
pow(22) };
535 std::vector<bb::fr> column_3_coefficients{
bb::fr(1),
bb::fr(1) + limb1_table_correction,
bb::fr(1) };
536 MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients);
538 table.
slice_sizes = { (1 << 11), (1 << 11), (1 << 10) };
553 table.
get_table_values = { &sparse_tables::get_sparse_table_with_rotation_values<CHOOSE_BASE, 6>,
554 &sparse_tables::get_sparse_table_with_rotation_values<CHOOSE_BASE, 0>,
555 &sparse_tables::get_sparse_table_with_rotation_values<CHOOSE_BASE, 3> };
607 bb::fr limb2_table_correction =
608 majority_rotation_coefficients[2] - majority_base.
pow(11) * majority_rotation_coefficients[1];
610 std::vector<bb::fr> column_1_coefficients{
bb::fr(1),
bb::fr(1 << 11),
bb::fr(1 << 22) };
611 std::vector<bb::fr> column_2_coefficients{
bb::fr(1), majority_base.
pow(11), majority_base.
pow(22) };
612 std::vector<bb::fr> column_3_coefficients{
bb::fr(1),
bb::fr(1),
bb::fr(1) + limb2_table_correction };
614 MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients);
616 table.
slice_sizes = { (1 << 11), (1 << 11), (1 << 10) };
631 table.
get_table_values = { &sparse_tables::get_sparse_table_with_rotation_values<MAJORITY_BASE, 2>,
632 &sparse_tables::get_sparse_table_with_rotation_values<MAJORITY_BASE, 2>,
633 &sparse_tables::get_sparse_table_with_rotation_values<MAJORITY_BASE, 0> };
constexpr uint64_t pow64(const uint64_t input, const uint64_t exponent)
MultiTable get_witness_extension_input_table(const MultiTableId id=SHA256_WITNESS_INPUT)
Constructs a MultiTable for decomposing a 32-bit word for message schedule extension.
MultiTable get_majority_input_table(const MultiTableId id=SHA256_MAJ_INPUT)
Constructs a MultiTable for decomposing a into sparse form and computing rotation components for Σ₀(a...
BasicTable generate_choose_normalization_table(BasicTableId id, const size_t table_index)
Generates a BasicTable for normalizing choose sparse digits.
MultiTable get_witness_extension_output_table(const MultiTableId id=SHA256_WITNESS_OUTPUT)
Constructs a MultiTable for normalizing witness extension sparse results back to normal form.
BasicTable generate_majority_normalization_table(BasicTableId id, const size_t table_index)
Generates a BasicTable for normalizing majority sparse digits.
MultiTable get_choose_output_table(const MultiTableId id=SHA256_CH_OUTPUT)
Constructs a MultiTable for normalizing choose sparse results back to normal form.
std::array< bb::fr, 3 > get_choose_rotation_multipliers()
Returns multipliers for computing Σ₁(e) rotations in choose_with_sigma1.
MultiTable get_choose_input_table(const MultiTableId id=SHA256_CH_INPUT)
Constructs a MultiTable for decomposing e into sparse form and computing rotation components for Σ₁(e...
MultiTable get_majority_output_table(const MultiTableId id=SHA256_MAJ_OUTPUT)
Constructs a MultiTable for normalizing majority sparse results back to normal form.
std::array< bb::fr, 3 > get_majority_rotation_multipliers()
Returns multipliers for computing Σ₀(a) rotations in majority_with_sigma0.
BasicTable generate_witness_extension_normalization_table(BasicTableId id, const size_t table_index)
Generates a BasicTable for normalizing witness extension sparse digits.
std::array< bb::fr, 2 > get_sparse_normalization_values(const std::array< uint64_t, 2 > key)
Computes the normalized output for a sparse value based on a provided normalization table.
BasicTable generate_sparse_normalization_table(BasicTableId id, const size_t table_index)
Generates a BasicTable for normalizing sparse form values back to normal form.
@ SHA256_WITNESS_SLICE_8_ROTATE_7
@ SHA256_WITNESS_SLICE_7_ROTATE_4
@ SHA256_WITNESS_NORMALIZE
@ SHA256_WITNESS_SLICE_14_ROTATE_1
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
BB_INLINE constexpr field pow(const uint256_t &exponent) const noexcept
A basic table from which we can perform lookups (for example, an xor table)
Container for managing multiple BasicTables plus the data needed to combine basic table outputs (e....
std::vector< BasicTableId > basic_table_ids
std::vector< uint64_t > slice_sizes
std::vector< table_out(*)(table_in)> get_table_values