pub struct ExternalLayerConstants<T, const WIDTH: usize> { /* private fields */ }Expand description
A struct which stores round-specific constants for both initial and terminal external layers.
Implementations§
Source§impl<T, const WIDTH: usize> ExternalLayerConstants<T, WIDTH>
impl<T, const WIDTH: usize> ExternalLayerConstants<T, WIDTH>
Sourcepub const fn new(initial: Vec<[T; WIDTH]>, terminal: Vec<[T; WIDTH]>) -> Self
pub const fn new(initial: Vec<[T; WIDTH]>, terminal: Vec<[T; WIDTH]>) -> Self
Create a new instance of external layer constants.
§Panics
Panics if initial.len() != terminal.len() since the Poseidon2 spec requires
the same number of initial and terminal rounds to maintain symmetry.
Sourcepub fn new_from_rng<R: Rng>(external_round_number: usize, rng: &mut R) -> Self
pub fn new_from_rng<R: Rng>(external_round_number: usize, rng: &mut R) -> Self
Randomly generate a new set of external constants using a provided RNG.
§Arguments
external_round_number: Total number of external rounds (must be even).rng: A random number generator that supports uniform sampling.
The constants are split equally between the initial and terminal rounds.
§Panics
Panics if external_round_number is not even.
Sourcepub fn new_from_saved_array<U, const N: usize>(
[initial, terminal]: [[[U; WIDTH]; N]; 2],
conversion_fn: fn([U; WIDTH]) -> [T; WIDTH],
) -> Selfwhere
T: Clone,
pub fn new_from_saved_array<U, const N: usize>(
[initial, terminal]: [[[U; WIDTH]; N]; 2],
conversion_fn: fn([U; WIDTH]) -> [T; WIDTH],
) -> Selfwhere
T: Clone,
Construct constants from statically stored arrays, using a conversion function.
This is useful when deserializing precomputed constants or embedding
them directly in the codebase (e.g., from [[[u32; WIDTH]; N]; 2] arrays).
§Arguments
initial,terminal: Two fixed-size arrays of sizeNcontaining round constants.conversion_fn: A function to convert from the source typeUtoT.
Sourcepub const fn get_initial_constants(&self) -> &Vec<[T; WIDTH]>
pub const fn get_initial_constants(&self) -> &Vec<[T; WIDTH]>
Get a reference to the list of initial round constants.
These are used in the first half of the external rounds.
Sourcepub const fn get_terminal_constants(&self) -> &Vec<[T; WIDTH]>
pub const fn get_terminal_constants(&self) -> &Vec<[T; WIDTH]>
Get a reference to the list of terminal round constants.
These are used in the second half (terminal rounds) of the external layer.
Trait Implementations§
Source§impl<T: Clone, const WIDTH: usize> Clone for ExternalLayerConstants<T, WIDTH>
impl<T: Clone, const WIDTH: usize> Clone for ExternalLayerConstants<T, WIDTH>
Source§fn clone(&self) -> ExternalLayerConstants<T, WIDTH>
fn clone(&self) -> ExternalLayerConstants<T, 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<T, const WIDTH: usize> Freeze for ExternalLayerConstants<T, WIDTH>
impl<T, const WIDTH: usize> RefUnwindSafe for ExternalLayerConstants<T, WIDTH>where
T: RefUnwindSafe,
impl<T, const WIDTH: usize> Send for ExternalLayerConstants<T, WIDTH>where
T: Send,
impl<T, const WIDTH: usize> Sync for ExternalLayerConstants<T, WIDTH>where
T: Sync,
impl<T, const WIDTH: usize> Unpin for ExternalLayerConstants<T, WIDTH>where
T: Unpin,
impl<T, const WIDTH: usize> UnwindSafe for ExternalLayerConstants<T, WIDTH>where
T: 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