58 auto t0 = input[0] + input[1];
59 auto t1 = input[2] + input[3];
60 auto t2 = input[1] + input[1];
62 auto t3 = input[3] + input[3];
80 for (
size_t i = 0; i <
t; ++i) {
89 for (
size_t i = 1; i <
t; ++i) {
92 for (
size_t i = 0; i <
t; ++i) {
100 static_assert(
t == 4,
"Only t=4 is supported");
112 auto xx = input.sqr();
113 auto xxxx = xx.sqr();
119 for (
auto& in : input) {
134 State current_state(input);
140 constexpr size_t rounds_f_beginning =
rounds_f / 2;
141 for (
size_t i = 0; i < rounds_f_beginning; ++i) {
148 const size_t p_end = rounds_f_beginning +
rounds_p;
149 for (
size_t i = rounds_f_beginning; i < p_end; ++i) {
161 return current_state;
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323.
static constexpr size_t NUM_ROUNDS
static constexpr size_t rounds_f
static constexpr size_t rounds_p
static constexpr State permutation(const State &input)
Native form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
static constexpr void matrix_multiplication_4x4(State &input)
static constexpr void apply_single_sbox(FF &input)
S-box: x -> x^5.
std::array< FF, t > RoundConstants
static constexpr void matrix_multiplication_internal(State &input)
static constexpr void matrix_multiplication_external(State &input)
static constexpr void add_round_constants(State &input, const RoundConstants &rc)
static constexpr size_t t
static constexpr void apply_sbox(State &input)
static constexpr MatrixDiagonal internal_matrix_diagonal
std::array< RoundConstants, NUM_ROUNDS > RoundConstantsContainer
std::array< FF, t > MatrixDiagonal
static constexpr RoundConstantsContainer round_constants
std::array< FF, t > State
Inner sum(Cont< Inner, Args... > const &in)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static constexpr size_t t
static constexpr std::array< FF, t > internal_matrix_diagonal
static constexpr size_t rounds_f
static constexpr size_t rounds_p
static constexpr std::array< std::array< FF, t >, rounds_f+rounds_p > round_constants