Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
poseidon2_hash_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 poseidon2_hashImpl<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 poseidon2_hash_TWOPOW64 = FF(uint256_t{ 0UL, 1UL, 0UL, 0UL });
19 const auto poseidon2_hash_IV = poseidon2_hash_TWOPOW64 * in.get(C::poseidon2_hash_input_len);
20 const auto poseidon2_hash_LATCH_CONDITION = in.get(C::poseidon2_hash_end) + in.get(C::precomputed_first_row);
21 const auto poseidon2_hash_PADDED_LEN = in.get(C::poseidon2_hash_input_len) + in.get(C::poseidon2_hash_padding);
22 const auto poseidon2_hash_NEXT_ROUND_COUNT = (in.get(C::poseidon2_hash_num_perm_rounds_rem) - FF(1));
23
24 {
25 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
26 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
27 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_sel)));
28 std::get<0>(evals) += (tmp * scaling_factor);
29 }
30 { // TRACE_CONTINUITY
31 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
32 auto tmp = (FF(1) - static_cast<View>(in.get(C::precomputed_first_row))) *
33 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_sel))) *
34 static_cast<View>(in.get(C::poseidon2_hash_sel_shift));
35 std::get<1>(evals) += (tmp * scaling_factor);
36 }
37 {
38 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
39 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
40 (static_cast<View>(in.get(C::poseidon2_hash_output_shift)) -
41 static_cast<View>(in.get(C::poseidon2_hash_output)));
42 std::get<2>(evals) += (tmp * scaling_factor);
43 }
44 {
45 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
46 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_start)) *
47 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_start)));
48 std::get<3>(evals) += (tmp * scaling_factor);
49 }
50 {
51 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
52 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel_shift)) *
53 (static_cast<View>(in.get(C::poseidon2_hash_start_shift)) - CView(poseidon2_hash_LATCH_CONDITION));
54 std::get<4>(evals) += (tmp * scaling_factor);
55 }
56 {
57 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
58 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_end)) *
59 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_end)));
60 std::get<5>(evals) += (tmp * scaling_factor);
61 }
62 { // SELECTOR_ON_END
63 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
64 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_end)) *
65 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_sel)));
66 std::get<6>(evals) += (tmp * scaling_factor);
67 }
68 {
69 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
70 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_padding)) *
71 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(1)) *
72 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(2));
73 std::get<7>(evals) += (tmp * scaling_factor);
74 }
75 {
76 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
77 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
78 static_cast<View>(in.get(C::poseidon2_hash_start)) *
79 (static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem)) * FF(3) -
80 CView(poseidon2_hash_PADDED_LEN));
81 std::get<8>(evals) += (tmp * scaling_factor);
82 }
83 {
84 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
85 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
86 ((static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_shift)) -
87 static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem))) +
88 FF(1));
89 std::get<9>(evals) += (tmp * scaling_factor);
90 }
91 {
92 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
93 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
94 ((CView(poseidon2_hash_NEXT_ROUND_COUNT) *
95 (static_cast<View>(in.get(C::poseidon2_hash_end)) *
96 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_inv))) +
97 static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_inv))) -
98 FF(1)) +
99 static_cast<View>(in.get(C::poseidon2_hash_end)));
100 std::get<10>(evals) += (tmp * scaling_factor);
101 }
102 {
103 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
104 auto tmp =
105 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
106 (static_cast<View>(in.get(C::poseidon2_hash_a_0)) - static_cast<View>(in.get(C::poseidon2_hash_input_0)));
107 std::get<11>(evals) += (tmp * scaling_factor);
108 }
109 {
110 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
111 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
112 ((static_cast<View>(in.get(C::poseidon2_hash_a_0_shift)) -
113 static_cast<View>(in.get(C::poseidon2_hash_b_0))) -
114 static_cast<View>(in.get(C::poseidon2_hash_input_0_shift)));
115 std::get<12>(evals) += (tmp * scaling_factor);
116 }
117 {
118 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
119 auto tmp =
120 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
121 (static_cast<View>(in.get(C::poseidon2_hash_a_1)) - static_cast<View>(in.get(C::poseidon2_hash_input_1)));
122 std::get<13>(evals) += (tmp * scaling_factor);
123 }
124 {
125 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
126 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
127 ((static_cast<View>(in.get(C::poseidon2_hash_a_1_shift)) -
128 static_cast<View>(in.get(C::poseidon2_hash_b_1))) -
129 static_cast<View>(in.get(C::poseidon2_hash_input_1_shift)));
130 std::get<14>(evals) += (tmp * scaling_factor);
131 }
132 {
133 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
134 auto tmp =
135 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
136 (static_cast<View>(in.get(C::poseidon2_hash_a_2)) - static_cast<View>(in.get(C::poseidon2_hash_input_2)));
137 std::get<15>(evals) += (tmp * scaling_factor);
138 }
139 {
140 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
141 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
142 ((static_cast<View>(in.get(C::poseidon2_hash_a_2_shift)) -
143 static_cast<View>(in.get(C::poseidon2_hash_b_2))) -
144 static_cast<View>(in.get(C::poseidon2_hash_input_2_shift)));
145 std::get<16>(evals) += (tmp * scaling_factor);
146 }
147 {
148 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
149 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
150 static_cast<View>(in.get(C::poseidon2_hash_start)) *
151 (static_cast<View>(in.get(C::poseidon2_hash_a_3)) - CView(poseidon2_hash_IV));
152 std::get<17>(evals) += (tmp * scaling_factor);
153 }
154 {
155 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
156 auto tmp =
157 static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
158 (static_cast<View>(in.get(C::poseidon2_hash_a_3_shift)) - static_cast<View>(in.get(C::poseidon2_hash_b_3)));
159 std::get<18>(evals) += (tmp * scaling_factor);
160 }
161 {
162 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
163 auto tmp =
164 static_cast<View>(in.get(C::poseidon2_hash_sel)) * CView(poseidon2_hash_LATCH_CONDITION) *
165 (static_cast<View>(in.get(C::poseidon2_hash_output)) - static_cast<View>(in.get(C::poseidon2_hash_b_0)));
166 std::get<19>(evals) += (tmp * scaling_factor);
167 }
168}
169
170} // 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.