|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
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 initial state by the external matrix \( M_E \). | |
| static void | matrix_multiplication_external (State &state) |
| 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 |
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 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; Mega also uses Poseidon2InitialExternalRelationImpl for the initial external linear layer. Mega constrains the internal rounds via a K=4 compressed block (Poseidon2TransitionEntryRelationImpl, Poseidon2QuadInternalRelationImpl, and Poseidon2QuadInternalTerminalRelationImpl); Ultra uses Poseidon2InternalRelationImpl.
Definition at line 33 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::FF = typename Params::FF |
Definition at line 48 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::NativePermutation = crypto::Poseidon2Permutation<Params> |
Definition at line 36 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::NativeState = std::array<FF, t> |
Definition at line 50 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::Params = crypto::Poseidon2Bn254ScalarFieldParams |
Definition at line 35 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstants = std::array<FF, t> |
Definition at line 52 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstantsContainer = std::array<RoundConstants, NUM_ROUNDS> |
Definition at line 53 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::State = std::array<field_t<Builder>, t> |
Definition at line 49 of file poseidon2_permutation.hpp.
|
static |
In-circuit method to efficiently multiply the initial state by the external matrix \( M_E \).
Separate function to do just the first linear layer (equivalent to external matrix mul).
Update the state with \( M_E \cdot (\text{state}[0], \text{state}[1], \text{state}[2],
\text{state}[3])^{\top}\). Where \( M_E \) is the external round matrix. See Poseidon2ExternalRelationImpl.
Definition at line 226 of file poseidon2_permutation.cpp.
|
static |
|
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.
| builder | |
| input |
|
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.
| builder | |
| state | an array of t field_t elements |
| block | Either poseidon2_external or poseidon2_internal block of the Execution Trace |
Definition at line 84 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 46 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 54 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 43 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 45 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 41 of file poseidon2_permutation.hpp.