Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::plookup::fixed_base Namespace Reference

Classes

class  FixedBaseTableTest
 
class  table
 Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of points. More...
 

Typedefs

using function_ptr = std::array< bb::fr, 2 >(*)(const std::array< uint64_t, 2 >)
 
using function_ptr_table = std::array< std::array< function_ptr, table::MAX_NUM_TABLES_IN_MULTITABLE >, table::NUM_FIXED_BASE_MULTI_TABLES >
 

Functions

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 pointers, so that we can specify the function pointer required for this method call using runtime variables multitable_index, table_index. (downstream code becomes a lot simpler if table_index is not compile time, particularly the init code in plookup_tables.cpp)
 
template grumpkin::g1::affine_element table::compute_generator_offset< table::BITS_PER_LO_SCALAR > (const grumpkin::g1::affine_element &input)
 
template grumpkin::g1::affine_element table::compute_generator_offset< table::BITS_PER_HI_SCALAR > (const grumpkin::g1::affine_element &input)
 
template table::fixed_base_scalar_mul_tables table::generate_tables< table::BITS_PER_LO_SCALAR > (const table::affine_element &input)
 
template table::fixed_base_scalar_mul_tables table::generate_tables< table::BITS_PER_HI_SCALAR > (const table::affine_element &input)
 
template MultiTable table::get_fixed_base_table< 0, table::BITS_PER_LO_SCALAR > (MultiTableId)
 
template MultiTable table::get_fixed_base_table< 1, table::BITS_PER_HI_SCALAR > (MultiTableId)
 
template MultiTable table::get_fixed_base_table< 2, table::BITS_PER_LO_SCALAR > (MultiTableId)
 
template MultiTable table::get_fixed_base_table< 3, table::BITS_PER_HI_SCALAR > (MultiTableId)
 
 TEST_F (FixedBaseTableTest, GeneratorPointsAndBasePointRelationships)
 Test that generator points are correctly initialized and have the expected relationships.
 
 TEST_F (FixedBaseTableTest, LookupTableGenerationCorrectness)
 Test that single lookup tables are generated correctly with the expected point progression.
 
 TEST_F (FixedBaseTableTest, MultiTableStructureAndOffsets)
 Test the complete multi-table structure and verify offset generators are computed correctly.
 
 TEST_F (FixedBaseTableTest, TableGenerationAndValueRetrieval)
 Test the generation of basic lookup tables and multi-tables, verifying value retrieval functions.
 
 TEST_F (FixedBaseTableTest, PartialTableHandling)
 Test that partial tables (using fewer than 9 bits) are handled correctly.
 

Typedef Documentation

◆ function_ptr

using bb::plookup::fixed_base::function_ptr = typedef std::array<bb::fr, 2> (*)(const std::array<uint64_t, 2>)

Definition at line 169 of file fixed_base.cpp.

◆ function_ptr_table

Function Documentation

◆ make_function_pointer_table()

constexpr function_ptr_table bb::plookup::fixed_base::make_function_pointer_table ( )
constexpr

create a compile-time static 2D array of all our required get_basic_fixed_base_table_values function pointers, so that we can specify the function pointer required for this method call using runtime variables multitable_index, table_index. (downstream code becomes a lot simpler if table_index is not compile time, particularly the init code in plookup_tables.cpp)

Returns
constexpr function_ptr_table

Definition at line 179 of file fixed_base.cpp.

◆ table::compute_generator_offset< table::BITS_PER_HI_SCALAR >()

◆ table::compute_generator_offset< table::BITS_PER_LO_SCALAR >()

◆ table::generate_tables< table::BITS_PER_HI_SCALAR >()

◆ table::generate_tables< table::BITS_PER_LO_SCALAR >()

◆ table::get_fixed_base_table< 0, table::BITS_PER_LO_SCALAR >()

◆ table::get_fixed_base_table< 1, table::BITS_PER_HI_SCALAR >()

◆ table::get_fixed_base_table< 2, table::BITS_PER_LO_SCALAR >()

◆ table::get_fixed_base_table< 3, table::BITS_PER_HI_SCALAR >()

◆ TEST_F() [1/5]

bb::plookup::fixed_base::TEST_F ( FixedBaseTableTest  ,
GeneratorPointsAndBasePointRelationships   
)

Test that generator points are correctly initialized and have the expected relationships.

This test verifies:

  • LHS and RHS generator points are valid curve points
  • LHS and RHS generators are distinct
  • The "lo" base points are identical to their respective generators
  • The "hi" base points are correctly computed as lo * 2^128 for handling the high bits of scalars

Definition at line 30 of file fixed_base.test.cpp.

◆ TEST_F() [2/5]

bb::plookup::fixed_base::TEST_F ( FixedBaseTableTest  ,
LookupTableGenerationCorrectness   
)

Test that single lookup tables are generated correctly with the expected point progression.

A lookup table contains precomputed multiples of a base point: [offset, offset + base, offset + 2*base, ...] This allows efficient scalar multiplication by table lookup instead of repeated point additions. The offset generator ensures table entries are never the point at infinity.e.

Definition at line 63 of file fixed_base.test.cpp.

◆ TEST_F() [3/5]

bb::plookup::fixed_base::TEST_F ( FixedBaseTableTest  ,
MultiTableStructureAndOffsets   
)

Test the complete multi-table structure and verify offset generators are computed correctly.

The fixed-base scalar multiplication system uses 4 multi-tables:

  • LHS_LO: 15 tables of 9 bits each for the low 128 bits of left scalars (last table uses only 2 bits)
  • LHS_HI: 14 tables of 9 bits each for the high 126 bits of left scalars
  • RHS_LO: 15 tables of 9 bits each for the low 128 bits of right scalars (last table uses only 2 bits)
  • RHS_HI: 14 tables of 9 bits each for the high 126 bits of right scalars

Each multi-table has an offset generator that ensures no table entries are the point at infinity.

Definition at line 94 of file fixed_base.test.cpp.

◆ TEST_F() [4/5]

bb::plookup::fixed_base::TEST_F ( FixedBaseTableTest  ,
PartialTableHandling   
)

Test that partial tables (using fewer than 9 bits) are handled correctly.

When splitting a 254-bit scalar into 9-bit chunks, the last chunk may have fewer bits. For 128-bit LO scalars: 14 tables × 9 bits + 1 table × 2 bits = 128 bits For 126-bit HI scalars: 14 tables × 9 bits = 126 bits (evenly divisible)

This test verifies that the last LO table only allocates space for 4 entries (2^2) while the last HI table uses the full 512 entries (2^9).

Definition at line 198 of file fixed_base.test.cpp.

◆ TEST_F() [5/5]

bb::plookup::fixed_base::TEST_F ( FixedBaseTableTest  ,
TableGenerationAndValueRetrieval   
)

Test the generation of basic lookup tables and multi-tables, verifying value retrieval functions.

Multi-tables combine multiple basic tables to handle multi-scalar multiplication efficiently. This test ensures that both table types are constructed correctly and that their lookup functions return the expected values.

Definition at line 146 of file fixed_base.test.cpp.