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 {
31 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
32 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
33 (static_cast<View>(in.get(C::poseidon2_hash_output_shift)) -
34 static_cast<View>(in.get(C::poseidon2_hash_output)));
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_start)) *
40 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_start)));
41 std::get<2>(evals) += (tmp * scaling_factor);
42 }
43 {
44 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
45 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel_shift)) *
46 (static_cast<View>(in.get(C::poseidon2_hash_start_shift)) - CView(poseidon2_hash_LATCH_CONDITION));
47 std::get<3>(evals) += (tmp * scaling_factor);
48 }
49 {
50 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
51 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_end)) *
52 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_end)));
53 std::get<4>(evals) += (tmp * scaling_factor);
54 }
55 {
56 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
57 auto tmp =
58 static_cast<View>(in.get(C::poseidon2_hash_end)) * static_cast<View>(in.get(C::precomputed_first_row));
59 std::get<5>(evals) += (tmp * scaling_factor);
60 }
61 {
62 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
63 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_padding)) *
64 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(1)) *
65 (static_cast<View>(in.get(C::poseidon2_hash_padding)) - FF(2));
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_sel)) *
71 static_cast<View>(in.get(C::poseidon2_hash_start)) *
72 (static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem)) * FF(3) -
73 CView(poseidon2_hash_PADDED_LEN));
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_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
79 ((static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_shift)) -
80 static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem))) +
81 FF(1));
82 std::get<8>(evals) += (tmp * scaling_factor);
83 }
84 {
85 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
86 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
87 ((CView(poseidon2_hash_NEXT_ROUND_COUNT) *
88 (static_cast<View>(in.get(C::poseidon2_hash_end)) *
89 (FF(1) - static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_inv))) +
90 static_cast<View>(in.get(C::poseidon2_hash_num_perm_rounds_rem_inv))) -
91 FF(1)) +
92 static_cast<View>(in.get(C::poseidon2_hash_end)));
93 std::get<9>(evals) += (tmp * scaling_factor);
94 }
95 {
96 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
97 auto tmp =
98 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
99 (static_cast<View>(in.get(C::poseidon2_hash_a_0)) - static_cast<View>(in.get(C::poseidon2_hash_input_0)));
100 std::get<10>(evals) += (tmp * scaling_factor);
101 }
102 {
103 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
104 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
105 ((static_cast<View>(in.get(C::poseidon2_hash_a_0_shift)) -
106 static_cast<View>(in.get(C::poseidon2_hash_b_0))) -
107 static_cast<View>(in.get(C::poseidon2_hash_input_0_shift)));
108 std::get<11>(evals) += (tmp * scaling_factor);
109 }
110 {
111 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
112 auto tmp =
113 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
114 (static_cast<View>(in.get(C::poseidon2_hash_a_1)) - static_cast<View>(in.get(C::poseidon2_hash_input_1)));
115 std::get<12>(evals) += (tmp * scaling_factor);
116 }
117 {
118 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
119 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
120 ((static_cast<View>(in.get(C::poseidon2_hash_a_1_shift)) -
121 static_cast<View>(in.get(C::poseidon2_hash_b_1))) -
122 static_cast<View>(in.get(C::poseidon2_hash_input_1_shift)));
123 std::get<13>(evals) += (tmp * scaling_factor);
124 }
125 {
126 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
127 auto tmp =
128 static_cast<View>(in.get(C::poseidon2_hash_sel)) * static_cast<View>(in.get(C::poseidon2_hash_start)) *
129 (static_cast<View>(in.get(C::poseidon2_hash_a_2)) - static_cast<View>(in.get(C::poseidon2_hash_input_2)));
130 std::get<14>(evals) += (tmp * scaling_factor);
131 }
132 {
133 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
134 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
135 ((static_cast<View>(in.get(C::poseidon2_hash_a_2_shift)) -
136 static_cast<View>(in.get(C::poseidon2_hash_b_2))) -
137 static_cast<View>(in.get(C::poseidon2_hash_input_2_shift)));
138 std::get<15>(evals) += (tmp * scaling_factor);
139 }
140 {
141 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
142 auto tmp = static_cast<View>(in.get(C::poseidon2_hash_sel)) *
143 static_cast<View>(in.get(C::poseidon2_hash_start)) *
144 (static_cast<View>(in.get(C::poseidon2_hash_a_3)) - CView(poseidon2_hash_IV));
145 std::get<16>(evals) += (tmp * scaling_factor);
146 }
147 {
148 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
149 auto tmp =
150 static_cast<View>(in.get(C::poseidon2_hash_sel)) * (FF(1) - CView(poseidon2_hash_LATCH_CONDITION)) *
151 (static_cast<View>(in.get(C::poseidon2_hash_a_3_shift)) - static_cast<View>(in.get(C::poseidon2_hash_b_3)));
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)) * CView(poseidon2_hash_LATCH_CONDITION) *
158 (static_cast<View>(in.get(C::poseidon2_hash_output)) - static_cast<View>(in.get(C::poseidon2_hash_b_0)));
159 std::get<18>(evals) += (tmp * scaling_factor);
160 }
161}
162
163} // 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.