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

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

#include <poseidon2_permutation.hpp>

Public Types

using Params = crypto::Poseidon2Bn254ScalarFieldParams
 
using NativePermutation = crypto::Poseidon2Permutation< Params >
 
using FF = typename Params::FF
 
using State = std::array< field_t< Builder >, t >
 
using NativeState = std::array< FF, t >
 
using RoundConstants = std::array< FF, t >
 
using RoundConstantsContainer = std::array< RoundConstants, NUM_ROUNDS >
 

Static Public Member Functions

static State permutation (Builder *builder, const State &input)
 Circuit form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
 
static void matrix_multiplication_external (State &state)
 In-circuit method to efficiently multiply the inital state by the external matrix \( M_E \). Uses 6 aritmetic gates.
 
static void propagate_current_state_to_next_row (Builder *builder, const State &state, auto &block)
 The result of applying a round of Poseidon2 is stored in the next row and is accessed by Poseidon2 Internal and External Relations via the shifts mechanism. Note that it does not activate any selectors since it only serves to store the values. See Poseidon2ExternalRelationImpl and Poseidon2InternalRelationImpl docs.
 

Static Public Attributes

static constexpr size_t t = Params::t
 
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 RoundConstantsContainer round_constants = Params::round_constants
 

Detailed Description

template<typename Builder>
class bb::stdlib::Poseidon2Permutation< Builder >

Circuit 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.

Note that except for the inital linear layer, we compute the round results natively and record them into Poseidon2 custom gates. This allows us to heavily reduce the number of arithmetic gates, that would have been otherwise required to perform expensive non-linear S-box operations in-circuit.

The external rounds are constrained via Poseidon2ExternalRelationImpl. The internal rounds are constrained via Poseidon2InternalRelationImpl.

Definition at line 30 of file poseidon2_permutation.hpp.

Member Typedef Documentation

◆ FF

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::FF = typename Params::FF

Definition at line 45 of file poseidon2_permutation.hpp.

◆ NativePermutation

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::NativePermutation = crypto::Poseidon2Permutation<Params>

Definition at line 33 of file poseidon2_permutation.hpp.

◆ NativeState

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::NativeState = std::array<FF, t>

Definition at line 47 of file poseidon2_permutation.hpp.

◆ Params

◆ RoundConstants

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstants = std::array<FF, t>

Definition at line 49 of file poseidon2_permutation.hpp.

◆ RoundConstantsContainer

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstantsContainer = std::array<RoundConstants, NUM_ROUNDS>

Definition at line 50 of file poseidon2_permutation.hpp.

◆ State

template<typename Builder >
using bb::stdlib::Poseidon2Permutation< Builder >::State = std::array<field_t<Builder>, t>

Definition at line 46 of file poseidon2_permutation.hpp.

Member Function Documentation

◆ matrix_multiplication_external()

template<typename Builder >
static void bb::stdlib::Poseidon2Permutation< Builder >::matrix_multiplication_external ( State state)
static

In-circuit method to efficiently multiply the inital state by the external matrix \( M_E \). Uses 6 aritmetic gates.

◆ permutation()

template<typename Builder >
static State bb::stdlib::Poseidon2Permutation< Builder >::permutation ( Builder builder,
const State input 
)
static

Circuit 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
builder
input
Returns
State

◆ propagate_current_state_to_next_row()

template<typename Builder >
static void bb::stdlib::Poseidon2Permutation< Builder >::propagate_current_state_to_next_row ( Builder builder,
const State state,
auto &  block 
)
inlinestatic

The result of applying a round of Poseidon2 is stored in the next row and is accessed by Poseidon2 Internal and External Relations via the shifts mechanism. Note that it does not activate any selectors since it only serves to store the values. See Poseidon2ExternalRelationImpl and Poseidon2InternalRelationImpl docs.

Parameters
builder
statean array of t field_t elements
blockEither poseidon2_external or poseidon2_internal block of the Execution Trace

Definition at line 78 of file poseidon2_permutation.hpp.

Member Data Documentation

◆ NUM_ROUNDS

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

Definition at line 43 of file poseidon2_permutation.hpp.

◆ round_constants

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

Definition at line 51 of file poseidon2_permutation.hpp.

◆ rounds_f

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

Definition at line 40 of file poseidon2_permutation.hpp.

◆ rounds_p

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

Definition at line 42 of file poseidon2_permutation.hpp.

◆ t

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

Definition at line 38 of file poseidon2_permutation.hpp.


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