Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_permutation_relation.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
9
10namespace bb {
11
12template <typename FF_> class TranslatorPermutationRelationImpl {
13 public:
14 using FF = FF_;
15 // 1 + polynomial degree of this relation
16 static constexpr size_t RELATION_LENGTH = 7;
17
18 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
19 7, // grand product construction sub-relation
20 3 // left-shiftable polynomial sub-relation
21 };
22
27 template <typename AllEntities> inline static bool skip(const AllEntities& in)
28 {
29 // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in
30 // non-trivial copy constraints.
31 return (in.z_perm - in.z_perm_shift).is_zero();
32 }
33
34 inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; }
35 inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; }
36
37 template <typename Accumulator, typename AllEntities, typename Parameters>
38 inline static Accumulator compute_grand_product_numerator(const AllEntities& in, const Parameters& params)
39 {
40 using View = typename Accumulator::View;
41 using ParameterView = GetParameterView<Parameters, View>;
42
43 auto interleaved_range_constraints_0 = View(in.interleaved_range_constraints_0);
44 auto interleaved_range_constraints_1 = View(in.interleaved_range_constraints_1);
45 auto interleaved_range_constraints_2 = View(in.interleaved_range_constraints_2);
46 auto interleaved_range_constraints_3 = View(in.interleaved_range_constraints_3);
47
48 auto ordered_extra_range_constraints_numerator = View(in.ordered_extra_range_constraints_numerator);
49
50 auto lagrange_masking = View(in.lagrange_masking);
51 const auto& gamma = ParameterView(params.gamma);
52 const auto& beta = ParameterView(params.beta);
53 return (interleaved_range_constraints_0 + lagrange_masking * beta + gamma) *
54 (interleaved_range_constraints_1 + lagrange_masking * beta + gamma) *
55 (interleaved_range_constraints_2 + lagrange_masking * beta + gamma) *
56 (interleaved_range_constraints_3 + lagrange_masking * beta + gamma) *
57 (ordered_extra_range_constraints_numerator + lagrange_masking * beta + gamma);
58 }
59
60 template <typename Accumulator, typename AllEntities, typename Parameters>
61 inline static Accumulator compute_grand_product_denominator(const AllEntities& in, const Parameters& params)
62 {
63 using View = typename Accumulator::View;
64 using ParameterView = GetParameterView<Parameters, View>;
65
66 auto ordered_range_constraints_0 = View(in.ordered_range_constraints_0);
67 auto ordered_range_constraints_1 = View(in.ordered_range_constraints_1);
68 auto ordered_range_constraints_2 = View(in.ordered_range_constraints_2);
69 auto ordered_range_constraints_3 = View(in.ordered_range_constraints_3);
70 auto ordered_range_constraints_4 = View(in.ordered_range_constraints_4);
71
72 auto lagrange_masking = View(in.lagrange_masking);
73
74 const auto& gamma = ParameterView(params.gamma);
75 const auto& beta = ParameterView(params.beta);
76 return (ordered_range_constraints_0 + lagrange_masking * beta + gamma) *
77 (ordered_range_constraints_1 + lagrange_masking * beta + gamma) *
78 (ordered_range_constraints_2 + lagrange_masking * beta + gamma) *
79 (ordered_range_constraints_3 + lagrange_masking * beta + gamma) *
80 (ordered_range_constraints_4 + lagrange_masking * beta + gamma);
81 }
105 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
106 static void accumulate(ContainerOverSubrelations& accumulators,
107 const AllEntities& in,
108 const Parameters& params,
109 const FF& scaling_factor);
110};
111
113
114} // namespace bb
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
static Accumulator compute_grand_product_denominator(const AllEntities &in, const Parameters &params)
static bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
static void accumulate(ContainerOverSubrelations &accumulators, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
Compute contribution of the goblin translator permutation relation for a given edge (internal functio...
static Accumulator compute_grand_product_numerator(const AllEntities &in, const Parameters &params)
Entry point for Barretenberg command-line interface.
std::conditional_t< IsField< typename Params::DataType >, typename Params::DataType, View > GetParameterView
A type to optionally extract a view of a relation parameter in a relation.
typename Flavor::FF FF