19template <
typename Builder>
23 const size_t table_size = 1UL << table_bits;
26 std::vector<Element> projective_points(table_size);
27 projective_points[0] =
Element(offset_generator);
29 for (
size_t i = 1; i < table_size; ++i) {
30 projective_points[i] = projective_points[i - 1] + base_proj;
32 Element::batch_normalize(projective_points.data(), table_size);
36 for (
size_t i = 0; i < table_size; ++i) {
51 for (
size_t i = 0; i < table_size; ++i) {
69template <
typename Builder>
72 , native_table(
std::move(
data.native_table))
94template <
typename Builder>
116 if (
index.is_constant()) {
122 auto native_index =
static_cast<size_t>(
uint256_t(
index.get_value()));
123 BB_ASSERT(native_index < native_table.size());
124 const auto& point = native_table[native_index];
127 auto x_idx = _context->add_variable(point.x);
128 auto y_idx = _context->add_variable(point.y);
133 entry.
value = { point.x, point.y };
134 _context->create_lookup_gate(
index.get_witness_index(), x_idx, y_idx, *_table, entry);
#define BB_ASSERT(expression,...)
Implements boolean logic in-circuit.
cycle_group represents a group Element of the proving system's embedded curve, i.e....
static field_t from_witness_index(Builder *ctx, uint32_t witness_index)
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
static field_t from_witness(Builder *ctx, const bb::fr &input)
void set_origin_tag(const OriginTag &new_tag) const
straus_plookup_table computes a plookup-based lookup table of size 1 << table_bits
typename Curve::Element Element
plookup::BasicTable * _table
typename Curve::AffineElement AffineElement
cycle_group< Builder > read(const field_t &index)
Read from the plookup table at the given index.
static PrecomputedData build_precomputed_data(const AffineElement &base_point, const AffineElement &offset_generator, size_t table_bits)
Compute native table entries and BasicTable column data without touching the circuit builder.
straus_plookup_table()=default
const std::vector< MemoryValue > data
StrictMock< MockContext > context
bb::curve::BN254::Element Element
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static OriginTag constant()
std::array< bb::fr, 2 > value
std::array< uint256_t, 2 > key
bb::fr column_2_step_size
bb::fr column_1_step_size
std::vector< bb::fr > column_3
std::vector< bb::fr > column_2
std::array< bb::fr, 2 >(* get_values_from_key)(const std::array< uint64_t, 2 >)
std::vector< bb::fr > column_1
bb::fr column_3_step_size
Precomputed data for two-phase construction. Contains all data computed without builder access.
plookup::BasicTable basic_table
std::vector< AffineElement > native_table