30 element accumulator = offset_generator;
31 for (
element& raw_entry : table_raw) {
32 raw_entry = accumulator;
33 accumulator += base_point;
40 for (
const element& raw_entry : table_raw) {
41 table.emplace_back(raw_entry.x, raw_entry.y);
60 tables.reserve(NUM_TABLES);
62 std::vector<uint8_t> input_buf;
63 write(input_buf, input);
67 for (
size_t i = 0; i < NUM_TABLES; ++i) {
70 accumulator = accumulator.
dbl();
91template <
size_t num_table_bits>
97 std::vector<uint8_t> input_buf;
98 write(input_buf, input);
105 for (
const auto& generator : offset_generators) {
106 total_offset += generator;
182 bb::constexpr_for<0, table::NUM_FIXED_BASE_MULTI_TABLES, 1>([&]<
size_t i>() {
183 bb::constexpr_for<0, table::MAX_NUM_TABLES_IN_MULTITABLE, 1>(
184 [&]<
size_t j>() {
table[i][j] = &table::get_basic_fixed_base_table_values<i, j>; });
201template <
size_t multitable_index>
207 const size_t multitable_bits = get_num_bits_of_multi_table<multitable_index>();
208 const size_t bits_covered_by_previous_tables_in_multitable =
BITS_PER_TABLE * table_index;
209 const bool is_small_table = (multitable_bits - bits_covered_by_previous_tables_in_multitable) <
BITS_PER_TABLE;
210 const size_t table_bits =
211 is_small_table ? multitable_bits - bits_covered_by_previous_tables_in_multitable :
BITS_PER_TABLE;
212 const auto table_size =
static_cast<size_t>(1ULL << table_bits);
214 BasicTable table{ .id = id, .table_index = basic_table_index, .use_twin_keys =
false };
218 for (
size_t i = 0; i < table_size; ++i) {
219 table.column_1.emplace_back(i);
220 table.column_2.emplace_back(basic_table[i].x);
221 table.column_3.emplace_back(basic_table[i].y);
225 table.get_values_from_key = get_values_from_key_table[multitable_index][table_index];
228 table.column_1_step_size = table_size;
270 table.get_table_values.resize(NUM_TABLES);
271 table.basic_table_ids.resize(NUM_TABLES);
272 for (
size_t i = 0; i < NUM_TABLES; ++i) {
274 table.get_table_values[i] = get_values_from_key_table[multitable_index][i];
276 size_t idx = i +
static_cast<size_t>(basic_table_ids[multitable_index]);
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_ASSERT_LT(left, right,...)
#define ASSERT(expression,...)
element class. Implements ecc group arithmetic using Jacobian coordinates See https://hyperelliptic....
constexpr element dbl() const noexcept
static void batch_normalize(element *elements, size_t num_elements) noexcept
static constexpr element point_at_infinity
static std::vector< affine_element > derive_generators(const std::vector< uint8_t > &domain_separator_bytes, const size_t num_generators, const size_t starting_index=0)
Derives generator points via hash-to-curve.
Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of ...
std::vector< affine_element > single_lookup_table
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_bi...
static 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 outpu...
std::array< fixed_base_scalar_mul_tables, NUM_FIXED_BASE_MULTI_TABLES > all_multi_tables
static bool lookup_table_exists_for_point(const affine_element &input)
Returns true iff provided point is one of the two for which we have a precomputed lookup table.
static constexpr affine_element rhs_generator_point()
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 con...
static fixed_base_scalar_mul_tables generate_tables(const affine_element &input)
For a given base point [P], compute the set of basic tables required to traverse a num_bits sized loo...
static const all_multi_tables & fixed_base_tables()
static affine_element lhs_base_point_lo()
static affine_element rhs_base_point_lo()
static const std::array< affine_element, table::NUM_FIXED_BASE_MULTI_TABLES > & fixed_base_table_offset_generators()
offset generators!
static affine_element lhs_base_point_hi()
static affine_element compute_generator_offset(const affine_element &input)
static std::array< MultiTableId, 2 > get_lookup_table_ids_for_point(const affine_element &input)
Given a point that is one of the two for which we have a precomputed lookup table,...
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.
static constexpr affine_element lhs_generator_point()
std::vector< single_lookup_table > fixed_base_scalar_mul_tables
static affine_element rhs_base_point_hi()
constexpr T ceil_div(const T &numerator, const T &denominator)
Computes the ceiling of the division of two integral types.
std::array< bb::fr, 2 >(*)(const std::array< uint64_t, 2 >) function_ptr
std::array< std::array< function_ptr, table::MAX_NUM_TABLES_IN_MULTITABLE >, table::NUM_FIXED_BASE_MULTI_TABLES > function_ptr_table
constexpr function_ptr_table make_function_pointer_table()
create a compile-time static 2D array of all our required get_basic_fixed_base_table_values function ...
void write(std::vector< uint8_t > &buf, ClientIVC::VerificationKey const &vk)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
A basic table from which we can perform lookups (for example, an xor table)
static constexpr size_t NUM_FIXED_BASE_MULTI_TABLES
static const bb::fr COLUMN_3_STEP_SIZE
static const bb::fr COLUMN_2_STEP_SIZE
static constexpr size_t MAX_TABLE_SIZE
static constexpr size_t BITS_PER_TABLE
static constexpr size_t BITS_PER_HI_SCALAR
static constexpr size_t MAX_NUM_TABLES_IN_MULTITABLE
static constexpr size_t BITS_PER_LO_SCALAR
Container for managing multiple BasicTables plus the data needed to combine basic table outputs (e....