Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ff_gt_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
6
7namespace bb::avm2 {
8
9template <typename FF_>
10template <typename ContainerOverSubrelations, typename AllEntities>
11void ff_gtImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
12 const AllEntities& in,
13 [[maybe_unused]] const RelationParameters<FF_>&,
14 [[maybe_unused]] const FF_& scaling_factor)
15{
16 using C = ColumnAndShifts;
17
18 const auto ff_gt_START = in.get(C::ff_gt_sel_gt) + in.get(C::ff_gt_sel_dec);
19 const auto ff_gt_LATCH_CONDITION = in.get(C::ff_gt_end) + in.get(C::precomputed_first_row);
20 const auto ff_gt_NOT_END = (in.get(C::ff_gt_sel) - in.get(C::ff_gt_end));
21 const auto ff_gt_POW_128 = FF(uint256_t{ 0UL, 0UL, 1UL, 0UL });
22 const auto ff_gt_P_LO = FF(uint256_t{ 4891460686036598785UL, 2896914383306846353UL, 0UL, 0UL });
23 const auto ff_gt_P_HI = FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL });
24 const auto ff_gt_A_SUB_B_LO =
25 ((in.get(C::ff_gt_a_lo) - in.get(C::ff_gt_b_lo)) - FF(1)) + in.get(C::ff_gt_borrow) * ff_gt_POW_128;
26 const auto ff_gt_A_SUB_B_HI = ((in.get(C::ff_gt_a_hi) - in.get(C::ff_gt_b_hi)) - in.get(C::ff_gt_borrow));
27 const auto ff_gt_B_SUB_A_LO =
28 (in.get(C::ff_gt_b_lo) - in.get(C::ff_gt_a_lo)) + in.get(C::ff_gt_borrow) * ff_gt_POW_128;
29 const auto ff_gt_B_SUB_A_HI = ((in.get(C::ff_gt_b_hi) - in.get(C::ff_gt_a_hi)) - in.get(C::ff_gt_borrow));
30 const auto ff_gt_IS_GT = in.get(C::ff_gt_sel_gt) * in.get(C::ff_gt_result);
31
32 {
33 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
34 auto tmp = static_cast<View>(in.get(C::ff_gt_sel)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel)));
35 std::get<0>(evals) += (tmp * scaling_factor);
36 }
37 {
38 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
39 auto tmp = static_cast<View>(in.get(C::ff_gt_result)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_result)));
40 std::get<1>(evals) += (tmp * scaling_factor);
41 }
42 {
43 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
44 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_gt)));
45 std::get<2>(evals) += (tmp * scaling_factor);
46 }
47 {
48 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
49 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_dec)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_dec)));
50 std::get<3>(evals) += (tmp * scaling_factor);
51 }
52 {
53 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
54 auto tmp = static_cast<View>(in.get(C::ff_gt_end)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_end)));
55 std::get<4>(evals) += (tmp * scaling_factor);
56 }
57 { // SEL_ON_START_OR_END
58 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
59 auto tmp = (CView(ff_gt_START) + static_cast<View>(in.get(C::ff_gt_end))) *
60 (FF(1) - static_cast<View>(in.get(C::ff_gt_sel)));
61 std::get<5>(evals) += (tmp * scaling_factor);
62 }
63 { // TRACE_CONTINUITY
64 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
65 auto tmp = (FF(1) - CView(ff_gt_LATCH_CONDITION)) *
66 (static_cast<View>(in.get(C::ff_gt_sel)) - static_cast<View>(in.get(C::ff_gt_sel_shift)));
67 std::get<6>(evals) += (tmp * scaling_factor);
68 }
69 { // START_AFTER_LATCH
70 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
71 auto tmp =
72 static_cast<View>(in.get(C::ff_gt_sel_shift)) *
73 ((static_cast<View>(in.get(C::ff_gt_sel_gt_shift)) + static_cast<View>(in.get(C::ff_gt_sel_dec_shift))) -
74 CView(ff_gt_LATCH_CONDITION));
75 std::get<7>(evals) += (tmp * scaling_factor);
76 }
77 {
78 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
79 auto tmp =
80 static_cast<View>(in.get(C::ff_gt_sel)) * (FF(128) - static_cast<View>(in.get(C::ff_gt_constant_128)));
81 std::get<8>(evals) += (tmp * scaling_factor);
82 }
83 { // A_DECOMPOSITION
84 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
85 auto tmp = CView(ff_gt_START) * (static_cast<View>(in.get(C::ff_gt_a)) -
86 (static_cast<View>(in.get(C::ff_gt_a_lo)) +
87 CView(ff_gt_POW_128) * static_cast<View>(in.get(C::ff_gt_a_hi))));
88 std::get<9>(evals) += (tmp * scaling_factor);
89 }
90 {
91 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
92 auto tmp =
93 static_cast<View>(in.get(C::ff_gt_p_a_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_p_a_borrow)));
94 std::get<10>(evals) += (tmp * scaling_factor);
95 }
96 { // P_SUB_A_LO
97 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
98 auto tmp = CView(ff_gt_START) * (static_cast<View>(in.get(C::ff_gt_p_sub_a_lo)) -
99 (((CView(ff_gt_P_LO) - static_cast<View>(in.get(C::ff_gt_a_lo))) - FF(1)) +
100 static_cast<View>(in.get(C::ff_gt_p_a_borrow)) * CView(ff_gt_POW_128)));
101 std::get<11>(evals) += (tmp * scaling_factor);
102 }
103 { // P_SUB_A_HI
104 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
105 auto tmp = CView(ff_gt_START) * (static_cast<View>(in.get(C::ff_gt_p_sub_a_hi)) -
106 ((CView(ff_gt_P_HI) - static_cast<View>(in.get(C::ff_gt_a_hi))) -
107 static_cast<View>(in.get(C::ff_gt_p_a_borrow))));
108 std::get<12>(evals) += (tmp * scaling_factor);
109 }
110 { // B_DECOMPOSITION
111 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
112 auto tmp =
113 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
114 (static_cast<View>(in.get(C::ff_gt_b)) - (static_cast<View>(in.get(C::ff_gt_b_lo)) +
115 CView(ff_gt_POW_128) * static_cast<View>(in.get(C::ff_gt_b_hi))));
116 std::get<13>(evals) += (tmp * scaling_factor);
117 }
118 {
119 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
120 auto tmp =
121 static_cast<View>(in.get(C::ff_gt_p_b_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_p_b_borrow)));
122 std::get<14>(evals) += (tmp * scaling_factor);
123 }
124 { // P_SUB_B_LO
125 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
126 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) *
127 (static_cast<View>(in.get(C::ff_gt_p_sub_b_lo)) -
128 (((CView(ff_gt_P_LO) - static_cast<View>(in.get(C::ff_gt_b_lo))) - FF(1)) +
129 static_cast<View>(in.get(C::ff_gt_p_b_borrow)) * CView(ff_gt_POW_128)));
130 std::get<15>(evals) += (tmp * scaling_factor);
131 }
132 { // P_SUB_B_HI
133 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
134 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) *
135 (static_cast<View>(in.get(C::ff_gt_p_sub_b_hi)) -
136 ((CView(ff_gt_P_HI) - static_cast<View>(in.get(C::ff_gt_b_hi))) -
137 static_cast<View>(in.get(C::ff_gt_p_b_borrow))));
138 std::get<16>(evals) += (tmp * scaling_factor);
139 }
140 {
141 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
142 auto tmp = static_cast<View>(in.get(C::ff_gt_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_borrow)));
143 std::get<17>(evals) += (tmp * scaling_factor);
144 }
145 { // RES_LO
146 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
147 auto tmp =
148 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
149 (static_cast<View>(in.get(C::ff_gt_res_lo)) -
150 (CView(ff_gt_A_SUB_B_LO) * CView(ff_gt_IS_GT) + CView(ff_gt_B_SUB_A_LO) * (FF(1) - CView(ff_gt_IS_GT))));
151 std::get<18>(evals) += (tmp * scaling_factor);
152 }
153 { // RES_HI
154 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
155 auto tmp =
156 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
157 (static_cast<View>(in.get(C::ff_gt_res_hi)) -
158 (CView(ff_gt_A_SUB_B_HI) * CView(ff_gt_IS_GT) + CView(ff_gt_B_SUB_A_HI) * (FF(1) - CView(ff_gt_IS_GT))));
159 std::get<19>(evals) += (tmp * scaling_factor);
160 }
161 { // RNG_CTR_GT_INIT
162 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
163 auto tmp =
164 static_cast<View>(in.get(C::ff_gt_sel_gt)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(4));
165 std::get<20>(evals) += (tmp * scaling_factor);
166 }
167 { // RNG_CTR_DEC_INIT
168 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
169 auto tmp =
170 static_cast<View>(in.get(C::ff_gt_sel_dec)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1));
171 std::get<21>(evals) += (tmp * scaling_factor);
172 }
173 { // RNG_CTR_DECREMENT
174 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
175 auto tmp = CView(ff_gt_NOT_END) * ((static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1)) -
176 static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_shift)));
177 std::get<22>(evals) += (tmp * scaling_factor);
178 }
179 { // RNG_CTR_END
180 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
181 auto tmp = static_cast<View>(in.get(C::ff_gt_end)) * static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr));
182 std::get<23>(evals) += (tmp * scaling_factor);
183 }
184 { // SHIFT_P_SUB_A_TO_A_LO
185 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
186 auto tmp = CView(ff_gt_NOT_END) *
187 (static_cast<View>(in.get(C::ff_gt_a_lo_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_a_lo)));
188 std::get<24>(evals) += (tmp * scaling_factor);
189 }
190 { // SHIFT_P_SUB_A_TO_A_HI
191 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
192 auto tmp = CView(ff_gt_NOT_END) *
193 (static_cast<View>(in.get(C::ff_gt_a_hi_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_a_hi)));
194 std::get<25>(evals) += (tmp * scaling_factor);
195 }
196 { // SHIFT_B_TO_P_SUB_A_LO
197 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
198 auto tmp = CView(ff_gt_NOT_END) *
199 (static_cast<View>(in.get(C::ff_gt_p_sub_a_lo_shift)) - static_cast<View>(in.get(C::ff_gt_b_lo)));
200 std::get<26>(evals) += (tmp * scaling_factor);
201 }
202 { // SHIFT_B_TO_P_SUB_A_HI
203 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
204 auto tmp = CView(ff_gt_NOT_END) *
205 (static_cast<View>(in.get(C::ff_gt_p_sub_a_hi_shift)) - static_cast<View>(in.get(C::ff_gt_b_hi)));
206 std::get<27>(evals) += (tmp * scaling_factor);
207 }
208 { // SHIFT_P_SUB_B_TO_B_LO
209 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
210 auto tmp = CView(ff_gt_NOT_END) *
211 (static_cast<View>(in.get(C::ff_gt_b_lo_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_b_lo)));
212 std::get<28>(evals) += (tmp * scaling_factor);
213 }
214 { // SHIFT_P_SUB_B_TO_B_HI
215 using View = typename std::tuple_element_t<29, ContainerOverSubrelations>::View;
216 auto tmp = CView(ff_gt_NOT_END) *
217 (static_cast<View>(in.get(C::ff_gt_b_hi_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_b_hi)));
218 std::get<29>(evals) += (tmp * scaling_factor);
219 }
220 { // SHIFT_RES_TO_P_SUB_B_LO
221 using View = typename std::tuple_element_t<30, ContainerOverSubrelations>::View;
222 auto tmp = CView(ff_gt_NOT_END) *
223 (static_cast<View>(in.get(C::ff_gt_p_sub_b_lo_shift)) - static_cast<View>(in.get(C::ff_gt_res_lo)));
224 std::get<30>(evals) += (tmp * scaling_factor);
225 }
226 { // SHIFT_RES_TO_P_SUB_B_HI
227 using View = typename std::tuple_element_t<31, ContainerOverSubrelations>::View;
228 auto tmp = CView(ff_gt_NOT_END) *
229 (static_cast<View>(in.get(C::ff_gt_p_sub_b_hi_shift)) - static_cast<View>(in.get(C::ff_gt_res_hi)));
230 std::get<31>(evals) += (tmp * scaling_factor);
231 }
232}
233
234} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
AvmFlavorSettings::FF FF
Definition field.hpp:10
ColumnAndShifts
Definition columns.hpp:34
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define CView(v)
Container for parameters used by the grand product (permutation, lookup) Honk relations.