Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of points.
More...
|
| static single_lookup_table | generate_single_lookup_table (const affine_element &base_point, const affine_element &offset_generator) |
| | Given a base_point [P] and an offset_generator [G], compute a lookup table of MAX_TABLE_SIZE that contains the following terms:
|
| |
| template<size_t num_bits> |
| static fixed_base_scalar_mul_tables | generate_tables (const affine_element &input) |
| | For a given base point [P], compute the lookup tables required to traverse a num_bits sized lookup.
|
| |
|
template<size_t num_table_bits> |
| static affine_element | generate_generator_offset (const affine_element &input) |
| |
| static bool | lookup_table_exists_for_point (const affine_element &input) |
| | Given a point, do we have a precomputed lookup table for this point?
|
| |
| static std::optional< std::array< MultiTableId, 2 > > | get_lookup_table_ids_for_point (const affine_element &input) |
| | Given a point, return (if it exists) the 2 MultiTableId's that correspond to the LO_SCALAR, HI_SCALAR MultiTables.
|
| |
| static std::optional< affine_element > | get_generator_offset_for_table_id (MultiTableId table_id) |
| | Given a table id, return the offset generator term that will be present in the final scalar mul output.
|
| |
| template<size_t multitable_index> |
| static BasicTable | generate_basic_fixed_base_table (BasicTableId id, size_t basic_table_index, size_t table_index) |
| | Generate a single fixed-base-scalar-mul plookup table.
|
| |
| template<size_t multitable_index, size_t num_bits> |
| static MultiTable | get_fixed_base_table (MultiTableId id) |
| | Generate a multi-table that describes the lookups required to cover a fixed-base-scalar-mul of num_bits
|
| |
|
template<size_t multitable_index, size_t table_index> |
| static std::array< barretenberg::fr, 2 > | get_basic_fixed_base_table_values (const std::array< uint64_t, 2 > key) |
| |
| template<size_t num_bits> |
| static constexpr size_t | get_num_tables_per_multi_table () noexcept |
| | For a scalar multiplication table that covers input scalars up to (1 << num_bits) - 1, how many individual lookup tables of max size BITS_PER_TABLE do we need? (e.g. if BITS_PER_TABLE = 9, for num_bits = 126 it's 14. For num_bits = 128 it's 15)
|
| |
| static constexpr size_t | get_num_bits_of_multi_table (const size_t multitable_index) |
| | For a given multitable index, how many scalar mul bits are we traversing with our multitable?
|
| |
Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of points.
template<size_t num_bits>
| template table::fixed_base_scalar_mul_tables plookup::fixed_base::table::generate_tables< table::BITS_PER_HI_SCALAR > |
( |
const affine_element & |
input | ) |
|
|
static |
For a given base point [P], compute the lookup tables required to traverse a num_bits sized lookup.
i.e. call generate_single_lookup_table for the following base points:
{ [P], [P] * (1 << BITS_PER_TABLE), [P] * (1 << BITS_PER_TABLE * 2), ..., [P] * (1 << BITS_PER_TABLE * (NUM_TABLES - 1)) }
- Template Parameters
-
- Parameters
-
- Returns
- table::fixed_base_scalar_mul_tables
| const std::array< table::affine_element, table::NUM_FIXED_BASE_MULTI_TABLES > plookup::fixed_base::table::fixed_base_table_offset_generators |
|
static |
Initial value:= {
table::generate_generator_offset<BITS_PER_LO_SCALAR>(lhs_base_point_lo),
table::generate_generator_offset<BITS_PER_HI_SCALAR>(lhs_base_point_hi),
table::generate_generator_offset<BITS_PER_LO_SCALAR>(rhs_base_point_lo),
table::generate_generator_offset<BITS_PER_HI_SCALAR>(rhs_base_point_hi),
}
offset generators!
We add a unique "offset generator" into each lookup table to ensure that we never trigger incomplete addition formulae for short Weierstrass curves. The offset generators are linearly independent from the fixed-base points we're multiplying, ensuring that a collision is as likely as solving the discrete logarithm problem. For example, imagine a 2-bit lookup table of a point [P]. The table would normally contain { 0.[P], 1.[P], 2.[P], 3.[P]}. But, we dont want to have to handle points at infinity and we also don't want to deal with windowed-non-adjacent-form complexities. Instead, we derive offset generator [G] and make the table equal to { [G] + 0.[P], [G] + 1.[P], [G] + 2.[P], [G] + 3.[P]}. Each table uses a unique offset generator to prevent collisions. The final scalar multiplication output will have a precisely-known contribution from the offset generators, which can then be subtracted off with a single point subtraction.