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

#include <translator_proving_key.hpp>

Public Types

using Flavor = TranslatorFlavor
 
using Circuit = typename Flavor::CircuitBuilder
 
using FF = typename Flavor::FF
 
using BF = typename Flavor::BF
 
using ProvingKey = typename Flavor::ProvingKey
 
using Polynomial = typename Flavor::Polynomial
 
using ProverPolynomials = typename Flavor::ProverPolynomials
 

Public Member Functions

 TranslatorProvingKey ()=default
 
 TranslatorProvingKey (const Circuit &circuit)
 
void compute_lagrange_polynomials ()
 Constructs all Lagrange precomputed polynomials required for Translator relations. These enforce properties at specific positions within the Translator trace. Translator operates on two circuit sizes (full and mini) both requiring separate Lagrange polynomials.
 
void compute_extra_range_constraint_numerator ()
 Compute the extra numerator for the grand product polynomial.
 
void compute_translator_range_constraint_ordered_polynomials ()
 Compute denominator polynomials for Translator's range constraint permutation.
 
void compute_concatenated_polynomials ()
 Construct a set of polynomials that are the result of concatenating a group of polynomials into one. Used in translator to reduce the number of commitments while preserving PCS compatibility.
 
void split_concatenated_random_coefficients_to_ordered ()
 Distribute the randomness from the 4 concatenated range constraint polynomials to the 5 ordered range constraints such that commitments and evaluations of ordered polynomials and their shifts are hidden.
 

Static Public Member Functions

static std::array< size_t, Flavor::SORTED_STEPS_COUNTget_sorted_steps ()
 Create the array of steps inserted in each ordered range constraint to ensure they respect the appropriate structure for applying the DeltaRangeConstraint relation.
 

Public Attributes

std::shared_ptr< ProvingKeyproving_key
 
BF batching_challenge_v = { 0 }
 
BF evaluation_input_x = { 0 }
 

Static Public Attributes

static constexpr size_t mini_circuit_dyadic_size = Flavor::MINI_CIRCUIT_SIZE
 
static constexpr size_t dyadic_circuit_size = mini_circuit_dyadic_size * Flavor::CONCATENATION_GROUP_SIZE
 
static constexpr size_t dyadic_mini_circuit_size_without_masking
 
static constexpr size_t dyadic_circuit_size_without_masking
 

Detailed Description

Definition at line 14 of file translator_proving_key.hpp.

Member Typedef Documentation

◆ BF

Definition at line 19 of file translator_proving_key.hpp.

◆ Circuit

◆ FF

Definition at line 18 of file translator_proving_key.hpp.

◆ Flavor

◆ Polynomial

◆ ProverPolynomials

◆ ProvingKey

Constructor & Destructor Documentation

◆ TranslatorProvingKey() [1/2]

bb::TranslatorProvingKey::TranslatorProvingKey ( )
default

◆ TranslatorProvingKey() [2/2]

bb::TranslatorProvingKey::TranslatorProvingKey ( const Circuit circuit)
inline

Definition at line 43 of file translator_proving_key.hpp.

Member Function Documentation

◆ compute_concatenated_polynomials()

void bb::TranslatorProvingKey::compute_concatenated_polynomials ( )

Construct a set of polynomials that are the result of concatenating a group of polynomials into one. Used in translator to reduce the number of commitments while preserving PCS compatibility.

Concatenation maps lane bits to MSB positions: concatenated_i[j * MINI_CIRCUIT_SIZE + k] = group_i_wire_j[k]

This ensures that the verifier can reconstruct concatenated evaluations from individual wire evaluations using Lagrange decomposition over the top 4 sumcheck challenges.

Definition at line 20 of file translator_proving_key.cpp.

◆ compute_extra_range_constraint_numerator()

void bb::TranslatorProvingKey::compute_extra_range_constraint_numerator ( )

Compute the extra numerator for the grand product polynomial.

Goblin proves that several polynomials contain only values in a certain range through 2 relations: 1) A grand product which ignores positions of elements (TranslatorPermutationRelation) 2) A relation enforcing a certain ordering on the elements of given polynomials (TranslatorDeltaRangeConstraintRelation)

We take the values from 4 concatenated range constraint polynomials, and spread them into 5 polynomials to be sorted (ordered_range_constraint_), adding all the steps from MAX_VALUE to 0 in each ordered range constraint to complete them. The latter polynomials will be in the denominator of the grand product, the former in the numerator. To make up for the added steps in the numerator, an additional polynomial needs to be generated which contains 5 MAX_VALUE, 5 (MAX_VALUE-STEP),... values.

Definition at line 335 of file translator_proving_key.cpp.

◆ compute_lagrange_polynomials()

void bb::TranslatorProvingKey::compute_lagrange_polynomials ( )

Constructs all Lagrange precomputed polynomials required for Translator relations. These enforce properties at specific positions within the Translator trace. Translator operates on two circuit sizes (full and mini) both requiring separate Lagrange polynomials.

With concatenation, the full circuit has CONCATENATION_GROUP_SIZE (16) blocks of MINI_CIRCUIT_SIZE each. Masking rows are scattered: the last NUM_MASKED_ROWS_END rows of each block, rather than contiguous at the end.

Full Circuit Lagranges:

  • lagrange_first: Active only at index 0, marks the first row of the full circuit
  • lagrange_real_last: Active at the last row with sorted values in ordered polynomials (before the contiguous masking region at circuit_size - MAX_RANDOM_VALUES_PER_ORDERED)
  • lagrange_last: Active at the very last row of the full circuit
  • lagrange_masking: Active at scattered masking positions — the last NUM_MASKED_ROWS_END rows of each of the CONCATENATION_GROUP_SIZE blocks
  • lagrange_ordered_masking: Active at the last MAX_RANDOM_VALUES_PER_ORDERED positions (contiguous at end), where random values are placed in ordered polynomials

Mini Circuit Lagranges:

  • lagrange_mini_masking: Active in two regions:
    1. Between RANDOMNESS_START and RESULT_ROW (random values at the beginning of the mini circuit)
    2. In the last rows of the mini circuit (for trailing randomness)
  • lagrange_even_in_minicircuit: Active at even indices within the actual ECC operation processing range, excluding randomness
  • lagrange_odd_in_minicircuit: Active at odd indices within the actual ECC operation processing range, excluding randomness
  • lagrange_result_row: Active only at the designated result row (Flavor::RESULT_ROW)
  • lagrange_last_in_minicircuit: Active at the last row before masking in the mini circuit

The even/odd Lagranges are needed because the Translator VM processes two rows of its execution trace simultaneously, with different relations applying to even and odd indexed rows.

Note
All Lagrange polynomials are initialized to 0 by default, and this function sets specific indices to 1 to create the desired selector behavior.
The masking regions contain random values used for zero-knowledge properties.

Definition at line 276 of file translator_proving_key.cpp.

◆ compute_translator_range_constraint_ordered_polynomials()

void bb::TranslatorProvingKey::compute_translator_range_constraint_ordered_polynomials ( )

Compute denominator polynomials for Translator's range constraint permutation.

We need to prove that all the range constraint wires in the concatenation groups indeed have values within the given range [0, 2^14 - 1]. To do this, we take the values from the 4 concatenated range constraint polynomials (concatenated_range_constraints_) and spread them into 5 ordered polynomials (ordered_range_constraints_) which, as the name suggests, are sorted in non-descending order. The TranslatorDeltaRangeConstraint relation operates on these ordered polynomials and ensures that sequential values differ by no more than 3, the last value is the maximum, and the first value is zero (zero at the start allows us to avoid complications with shifts). Then, we run the TranslatorPermutationRelation on the concatenated and ordered polynomials to show that they contain the same multiset of values, which implies that the wires in the groups are indeed within the correct range.

Ideally, we could simply rearrange the values from the 4 concatenated polynomials into 4 ordered polynomials, but we could hit the worst case scenario: every value in the polynomials is the maximum value. In that case we still need to add (max_range / 3 + 1) stepping-stone values to each ordered polynomial for the delta range constraint to hold. So we also need a 5th ordered polynomial to store the overflow: k * (max_range / 3 + 1) values that couldn't fit, plus (max_range / 3 + 1) connecting values. To counteract the extra (k + 1) * (max_range / 3 + 1) values in the denominator, we place a corresponding extra numerator polynomial (ordered_extra_range_constraints_numerator). The construction is feasible when (k + 1) * (max_range / 3 + 1) < concatenated polynomial size.

With concatenation, masking rows are scattered: the last NUM_MASKED_ROWS_END rows of each block. Sorted values occupy non-masking positions; masking values sit in the holes.

Definition at line 72 of file translator_proving_key.cpp.

◆ get_sorted_steps()

static std::array< size_t, Flavor::SORTED_STEPS_COUNT > bb::TranslatorProvingKey::get_sorted_steps ( )
inlinestatic

Create the array of steps inserted in each ordered range constraint to ensure they respect the appropriate structure for applying the DeltaRangeConstraint relation.

The delta range relation enforces values of a polynomial are within a certain range ([0, 2¹⁴ - 1] for translator). It achieves this efficiently by sorting the polynomial and checking that the difference between two adjacent values is no more than 3. In the event that the distribution of a polynomial is not uniform across the range (e.g. p_1(x) = {0, 2^14 - 1, 2^14 - 1, 2^14 - 1}), to ensure the relation is still satisfied, we concatenate the set of coefficients to a set of steps that span across the desired range.

Definition at line 106 of file translator_proving_key.hpp.

◆ split_concatenated_random_coefficients_to_ordered()

void bb::TranslatorProvingKey::split_concatenated_random_coefficients_to_ordered ( )

Distribute the randomness from the 4 concatenated range constraint polynomials to the 5 ordered range constraints such that commitments and evaluations of ordered polynomials and their shifts are hidden.

With concatenation, masking values are at scattered positions: the last NUM_MASKED_ROWS_END rows of each block (positions [j * MINI + (MINI - NUM_MASKED_ROWS_END), j * MINI + MINI) for each j in [0,16)). We extract these random values from the concatenated polynomials and distribute them to the ordered polynomials at the same scattered masking positions.

Definition at line 190 of file translator_proving_key.cpp.

Member Data Documentation

◆ batching_challenge_v

BF bb::TranslatorProvingKey::batching_challenge_v = { 0 }

Definition at line 38 of file translator_proving_key.hpp.

◆ dyadic_circuit_size

constexpr size_t bb::TranslatorProvingKey::dyadic_circuit_size = mini_circuit_dyadic_size * Flavor::CONCATENATION_GROUP_SIZE
staticconstexpr

Definition at line 26 of file translator_proving_key.hpp.

◆ dyadic_circuit_size_without_masking

constexpr size_t bb::TranslatorProvingKey::dyadic_circuit_size_without_masking
staticconstexpr
Initial value:

Definition at line 33 of file translator_proving_key.hpp.

◆ dyadic_mini_circuit_size_without_masking

constexpr size_t bb::TranslatorProvingKey::dyadic_mini_circuit_size_without_masking
staticconstexpr
Initial value:

Definition at line 31 of file translator_proving_key.hpp.

◆ evaluation_input_x

BF bb::TranslatorProvingKey::evaluation_input_x = { 0 }

Definition at line 39 of file translator_proving_key.hpp.

◆ mini_circuit_dyadic_size

constexpr size_t bb::TranslatorProvingKey::mini_circuit_dyadic_size = Flavor::MINI_CIRCUIT_SIZE
staticconstexpr

Definition at line 23 of file translator_proving_key.hpp.

◆ proving_key

std::shared_ptr<ProvingKey> bb::TranslatorProvingKey::proving_key

Definition at line 36 of file translator_proving_key.hpp.


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