pub struct MdsMatrix<const STATE_SIZE: usize, const STATE_SIZE_MINUS_1: usize, const NUM_ELEMENTS: usize, const NUM_ELEMENTS_STATE_SIZE_MINUS_1_2: usize>(pub SquareMatrix<STATE_SIZE, NUM_ELEMENTS>);
Expand description
Represents an MDS (maximum distance separable) matrix.
Tuple Fields§
§0: SquareMatrix<STATE_SIZE, NUM_ELEMENTS>
Implementations§
Source§impl<const STATE_SIZE: usize, const STATE_SIZE_MINUS_1: usize, const NUM_ELEMENTS: usize, const NUM_ELEMENTS_STATE_SIZE_MINUS_1_2: usize> MdsMatrix<STATE_SIZE, STATE_SIZE_MINUS_1, NUM_ELEMENTS, NUM_ELEMENTS_STATE_SIZE_MINUS_1_2>
impl<const STATE_SIZE: usize, const STATE_SIZE_MINUS_1: usize, const NUM_ELEMENTS: usize, const NUM_ELEMENTS_STATE_SIZE_MINUS_1_2: usize> MdsMatrix<STATE_SIZE, STATE_SIZE_MINUS_1, NUM_ELEMENTS, NUM_ELEMENTS_STATE_SIZE_MINUS_1_2>
Sourcepub fn from_elements(elements: &[Fq]) -> Self
pub fn from_elements(elements: &[Fq]) -> Self
Instantiate an MDS matrix from a list of elements.
§Security
You must ensure this matrix was generated securely,
using the Cauchy method in fixed_cauchy_matrix
or
using the random subsampling method described in the original
paper.
pub fn transpose(&self) -> Self
Sourcepub fn inverse(&self) -> SquareMatrix<STATE_SIZE, NUM_ELEMENTS>
pub fn inverse(&self) -> SquareMatrix<STATE_SIZE, NUM_ELEMENTS>
Compute inverse of MDS matrix
Sourcepub fn v(&self) -> Matrix<1, STATE_SIZE_MINUS_1, STATE_SIZE_MINUS_1>
pub fn v(&self) -> Matrix<1, STATE_SIZE_MINUS_1, STATE_SIZE_MINUS_1>
Return the elements M_{0,1} .. M_{0,t} from the first row
Ref: p.20 of the Poseidon paper
Sourcepub fn w(&self) -> Matrix<STATE_SIZE_MINUS_1, 1, STATE_SIZE_MINUS_1>
pub fn w(&self) -> Matrix<STATE_SIZE_MINUS_1, 1, STATE_SIZE_MINUS_1>
Return the elements M_{1,0} .. M_{t,0} from the first column
Ref: p.20 of the Poseidon paper
Sourcepub fn hat(
&self,
) -> SquareMatrix<STATE_SIZE_MINUS_1, NUM_ELEMENTS_STATE_SIZE_MINUS_1_2>
pub fn hat( &self, ) -> SquareMatrix<STATE_SIZE_MINUS_1, NUM_ELEMENTS_STATE_SIZE_MINUS_1_2>
Compute the (t - 1) x (t - 1) Mhat matrix from the MDS matrix
This is simply the MDS matrix with the first row and column removed
Ref: p.20 of the Poseidon paper
Sourcepub const fn new_from_known(elements: [Fq; NUM_ELEMENTS]) -> Self
pub const fn new_from_known(elements: [Fq; NUM_ELEMENTS]) -> Self
Create a new matrix from a slice of elements.
§Security
You must ensure this matrix was generated securely,
using the Cauchy method in fixed_cauchy_matrix
or
using the random subsampling method described in the original
paper.