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