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

#include <utils.hpp>

Public Types

using FF = typename Flavor::FF
 
using Relations = typename Flavor::Relations
 
using PolynomialEvaluations = typename Flavor::AllValues
 
using RelationEvaluations = decltype(create_tuple_of_arrays_of_values< typename Flavor::Relations >())
 
using SubrelationSeparators = typename Flavor::SubrelationSeparators
 

Static Public Member Functions

template<class Operation >
static void apply_to_tuple_of_tuples (auto &tuple, Operation &&operation)
 General purpose method for applying an operation to a tuple of tuples of Univariates.
 
static void zero_univariates (auto &tuple)
 Set all coefficients of Univariates to zero.
 
static void scale_univariates (auto &tuple, const SubrelationSeparators &subrelation_separators)
 Scale Univariates, each representing a subrelation, by different challenges.
 
template<typename Tuple >
static constexpr void add_tuples (Tuple &tuple_1, const Tuple &tuple_2)
 Componentwise addition of two tuples.
 
template<typename Tuple >
static constexpr void add_nested_tuples (Tuple &tuple_1, const Tuple &tuple_2)
 Componentwise addition of nested tuples (tuples of tuples)
 
template<typename Parameters >
static void accumulate_relation_evaluations_without_skipping (const PolynomialEvaluations &evaluations, RelationEvaluations &relation_evaluations, const Parameters &relation_parameters, const FF &partial_evaluation_result)
 Calculate the contribution of each relation to the expected value of the full Honk relation.
 
template<typename Parameters >
static RelationEvaluations accumulate_relation_evaluations (const PolynomialEvaluations &evaluations, const Parameters &relation_parameters, const FF &partial_evaluation_result)
 Calculate the contribution of each relation to the expected value of the full Honk relation.
 
template<typename Parameters , size_t relation_idx, bool consider_skipping = true>
static void accumulate_single_relation (const PolynomialEvaluations &evaluations, RelationEvaluations &relation_evaluations, const Parameters &relation_parameters, const FF &partial_evaluation_result)
 
static void zero_elements (auto &tuple)
 Set each element in a tuple of arrays to zero.
 
static FF scale_and_batch_elements (auto &tuple, const SubrelationSeparators &subrelation_separators)
 Scale elements, representing evaluations of subrelations, by separate challenges then sum them.
 
template<typename Operation >
static void apply_to_tuple_of_arrays (Operation &&operation, auto &tuple)
 General purpose method for applying a tuple of arrays (of FFs)
 
template<typename Operation , typename tuple_type >
static void apply_to_tuple_of_arrays_elements (Operation &&operation, const tuple_type &tuple)
 Recursive template function to apply a specific operation on each element of several arrays in a tuple.
 

Static Public Attributes

static constexpr size_t NUM_RELATIONS = Flavor::NUM_RELATIONS
 
static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS
 

Detailed Description

template<typename Flavor>
class bb::RelationUtils< Flavor >

Definition at line 22 of file utils.hpp.

Member Typedef Documentation

◆ FF

template<typename Flavor >
using bb::RelationUtils< Flavor >::FF = typename Flavor::FF

Definition at line 24 of file utils.hpp.

◆ PolynomialEvaluations

template<typename Flavor >
using bb::RelationUtils< Flavor >::PolynomialEvaluations = typename Flavor::AllValues

Definition at line 26 of file utils.hpp.

◆ RelationEvaluations

template<typename Flavor >
using bb::RelationUtils< Flavor >::RelationEvaluations = decltype(create_tuple_of_arrays_of_values<typename Flavor::Relations>())

Definition at line 27 of file utils.hpp.

◆ Relations

template<typename Flavor >
using bb::RelationUtils< Flavor >::Relations = typename Flavor::Relations

Definition at line 25 of file utils.hpp.

◆ SubrelationSeparators

template<typename Flavor >
using bb::RelationUtils< Flavor >::SubrelationSeparators = typename Flavor::SubrelationSeparators

Definition at line 28 of file utils.hpp.

Member Function Documentation

◆ accumulate_relation_evaluations()

template<typename Flavor >
template<typename Parameters >
static RelationEvaluations bb::RelationUtils< Flavor >::accumulate_relation_evaluations ( const PolynomialEvaluations evaluations,
const Parameters &  relation_parameters,
const FF partial_evaluation_result 
)
inlinestatic

Calculate the contribution of each relation to the expected value of the full Honk relation.

For each relation, use the purported values (supplied by the prover) of the multivariates to calculate a contribution to the purported value of the full Honk relation. These are stored in evaluations. Adding these together, with appropriate scaling factors, produces the expected value of the full Honk relation. This value is checked against the final value of the target total sum (called sigma_0 in the thesis).

Definition at line 155 of file utils.hpp.

◆ accumulate_relation_evaluations_without_skipping()

template<typename Flavor >
template<typename Parameters >
static void bb::RelationUtils< Flavor >::accumulate_relation_evaluations_without_skipping ( const PolynomialEvaluations evaluations,
RelationEvaluations relation_evaluations,
const Parameters &  relation_parameters,
const FF partial_evaluation_result 
)
inlinestatic

Calculate the contribution of each relation to the expected value of the full Honk relation.

For each relation, use the purported values (supplied by the prover) of the multivariates to calculate a contribution to the purported value of the full Honk relation. These are stored in evaluations. Adding these together, with appropriate scaling factors, produces the expected value of the full Honk relation. This value is checked against the final value of the target total sum (called sigma_0 in the thesis).

Definition at line 133 of file utils.hpp.

◆ accumulate_single_relation()

template<typename Flavor >
template<typename Parameters , size_t relation_idx, bool consider_skipping = true>
static void bb::RelationUtils< Flavor >::accumulate_single_relation ( const PolynomialEvaluations evaluations,
RelationEvaluations relation_evaluations,
const Parameters &  relation_parameters,
const FF partial_evaluation_result 
)
inlinestatic

Definition at line 168 of file utils.hpp.

◆ add_nested_tuples()

template<typename Flavor >
template<typename Tuple >
static constexpr void bb::RelationUtils< Flavor >::add_nested_tuples ( Tuple &  tuple_1,
const Tuple &  tuple_2 
)
inlinestaticconstexpr

Componentwise addition of nested tuples (tuples of tuples)

Used for summing tuples of tuples of Univariates. Needed for Sumcheck multithreading. Each thread accumulates relation contributions across a portion of the hypecube and then the results are accumulated into a single nested tuple.

Template Parameters
Tuple
IndexIndex into outer tuple
Parameters
tuple_1First nested tuple summand. Result stored here
tuple_2Second summand

Definition at line 117 of file utils.hpp.

◆ add_tuples()

template<typename Flavor >
template<typename Tuple >
static constexpr void bb::RelationUtils< Flavor >::add_tuples ( Tuple &  tuple_1,
const Tuple &  tuple_2 
)
inlinestaticconstexpr

Componentwise addition of two tuples.

Used for adding tuples of Univariates but in general works for any object for which += is defined. The result is stored in the first tuple.

Template Parameters
TType of the elements contained in the tuples
Parameters
tuple_1First summand. Result stored in this tuple
tuple_2Second summand

Definition at line 97 of file utils.hpp.

◆ apply_to_tuple_of_arrays()

template<typename Flavor >
template<typename Operation >
static void bb::RelationUtils< Flavor >::apply_to_tuple_of_arrays ( Operation &&  operation,
auto &  tuple 
)
inlinestatic

General purpose method for applying a tuple of arrays (of FFs)

Template Parameters
OperationAny operation valid on elements of the inner arrays (FFs)
Parameters
tupleTuple of arrays (of FFs)

Definition at line 238 of file utils.hpp.

◆ apply_to_tuple_of_arrays_elements()

template<typename Flavor >
template<typename Operation , typename tuple_type >
static void bb::RelationUtils< Flavor >::apply_to_tuple_of_arrays_elements ( Operation &&  operation,
const tuple_type &  tuple 
)
inlinestatic

Recursive template function to apply a specific operation on each element of several arrays in a tuple.

We need this method in addition to the apply_to_tuple_of_arrays when we aim to perform different operations depending on the array element. More explicitly, in our codebase this method is used when the elements of array are values of subrelations and we want to accumulate some of these values separately (the linearly dependent contribution when we compute the evaluation of full rel_U(G)H at particular row.)

Definition at line 259 of file utils.hpp.

◆ apply_to_tuple_of_tuples()

template<typename Flavor >
template<class Operation >
static void bb::RelationUtils< Flavor >::apply_to_tuple_of_tuples ( auto &  tuple,
Operation &&  operation 
)
inlinestatic

General purpose method for applying an operation to a tuple of tuples of Univariates.

Utility methods for tuple of tuples of Univariates

Template Parameters
OperationAny operation valid on Univariates
Parameters
tupleA Tuple of tuples of Univariates
operationOperation to apply to Univariates

Definition at line 43 of file utils.hpp.

◆ scale_and_batch_elements()

template<typename Flavor >
static FF bb::RelationUtils< Flavor >::scale_and_batch_elements ( auto &  tuple,
const SubrelationSeparators subrelation_separators 
)
inlinestatic

Scale elements, representing evaluations of subrelations, by separate challenges then sum them.

Parameters
challengesArray of NUM_SUBRELATIONS - 1 challenges (because the first subrelation does not need to be scaled)
resultBatched result

Definition at line 215 of file utils.hpp.

◆ scale_univariates()

template<typename Flavor >
static void bb::RelationUtils< Flavor >::scale_univariates ( auto &  tuple,
const SubrelationSeparators subrelation_separators 
)
inlinestatic

Scale Univariates, each representing a subrelation, by different challenges.

Parameters
tupleTuple of tuples of Univariates
subrelation_separatorsArray of NUM_SUBRELATIONS challenges with the first entry equal to 1. scaled)

Definition at line 76 of file utils.hpp.

◆ zero_elements()

template<typename Flavor >
static void bb::RelationUtils< Flavor >::zero_elements ( auto &  tuple)
inlinestatic

Set each element in a tuple of arrays to zero.

Utility methods for tuple of arrays

FF's default constructor may not initialize to zero (e.g., bb::fr), hence we can't rely on aggregate initialization of the evaluations array.

Definition at line 203 of file utils.hpp.

◆ zero_univariates()

template<typename Flavor >
static void bb::RelationUtils< Flavor >::zero_univariates ( auto &  tuple)
inlinestatic

Set all coefficients of Univariates to zero.

After computing the round univariate, it is necessary to zero-out the accumulators used to compute it.

Definition at line 61 of file utils.hpp.

Member Data Documentation

◆ NUM_RELATIONS

template<typename Flavor >
constexpr size_t bb::RelationUtils< Flavor >::NUM_RELATIONS = Flavor::NUM_RELATIONS
staticconstexpr

Definition at line 30 of file utils.hpp.

◆ NUM_SUBRELATIONS

template<typename Flavor >
constexpr size_t bb::RelationUtils< Flavor >::NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS
staticconstexpr

Definition at line 31 of file utils.hpp.


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