Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_extra_short_relations.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 TranslatorOpcodeConstraintShortRelationImpl {
14 public:
15 using FF = FF_;
16
17 // 1 + polynomial degree of this relation
18 static constexpr size_t RELATION_LENGTH = 6;
19 static constexpr std::array<size_t, 5> SUBRELATION_PARTIAL_LENGTHS{
20 6, // opcode constraint relation
21 6, // opcode constraint relation
22 6, // opcode constraint relation
23 6, // opcode constraint relation
24 6 // opcode constraint relation
25 };
26
31 template <typename AllEntities> static bool skip(const AllEntities& in)
32 {
33 // Skip evaluation when not at even indices in the minicircuit and not in the masking area
34 // as the contribution is zero in these regions.
35 return (in.lagrange_even_in_minicircuit + in.lagrange_mini_masking).is_zero();
36 }
51 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
52 static void accumulate(ContainerOverSubrelations& accumulators,
53 const AllEntities& in,
54 const Parameters&,
55 const FF& scaling_factor);
56};
57
59 public:
60 using FF = FF_;
61
62 // 1 + polynomial degree of this relation
63 static constexpr size_t RELATION_LENGTH = 4; // degree((SOME_LAGRANGE)(A-B)) = 2
64 static constexpr std::array<size_t, 12> SUBRELATION_PARTIAL_LENGTHS{
65 4, // transfer accumulator limb 0 at odd index subrelation
66 4, // transfer accumulator limb 1 at odd index subrelation
67 4, // transfer accumulator limb 2 at odd index subrelation
68 4, // transfer accumulator limb 3 at odd index subrelation
69 3, // accumulator limb 0 is zero at the start of accumulation subrelation
70 3, // accumulator limb 1 is zero at the start of accumulation subrelation
71 3, // accumulator limb 2 is zero at the start of accumulation subrelation
72 3, // accumulator limb 3 is zero at the start of accumulation subrelation
73 3, // accumulator limb 0 is equal to given result at the end of accumulation subrelation
74 3, // accumulator limb 1 is equal to given result at the end of accumulation subrelation
75 3, // accumulator limb 2 is equal to given result at the end of accumulation subrelation
76 3 // accumulator limb 3 is equal to given result at the end of accumulation subrelation
77
78 };
79
88 template <typename AllEntities> static bool skip(const AllEntities& in)
89 {
90 // All contributions are zero outside the minicircuit and at even indices within the minicircuit
91 // (except the last and result row in minicircuit)
92 return (in.lagrange_odd_in_minicircuit + in.lagrange_last_in_minicircuit + in.lagrange_result_row).is_zero();
93 }
107 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
108 static void accumulate(ContainerOverSubrelations& accumulators,
109 const AllEntities& in,
110 const Parameters& params,
111 const FF& scaling_factor);
112};
113
114template <typename FF_> class TranslatorZeroConstraintsShortRelationImpl {
115 public:
116 using FF = FF_;
117
118 // 1 + polynomial degree of this relation
119 static constexpr size_t RELATION_LENGTH = 3; // degree((some lagrange)(A)) = 2
120
121 static constexpr std::array<size_t, 68> SUBRELATION_PARTIAL_LENGTHS{
122 3, // p_x_low_limbs_range_constraint_0 is zero outside of the minicircuit
123 3, // p_x_low_limbs_range_constraint_1 is zero outside of the minicircuit
124 3, // p_x_low_limbs_range_constraint_2 is zero outside of the minicircuit
125 3, // p_x_low_limbs_range_constraint_3 is zero outside of the minicircuit
126 3, // p_x_low_limbs_range_constraint_4 is zero outside of the minicircuit
127 3, // p_x_high_limbs_range_constraint_0 is zero outside of the minicircuit
128 3, // p_x_high_limbs_range_constraint_1 is zero outside of the minicircuit
129 3, // p_x_high_limbs_range_constraint_2 is zero outside of the minicircuit
130 3, // p_x_high_limbs_range_constraint_3 is zero outside of the minicircuit
131 3, // p_x_high_limbs_range_constraint_4 is zero outside of the minicircuit
132 3, // p_y_low_limbs_range_constraint_0 is zero outside of the minicircuit
133 3, // p_y_low_limbs_range_constraint_1 is zero outside of the minicircuit
134 3, // p_y_low_limbs_range_constraint_2 is zero outside of the minicircuit
135 3, // p_y_low_limbs_range_constraint_3 is zero outside of the minicircuit
136 3, // p_y_low_limbs_range_constraint_4 is zero outside of the minicircuit
137 3, // p_y_high_limbs_range_constraint_0 is zero outside of the minicircuit
138 3, // p_y_high_limbs_range_constraint_1 is zero outside of the minicircuit
139 3, // p_y_high_limbs_range_constraint_2 is zero outside of the minicircuit
140 3, // p_y_high_limbs_range_constraint_3 is zero outside of the minicircuit
141 3, // p_y_high_limbs_range_constraint_4 is zero outside of the minicircuit
142 3, // z_low_limbs_range_constraint_0 is zero outside of the minicircuit
143 3, // z_low_limbs_range_constraint_1 is zero outside of the minicircuit
144 3, // z_low_limbs_range_constraint_2 is zero outside of the minicircuit
145 3, // z_low_limbs_range_constraint_3 is zero outside of the minicircuit
146 3, // z_low_limbs_range_constraint_4 is zero outside of the minicircuit
147 3, // z_high_limbs_range_constraint_0 is zero outside of the minicircuit
148 3, // z_high_limbs_range_constraint_1 is zero outside of the minicircuit
149 3, // z_high_limbs_range_constraint_2 is zero outside of the minicircuit
150 3, // z_high_limbs_range_constraint_3 is zero outside of the minicircuit
151 3, // z_high_limbs_range_constraint_4 is zero outside of the minicircuit
152 3, // accumulator_low_limbs_range_constraint_0 is zero outside of the minicircuit
153 3, // accumulator_low_limbs_range_constraint_1 is zero outside of the minicircuit
154 3, // accumulator_low_limbs_range_constraint_2 is zero outside of the minicircuit
155 3, // accumulator_low_limbs_range_constraint_3 is zero outside of the minicircuit
156 3, // accumulator_low_limbs_range_constraint_4 is zero outside of the minicircuit
157 3, // accumulator_high_limbs_range_constraint_0 is zero outside of the minicircuit
158 3, // accumulator_high_limbs_range_constraint_1 is zero outside of the minicircuit
159 3, // accumulator_high_limbs_range_constraint_2 is zero outside of the minicircuit
160 3, // accumulator_high_limbs_range_constraint_3 is zero outside of the minicircuit
161 3, // accumulator_high_limbs_range_constraint_4 is zero outside of the minicircuit
162 3, // quotient_low_limbs_range_constraint_0 is zero outside of the minicircuit
163 3, // quotient_low_limbs_range_constraint_1 is zero outside of the minicircuit
164 3, // quotient_low_limbs_range_constraint_2 is zero outside of the minicircuit
165 3, // quotient_low_limbs_range_constraint_3 is zero outside of the minicircuit
166 3, // quotient_low_limbs_range_constraint_4 is zero outside of the minicircuit
167 3, // quotient_high_limbs_range_constraint_0 is zero outside of the minicircuit
168 3, // quotient_high_limbs_range_constraint_1 is zero outside of the minicircuit
169 3, // quotient_high_limbs_range_constraint_2 is zero outside of the minicircuit
170 3, // quotient_high_limbs_range_constraint_3 is zero outside of the minicircuit
171 3, // quotient_high_limbs_range_constraint_4 is zero outside of the minicircuit
172 3, // relation_wide_limbs_range_constraint_0 is zero outside of the minicircuit
173 3, // relation_wide_limbs_range_constraint_1 is zero outside of the minicircuit
174 3, // relation_wide_limbs_range_constraint_2 is zero outside of the minicircuit
175 3, // relation_wide_limbs_range_constraint_3 is zero outside of the minicircuit
176 3, // p_x_low_limbs_range_constraint_tail is zero outside of the minicircuit
177 3, // p_x_high_limbs_range_constraint_tail is zero outside of the minicircuit
178 3, // p_y_low_limbs_range_constraint_tail is zero outside of the minicircuit
179 3, // p_y_high_limbs_range_constraint_tail is zero outside of the minicircuit
180 3, // z_low_limbs_range_constraint_tail is zero outside of the minicircuit
181 3, // z_high_limbs_range_constraint_tail is zero outside of the minicircuit
182 3, // accumulator_low_limbs_range_constraint_tail is zero outside of the minicircuit
183 3, // accumulator_high_limbs_range_constraint_tail is zero outside of the minicircuit
184 3, // quotient_low_limbs_range_constraint_tail is zero outside of the minicircuit
185 3, // quotient_high_limbs_range_constraint_tail is zero outside of the minicircuit
186 3, // op is zero outside of the minicircuit
187 3, // x_lo_y_hi is zero outside of the minicircuit
188 3, // x_hi_z_1 is zero outside of the minicircuit
189 3, // y_lo_z_2 is zero outside of the minicircuit
190 };
191
197 template <typename AllEntities> static bool skip(const AllEntities& in)
198 {
199 // The contribution of every subrelation is wire * (lagrange_odd + lagrange_even + lagrange_mini_masking - 1).
200 // Let s = lagrange_odd + lagrange_even + lagrange_mini_masking. Per row s is 1 exactly where this relation is
201 // inactive (the minicircuit processing rows and the masking rows, where the selector s - 1 vanishes) and 0 on
202 // the remaining rows (the no-op head and the zero-padding tail). On the s == 0 rows every constrained wire is
203 // identically zero for the honest prover, so the contribution vanishes there too.
204 //
205 // We may therefore skip any edge on which s is constant: s == 1 makes the selector identically zero, and s == 0
206 // makes all wires identically zero (this is preserved under partial evaluation, since a folded s evaluates to 0
207 // only when both endpoints had s == 0, where the folded wires are likewise 0). Only edges straddling the
208 // active/inactive boundary, where s is non-constant, must be evaluated. Skipping only on s - 1 == 0 (as a pure
209 // selector argument would) needlessly evaluates the large zero-padding tail; skipping only on lagrange_odd +
210 // lagrange_even == 0 would be unsound, as it also drops masking-vs-head/tail straddle edges whose contribution
211 // is non-zero away from the edge endpoints.
212 static constexpr auto minus_one = -FF(1);
213 const auto s = in.lagrange_odd_in_minicircuit + in.lagrange_even_in_minicircuit + in.lagrange_mini_masking;
214 return (s + minus_one).is_zero() || s.is_zero();
215 }
225 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
226 static void accumulate(ContainerOverSubrelations& accumulators,
227 const AllEntities& in,
228 const Parameters& params,
229 const FF& scaling_factor);
230};
231
232template <typename FF>
234
235template <typename FF>
237
238template <typename FF>
240
241} // namespace bb
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
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)
Relation enforcing non-arithmetic transitions of accumulator (value that is tracking the batched eval...
static constexpr std::array< size_t, 12 > SUBRELATION_PARTIAL_LENGTHS
static constexpr std::array< size_t, 5 > SUBRELATION_PARTIAL_LENGTHS
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 &, const FF &scaling_factor)
Enforces two constraints on the opcode value:
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)
Relation enforcing all the range-constraint polynomials to be zero after the minicircuit.
static constexpr std::array< size_t, 68 > SUBRELATION_PARTIAL_LENGTHS
Entry point for Barretenberg command-line interface.
Definition api.hpp:5