Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::crypto::Poseidon2Permutation< Params > Class Template Reference

Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323 . This algorithm was implemented using https://github.com/HorizenLabs/poseidon2 as a reference. More...

#include <poseidon2_permutation.hpp>

Public Types

using FF = typename Params::FF
 
using State = std::array< FF, t >
 
using RoundConstants = std::array< FF, t >
 
using MatrixDiagonal = std::array< FF, t >
 
using RoundConstantsContainer = std::array< RoundConstants, NUM_ROUNDS >
 

Static Public Member Functions

static constexpr void matrix_multiplication_4x4 (State &input)
 
static constexpr void add_round_constants (State &input, const RoundConstants &rc)
 
static constexpr void matrix_multiplication_internal (State &input)
 
static constexpr void matrix_multiplication_external (State &input)
 
static constexpr void apply_single_sbox (FF &input)
 
static constexpr void apply_sbox (State &input)
 
static constexpr State permutation (const State &input)
 Native form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
 

Static Public Attributes

static constexpr size_t t = Params::t
 
static constexpr size_t d = Params::d
 
static constexpr size_t sbox_size = Params::sbox_size
 
static constexpr size_t rounds_f = Params::rounds_f
 
static constexpr size_t rounds_p = Params::rounds_p
 
static constexpr size_t NUM_ROUNDS = Params::rounds_f + Params::rounds_p
 
static constexpr MatrixDiagonal internal_matrix_diagonal = Params::internal_matrix_diagonal
 
static constexpr RoundConstantsContainer round_constants = Params::round_constants
 

Detailed Description

template<typename Params>
class bb::crypto::Poseidon2Permutation< Params >

Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323 . This algorithm was implemented using https://github.com/HorizenLabs/poseidon2 as a reference.

Template Parameters
Params

Definition at line 25 of file poseidon2_permutation.hpp.

Member Typedef Documentation

◆ FF

template<typename Params >
using bb::crypto::Poseidon2Permutation< Params >::FF = typename Params::FF

Definition at line 43 of file poseidon2_permutation.hpp.

◆ MatrixDiagonal

template<typename Params >
using bb::crypto::Poseidon2Permutation< Params >::MatrixDiagonal = std::array<FF, t>

Definition at line 46 of file poseidon2_permutation.hpp.

◆ RoundConstants

template<typename Params >
using bb::crypto::Poseidon2Permutation< Params >::RoundConstants = std::array<FF, t>

Definition at line 45 of file poseidon2_permutation.hpp.

◆ RoundConstantsContainer

template<typename Params >
using bb::crypto::Poseidon2Permutation< Params >::RoundConstantsContainer = std::array<RoundConstants, NUM_ROUNDS>

Definition at line 47 of file poseidon2_permutation.hpp.

◆ State

template<typename Params >
using bb::crypto::Poseidon2Permutation< Params >::State = std::array<FF, t>

Definition at line 44 of file poseidon2_permutation.hpp.

Member Function Documentation

◆ add_round_constants()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::add_round_constants ( State input,
const RoundConstants rc 
)
inlinestaticconstexpr

Definition at line 85 of file poseidon2_permutation.hpp.

◆ apply_sbox()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::apply_sbox ( State input)
inlinestaticconstexpr

Definition at line 123 of file poseidon2_permutation.hpp.

◆ apply_single_sbox()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::apply_single_sbox ( FF input)
inlinestaticconstexpr

Definition at line 115 of file poseidon2_permutation.hpp.

◆ matrix_multiplication_4x4()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::matrix_multiplication_4x4 ( State input)
inlinestaticconstexpr

hardcoded algorithm that evaluates matrix multiplication using the following MDS matrix: / \ | 5 7 1 3 | | 4 6 1 1 | | 1 3 5 7 | | 1 1 4 6 | \ /

Algorithm is taken directly from the Poseidon2 paper.

Definition at line 52 of file poseidon2_permutation.hpp.

◆ matrix_multiplication_external()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::matrix_multiplication_external ( State input)
inlinestaticconstexpr

Definition at line 105 of file poseidon2_permutation.hpp.

◆ matrix_multiplication_internal()

template<typename Params >
static constexpr void bb::crypto::Poseidon2Permutation< Params >::matrix_multiplication_internal ( State input)
inlinestaticconstexpr

Definition at line 92 of file poseidon2_permutation.hpp.

◆ permutation()

template<typename Params >
static constexpr State bb::crypto::Poseidon2Permutation< Params >::permutation ( const State input)
inlinestaticconstexpr

Native form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.

The permutation consists of one initial linear layer, then a set of external rounds, a set of internal rounds, and a set of external rounds.

Parameters
input
Returns
constexpr State

Definition at line 137 of file poseidon2_permutation.hpp.

Member Data Documentation

◆ d

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::d = Params::d
staticconstexpr

Definition at line 34 of file poseidon2_permutation.hpp.

◆ internal_matrix_diagonal

template<typename Params >
constexpr MatrixDiagonal bb::crypto::Poseidon2Permutation< Params >::internal_matrix_diagonal = Params::internal_matrix_diagonal
staticconstexpr

Definition at line 49 of file poseidon2_permutation.hpp.

◆ NUM_ROUNDS

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::NUM_ROUNDS = Params::rounds_f + Params::rounds_p
staticconstexpr

Definition at line 41 of file poseidon2_permutation.hpp.

◆ round_constants

template<typename Params >
constexpr RoundConstantsContainer bb::crypto::Poseidon2Permutation< Params >::round_constants = Params::round_constants
staticconstexpr

Definition at line 50 of file poseidon2_permutation.hpp.

◆ rounds_f

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::rounds_f = Params::rounds_f
staticconstexpr

Definition at line 38 of file poseidon2_permutation.hpp.

◆ rounds_p

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::rounds_p = Params::rounds_p
staticconstexpr

Definition at line 40 of file poseidon2_permutation.hpp.

◆ sbox_size

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::sbox_size = Params::sbox_size
staticconstexpr

Definition at line 36 of file poseidon2_permutation.hpp.

◆ t

template<typename Params >
constexpr size_t bb::crypto::Poseidon2Permutation< Params >::t = Params::t
staticconstexpr

Definition at line 31 of file poseidon2_permutation.hpp.


The documentation for this class was generated from the following file: