pub struct Poseidon1Constants<F, const WIDTH: usize> {
pub rounds_f: usize,
pub rounds_p: usize,
pub mds_circ_col: [i64; WIDTH],
pub round_constants: Vec<[F; WIDTH]>,
}Expand description
Raw Poseidon1 parameters before the sparse matrix optimization.
These are the “textbook” parameters as generated by the Grain LFSR or any other parameter-generation script. They are transformed into the optimized sparse form used at runtime.
§Round Constant Layout
Constants are stored in a flat array with three consecutive sections:
┌──────────────┬──────────────────┬──────────────────┐
│ initial full │ partial rounds │ terminal full │
│ (RF/2 items) │ (RP items) │ (RF/2 items) │
└──────────────┴──────────────────┴──────────────────┘Each entry is a WIDTH-sized vector (one constant per state element per round).
Fields§
§rounds_f: usizeTotal number of full rounds (split equally between initial and terminal).
rounds_p: usizeNumber of partial rounds.
mds_circ_col: [i64; WIDTH]First column of the circulant MDS matrix, stored as signed integers.
This matches the representation used by the MDS crate, so concrete fields can pass their verified constants directly without duplication. During initialization, the dense form is expanded once for the sparse decomposition, then discarded.
round_constants: Vec<[F; WIDTH]>Round constants, one WIDTH-sized vector per round.
Total length = rounds_f + rounds_p.
Implementations§
Source§impl<F: PrimeField, const WIDTH: usize> Poseidon1Constants<F, WIDTH>
impl<F: PrimeField, const WIDTH: usize> Poseidon1Constants<F, WIDTH>
Sourcepub fn to_optimized(
&self,
) -> (FullRoundConstants<F, WIDTH>, PartialRoundConstants<F, WIDTH>)
pub fn to_optimized( &self, ) -> (FullRoundConstants<F, WIDTH>, PartialRoundConstants<F, WIDTH>)
Compute the optimized sparse-form constants from these raw parameters.
This performs two transformations:
-
Sparse matrix decomposition: factors the dense MDS matrix into one dense transition matrix and several sparse matrices. Each sparse matrix is parameterized by two vectors of length WIDTH-1.
-
Round constant compression: via backward substitution through the inverse MDS matrix, reduces each partial round’s full constant vector to a single scalar, except for the first partial round.
Trait Implementations§
Source§impl<F: Clone, const WIDTH: usize> Clone for Poseidon1Constants<F, WIDTH>
impl<F: Clone, const WIDTH: usize> Clone for Poseidon1Constants<F, WIDTH>
Source§fn clone(&self) -> Poseidon1Constants<F, WIDTH>
fn clone(&self) -> Poseidon1Constants<F, WIDTH>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<F, const WIDTH: usize> Freeze for Poseidon1Constants<F, WIDTH>
impl<F, const WIDTH: usize> RefUnwindSafe for Poseidon1Constants<F, WIDTH>where
F: RefUnwindSafe,
impl<F, const WIDTH: usize> Send for Poseidon1Constants<F, WIDTH>where
F: Send,
impl<F, const WIDTH: usize> Sync for Poseidon1Constants<F, WIDTH>where
F: Sync,
impl<F, const WIDTH: usize> Unpin for Poseidon1Constants<F, WIDTH>where
F: Unpin,
impl<F, const WIDTH: usize> UnsafeUnpin for Poseidon1Constants<F, WIDTH>
impl<F, const WIDTH: usize> UnwindSafe for Poseidon1Constants<F, WIDTH>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more