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 when not at even indices in the minicircuit and not in the masking area
33 // as the contribution is zero in these regions.
34 return (in.lagrange_even_in_minicircuit + in.lagrange_mini_masking).is_zero();
35 }
50 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
51 static void accumulate(ContainerOverSubrelations& accumulators,
52 const AllEntities& in,
53 const Parameters&,
54 const FF& scaling_factor);
55};
56
57template <typename FF_> class TranslatorAccumulatorTransferRelationImpl {
58 public:
59 using FF = FF_;
60
61 // 1 + polynomial degree of this relation
62 static constexpr size_t RELATION_LENGTH = 4; // degree((SOME_LAGRANGE)(A-B)) = 2
63 static constexpr std::array<size_t, 12> SUBRELATION_PARTIAL_LENGTHS{
64 4, // transfer accumulator limb 0 at odd index subrelation
65 4, // transfer accumulator limb 1 at odd index subrelation
66 4, // transfer accumulator limb 2 at odd index subrelation
67 4, // transfer accumulator limb 3 at odd index subrelation
68 3, // accumulator limb 0 is zero at the start of accumulation subrelation
69 3, // accumulator limb 1 is zero at the start of accumulation subrelation
70 3, // accumulator limb 2 is zero at the start of accumulation subrelation
71 3, // accumulator limb 3 is zero at the start of accumulation subrelation
72 3, // accumulator limb 0 is equal to given result at the end of accumulation subrelation
73 3, // accumulator limb 1 is equal to given result at the end of accumulation subrelation
74 3, // accumulator limb 2 is equal to given result at the end of accumulation subrelation
75 3 // accumulator limb 3 is equal to given result at the end of accumulation subrelation
76
77 };
78
87 template <typename AllEntities> static bool skip(const AllEntities& in)
88 {
89 // All contributions are zero outside the minicircuit and at even indices within the minicircuit
90 // (except the last and result row in minicircuit)
91 return (in.lagrange_odd_in_minicircuit + in.lagrange_last_in_minicircuit + in.lagrange_result_row).is_zero();
92 }
106 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
107 static void accumulate(ContainerOverSubrelations& accumulators,
108 const AllEntities& in,
109 const Parameters& params,
110 const FF& scaling_factor);
111};
112
113template <typename FF_> class TranslatorZeroConstraintsRelationImpl {
114 public:
115 using FF = FF_;
116
117 // 1 + polynomial degree of this relation
118 static constexpr size_t RELATION_LENGTH = 3; // degree((some lagrange)(A)) = 2
119
120 static constexpr std::array<size_t, 68> SUBRELATION_PARTIAL_LENGTHS{
121 3, // p_x_low_limbs_range_constraint_0 is zero outside of the minicircuit
122 3, // p_x_low_limbs_range_constraint_1 is zero outside of the minicircuit
123 3, // p_x_low_limbs_range_constraint_2 is zero outside of the minicircuit
124 3, // p_x_low_limbs_range_constraint_3 is zero outside of the minicircuit
125 3, // p_x_low_limbs_range_constraint_4 is zero outside of the minicircuit
126 3, // p_x_high_limbs_range_constraint_0 is zero outside of the minicircuit
127 3, // p_x_high_limbs_range_constraint_1 is zero outside of the minicircuit
128 3, // p_x_high_limbs_range_constraint_2 is zero outside of the minicircuit
129 3, // p_x_high_limbs_range_constraint_3 is zero outside of the minicircuit
130 3, // p_x_high_limbs_range_constraint_4 is zero outside of the minicircuit
131 3, // p_y_low_limbs_range_constraint_0 is zero outside of the minicircuit
132 3, // p_y_low_limbs_range_constraint_1 is zero outside of the minicircuit
133 3, // p_y_low_limbs_range_constraint_2 is zero outside of the minicircuit
134 3, // p_y_low_limbs_range_constraint_3 is zero outside of the minicircuit
135 3, // p_y_low_limbs_range_constraint_4 is zero outside of the minicircuit
136 3, // p_y_high_limbs_range_constraint_0 is zero outside of the minicircuit
137 3, // p_y_high_limbs_range_constraint_1 is zero outside of the minicircuit
138 3, // p_y_high_limbs_range_constraint_2 is zero outside of the minicircuit
139 3, // p_y_high_limbs_range_constraint_3 is zero outside of the minicircuit
140 3, // p_y_high_limbs_range_constraint_4 is zero outside of the minicircuit
141 3, // z_low_limbs_range_constraint_0 is zero outside of the minicircuit
142 3, // z_low_limbs_range_constraint_1 is zero outside of the minicircuit
143 3, // z_low_limbs_range_constraint_2 is zero outside of the minicircuit
144 3, // z_low_limbs_range_constraint_3 is zero outside of the minicircuit
145 3, // z_low_limbs_range_constraint_4 is zero outside of the minicircuit
146 3, // z_high_limbs_range_constraint_0 is zero outside of the minicircuit
147 3, // z_high_limbs_range_constraint_1 is zero outside of the minicircuit
148 3, // z_high_limbs_range_constraint_2 is zero outside of the minicircuit
149 3, // z_high_limbs_range_constraint_3 is zero outside of the minicircuit
150 3, // z_high_limbs_range_constraint_4 is zero outside of the minicircuit
151 3, // accumulator_low_limbs_range_constraint_0 is zero outside of the minicircuit
152 3, // accumulator_low_limbs_range_constraint_1 is zero outside of the minicircuit
153 3, // accumulator_low_limbs_range_constraint_2 is zero outside of the minicircuit
154 3, // accumulator_low_limbs_range_constraint_3 is zero outside of the minicircuit
155 3, // accumulator_low_limbs_range_constraint_4 is zero outside of the minicircuit
156 3, // accumulator_high_limbs_range_constraint_0 is zero outside of the minicircuit
157 3, // accumulator_high_limbs_range_constraint_1 is zero outside of the minicircuit
158 3, // accumulator_high_limbs_range_constraint_2 is zero outside of the minicircuit
159 3, // accumulator_high_limbs_range_constraint_3 is zero outside of the minicircuit
160 3, // accumulator_high_limbs_range_constraint_4 is zero outside of the minicircuit
161 3, // quotient_low_limbs_range_constraint_0 is zero outside of the minicircuit
162 3, // quotient_low_limbs_range_constraint_1 is zero outside of the minicircuit
163 3, // quotient_low_limbs_range_constraint_2 is zero outside of the minicircuit
164 3, // quotient_low_limbs_range_constraint_3 is zero outside of the minicircuit
165 3, // quotient_low_limbs_range_constraint_4 is zero outside of the minicircuit
166 3, // quotient_high_limbs_range_constraint_0 is zero outside of the minicircuit
167 3, // quotient_high_limbs_range_constraint_1 is zero outside of the minicircuit
168 3, // quotient_high_limbs_range_constraint_2 is zero outside of the minicircuit
169 3, // quotient_high_limbs_range_constraint_3 is zero outside of the minicircuit
170 3, // quotient_high_limbs_range_constraint_4 is zero outside of the minicircuit
171 3, // relation_wide_limbs_range_constraint_0 is zero outside of the minicircuit
172 3, // relation_wide_limbs_range_constraint_1 is zero outside of the minicircuit
173 3, // relation_wide_limbs_range_constraint_2 is zero outside of the minicircuit
174 3, // relation_wide_limbs_range_constraint_3 is zero outside of the minicircuit
175 3, // p_x_low_limbs_range_constraint_tail is zero outside of the minicircuit
176 3, // p_x_high_limbs_range_constraint_tail is zero outside of the minicircuit
177 3, // p_y_low_limbs_range_constraint_tail is zero outside of the minicircuit
178 3, // p_y_high_limbs_range_constraint_tail is zero outside of the minicircuit
179 3, // z_low_limbs_range_constraint_tail is zero outside of the minicircuit
180 3, // z_high_limbs_range_constraint_tail is zero outside of the minicircuit
181 3, // accumulator_low_limbs_range_constraint_tail is zero outside of the minicircuit
182 3, // accumulator_high_limbs_range_constraint_tail is zero outside of the minicircuit
183 3, // quotient_low_limbs_range_constraint_tail is zero outside of the minicircuit
184 3, // quotient_high_limbs_range_constraint_tail is zero outside of the minicircuit
185 3, // op is zero outside of the minicircuit
186 3, // x_lo_y_hi is zero outside of the minicircuit
187 3, // x_hi_z_1 is zero outside of the minicircuit
188 3, // y_lo_z_2 is zero outside of the minicircuit
189 };
190
196 template <typename AllEntities> static bool skip(const AllEntities& in)
197 {
198 // Skip evaluation when inside the minicircuit or in the masking area. The relation constrains
199 // polynomials to be zero outside these regions.
200 static constexpr auto minus_one = -FF(1);
201 return (in.lagrange_odd_in_minicircuit + in.lagrange_even_in_minicircuit + in.lagrange_mini_masking + minus_one)
202 .is_zero();
203 }
213 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
214 static void accumulate(ContainerOverSubrelations& accumulators,
215 const AllEntities& in,
216 const Parameters& params,
217 const FF& scaling_factor);
218};
219
221
222template <typename FF>
224
226
227} // 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 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