Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::UltraEccOpsTable Class Reference

Stores a table of elliptic curve operations represented in the Ultra format. More...

#include <ecc_ops_table.hpp>

Public Member Functions

size_t num_ops () const
 
size_t num_ultra_rows () const
 
size_t ultra_table_size_up_to_tail () const
 
void create_new_subtable (size_t size_hint=0)
 
void push (const UltraOp &op)
 
bool has_fixed_append_offset () const
 
bool has_zk_ops () const
 
void merge ()
 
void merge_with_fixed_append_offset (size_t offset)
 
size_t get_current_subtable_size () const
 
std::vector< UltraOpget_no_zk_reconstructed_ultra_ops () const
 
std::vector< UltraOpget_zk_reconstructed_ultra_ops () const
 
std::pair< ColumnPolynomials, ECCVMOperationconstruct_zk_columns ()
 
std::vector< ColumnPolynomialsconstruct_subtable_columns () const
 
ColumnPolynomials construct_table_columns (const bool include_zk_ops=true) const
 
ColumnPolynomials construct_table_columns_up_to_tail () const
 
ColumnPolynomials construct_current_ultra_ops_subtable_columns () const
 

Static Public Member Functions

static std::pair< UltraOp, ECCVMOperationmake_hiding_op_pair (const curve::BN254::BaseField &Px, const curve::BN254::BaseField &Py)
 Build a hiding op as paired Ultra and ECCVM operations from raw Fq coordinates.
 

Static Public Attributes

static constexpr size_t TABLE_WIDTH = 4
 
static constexpr size_t NUM_ROWS_PER_OP = 2
 
static constexpr size_t ZK_ULTRA_OPS
 
static constexpr size_t APPEND_TRACE_OFFSET = NUM_DISABLED_ROWS_IN_SUMCHECK
 

Private Types

using Curve = curve::BN254
 
using Fr = Curve::ScalarField
 
using UltraOpsTable = EccOpsTable< UltraOp >
 
using ColumnPolynomials = std::array< Polynomial< Fr >, TABLE_WIDTH >
 

Private Member Functions

std::vector< UltraOpget_reconstructed (const bool include_zk_ops) const
 
ColumnPolynomials construct_columns_in_range (const size_t poly_size, const size_t subtable_start_idx, const size_t subtable_end_idx, const bool include_zk_ops=false, const std::optional< size_t > fixed_append_offset_for_last=std::nullopt) const
 Construct column polynomials covering subtables [start, end), optionally with a ZK prefix and an optional fixed-location placement of the last-in-range subtable.
 

Static Private Member Functions

static void write_op_to_polynomials (ColumnPolynomials &column_polynomials, const UltraOp &op, const size_t row_idx)
 Write a single UltraOp to the column polynomials at the given position.
 

Private Attributes

UltraOpsTable table
 
std::vector< UltraOpzk_ops
 
std::optional< size_t > fixed_append_offset
 

Detailed Description

Stores a table of elliptic curve operations represented in the Ultra format.

An ECC operation OP involing point P(X,Y) and scalar z is represented in the Ultra format as a tuple of the form {OP, X_lo, X_hi, Y_lo, Y_hi, z1, z2}, where the coordinates are split into hi and lo limbs and z1, z2 are the endomorphism scalars associated with z. Because the Ultra/Mega arithmetization utilizes 4 wires, each op occupies two rows in a width-4 execution trace, arranged as follows:

OP | X_lo | X_hi | Y_lo 0 | Y_hi | z1 | z2

The table data is stored in the UltraOp tuple format but is converted to four columns of Fr scalars for use in the polynomials in the proving system.

Definition at line 210 of file ecc_ops_table.hpp.

Member Typedef Documentation

◆ ColumnPolynomials

Definition at line 264 of file ecc_ops_table.hpp.

◆ Curve

Definition at line 261 of file ecc_ops_table.hpp.

◆ Fr

Definition at line 262 of file ecc_ops_table.hpp.

◆ UltraOpsTable

Definition at line 263 of file ecc_ops_table.hpp.

Member Function Documentation

◆ construct_columns_in_range()

ColumnPolynomials bb::UltraEccOpsTable::construct_columns_in_range ( const size_t  poly_size,
const size_t  subtable_start_idx,
const size_t  subtable_end_idx,
const bool  include_zk_ops = false,
const std::optional< size_t >  fixed_append_offset_for_last = std::nullopt 
) const
inlineprivate

Construct column polynomials covering subtables [start, end), optionally with a ZK prefix and an optional fixed-location placement of the last-in-range subtable.

Layout (rows in NUM_ROWS_PER_OP units, advancing left to right): [optional ZK prefix] [subtables [start, sequential_end)] [optional gap] [optional last-in-range subtable preceded by APPEND_TRACE_OFFSET]

If fixed_append_offset_for_last is set, sequential_end = end - 1 and the last-in-range subtable is placed at row (zk_size + offset * NUM_ROWS_PER_OP + APPEND_TRACE_OFFSET). Any intervening rows are left at the zero-initialized default. Otherwise sequential_end = end and there is no gap.

Definition at line 529 of file ecc_ops_table.hpp.

◆ construct_current_ultra_ops_subtable_columns()

ColumnPolynomials bb::UltraEccOpsTable::construct_current_ultra_ops_subtable_columns ( ) const
inline

Definition at line 474 of file ecc_ops_table.hpp.

◆ construct_subtable_columns()

std::vector< ColumnPolynomials > bb::UltraEccOpsTable::construct_subtable_columns ( ) const
inline

Definition at line 435 of file ecc_ops_table.hpp.

◆ construct_table_columns()

ColumnPolynomials bb::UltraEccOpsTable::construct_table_columns ( const bool  include_zk_ops = true) const
inline

Definition at line 450 of file ecc_ops_table.hpp.

◆ construct_table_columns_up_to_tail()

ColumnPolynomials bb::UltraEccOpsTable::construct_table_columns_up_to_tail ( ) const
inline

Definition at line 459 of file ecc_ops_table.hpp.

◆ construct_zk_columns()

std::pair< ColumnPolynomials, ECCVMOperation > bb::UltraEccOpsTable::construct_zk_columns ( )
inline

Definition at line 388 of file ecc_ops_table.hpp.

◆ create_new_subtable()

void bb::UltraEccOpsTable::create_new_subtable ( size_t  size_hint = 0)
inline

Definition at line 306 of file ecc_ops_table.hpp.

◆ get_current_subtable_size()

size_t bb::UltraEccOpsTable::get_current_subtable_size ( ) const
inline

Definition at line 332 of file ecc_ops_table.hpp.

◆ get_no_zk_reconstructed_ultra_ops()

std::vector< UltraOp > bb::UltraEccOpsTable::get_no_zk_reconstructed_ultra_ops ( ) const
inline

Definition at line 334 of file ecc_ops_table.hpp.

◆ get_reconstructed()

std::vector< UltraOp > bb::UltraEccOpsTable::get_reconstructed ( const bool  include_zk_ops) const
inlineprivate

Definition at line 345 of file ecc_ops_table.hpp.

◆ get_zk_reconstructed_ultra_ops()

std::vector< UltraOp > bb::UltraEccOpsTable::get_zk_reconstructed_ultra_ops ( ) const
inline

Definition at line 339 of file ecc_ops_table.hpp.

◆ has_fixed_append_offset()

bool bb::UltraEccOpsTable::has_fixed_append_offset ( ) const
inline

Definition at line 308 of file ecc_ops_table.hpp.

◆ has_zk_ops()

bool bb::UltraEccOpsTable::has_zk_ops ( ) const
inline

Definition at line 309 of file ecc_ops_table.hpp.

◆ make_hiding_op_pair()

static std::pair< UltraOp, ECCVMOperation > bb::UltraEccOpsTable::make_hiding_op_pair ( const curve::BN254::BaseField Px,
const curve::BN254::BaseField Py 
)
inlinestatic

Build a hiding op as paired Ultra and ECCVM operations from raw Fq coordinates.

Uses opcode q_eq=q_reset=1 (value 3) for Translator compatibility. The base point is constructed directly from (Px, Py); these are not required to lie on the curve since on-curve and equality constraints are gated off at the row where the hiding op lands (lagrange_second in ECCVM). z_1 and z_2 are zero in the Ultra representation since the hiding op performs no scalar multiplication.

Definition at line 232 of file ecc_ops_table.hpp.

◆ merge()

void bb::UltraEccOpsTable::merge ( )
inline

Definition at line 310 of file ecc_ops_table.hpp.

◆ merge_with_fixed_append_offset()

void bb::UltraEccOpsTable::merge_with_fixed_append_offset ( size_t  offset)
inline

Definition at line 315 of file ecc_ops_table.hpp.

◆ num_ops()

size_t bb::UltraEccOpsTable::num_ops ( ) const
inline

Definition at line 278 of file ecc_ops_table.hpp.

◆ num_ultra_rows()

size_t bb::UltraEccOpsTable::num_ultra_rows ( ) const
inline

Definition at line 283 of file ecc_ops_table.hpp.

◆ push()

void bb::UltraEccOpsTable::push ( const UltraOp op)
inline

Definition at line 307 of file ecc_ops_table.hpp.

◆ ultra_table_size_up_to_tail()

size_t bb::UltraEccOpsTable::ultra_table_size_up_to_tail ( ) const
inline

Definition at line 293 of file ecc_ops_table.hpp.

◆ write_op_to_polynomials()

static void bb::UltraEccOpsTable::write_op_to_polynomials ( ColumnPolynomials column_polynomials,
const UltraOp op,
const size_t  row_idx 
)
inlinestaticprivate

Write a single UltraOp to the column polynomials at the given position.

Each op is written across 2 rows (NUM_ROWS_PER_OP)

Parameters
column_polynomialsThe column polynomials to write to
opThe operation to write
row_idxThe starting row index (will write to row_idx and row_idx+1)

Definition at line 505 of file ecc_ops_table.hpp.

Member Data Documentation

◆ APPEND_TRACE_OFFSET

constexpr size_t bb::UltraEccOpsTable::APPEND_TRACE_OFFSET = NUM_DISABLED_ROWS_IN_SUMCHECK
staticconstexpr

Definition at line 221 of file ecc_ops_table.hpp.

◆ fixed_append_offset

std::optional<size_t> bb::UltraEccOpsTable::fixed_append_offset
private

Definition at line 274 of file ecc_ops_table.hpp.

◆ NUM_ROWS_PER_OP

constexpr size_t bb::UltraEccOpsTable::NUM_ROWS_PER_OP = 2
staticconstexpr

Definition at line 213 of file ecc_ops_table.hpp.

◆ table

UltraOpsTable bb::UltraEccOpsTable::table
private

Definition at line 266 of file ecc_ops_table.hpp.

◆ TABLE_WIDTH

constexpr size_t bb::UltraEccOpsTable::TABLE_WIDTH = 4
staticconstexpr

Definition at line 212 of file ecc_ops_table.hpp.

◆ zk_ops

std::vector<UltraOp> bb::UltraEccOpsTable::zk_ops
private

Definition at line 267 of file ecc_ops_table.hpp.

◆ ZK_ULTRA_OPS

constexpr size_t bb::UltraEccOpsTable::ZK_ULTRA_OPS
staticconstexpr
Initial value:
=
(ECC_NUM_RANDOM_OPS_START + ECC_NUM_NO_OPS_START + ECC_NUM_HIDING_OPS_START) * NUM_ROWS_PER_OP
static constexpr size_t NUM_ROWS_PER_OP

Definition at line 214 of file ecc_ops_table.hpp.


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