Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ecc_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 eccImpl<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/ecc");
18
19 const auto ecc_INFINITY_X = FF(0);
20 const auto ecc_INFINITY_Y = FF(0);
21 const auto ecc_X_DIFF = (in.get(C::ecc_q_x) - in.get(C::ecc_p_x));
22 const auto ecc_Y_DIFF = (in.get(C::ecc_q_y) - in.get(C::ecc_p_y));
23 const auto ecc_INFINITY_PRED = in.get(C::ecc_x_match) * (FF(1) - in.get(C::ecc_y_match));
24 const auto ecc_BOTH_INF = in.get(C::ecc_p_is_inf) * in.get(C::ecc_q_is_inf);
25 const auto ecc_BOTH_NON_INF = (FF(1) - in.get(C::ecc_p_is_inf)) * (FF(1) - in.get(C::ecc_q_is_inf));
26 const auto ecc_COMPUTED_R_X =
27 ((in.get(C::ecc_lambda) * in.get(C::ecc_lambda) - in.get(C::ecc_p_x)) - in.get(C::ecc_q_x));
28 const auto ecc_COMPUTED_R_Y =
29 (in.get(C::ecc_lambda) * (in.get(C::ecc_p_x) - in.get(C::ecc_r_x)) - in.get(C::ecc_p_y));
30 const auto ecc_EITHER_INF = ((in.get(C::ecc_p_is_inf) + in.get(C::ecc_q_is_inf)) - FF(2) * ecc_BOTH_INF);
31
32 {
33 using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
34 auto tmp = in.get(C::ecc_sel) * (FF(1) - in.get(C::ecc_sel));
35 tmp *= scaling_factor;
36 std::get<0>(evals) += typename Accumulator::View(tmp);
37 }
38 {
39 using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
40 auto tmp = in.get(C::ecc_double_op) * (FF(1) - in.get(C::ecc_double_op));
41 tmp *= scaling_factor;
42 std::get<1>(evals) += typename Accumulator::View(tmp);
43 }
44 {
45 using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
46 auto tmp = in.get(C::ecc_add_op) * (FF(1) - in.get(C::ecc_add_op));
47 tmp *= scaling_factor;
48 std::get<2>(evals) += typename Accumulator::View(tmp);
49 }
50 {
51 using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
52 auto tmp = (in.get(C::ecc_sel) - (in.get(C::ecc_double_op) + in.get(C::ecc_add_op) + ecc_INFINITY_PRED));
53 tmp *= scaling_factor;
54 std::get<3>(evals) += typename Accumulator::View(tmp);
55 }
56 {
57 using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
58 auto tmp = in.get(C::ecc_p_is_inf) * (FF(1) - in.get(C::ecc_p_is_inf));
59 tmp *= scaling_factor;
60 std::get<4>(evals) += typename Accumulator::View(tmp);
61 }
62 {
63 using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
64 auto tmp = in.get(C::ecc_q_is_inf) * (FF(1) - in.get(C::ecc_q_is_inf));
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::ecc_r_is_inf) * (FF(1) - in.get(C::ecc_r_is_inf));
71 tmp *= scaling_factor;
72 std::get<6>(evals) += typename Accumulator::View(tmp);
73 }
74 {
75 using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
76 auto tmp = in.get(C::ecc_x_match) * (FF(1) - in.get(C::ecc_x_match));
77 tmp *= scaling_factor;
78 std::get<7>(evals) += typename Accumulator::View(tmp);
79 }
80 {
81 using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
82 auto tmp =
83 in.get(C::ecc_sel) *
84 ((ecc_X_DIFF * (in.get(C::ecc_x_match) * (FF(1) - in.get(C::ecc_inv_x_diff)) + in.get(C::ecc_inv_x_diff)) -
85 FF(1)) +
86 in.get(C::ecc_x_match));
87 tmp *= scaling_factor;
88 std::get<8>(evals) += typename Accumulator::View(tmp);
89 }
90 {
91 using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
92 auto tmp = in.get(C::ecc_y_match) * (FF(1) - in.get(C::ecc_y_match));
93 tmp *= scaling_factor;
94 std::get<9>(evals) += typename Accumulator::View(tmp);
95 }
96 {
97 using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
98 auto tmp =
99 in.get(C::ecc_sel) *
100 ((ecc_Y_DIFF * (in.get(C::ecc_y_match) * (FF(1) - in.get(C::ecc_inv_y_diff)) + in.get(C::ecc_inv_y_diff)) -
101 FF(1)) +
102 in.get(C::ecc_y_match));
103 tmp *= scaling_factor;
104 std::get<10>(evals) += typename Accumulator::View(tmp);
105 }
106 { // DOUBLE_PRED
107 using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
108 auto tmp = (in.get(C::ecc_double_op) - in.get(C::ecc_x_match) * in.get(C::ecc_y_match));
109 tmp *= scaling_factor;
110 std::get<11>(evals) += typename Accumulator::View(tmp);
111 }
112 { // INFINITY_RESULT
113 using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
114 auto tmp = in.get(C::ecc_sel) *
115 (in.get(C::ecc_result_infinity) - (ecc_INFINITY_PRED * ecc_BOTH_NON_INF + ecc_BOTH_INF));
116 tmp *= scaling_factor;
117 std::get<12>(evals) += typename Accumulator::View(tmp);
118 }
119 {
120 using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
121 auto tmp = (FF(1) - in.get(C::ecc_result_infinity)) * in.get(C::ecc_double_op) *
122 (FF(2) * in.get(C::ecc_p_y) * in.get(C::ecc_inv_2_p_y) - FF(1));
123 tmp *= scaling_factor;
124 std::get<13>(evals) += typename Accumulator::View(tmp);
125 }
126 { // COMPUTED_LAMBDA
127 using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>;
128 auto tmp = in.get(C::ecc_sel) *
129 (in.get(C::ecc_lambda) - (in.get(C::ecc_double_op) * FF(3) * in.get(C::ecc_p_x) *
130 in.get(C::ecc_p_x) * in.get(C::ecc_inv_2_p_y) +
131 in.get(C::ecc_add_op) * ecc_Y_DIFF * in.get(C::ecc_inv_x_diff)));
132 tmp *= scaling_factor;
133 std::get<14>(evals) += typename Accumulator::View(tmp);
134 }
135 {
136 using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>;
137 auto tmp =
138 (in.get(C::ecc_use_computed_result) - in.get(C::ecc_sel) * (FF(1) - in.get(C::ecc_p_is_inf)) *
139 (FF(1) - in.get(C::ecc_q_is_inf)) * (FF(1) - ecc_INFINITY_PRED));
140 tmp *= scaling_factor;
141 std::get<15>(evals) += typename Accumulator::View(tmp);
142 }
143 { // OUTPUT_X_COORD
144 using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>;
145 auto tmp = in.get(C::ecc_sel) *
146 (((in.get(C::ecc_r_x) - ecc_EITHER_INF * (in.get(C::ecc_p_is_inf) * in.get(C::ecc_q_x) +
147 in.get(C::ecc_q_is_inf) * in.get(C::ecc_p_x))) -
148 in.get(C::ecc_result_infinity) * ecc_INFINITY_X) -
149 in.get(C::ecc_use_computed_result) * ecc_COMPUTED_R_X);
150 tmp *= scaling_factor;
151 std::get<16>(evals) += typename Accumulator::View(tmp);
152 }
153 { // OUTPUT_Y_COORD
154 using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>;
155 auto tmp = in.get(C::ecc_sel) *
156 (((in.get(C::ecc_r_y) - ecc_EITHER_INF * (in.get(C::ecc_p_is_inf) * in.get(C::ecc_q_y) +
157 in.get(C::ecc_q_is_inf) * in.get(C::ecc_p_y))) -
158 in.get(C::ecc_result_infinity) * ecc_INFINITY_Y) -
159 in.get(C::ecc_use_computed_result) * ecc_COMPUTED_R_Y);
160 tmp *= scaling_factor;
161 std::get<17>(evals) += typename Accumulator::View(tmp);
162 }
163 { // OUTPUT_INF_FLAG
164 using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>;
165 auto tmp = in.get(C::ecc_sel) * (in.get(C::ecc_r_is_inf) - in.get(C::ecc_result_infinity));
166 tmp *= scaling_factor;
167 std::get<18>(evals) += typename Accumulator::View(tmp);
168 }
169}
170
171} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
Definition ecc_impl.hpp:10
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.