|
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 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 |
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.
| using bb::stdlib::Poseidon2Permutation< Builder >::FF = typename Params::FF |
Definition at line 45 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::NativePermutation = crypto::Poseidon2Permutation<Params> |
Definition at line 33 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::NativeState = std::array<FF, t> |
Definition at line 47 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::Params = crypto::Poseidon2Bn254ScalarFieldParams |
Definition at line 32 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstants = std::array<FF, t> |
Definition at line 49 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::RoundConstantsContainer = std::array<RoundConstants, NUM_ROUNDS> |
Definition at line 50 of file poseidon2_permutation.hpp.
| using bb::stdlib::Poseidon2Permutation< Builder >::State = std::array<field_t<Builder>, t> |
Definition at line 46 of file poseidon2_permutation.hpp.
|
static |
In-circuit method to efficiently multiply the inital state by the external matrix \( M_E \). Uses 6 aritmetic gates.
|
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 78 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 43 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 51 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 40 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 42 of file poseidon2_permutation.hpp.
|
staticconstexpr |
Definition at line 38 of file poseidon2_permutation.hpp.