Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
scalar_mul_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 scalar_mulImpl<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 ecc_INFINITY_X = FF(0);
19 const auto ecc_INFINITY_Y = FF(0);
20 const auto scalar_mul_LATCH_CONDITION = in.get(C::scalar_mul_end) + in.get(C::precomputed_first_row);
21 const auto scalar_mul_SHOULD_PASS = in.get(C::scalar_mul_sel_not_end) * (FF(1) - in.get(C::scalar_mul_bit));
22
23 {
24 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
25 auto tmp =
26 static_cast<View>(in.get(C::scalar_mul_sel)) * (FF(1) - static_cast<View>(in.get(C::scalar_mul_sel)));
27 std::get<0>(evals) += (tmp * scaling_factor);
28 }
29 {
30 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
31 auto tmp = static_cast<View>(in.get(C::scalar_mul_point_inf)) *
32 (FF(1) - static_cast<View>(in.get(C::scalar_mul_point_inf)));
33 std::get<1>(evals) += (tmp * scaling_factor);
34 }
35 {
36 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
37 auto tmp =
38 static_cast<View>(in.get(C::scalar_mul_start)) * (FF(1) - static_cast<View>(in.get(C::scalar_mul_start)));
39 std::get<2>(evals) += (tmp * scaling_factor);
40 }
41 {
42 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
43 auto tmp =
44 static_cast<View>(in.get(C::scalar_mul_end)) * (FF(1) - static_cast<View>(in.get(C::scalar_mul_end)));
45 std::get<3>(evals) += (tmp * scaling_factor);
46 }
47 { // START_AFTER_LATCH
48 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
49 auto tmp = static_cast<View>(in.get(C::scalar_mul_sel_shift)) *
50 (static_cast<View>(in.get(C::scalar_mul_start_shift)) - CView(scalar_mul_LATCH_CONDITION));
51 std::get<4>(evals) += (tmp * scaling_factor);
52 }
53 { // SELECTOR_ON_START_OR_END
54 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
55 auto tmp = (static_cast<View>(in.get(C::scalar_mul_start)) + static_cast<View>(in.get(C::scalar_mul_end))) *
56 (FF(1) - static_cast<View>(in.get(C::scalar_mul_sel)));
57 std::get<5>(evals) += (tmp * scaling_factor);
58 }
59 { // SELECTOR_CONSISTENCY
60 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
61 auto tmp = (static_cast<View>(in.get(C::scalar_mul_sel_shift)) - static_cast<View>(in.get(C::scalar_mul_sel))) *
62 (FF(1) - CView(scalar_mul_LATCH_CONDITION));
63 std::get<6>(evals) += (tmp * scaling_factor);
64 }
65 {
66 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
67 auto tmp = (static_cast<View>(in.get(C::scalar_mul_sel_not_end)) -
68 (static_cast<View>(in.get(C::scalar_mul_sel)) - static_cast<View>(in.get(C::scalar_mul_end))));
69 std::get<7>(evals) += (tmp * scaling_factor);
70 }
71 { // INPUT_CONSISTENCY_X
72 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
73 auto tmp =
74 static_cast<View>(in.get(C::scalar_mul_sel_not_end)) *
75 (static_cast<View>(in.get(C::scalar_mul_point_x)) - static_cast<View>(in.get(C::scalar_mul_point_x_shift)));
76 std::get<8>(evals) += (tmp * scaling_factor);
77 }
78 { // INPUT_CONSISTENCY_Y
79 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
80 auto tmp =
81 static_cast<View>(in.get(C::scalar_mul_sel_not_end)) *
82 (static_cast<View>(in.get(C::scalar_mul_point_y)) - static_cast<View>(in.get(C::scalar_mul_point_y_shift)));
83 std::get<9>(evals) += (tmp * scaling_factor);
84 }
85 { // INPUT_CONSISTENCY_INF
86 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
87 auto tmp = static_cast<View>(in.get(C::scalar_mul_sel_not_end)) *
88 (static_cast<View>(in.get(C::scalar_mul_point_inf)) -
89 static_cast<View>(in.get(C::scalar_mul_point_inf_shift)));
90 std::get<10>(evals) += (tmp * scaling_factor);
91 }
92 { // INPUT_CONSISTENCY_SCALAR
93 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
94 auto tmp =
95 static_cast<View>(in.get(C::scalar_mul_sel_not_end)) *
96 (static_cast<View>(in.get(C::scalar_mul_scalar)) - static_cast<View>(in.get(C::scalar_mul_scalar_shift)));
97 std::get<11>(evals) += (tmp * scaling_factor);
98 }
99 {
100 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
101 auto tmp = static_cast<View>(in.get(C::scalar_mul_start)) *
102 (static_cast<View>(in.get(C::scalar_mul_bit_idx)) - FF(253));
103 std::get<12>(evals) += (tmp * scaling_factor);
104 }
105 {
106 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
107 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) * static_cast<View>(in.get(C::scalar_mul_bit_idx));
108 std::get<13>(evals) += (tmp * scaling_factor);
109 }
110 { // DECREMENT_INDEX
111 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
112 auto tmp = static_cast<View>(in.get(C::scalar_mul_sel_not_end)) *
113 (static_cast<View>(in.get(C::scalar_mul_bit_idx)) -
114 (static_cast<View>(in.get(C::scalar_mul_bit_idx_shift)) + FF(1)));
115 std::get<14>(evals) += (tmp * scaling_factor);
116 }
117 {
118 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
119 auto tmp =
120 static_cast<View>(in.get(C::scalar_mul_sel)) * (static_cast<View>(in.get(C::scalar_mul_const_two)) - FF(2));
121 std::get<15>(evals) += (tmp * scaling_factor);
122 }
123 {
124 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
125 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) *
126 (static_cast<View>(in.get(C::scalar_mul_temp_x)) - static_cast<View>(in.get(C::scalar_mul_point_x)));
127 std::get<16>(evals) += (tmp * scaling_factor);
128 }
129 {
130 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
131 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) *
132 (static_cast<View>(in.get(C::scalar_mul_temp_y)) - static_cast<View>(in.get(C::scalar_mul_point_y)));
133 std::get<17>(evals) += (tmp * scaling_factor);
134 }
135 {
136 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
137 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) * (static_cast<View>(in.get(C::scalar_mul_temp_inf)) -
138 static_cast<View>(in.get(C::scalar_mul_point_inf)));
139 std::get<18>(evals) += (tmp * scaling_factor);
140 }
141 {
142 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
143 auto tmp = (static_cast<View>(in.get(C::scalar_mul_temp_x_shift)) -
144 static_cast<View>(in.get(C::scalar_mul_temp_x_shift)));
145 std::get<19>(evals) += (tmp * scaling_factor);
146 }
147 {
148 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
149 auto tmp = (static_cast<View>(in.get(C::scalar_mul_temp_y_shift)) -
150 static_cast<View>(in.get(C::scalar_mul_temp_y_shift)));
151 std::get<20>(evals) += (tmp * scaling_factor);
152 }
153 {
154 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
155 auto tmp = (static_cast<View>(in.get(C::scalar_mul_temp_inf_shift)) -
156 static_cast<View>(in.get(C::scalar_mul_temp_inf_shift)));
157 std::get<21>(evals) += (tmp * scaling_factor);
158 }
159 {
160 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
161 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) *
162 ((static_cast<View>(in.get(C::scalar_mul_point_x)) * static_cast<View>(in.get(C::scalar_mul_bit)) +
163 CView(ecc_INFINITY_X) * (FF(1) - static_cast<View>(in.get(C::scalar_mul_bit)))) -
164 static_cast<View>(in.get(C::scalar_mul_res_x)));
165 std::get<22>(evals) += (tmp * scaling_factor);
166 }
167 {
168 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
169 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) *
170 ((static_cast<View>(in.get(C::scalar_mul_point_y)) * static_cast<View>(in.get(C::scalar_mul_bit)) +
171 CView(ecc_INFINITY_Y) * (FF(1) - static_cast<View>(in.get(C::scalar_mul_bit)))) -
172 static_cast<View>(in.get(C::scalar_mul_res_y)));
173 std::get<23>(evals) += (tmp * scaling_factor);
174 }
175 {
176 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
177 auto tmp = static_cast<View>(in.get(C::scalar_mul_end)) *
178 (((static_cast<View>(in.get(C::scalar_mul_point_inf)) - FF(1)) *
179 static_cast<View>(in.get(C::scalar_mul_bit)) +
180 FF(1)) -
181 static_cast<View>(in.get(C::scalar_mul_res_inf)));
182 std::get<24>(evals) += (tmp * scaling_factor);
183 }
184 {
185 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
186 auto tmp =
187 (static_cast<View>(in.get(C::scalar_mul_should_add)) -
188 static_cast<View>(in.get(C::scalar_mul_sel_not_end)) * static_cast<View>(in.get(C::scalar_mul_bit)));
189 std::get<25>(evals) += (tmp * scaling_factor);
190 }
191 {
192 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
193 auto tmp = CView(scalar_mul_SHOULD_PASS) * (static_cast<View>(in.get(C::scalar_mul_res_x)) -
194 static_cast<View>(in.get(C::scalar_mul_res_x_shift)));
195 std::get<26>(evals) += (tmp * scaling_factor);
196 }
197 {
198 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
199 auto tmp = CView(scalar_mul_SHOULD_PASS) * (static_cast<View>(in.get(C::scalar_mul_res_y)) -
200 static_cast<View>(in.get(C::scalar_mul_res_y_shift)));
201 std::get<27>(evals) += (tmp * scaling_factor);
202 }
203 {
204 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
205 auto tmp = CView(scalar_mul_SHOULD_PASS) * (static_cast<View>(in.get(C::scalar_mul_res_inf)) -
206 static_cast<View>(in.get(C::scalar_mul_res_inf_shift)));
207 std::get<28>(evals) += (tmp * scaling_factor);
208 }
209}
210
211} // 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.