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