Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_permutation_short_relation.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
10
11namespace bb {
12
13template <typename FF_> class TranslatorPermutationShortRelationImpl {
14 public:
15 using FF = FF_;
16 // 1 + polynomial degree of this relation
17 static constexpr size_t RELATION_LENGTH = 7;
18
19 static constexpr std::array<size_t, 3> SUBRELATION_PARTIAL_LENGTHS{
20 7, // grand product construction sub-relation
21 3, // left-shiftable polynomial sub-relation
22 3 // z_perm initialization sub-relation
23 };
24
29 template <typename AllEntities> inline static bool skip(const AllEntities& in)
30 {
31 // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in
32 // non-trivial copy constraints.
33 return (in.z_perm - in.z_perm_shift).is_zero();
34 }
35
36 inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; }
37 inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; }
38
39 template <typename Accumulator, typename AllEntities, typename Parameters>
40 inline static Accumulator compute_grand_product_numerator(const AllEntities& in, const Parameters& params)
41 {
43 using ParameterView = Parameters::DataType;
44
45 auto concatenated_range_constraints_0 = View(in.concatenated_range_constraints_0);
46 auto concatenated_range_constraints_1 = View(in.concatenated_range_constraints_1);
47 auto concatenated_range_constraints_2 = View(in.concatenated_range_constraints_2);
48 auto concatenated_range_constraints_3 = View(in.concatenated_range_constraints_3);
49
50 auto ordered_extra_range_constraints_numerator = View(in.ordered_extra_range_constraints_numerator);
51
52 auto lagrange_masking = View(in.lagrange_masking);
53 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
54 const auto& gamma = ParameterView(params.gamma);
55 const auto& beta = ParameterView(params.beta);
56 // First 4 factors use scattered masking (lagrange_masking), last factor uses contiguous masking.
57 // Keep the first multiply in coefficient basis, then materialize once the degree exceeds the quadratic
58 // coefficient-basis helper.
59 auto chosen_set = lagrange_masking * beta;
60 auto chosen_set2 = lagrange_ordered_masking * beta;
61 auto product = Accumulator((concatenated_range_constraints_0 + chosen_set + gamma) *
62 (concatenated_range_constraints_1 + chosen_set + gamma)) *
63 Accumulator((concatenated_range_constraints_2 + chosen_set + gamma) *
64 (concatenated_range_constraints_3 + chosen_set + gamma));
65 product *= Accumulator(ordered_extra_range_constraints_numerator + chosen_set2 + gamma);
66 return product;
67 }
68
69 template <typename Accumulator, typename AllEntities, typename Parameters, typename Factor>
70 inline static Accumulator compute_grand_product_numerator_with_factor(const AllEntities& in,
71 const Parameters& params,
72 const Factor& factor)
73 {
75 using ParameterView = Parameters::DataType;
76
77 auto concatenated_range_constraints_0 = View(in.concatenated_range_constraints_0);
78 auto concatenated_range_constraints_1 = View(in.concatenated_range_constraints_1);
79 auto concatenated_range_constraints_2 = View(in.concatenated_range_constraints_2);
80 auto concatenated_range_constraints_3 = View(in.concatenated_range_constraints_3);
81
82 auto ordered_extra_range_constraints_numerator = View(in.ordered_extra_range_constraints_numerator);
83
84 auto lagrange_masking = View(in.lagrange_masking);
85 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
86 const auto& gamma = ParameterView(params.gamma);
87 const auto& beta = ParameterView(params.beta);
88 // The sumcheck contribution multiplies this 5-factor grand product by an outer linear factor. Build the
89 // resulting 6-factor product as three quadratic coefficient-basis products before materializing.
90 auto chosen_set = lagrange_masking * beta;
91 auto chosen_set2 = lagrange_ordered_masking * beta;
92 auto product = Accumulator(factor * (concatenated_range_constraints_0 + chosen_set + gamma)) *
93 Accumulator((concatenated_range_constraints_1 + chosen_set + gamma) *
94 (concatenated_range_constraints_2 + chosen_set + gamma));
95 product *= Accumulator((concatenated_range_constraints_3 + chosen_set + gamma) *
96 (ordered_extra_range_constraints_numerator + chosen_set2 + gamma));
97 return product;
98 }
99
100 template <typename Accumulator, typename AllEntities, typename Parameters>
101 inline static Accumulator compute_grand_product_denominator(const AllEntities& in, const Parameters& params)
102 {
104 using ParameterView = Parameters::DataType;
105
106 auto ordered_range_constraints_0 = View(in.ordered_range_constraints_0);
107 auto ordered_range_constraints_1 = View(in.ordered_range_constraints_1);
108 auto ordered_range_constraints_2 = View(in.ordered_range_constraints_2);
109 auto ordered_range_constraints_3 = View(in.ordered_range_constraints_3);
110 auto ordered_range_constraints_4 = View(in.ordered_range_constraints_4);
111
112 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
113
114 const auto& gamma = ParameterView(params.gamma);
115 const auto& beta = ParameterView(params.beta);
116 // All 5 factors use contiguous masking at the end (lagrange_ordered_masking).
117 auto chosen_set = lagrange_ordered_masking * beta;
118 auto product = Accumulator((ordered_range_constraints_0 + chosen_set + gamma) *
119 (ordered_range_constraints_1 + chosen_set + gamma)) *
120 Accumulator((ordered_range_constraints_2 + chosen_set + gamma) *
121 (ordered_range_constraints_3 + chosen_set + gamma));
122 product *= Accumulator(ordered_range_constraints_4 + chosen_set + gamma);
123 return product;
124 }
125
126 template <typename Accumulator, typename AllEntities, typename Parameters, typename Factor>
127 inline static Accumulator compute_grand_product_denominator_with_factor(const AllEntities& in,
128 const Parameters& params,
129 const Factor& factor)
130 {
132 using ParameterView = Parameters::DataType;
133
134 auto ordered_range_constraints_0 = View(in.ordered_range_constraints_0);
135 auto ordered_range_constraints_1 = View(in.ordered_range_constraints_1);
136 auto ordered_range_constraints_2 = View(in.ordered_range_constraints_2);
137 auto ordered_range_constraints_3 = View(in.ordered_range_constraints_3);
138 auto ordered_range_constraints_4 = View(in.ordered_range_constraints_4);
139
140 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
141
142 const auto& gamma = ParameterView(params.gamma);
143 const auto& beta = ParameterView(params.beta);
144 // The sumcheck contribution multiplies this 5-factor grand product by an outer linear factor. Build the
145 // resulting 6-factor product as three quadratic coefficient-basis products before materializing.
146 auto chosen_set = lagrange_ordered_masking * beta;
147 auto product = Accumulator(factor * (ordered_range_constraints_0 + chosen_set + gamma)) *
148 Accumulator((ordered_range_constraints_1 + chosen_set + gamma) *
149 (ordered_range_constraints_2 + chosen_set + gamma));
150 product *= Accumulator((ordered_range_constraints_3 + chosen_set + gamma) *
151 (ordered_range_constraints_4 + chosen_set + gamma));
152 return product;
153 }
185 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
186 static void accumulate(ContainerOverSubrelations& accumulators,
187 const AllEntities& in,
188 const Parameters& params,
189 const FF& scaling_factor);
190};
191
193
194} // namespace bb
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static Accumulator compute_grand_product_numerator(const AllEntities &in, const Parameters &params)
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_denominator(const AllEntities &in, const Parameters &params)
static Accumulator compute_grand_product_numerator_with_factor(const AllEntities &in, const Parameters &params, const Factor &factor)
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
static Accumulator compute_grand_product_denominator_with_factor(const AllEntities &in, const Parameters &params, const Factor &factor)
static bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
typename Accumulator::CoefficientAccumulator TranslatorShortMonomialView