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_SEL_START = in.get(C::ff_gt_sel_gt) + in.get(C::ff_gt_sel_dec);
19 const auto ff_gt_POW_128 = FF(uint256_t{ 0UL, 0UL, 1UL, 0UL });
20 const auto ff_gt_P_LO = FF(uint256_t{ 4891460686036598785UL, 2896914383306846353UL, 0UL, 0UL });
21 const auto ff_gt_P_HI = FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL });
22 const auto ff_gt_A_SUB_B_LO =
23 ((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;
24 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));
25 const auto ff_gt_B_SUB_A_LO =
26 (in.get(C::ff_gt_b_lo) - in.get(C::ff_gt_a_lo)) + in.get(C::ff_gt_borrow) * ff_gt_POW_128;
27 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));
28 const auto ff_gt_IS_GT = in.get(C::ff_gt_sel_gt) * in.get(C::ff_gt_result);
30 {
31 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
32 auto tmp = static_cast<View>(in.get(C::ff_gt_sel)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel)));
33 std::get<0>(evals) += (tmp * scaling_factor);
34 }
35 {
36 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
37 auto tmp = static_cast<View>(in.get(C::ff_gt_result)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_result)));
38 std::get<1>(evals) += (tmp * scaling_factor);
39 }
40 {
41 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
42 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_gt)));
43 std::get<2>(evals) += (tmp * scaling_factor);
44 }
45 {
46 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
47 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_dec)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_dec)));
48 std::get<3>(evals) += (tmp * scaling_factor);
49 }
50 {
51 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
52 auto tmp =
53 static_cast<View>(in.get(C::ff_gt_sel)) * (FF(128) - static_cast<View>(in.get(C::ff_gt_constant_128)));
54 std::get<4>(evals) += (tmp * scaling_factor);
55 }
56 { // A_DECOMPOSITION
57 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
58 auto tmp = CView(ff_gt_SEL_START) * (static_cast<View>(in.get(C::ff_gt_a)) -
59 (static_cast<View>(in.get(C::ff_gt_a_lo)) +
60 CView(ff_gt_POW_128) * static_cast<View>(in.get(C::ff_gt_a_hi))));
61 std::get<5>(evals) += (tmp * scaling_factor);
62 }
63 {
64 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
65 auto tmp =
66 static_cast<View>(in.get(C::ff_gt_p_a_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_p_a_borrow)));
67 std::get<6>(evals) += (tmp * scaling_factor);
68 }
69 { // P_SUB_A_LO
70 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
71 auto tmp = CView(ff_gt_SEL_START) * (static_cast<View>(in.get(C::ff_gt_p_sub_a_lo)) -
72 (((CView(ff_gt_P_LO) - static_cast<View>(in.get(C::ff_gt_a_lo))) - FF(1)) +
73 static_cast<View>(in.get(C::ff_gt_p_a_borrow)) * CView(ff_gt_POW_128)));
74 std::get<7>(evals) += (tmp * scaling_factor);
75 }
76 { // P_SUB_A_HI
77 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
78 auto tmp = CView(ff_gt_SEL_START) * (static_cast<View>(in.get(C::ff_gt_p_sub_a_hi)) -
79 ((CView(ff_gt_P_HI) - static_cast<View>(in.get(C::ff_gt_a_hi))) -
80 static_cast<View>(in.get(C::ff_gt_p_a_borrow))));
81 std::get<8>(evals) += (tmp * scaling_factor);
82 }
83 { // B_DECOMPOSITION
84 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
85 auto tmp =
86 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
87 (static_cast<View>(in.get(C::ff_gt_b)) - (static_cast<View>(in.get(C::ff_gt_b_lo)) +
88 CView(ff_gt_POW_128) * static_cast<View>(in.get(C::ff_gt_b_hi))));
89 std::get<9>(evals) += (tmp * scaling_factor);
90 }
91 {
92 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
93 auto tmp =
94 static_cast<View>(in.get(C::ff_gt_p_b_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_p_b_borrow)));
95 std::get<10>(evals) += (tmp * scaling_factor);
96 }
97 { // P_SUB_B_LO
98 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
99 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) *
100 (static_cast<View>(in.get(C::ff_gt_p_sub_b_lo)) -
101 (((CView(ff_gt_P_LO) - static_cast<View>(in.get(C::ff_gt_b_lo))) - FF(1)) +
102 static_cast<View>(in.get(C::ff_gt_p_b_borrow)) * CView(ff_gt_POW_128)));
103 std::get<11>(evals) += (tmp * scaling_factor);
104 }
105 { // P_SUB_B_HI
106 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
107 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_gt)) *
108 (static_cast<View>(in.get(C::ff_gt_p_sub_b_hi)) -
109 ((CView(ff_gt_P_HI) - static_cast<View>(in.get(C::ff_gt_b_hi))) -
110 static_cast<View>(in.get(C::ff_gt_p_b_borrow))));
111 std::get<12>(evals) += (tmp * scaling_factor);
112 }
113 {
114 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
115 auto tmp = static_cast<View>(in.get(C::ff_gt_borrow)) * (FF(1) - static_cast<View>(in.get(C::ff_gt_borrow)));
116 std::get<13>(evals) += (tmp * scaling_factor);
117 }
118 { // RES_LO
119 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
120 auto tmp =
121 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
122 (static_cast<View>(in.get(C::ff_gt_res_lo)) -
123 (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))));
124 std::get<14>(evals) += (tmp * scaling_factor);
125 }
126 { // RES_HI
127 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
128 auto tmp =
129 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
130 (static_cast<View>(in.get(C::ff_gt_res_hi)) -
131 (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))));
132 std::get<15>(evals) += (tmp * scaling_factor);
133 }
134 { // RNG_CTR_GT_INIT
135 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
136 auto tmp =
137 static_cast<View>(in.get(C::ff_gt_sel_gt)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(4));
138 std::get<16>(evals) += (tmp * scaling_factor);
139 }
140 { // RNG_CTR_DEC_INIT
141 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
142 auto tmp =
143 static_cast<View>(in.get(C::ff_gt_sel_dec)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1));
144 std::get<17>(evals) += (tmp * scaling_factor);
145 }
146 { // RNG_CTR_DECREMENT
147 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
148 auto tmp = static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) *
149 ((static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1)) -
150 static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_shift)));
151 std::get<18>(evals) += (tmp * scaling_factor);
152 }
153 {
154 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
155 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_shift_rng)) *
156 (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_shift_rng)));
157 std::get<19>(evals) += (tmp * scaling_factor);
158 }
159 { // RNG_CTR_NON_ZERO
160 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
161 auto tmp = (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) *
162 ((FF(1) - static_cast<View>(in.get(C::ff_gt_sel_shift_rng))) *
163 (FF(1) - static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_inv))) +
164 static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_inv))) -
165 static_cast<View>(in.get(C::ff_gt_sel_shift_rng)));
166 std::get<20>(evals) += (tmp * scaling_factor);
167 }
168 { // SHIFT_0
169 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
170 auto tmp = (static_cast<View>(in.get(C::ff_gt_a_lo_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_a_lo))) *
171 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
172 std::get<21>(evals) += (tmp * scaling_factor);
173 }
174 {
175 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
176 auto tmp = (static_cast<View>(in.get(C::ff_gt_a_hi_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_a_hi))) *
177 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
178 std::get<22>(evals) += (tmp * scaling_factor);
179 }
180 { // SHIFT_1
181 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
182 auto tmp = (static_cast<View>(in.get(C::ff_gt_p_sub_a_lo_shift)) - static_cast<View>(in.get(C::ff_gt_b_lo))) *
183 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
184 std::get<23>(evals) += (tmp * scaling_factor);
185 }
186 {
187 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
188 auto tmp = (static_cast<View>(in.get(C::ff_gt_p_sub_a_hi_shift)) - static_cast<View>(in.get(C::ff_gt_b_hi))) *
189 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
190 std::get<24>(evals) += (tmp * scaling_factor);
191 }
192 { // SHIFT_2
193 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
194 auto tmp = (static_cast<View>(in.get(C::ff_gt_b_lo_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_b_lo))) *
195 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
196 std::get<25>(evals) += (tmp * scaling_factor);
197 }
198 {
199 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
200 auto tmp = (static_cast<View>(in.get(C::ff_gt_b_hi_shift)) - static_cast<View>(in.get(C::ff_gt_p_sub_b_hi))) *
201 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
202 std::get<26>(evals) += (tmp * scaling_factor);
203 }
204 { // SHIFT_3
205 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
206 auto tmp = (static_cast<View>(in.get(C::ff_gt_p_sub_b_lo_shift)) - static_cast<View>(in.get(C::ff_gt_res_lo))) *
207 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
208 std::get<27>(evals) += (tmp * scaling_factor);
209 }
210 {
211 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
212 auto tmp = (static_cast<View>(in.get(C::ff_gt_p_sub_b_hi_shift)) - static_cast<View>(in.get(C::ff_gt_res_hi))) *
213 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
214 std::get<28>(evals) += (tmp * scaling_factor);
215 }
216 { // SEL_CONSISTENCY
217 using View = typename std::tuple_element_t<29, ContainerOverSubrelations>::View;
218 auto tmp =
219 ((static_cast<View>(in.get(C::ff_gt_sel_shift_rng)) + static_cast<View>(in.get(C::ff_gt_sel_gt_shift)) +
220 static_cast<View>(in.get(C::ff_gt_sel_dec_shift))) -
221 static_cast<View>(in.get(C::ff_gt_sel_shift)));
222 std::get<29>(evals) += (tmp * scaling_factor);
223 }
224}
225
226} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
ColumnAndShifts
Definition columns.hpp:34
AvmFlavorSettings::FF FF
Definition field.hpp:10
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.