Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::GenericPermutationRelationImpl< Settings, FF_ > Class Template Reference

Implementation of a generic permutation relation. More...

#include <generic_permutation_relation.hpp>

Public Types

using FF = FF_
 
using PolynomialStructure = PermutationPolynomialStructure< Settings >
 

Static Public Member Functions

template<typename AllValues >
static bool operation_exists_at_row (const AllValues &row)
 Check if we need to compute the inverse polynomial element value for this row.
 
template<typename AllEntities >
static auto & get_inverse_polynomial (AllEntities &in)
 Get the inverse permutation polynomial (needed to compute its value)
 
template<typename Accumulator , typename AllEntities >
static Accumulator compute_inverse_exists (const AllEntities &in)
 Get selector/wire switching on (1) or off (0) inverse computation.
 
template<typename Accumulator , size_t lookup_index, typename AllEntities >
static Accumulator get_lookup_term_predicate (const AllEntities &in)
 Extract predicate enabling looking up a given lookup term at this row.
 
template<typename Accumulator , size_t table_index, typename AllEntities >
static Accumulator get_table_term_predicate (const AllEntities &in)
 Extract predicate enabling looking up a given table term at this row.
 
template<typename Accumulator , size_t lookup_index, typename AllEntities , typename Parameters >
static Accumulator compute_lookup_term (const AllEntities &in, const Parameters &params)
 Compute the value of the lookup term at a given index.
 
template<typename Accumulator , size_t table_index, typename AllEntities , typename Parameters >
static Accumulator compute_table_term (const AllEntities &in, const Parameters &params)
 Compute the value of a table term at a given index.
 
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void accumulate (ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
 Compute generic log-derivative set permutation subrelation accumulation.
 

Static Public Attributes

static constexpr size_t NUM_LOOKUP_TERMS = 1
 
static constexpr size_t NUM_TABLE_TERMS = 1
 
static constexpr size_t FIRST_RELATION_PARTIAL_LENGTH
 
static constexpr size_t SECOND_RELATION_PARTIAL_LENGTH
 
static constexpr size_t LENGTH = std::max(FIRST_RELATION_PARTIAL_LENGTH, SECOND_RELATION_PARTIAL_LENGTH)
 
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
 
static constexpr std::array< bool, 2 > SUBRELATION_LINEARLY_INDEPENDENT = { true, false }
 We apply the power polynomial only to the first subrelation.
 

Detailed Description

template<typename Settings, typename FF_>
class bb::GenericPermutationRelationImpl< Settings, FF_ >

Implementation of a generic permutation relation.

Implementation of a generic permutation relation that uses a log-derivative argument to prove that elements in two columns of the execution trace are equal. The strategy is to use the lookup log-derivate argument with read counts (i.e., number of times the lookup terms are looked up) equal to 1. This enforces the sets we are comparing to be permutations of one another. The relation is composed of two subrelations, the first is equal to the first subrelation in GenericLookupRelationImpl. The second one is the modification of the second subrelation of the generic lookup in which we hard-code the read counts to 1:

\[ \sum_{i=0}^{\text{NUM_LOOKUP_TERMS}} \text{lookup_entry_predicate}_i(x) \cdot \frac{1}{\text{lookup_entry}_i(x)} - \sum_{i=0}^{\text{NUM_TABLE_TERMS}} \text{table_entry_predicate}_i(x) \cdot \frac{1}{\text{table_entry}_i(x)} \]

Note
The predicates involved in the second subrelation are assumed to have been constrained to be boolean outside this relation.

Definition at line 68 of file generic_permutation_relation.hpp.

Member Typedef Documentation

◆ FF

template<typename Settings , typename FF_ >
using bb::GenericPermutationRelationImpl< Settings, FF_ >::FF = FF_

Definition at line 70 of file generic_permutation_relation.hpp.

◆ PolynomialStructure

template<typename Settings , typename FF_ >
using bb::GenericPermutationRelationImpl< Settings, FF_ >::PolynomialStructure = PermutationPolynomialStructure<Settings>

Definition at line 71 of file generic_permutation_relation.hpp.

Member Function Documentation

◆ accumulate()

template<typename Settings , typename FF_ >
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void bb::GenericPermutationRelationImpl< Settings, FF_ >::accumulate ( ContainerOverSubrelations &  accumulator,
const AllEntities &  in,
const Parameters &  params,
const FF scaling_factor 
)
inlinestatic

Compute generic log-derivative set permutation subrelation accumulation.

he generic log-derivative lookup relation consists of two subrelations. The first demonstrates that the inverse polynomial I has been computed correctly. The second establishes the correctness of the lookups themselves based on the log-derivative lookup argument. Note that the latter subrelation is "linearly dependent" in the sense that it establishes that a sum across all rows of the exectution trace is zero, rather than that some expression holds independently at each row. Accordingly, this subrelation is not multiplied by a scaling factor at each accumulation step. See the documentation for GenericPermutationRelationImpl for the definition of the subrelations.

Template Parameters
ContainerOverSubrelationsContainer type for accumulating subrelation contributions
AllEntitiesType containing all polynomial entities
ParametersType containing relation parameters
Parameters
accumulatortransformed to evals + C(in(X)...)*scaling_factor
inan std::array containing the fully extended Accumulator edges.
relation_paramscontains beta, gamma, and public_input_delta, ....
scaling_factoroptional term to scale the evaluation before adding to evals.

Definition at line 275 of file generic_permutation_relation.hpp.

◆ compute_inverse_exists()

template<typename Settings , typename FF_ >
template<typename Accumulator , typename AllEntities >
static Accumulator bb::GenericPermutationRelationImpl< Settings, FF_ >::compute_inverse_exists ( const AllEntities &  in)
inlinestatic

Get selector/wire switching on (1) or off (0) inverse computation.

Template Parameters
AccumulatorAccumulator type for polynomial evaluations
AllEntitiesType containing all polynomial entities
Parameters
inAll entities
Returns
Accumulator value indicating whether inverse should be computed (1) or not (0)

Definition at line 135 of file generic_permutation_relation.hpp.

◆ compute_lookup_term()

template<typename Settings , typename FF_ >
template<typename Accumulator , size_t lookup_index, typename AllEntities , typename Parameters >
static Accumulator bb::GenericPermutationRelationImpl< Settings, FF_ >::compute_lookup_term ( const AllEntities &  in,
const Parameters &  params 
)
inlinestatic

Compute the value of the lookup term at a given index.

Template Parameters
AccumulatorAccumulator type for polynomial evaluations
lookup_indexIndex of the lookup term to compute (kept for compatibility with lookups, always 0)
AllEntitiesType containing all polynomial entities
ParametersType containing relation parameters (beta, gamma)
Parameters
inAll entities
paramsRelation parameters
Returns
Accumulator containing the computed lookup term value

Definition at line 202 of file generic_permutation_relation.hpp.

◆ compute_table_term()

template<typename Settings , typename FF_ >
template<typename Accumulator , size_t table_index, typename AllEntities , typename Parameters >
static Accumulator bb::GenericPermutationRelationImpl< Settings, FF_ >::compute_table_term ( const AllEntities &  in,
const Parameters &  params 
)
inlinestatic

Compute the value of a table term at a given index.

Template Parameters
AccumulatorAccumulator type for polynomial evaluations
table_indexIndex of the table term to compute (kept for compatibility with lookups, always 0)
AllEntitiesType containing all polynomial entities
ParametersType containing relation parameters (beta, gamma)
Parameters
inAll entities
paramsRelation parameters
Returns
Accumulator containing the computed table term value

Definition at line 235 of file generic_permutation_relation.hpp.

◆ get_inverse_polynomial()

template<typename Settings , typename FF_ >
template<typename AllEntities >
static auto & bb::GenericPermutationRelationImpl< Settings, FF_ >::get_inverse_polynomial ( AllEntities &  in)
inlinestatic

Get the inverse permutation polynomial (needed to compute its value)

Definition at line 121 of file generic_permutation_relation.hpp.

◆ get_lookup_term_predicate()

template<typename Settings , typename FF_ >
template<typename Accumulator , size_t lookup_index, typename AllEntities >
static Accumulator bb::GenericPermutationRelationImpl< Settings, FF_ >::get_lookup_term_predicate ( const AllEntities &  in)
inlinestatic

Extract predicate enabling looking up a given lookup term at this row.

Template Parameters
AccumulatorAccumulator type for polynomial evaluations
lookup_indexIndex of the lookup term (kept for compatibility with lookups, always 0)
AllEntitiesType containing all polynomial entities
Parameters
inAll entities
Returns
Accumulator containing the predicate for the specified lookup term

Definition at line 159 of file generic_permutation_relation.hpp.

◆ get_table_term_predicate()

template<typename Settings , typename FF_ >
template<typename Accumulator , size_t table_index, typename AllEntities >
static Accumulator bb::GenericPermutationRelationImpl< Settings, FF_ >::get_table_term_predicate ( const AllEntities &  in)
inlinestatic

Extract predicate enabling looking up a given table term at this row.

Template Parameters
AccumulatorAccumulator type for polynomial evaluations
table_indexIndex of the table term (kept for compatibility with lookups, always 0)
AllEntitiesType containing all polynomial entities
Parameters
inAll entities
Returns
Accumulator containing the predicate for the specified table term

Definition at line 181 of file generic_permutation_relation.hpp.

◆ operation_exists_at_row()

template<typename Settings , typename FF_ >
template<typename AllValues >
static bool bb::GenericPermutationRelationImpl< Settings, FF_ >::operation_exists_at_row ( const AllValues &  row)
inlinestatic

Check if we need to compute the inverse polynomial element value for this row.

Template Parameters
AllValuesType containing all polynomial values at a given row
Parameters
rowAll values at row
Returns
true if the inverse polynomial should be computed at this row, false otherwise

Definition at line 111 of file generic_permutation_relation.hpp.

Member Data Documentation

◆ FIRST_RELATION_PARTIAL_LENGTH

template<typename Settings , typename FF_ >
constexpr size_t bb::GenericPermutationRelationImpl< Settings, FF_ >::FIRST_RELATION_PARTIAL_LENGTH
staticconstexpr
Initial value:
Settings::INVERSE_EXISTS_POLYNOMIAL_DEGREE) +
1
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13

Definition at line 81 of file generic_permutation_relation.hpp.

◆ LENGTH

template<typename Settings , typename FF_ >
constexpr size_t bb::GenericPermutationRelationImpl< Settings, FF_ >::LENGTH = std::max(FIRST_RELATION_PARTIAL_LENGTH, SECOND_RELATION_PARTIAL_LENGTH)
staticconstexpr

Definition at line 86 of file generic_permutation_relation.hpp.

◆ NUM_LOOKUP_TERMS

template<typename Settings , typename FF_ >
constexpr size_t bb::GenericPermutationRelationImpl< Settings, FF_ >::NUM_LOOKUP_TERMS = 1
staticconstexpr

Definition at line 75 of file generic_permutation_relation.hpp.

◆ NUM_TABLE_TERMS

template<typename Settings , typename FF_ >
constexpr size_t bb::GenericPermutationRelationImpl< Settings, FF_ >::NUM_TABLE_TERMS = 1
staticconstexpr

Definition at line 76 of file generic_permutation_relation.hpp.

◆ SECOND_RELATION_PARTIAL_LENGTH

template<typename Settings , typename FF_ >
constexpr size_t bb::GenericPermutationRelationImpl< Settings, FF_ >::SECOND_RELATION_PARTIAL_LENGTH
staticconstexpr
Initial value:

Definition at line 84 of file generic_permutation_relation.hpp.

◆ SUBRELATION_LINEARLY_INDEPENDENT

template<typename Settings , typename FF_ >
constexpr std::array<bool, 2> bb::GenericPermutationRelationImpl< Settings, FF_ >::SUBRELATION_LINEARLY_INDEPENDENT = { true, false }
staticconstexpr

We apply the power polynomial only to the first subrelation.

The first subrelation establishes correspondence between the inverse polynomial elements and the terms. The second relation computes the inverses of individual terms, which are then summed up with sumcheck

Definition at line 102 of file generic_permutation_relation.hpp.

◆ SUBRELATION_PARTIAL_LENGTHS

template<typename Settings , typename FF_ >
constexpr std::array<size_t, 2> bb::GenericPermutationRelationImpl< Settings, FF_ >::SUBRELATION_PARTIAL_LENGTHS
staticconstexpr
Initial value:

Definition at line 90 of file generic_permutation_relation.hpp.


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