Crate p3_poseidon2

Crate p3_poseidon2 

Source
Expand description

The Poseidon2 permutation.

This implementation was based upon the following resources:

  • <https://github.com/HorizenLabs/poseidon2/blob/main/plain_implementations/src/poseidon2/poseidon2.rs>
  • <https://eprint.iacr.org/2023/323.pdf>

Structs§

ExternalLayerConstants
A struct which stores round-specific constants for both initial and terminal external layers.
HLMDSMat4
The 4x4 MDS matrix used by the Horizon Labs implementation of Poseidon2.
MDSMat4
The fastest 4x4 MDS matrix.
Poseidon2
The Poseidon2 permutation.

Traits§

ExternalLayer
A trait containing all data needed to implement the external layers of Poseidon2.
ExternalLayerConstructor
Initialize an external layer from a set of constants.
GenericPoseidon2LinearLayers
InternalLayer
A trait containing all data needed to implement the internal layers of Poseidon2.
InternalLayerConstructor
Initialize an internal layer from a set of constants.

Functions§

add_rc_and_sbox_generic
A generic method performing the transformation:
external_initial_permute_state
Applies the initial external rounds of the Poseidon2 permutation.
external_terminal_permute_state
Applies the terminal external rounds of the Poseidon2 permutation.
internal_permute_state
A helper method which allows any field to easily implement Internal Layer. This should only be used in places where performance is not critical.
matmul_internal
Given a vector v compute the matrix vector product (1 + diag(v))state with 1 denoting the constant matrix of ones.
mds_light_permutation
Implement the matrix multiplication used by the external layer.
poseidon2_round_numbers_128
Given a field, a width and an D return the number of full and partial rounds needed to achieve 128 bit security.