Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_extra_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
9
10namespace bb {
11
12template <typename FF_> class TranslatorOpcodeConstraintRelationImpl {
13 public:
14 using FF = FF_;
15
16 // 1 + polynomial degree of this relation
17 static constexpr size_t RELATION_LENGTH = 6;
18 static constexpr std::array<size_t, 5> SUBRELATION_PARTIAL_LENGTHS{
19 6, // opcode constraint relation
20 6, // opcode constraint relation
21 6, // opcode constraint relation
22 6, // opcode constraint relation
23 6 // opcode constraint relation
24 };
25
30 template <typename AllEntities> static bool skip(const AllEntities& in)
31 {
32 // Skip evaluation outside the genuine-op processing range (i.e. at neither even nor odd minicircuit indices),
33 // where every contribution is zero. The masking region has both lagranges zero and is therefore skipped.
34 return (in.lagrange_even_in_minicircuit + in.lagrange_odd_in_minicircuit).is_zero();
35 }
54 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
55 static void accumulate(ContainerOverSubrelations& accumulators,
56 const AllEntities& in,
57 const Parameters&,
58 const FF& scaling_factor);
59};
60
61template <typename FF_> class TranslatorAccumulatorTransferRelationImpl {
62 public:
63 using FF = FF_;
64
65 // 1 + polynomial degree of this relation
66 static constexpr size_t RELATION_LENGTH = 4; // degree((SOME_LAGRANGE)(A-B)) = 2
67 static constexpr std::array<size_t, 12> SUBRELATION_PARTIAL_LENGTHS{
68 4, // transfer accumulator limb 0 at odd index subrelation
69 4, // transfer accumulator limb 1 at odd index subrelation
70 4, // transfer accumulator limb 2 at odd index subrelation
71 4, // transfer accumulator limb 3 at odd index subrelation
72 3, // accumulator limb 0 is zero at the start of accumulation subrelation
73 3, // accumulator limb 1 is zero at the start of accumulation subrelation
74 3, // accumulator limb 2 is zero at the start of accumulation subrelation
75 3, // accumulator limb 3 is zero at the start of accumulation subrelation
76 3, // accumulator limb 0 is equal to given result at the end of accumulation subrelation
77 3, // accumulator limb 1 is equal to given result at the end of accumulation subrelation
78 3, // accumulator limb 2 is equal to given result at the end of accumulation subrelation
79 3 // accumulator limb 3 is equal to given result at the end of accumulation subrelation
80
81 };
82
91 template <typename AllEntities> static bool skip(const AllEntities& in)
92 {
93 // All contributions are zero outside the minicircuit and at even indices within the minicircuit
94 // (except the last and result row in minicircuit)
95 return (in.lagrange_odd_in_minicircuit + in.lagrange_last_in_minicircuit + in.lagrange_result_row).is_zero();
96 }
110 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
111 static void accumulate(ContainerOverSubrelations& accumulators,
112 const AllEntities& in,
113 const Parameters& params,
114 const FF& scaling_factor);
115};
116
117template <typename FF_> class TranslatorZeroConstraintsRelationImpl {
118 public:
119 using FF = FF_;
120
121 // 1 + polynomial degree of this relation
122 static constexpr size_t RELATION_LENGTH = 3; // degree((some lagrange)(A)) = 2
123
124 static constexpr std::array<size_t, 68> SUBRELATION_PARTIAL_LENGTHS{
125 3, // p_x_low_limbs_range_constraint_0 is zero outside of the minicircuit
126 3, // p_x_low_limbs_range_constraint_1 is zero outside of the minicircuit
127 3, // p_x_low_limbs_range_constraint_2 is zero outside of the minicircuit
128 3, // p_x_low_limbs_range_constraint_3 is zero outside of the minicircuit
129 3, // p_x_low_limbs_range_constraint_4 is zero outside of the minicircuit
130 3, // p_x_high_limbs_range_constraint_0 is zero outside of the minicircuit
131 3, // p_x_high_limbs_range_constraint_1 is zero outside of the minicircuit
132 3, // p_x_high_limbs_range_constraint_2 is zero outside of the minicircuit
133 3, // p_x_high_limbs_range_constraint_3 is zero outside of the minicircuit
134 3, // p_x_high_limbs_range_constraint_4 is zero outside of the minicircuit
135 3, // p_y_low_limbs_range_constraint_0 is zero outside of the minicircuit
136 3, // p_y_low_limbs_range_constraint_1 is zero outside of the minicircuit
137 3, // p_y_low_limbs_range_constraint_2 is zero outside of the minicircuit
138 3, // p_y_low_limbs_range_constraint_3 is zero outside of the minicircuit
139 3, // p_y_low_limbs_range_constraint_4 is zero outside of the minicircuit
140 3, // p_y_high_limbs_range_constraint_0 is zero outside of the minicircuit
141 3, // p_y_high_limbs_range_constraint_1 is zero outside of the minicircuit
142 3, // p_y_high_limbs_range_constraint_2 is zero outside of the minicircuit
143 3, // p_y_high_limbs_range_constraint_3 is zero outside of the minicircuit
144 3, // p_y_high_limbs_range_constraint_4 is zero outside of the minicircuit
145 3, // z_low_limbs_range_constraint_0 is zero outside of the minicircuit
146 3, // z_low_limbs_range_constraint_1 is zero outside of the minicircuit
147 3, // z_low_limbs_range_constraint_2 is zero outside of the minicircuit
148 3, // z_low_limbs_range_constraint_3 is zero outside of the minicircuit
149 3, // z_low_limbs_range_constraint_4 is zero outside of the minicircuit
150 3, // z_high_limbs_range_constraint_0 is zero outside of the minicircuit
151 3, // z_high_limbs_range_constraint_1 is zero outside of the minicircuit
152 3, // z_high_limbs_range_constraint_2 is zero outside of the minicircuit
153 3, // z_high_limbs_range_constraint_3 is zero outside of the minicircuit
154 3, // z_high_limbs_range_constraint_4 is zero outside of the minicircuit
155 3, // accumulator_low_limbs_range_constraint_0 is zero outside of the minicircuit
156 3, // accumulator_low_limbs_range_constraint_1 is zero outside of the minicircuit
157 3, // accumulator_low_limbs_range_constraint_2 is zero outside of the minicircuit
158 3, // accumulator_low_limbs_range_constraint_3 is zero outside of the minicircuit
159 3, // accumulator_low_limbs_range_constraint_4 is zero outside of the minicircuit
160 3, // accumulator_high_limbs_range_constraint_0 is zero outside of the minicircuit
161 3, // accumulator_high_limbs_range_constraint_1 is zero outside of the minicircuit
162 3, // accumulator_high_limbs_range_constraint_2 is zero outside of the minicircuit
163 3, // accumulator_high_limbs_range_constraint_3 is zero outside of the minicircuit
164 3, // accumulator_high_limbs_range_constraint_4 is zero outside of the minicircuit
165 3, // quotient_low_limbs_range_constraint_0 is zero outside of the minicircuit
166 3, // quotient_low_limbs_range_constraint_1 is zero outside of the minicircuit
167 3, // quotient_low_limbs_range_constraint_2 is zero outside of the minicircuit
168 3, // quotient_low_limbs_range_constraint_3 is zero outside of the minicircuit
169 3, // quotient_low_limbs_range_constraint_4 is zero outside of the minicircuit
170 3, // quotient_high_limbs_range_constraint_0 is zero outside of the minicircuit
171 3, // quotient_high_limbs_range_constraint_1 is zero outside of the minicircuit
172 3, // quotient_high_limbs_range_constraint_2 is zero outside of the minicircuit
173 3, // quotient_high_limbs_range_constraint_3 is zero outside of the minicircuit
174 3, // quotient_high_limbs_range_constraint_4 is zero outside of the minicircuit
175 3, // relation_wide_limbs_range_constraint_0 is zero outside of the minicircuit
176 3, // relation_wide_limbs_range_constraint_1 is zero outside of the minicircuit
177 3, // relation_wide_limbs_range_constraint_2 is zero outside of the minicircuit
178 3, // relation_wide_limbs_range_constraint_3 is zero outside of the minicircuit
179 3, // p_x_low_limbs_range_constraint_tail is zero outside of the minicircuit
180 3, // p_x_high_limbs_range_constraint_tail is zero outside of the minicircuit
181 3, // p_y_low_limbs_range_constraint_tail is zero outside of the minicircuit
182 3, // p_y_high_limbs_range_constraint_tail is zero outside of the minicircuit
183 3, // z_low_limbs_range_constraint_tail is zero outside of the minicircuit
184 3, // z_high_limbs_range_constraint_tail is zero outside of the minicircuit
185 3, // accumulator_low_limbs_range_constraint_tail is zero outside of the minicircuit
186 3, // accumulator_high_limbs_range_constraint_tail is zero outside of the minicircuit
187 3, // quotient_low_limbs_range_constraint_tail is zero outside of the minicircuit
188 3, // quotient_high_limbs_range_constraint_tail is zero outside of the minicircuit
189 3, // op is zero outside of the minicircuit
190 3, // x_lo_y_hi is zero outside of the minicircuit
191 3, // x_hi_z_1 is zero outside of the minicircuit
192 3, // y_lo_z_2 is zero outside of the minicircuit
193 };
194
200 template <typename AllEntities> static bool skip(const AllEntities& in)
201 {
202 // Skip evaluation when inside the minicircuit or in the masking area. The relation constrains
203 // polynomials to be zero outside these regions.
204 static constexpr auto minus_one = -FF(1);
205 return (in.lagrange_odd_in_minicircuit + in.lagrange_even_in_minicircuit + in.lagrange_mini_masking + minus_one)
206 .is_zero();
207 }
217 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
218 static void accumulate(ContainerOverSubrelations& accumulators,
219 const AllEntities& in,
220 const Parameters& params,
221 const FF& scaling_factor);
222};
223
225
226template <typename FF>
228
230
231} // 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, 12 > SUBRELATION_PARTIAL_LENGTHS
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 bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
static bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
static constexpr std::array< size_t, 5 > SUBRELATION_PARTIAL_LENGTHS
static void accumulate(ContainerOverSubrelations &accumulators, const AllEntities &in, const Parameters &, const FF &scaling_factor)
Enforces 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