Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::stdlib::straus_plookup_table< Builder > Class Template Reference

straus_plookup_table computes a plookup-based lookup table of size 1 << table_bits More...

#include <straus_plookup_table.hpp>

Classes

struct  PrecomputedData
 Precomputed data for two-phase construction. Contains all data computed without builder access. More...
 

Public Types

using field_t = stdlib::field_t< Builder >
 
using bool_t = stdlib::bool_t< Builder >
 
using Curve = typename Builder::EmbeddedCurve
 
using Group = typename Curve::Group
 
using Element = typename Curve::Element
 
using AffineElement = typename Curve::AffineElement
 

Public Member Functions

 straus_plookup_table ()=default
 
 straus_plookup_table (Builder *context, const AffineElement &base_point, const AffineElement &offset_generator, size_t table_bits)
 Construct a plookup-based Straus lookup table for a constant base point.
 
 straus_plookup_table (Builder *context, PrecomputedData data)
 Construct from precomputed data — serial Phase 2, only touches the circuit builder.
 
cycle_group< Builderread (const field_t &index)
 Read from the plookup table at the given index.
 
const std::vector< AffineElement > & get_native_table () const
 

Static Public Member Functions

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.
 

Private Attributes

Builder_context = nullptr
 
plookup::BasicTable_table = nullptr
 
std::vector< AffineElementnative_table
 
OriginTag tag
 

Detailed Description

template<typename Builder>
class bb::stdlib::straus_plookup_table< Builder >

straus_plookup_table computes a plookup-based lookup table of size 1 << table_bits

For a CONSTANT base_point [P] and offset_generator point [G], where N = 1 << table_bits, the following is computed:

{ [G] + 0.[P], [G] + 1.[P], ..., [G] + (N - 1).[P] }

Unlike straus_lookup_table (which uses ROM tables), this class creates plookup BasicTable entries. Plookup tables have zero construction cost (table data is part of the proving polynomial) and each read costs exactly 1 lookup gate with no finalization overhead. This makes them significantly cheaper than ROM tables for fixed/constant base points.

Note
This class requires the base point to be a circuit constant (not a witness). For witness base points, use straus_lookup_table instead.
The offset generator [G] prevents point-at-infinity edge cases, same as in straus_lookup_table.

Definition at line 31 of file straus_plookup_table.hpp.

Member Typedef Documentation

◆ AffineElement

template<typename Builder >
using bb::stdlib::straus_plookup_table< Builder >::AffineElement = typename Curve::AffineElement

Definition at line 38 of file straus_plookup_table.hpp.

◆ bool_t

template<typename Builder >
using bb::stdlib::straus_plookup_table< Builder >::bool_t = stdlib::bool_t<Builder>

Definition at line 34 of file straus_plookup_table.hpp.

◆ Curve

template<typename Builder >
using bb::stdlib::straus_plookup_table< Builder >::Curve = typename Builder::EmbeddedCurve

Definition at line 35 of file straus_plookup_table.hpp.

◆ Element

Definition at line 37 of file straus_plookup_table.hpp.

◆ field_t

◆ Group

template<typename Builder >
using bb::stdlib::straus_plookup_table< Builder >::Group = typename Curve::Group

Definition at line 36 of file straus_plookup_table.hpp.

Constructor & Destructor Documentation

◆ straus_plookup_table() [1/3]

template<typename Builder >
bb::stdlib::straus_plookup_table< Builder >::straus_plookup_table ( )
default

◆ straus_plookup_table() [2/3]

template<typename Builder >
bb::stdlib::straus_plookup_table< Builder >::straus_plookup_table ( Builder context,
const AffineElement base_point,
const AffineElement offset_generator,
size_t  table_bits 
)

Construct a plookup-based Straus lookup table for a constant base point.

Creates a BasicTable with (1 << table_bits) entries of the form: { offset_generator + i * base_point } for i in [0, 1 << table_bits)

The table is pushed directly into the builder's lookup_tables deque. Table data becomes part of the proving polynomial (zero gate cost). Each subsequent read costs exactly 1 lookup gate.

Parameters
contextThe circuit builder
base_pointConstant base point (must not be a witness)
offset_generatorOffset to prevent point-at-infinity edge cases
table_bitsNumber of bits per table (table has 1 << table_bits entries)

Definition at line 95 of file straus_plookup_table.cpp.

◆ straus_plookup_table() [3/3]

template<typename Builder >
bb::stdlib::straus_plookup_table< Builder >::straus_plookup_table ( Builder context,
PrecomputedData  data 
)

Construct from precomputed data — serial Phase 2, only touches the circuit builder.

Assigns table_index and pushes the BasicTable into the builder's lookup_tables deque. Must be called serially (builder is not thread-safe).

Parameters
contextThe circuit builder
dataPrecomputed native table + BasicTable columns

Definition at line 70 of file straus_plookup_table.cpp.

Member Function Documentation

◆ build_precomputed_data()

template<typename Builder >
straus_plookup_table< Builder >::PrecomputedData bb::stdlib::straus_plookup_table< Builder >::build_precomputed_data ( const AffineElement base_point,
const AffineElement offset_generator,
size_t  table_bits 
)
static

Compute native table entries and BasicTable column data without touching the circuit builder.

This is the parallelizable part of table construction. It builds:

  • native_table: affine points { offset_generator + i * base_point } for i in [0, table_size)
  • basic_table: a BasicTable with columns populated but table_index NOT yet assigned
Parameters
base_pointConstant base point
offset_generatorOffset to prevent point-at-infinity edge cases
table_bitsNumber of bits per table (table has 1 << table_bits entries)
Returns
PrecomputedData Contains native_table and basic_table (without table_index)

Definition at line 20 of file straus_plookup_table.cpp.

◆ get_native_table()

template<typename Builder >
const std::vector< AffineElement > & bb::stdlib::straus_plookup_table< Builder >::get_native_table ( ) const
inline

Definition at line 63 of file straus_plookup_table.hpp.

◆ read()

template<typename Builder >
cycle_group< Builder > bb::stdlib::straus_plookup_table< Builder >::read ( const field_t _index)

Read from the plookup table at the given index.

Creates a single lookup gate constraining (index, x, y) to a valid row in this table. The index witness is reused as the lookup key so the scalar slice is directly constrained.

Parameters
_indexThe lookup index (witness or constant, typically a scalar slice)
Returns
cycle_group<Builder> The point at native_table[index]

Definition at line 111 of file straus_plookup_table.cpp.

Member Data Documentation

◆ _context

template<typename Builder >
Builder* bb::stdlib::straus_plookup_table< Builder >::_context = nullptr
private

Definition at line 66 of file straus_plookup_table.hpp.

◆ _table

template<typename Builder >
plookup::BasicTable* bb::stdlib::straus_plookup_table< Builder >::_table = nullptr
private

Definition at line 67 of file straus_plookup_table.hpp.

◆ native_table

template<typename Builder >
std::vector<AffineElement> bb::stdlib::straus_plookup_table< Builder >::native_table
private

Definition at line 68 of file straus_plookup_table.hpp.

◆ tag

template<typename Builder >
OriginTag bb::stdlib::straus_plookup_table< Builder >::tag
private

Definition at line 69 of file straus_plookup_table.hpp.


The documentation for this class was generated from the following files: