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

#include <poseidon2_permutation.hpp>

Public Types

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 (Builder *builder, State &state)
 Separate function to do just the first linear layer (equivalent to external matrix mul).
 

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 RoundConstantsContainer round_constants = Params::round_constants
 

Detailed Description

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

Definition at line 18 of file poseidon2_permutation.hpp.

Member Typedef Documentation

◆ FF

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

Definition at line 37 of file poseidon2_permutation.hpp.

◆ NativePermutation

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

Definition at line 20 of file poseidon2_permutation.hpp.

◆ NativeState

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

Definition at line 39 of file poseidon2_permutation.hpp.

◆ RoundConstants

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

Definition at line 41 of file poseidon2_permutation.hpp.

◆ RoundConstantsContainer

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

Definition at line 42 of file poseidon2_permutation.hpp.

◆ State

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

Definition at line 38 of file poseidon2_permutation.hpp.

Member Function Documentation

◆ matrix_multiplication_external()

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

Separate function to do just the first linear layer (equivalent to external matrix mul).

We use 6 arithmetic gates to implement: gate 1: Compute tmp1 = state[0] + state[1] + 2 * state[3] gate 2: Compute tmp2 = 2 * state[1] + state[2] + state[3] gate 3: Compute v2 = 4 * state[0] + 4 * state[1] + tmp2 gate 4: Compute v1 = v2 + tmp1 gate 5: Compute v4 = tmp1 + 4 * state[2] + 4 * state[3] gate 6: Compute v3 = v4 + tmp2 output state is [v1, v2, v3, v4]

Parameters
builder
state

◆ permutation()

template<typename Params , typename Builder >
static State bb::stdlib::Poseidon2Permutation< Params, 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

Member Data Documentation

◆ d

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

Definition at line 28 of file poseidon2_permutation.hpp.

◆ NUM_ROUNDS

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

Definition at line 35 of file poseidon2_permutation.hpp.

◆ round_constants

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

Definition at line 43 of file poseidon2_permutation.hpp.

◆ rounds_f

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

Definition at line 32 of file poseidon2_permutation.hpp.

◆ rounds_p

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

Definition at line 34 of file poseidon2_permutation.hpp.

◆ sbox_size

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

Definition at line 30 of file poseidon2_permutation.hpp.

◆ t

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

Definition at line 25 of file poseidon2_permutation.hpp.


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