poseidon_parameters/v2.rs
1pub use crate::alpha::Alpha;
2pub use crate::arc_matrix::ArcMatrix;
3pub use crate::matrix::SquareMatrix;
4pub use crate::round_numbers::RoundNumbers;
5
6pub use crate::{matrix_ops::MatrixOperations, matrix_ops::SquareMatrixOperations};
7
8/// A set of Poseidon2 parameters for a given set of input parameters.
9///
10/// The const `STATE_SIZE` corresponds to $t$ in the paper, the width of the hash function,
11/// e.g. $t=3$ corresponds to a 2-to-1 hash.
12///
13/// The const `NUM_MDS_ELEMENTS` corresponds to the number of elements in the MDS matrices, which
14/// should equal `STATE_SIZE * STATE_SIZE`.
15///
16/// The const `NUM_ROUND_ROWS`, `NUM_ROUND_COLS`, and `NUM_ROUND_ELEMENTS` correspond to the number
17/// of rows in the round constants matrix.
18#[derive(Clone, Debug)]
19pub struct PoseidonParameters<
20 const STATE_SIZE: usize,
21 const NUM_MDS_ELEMENTS: usize,
22 const NUM_ROUND_ROWS: usize,
23 const NUM_ROUND_COLS: usize,
24 const NUM_ROUND_ELEMENTS: usize,
25> {
26 // Input parameters.
27 /// Security level.
28 pub M: usize,
29
30 // Generated parameters.
31 /// Exponent of the Sbox, i.e. S-box(x) = x^{\alpha} used in the `SubWords` step
32 pub alpha: Alpha,
33
34 /// Round numbers
35 pub rounds: RoundNumbers,
36
37 /// External matrix
38 pub m_e: SquareMatrix<STATE_SIZE, NUM_MDS_ELEMENTS>,
39
40 /// Internal matrix
41 pub m_i: SquareMatrix<STATE_SIZE, NUM_MDS_ELEMENTS>,
42
43 /// Round constants
44 pub arc: ArcMatrix<NUM_ROUND_ROWS, NUM_ROUND_COLS, NUM_ROUND_ELEMENTS>,
45}