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);
29
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 { // RES_LO
114 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
115 auto tmp =
116 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
117 (static_cast<View>(in.get(C::ff_gt_res_lo)) -
118 (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))));
119 std::get<13>(evals) += (tmp * scaling_factor);
120 }
121 { // RES_HI
122 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
123 auto tmp =
124 static_cast<View>(in.get(C::ff_gt_sel_gt)) *
125 (static_cast<View>(in.get(C::ff_gt_res_hi)) -
126 (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))));
127 std::get<14>(evals) += (tmp * scaling_factor);
128 }
129 { // RNG_CTR_GT_INIT
130 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
131 auto tmp =
132 static_cast<View>(in.get(C::ff_gt_sel_gt)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(4));
133 std::get<15>(evals) += (tmp * scaling_factor);
134 }
135 { // RNG_CTR_DEC_INIT
136 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
137 auto tmp =
138 static_cast<View>(in.get(C::ff_gt_sel_dec)) * (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1));
139 std::get<16>(evals) += (tmp * scaling_factor);
140 }
141 { // RNG_CTR_DECREMENT
142 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
143 auto tmp = static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) *
144 ((static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) - FF(1)) -
145 static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_shift)));
146 std::get<17>(evals) += (tmp * scaling_factor);
147 }
148 {
149 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
150 auto tmp = static_cast<View>(in.get(C::ff_gt_sel_shift_rng)) *
151 (FF(1) - static_cast<View>(in.get(C::ff_gt_sel_shift_rng)));
152 std::get<18>(evals) += (tmp * scaling_factor);
153 }
154 { // RNG_CTR_NON_ZERO
155 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
156 auto tmp = (static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr)) *
157 ((FF(1) - static_cast<View>(in.get(C::ff_gt_sel_shift_rng))) *
158 (FF(1) - static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_inv))) +
159 static_cast<View>(in.get(C::ff_gt_cmp_rng_ctr_inv))) -
160 static_cast<View>(in.get(C::ff_gt_sel_shift_rng)));
161 std::get<19>(evals) += (tmp * scaling_factor);
162 }
163 { // SHIFT_0
164 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
165 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))) *
166 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
167 std::get<20>(evals) += (tmp * scaling_factor);
168 }
169 {
170 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
171 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))) *
172 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
173 std::get<21>(evals) += (tmp * scaling_factor);
174 }
175 { // SHIFT_1
176 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
177 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))) *
178 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
179 std::get<22>(evals) += (tmp * scaling_factor);
180 }
181 {
182 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
183 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))) *
184 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
185 std::get<23>(evals) += (tmp * scaling_factor);
186 }
187 { // SHIFT_2
188 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
189 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))) *
190 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
191 std::get<24>(evals) += (tmp * scaling_factor);
192 }
193 {
194 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
195 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))) *
196 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
197 std::get<25>(evals) += (tmp * scaling_factor);
198 }
199 { // SHIFT_3
200 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
201 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))) *
202 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
203 std::get<26>(evals) += (tmp * scaling_factor);
204 }
205 {
206 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
207 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))) *
208 static_cast<View>(in.get(C::ff_gt_sel_shift_rng));
209 std::get<27>(evals) += (tmp * scaling_factor);
210 }
211 { // SEL_CONSISTENCY
212 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
213 auto tmp =
214 ((static_cast<View>(in.get(C::ff_gt_sel_shift_rng)) + static_cast<View>(in.get(C::ff_gt_sel_gt_shift)) +
215 static_cast<View>(in.get(C::ff_gt_sel_dec_shift))) -
216 static_cast<View>(in.get(C::ff_gt_sel_shift)));
217 std::get<28>(evals) += (tmp * scaling_factor);
218 }
219}
220
221} // 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.