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