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_LATCH_CONDITION = in.get(C::poseidon2_hash_end) + in.get(C::precomputed_first_row);
19 const auto poseidon2_hash_TWOPOW64 = FF(uint256_t{ 0UL, 1UL, 0UL, 0UL });
20 const auto poseidon2_hash_IV = poseidon2_hash_TWOPOW64 * in.get(C::poseidon2_hash_input_len);
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 {
31 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
32 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_start)) *
33 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_start)));
34 std::get<1>(evals) += (tmp * scaling_factor);
35 }
36 {
37 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
38 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_end)) *
39 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_end)));
40 std::get<2>(evals) += (tmp * scaling_factor);
41 }
42 { // SEL_ON_START_OR_END
43 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
44 auto tmp =
45 (static_cast<View>(in.get(C::poseidon2_hash_start)) + static_cast<View>(in.get(C::poseidon2_hash_end))) *
46 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_sel)));
47 std::get<3>(evals) += (tmp * scaling_factor);
48 }
49 { // TRACE_CONTINUITY
50 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
51 auto tmp =
52 (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
53 (static_cast<View>(in.get(C::poseidon2_hash_sel)) - static_cast<View>(in.get(C::poseidon2_hash_sel_shift)));
54 std::get<4>(evals) += (tmp * scaling_factor);
55 }
56 { // START_AFTER_LATCH
57 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
58 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel_shift)) *
59 (static_cast<View>(in.get(C::poseidon2_hash_start_shift)) - CView(poseidon2_hash_LATCH_CONDITION));
60 std::get<5>(evals) += (tmp * scaling_factor);
61 }
62 {
63 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
64 auto tmp = (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
65 (static_cast<View>(in.get(C::poseidon2_hash_output_shift)) -
66 static_cast<View>(in.get(C::poseidon2_hash_output)));
67 std::get<6>(evals) += (tmp * scaling_factor);
68 }
69 {
70 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
71 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_padding)) *
72 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(1)) *
73 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(2));
74 std::get<7>(evals) += (tmp * scaling_factor);
75 }
76 {
77 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
78 auto tmp = 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_min_one_inv))) +
97 static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_min_one_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_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 = (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_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 = (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_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 = (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_start)) *
150 (static_cast<View>(in.get(C::poseidon2_hash_a_3)) - CView(poseidon2_hash_IV));
151 std::get<17>(evals) += (tmp * scaling_factor);
152 }
153 {
154 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
155 auto tmp =
156 (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
157 (static_cast<View>(in.get(C::poseidon2_hash_a_3_shift)) - static_cast<View>(in.get(C::poseidon2_hash_b_3)));
158 std::get<18>(evals) += (tmp * scaling_factor);
159 }
160 {
161 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
162 auto tmp =
163 static_cast<View>(in.get(C::poseidon2_hash_end)) *
164 (static_cast<View>(in.get(C::poseidon2_hash_output)) - static_cast<View>(in.get(C::poseidon2_hash_b_0)));
165 std::get<19>(evals) += (tmp * scaling_factor);
166 }
167}
168
169} // 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.