44 using State = std::array<FF, t>;
65 auto t0 = input[0] + input[1];
66 auto t1 = input[2] + input[3];
67 auto t2 = input[1] + input[1];
69 auto t3 = input[3] + input[3];
87 for (
size_t i = 0; i <
t; ++i) {
96 for (
size_t i = 1; i <
t; ++i) {
99 for (
size_t i = 0; i <
t; ++i) {
107 if constexpr (
t == 4) {
118 auto xx = input.sqr();
119 auto xxxx = xx.sqr();
125 for (
auto& in : input) {
140 State current_state(input);
146 constexpr size_t rounds_f_beginning =
rounds_f / 2;
147 for (
size_t i = 0; i < rounds_f_beginning; ++i) {
154 const size_t p_end = rounds_f_beginning +
rounds_p;
155 for (
size_t i = rounds_f_beginning; i < p_end; ++i) {
167 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)
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 d
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 size_t sbox_size
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 sbox_size
static constexpr size_t rounds_f
static constexpr size_t d
static constexpr size_t rounds_p
static constexpr std::array< std::array< FF, t >, rounds_f+rounds_p > round_constants
void throw_or_abort(std::string const &err)