pub struct Poseidon2<P: PoseidonParams<F>, F: PrimeField> { /* private fields */ }Expand description
Poseidon2 sponge that can absorb any number of F field elements and be
squeezed to a finite number of F field elements.
§Security Notice
This is a low-level primitive that does not implement padding or domain separation. Users must ensure proper input formatting and security practices for their specific cryptographic protocols.
Implementations§
Source§impl<P: PoseidonParams<F>, F: PrimeField> Poseidon2<P, F>
impl<P: PoseidonParams<F>, F: PrimeField> Poseidon2<P, F>
Sourcepub const fn state_size() -> usize
pub const fn state_size() -> usize
Size of poseidon sponge’s state.
Sourcepub fn absorb(&mut self, elem: &F)
pub fn absorb(&mut self, elem: &F)
Absorb a single element into the sponge.
Transitions from Mode::Absorbing to Mode::Squeezing mode are
unidirectional.
§Panics
May panic if absorbing while squeezing.
Sourcepub fn absorb_batch(&mut self, elems: &[F])
pub fn absorb_batch(&mut self, elems: &[F])
Absorb batch of elements into the sponge.
Sourcepub fn squeeze(&mut self) -> F
pub fn squeeze(&mut self) -> F
Squeeze a single element from the sponge.
When invoked from Mode::Absorbing mode, this function triggers a
permutation and transitions to Mode::Squeezing mode.
Sourcepub fn squeeze_batch(&mut self, n: usize) -> Vec<F>
pub fn squeeze_batch(&mut self, n: usize) -> Vec<F>
Squeeze a batch of elements from the sponge.
Trait Implementations§
Source§impl<P: Clone + PoseidonParams<F>, F: Clone + PrimeField> Clone for Poseidon2<P, F>
impl<P: Clone + PoseidonParams<F>, F: Clone + PrimeField> Clone for Poseidon2<P, F>
Source§impl<P: Debug + PoseidonParams<F>, F: Debug + PrimeField> Debug for Poseidon2<P, F>
impl<P: Debug + PoseidonParams<F>, F: Debug + PrimeField> Debug for Poseidon2<P, F>
Source§impl<P: PoseidonParams<F>, F: PrimeField> Default for Poseidon2<P, F>
impl<P: PoseidonParams<F>, F: PrimeField> Default for Poseidon2<P, F>
Auto Trait Implementations§
impl<P, F> Freeze for Poseidon2<P, F>
impl<P, F> RefUnwindSafe for Poseidon2<P, F>where
P: RefUnwindSafe,
F: RefUnwindSafe,
impl<P, F> Send for Poseidon2<P, F>where
P: Send,
impl<P, F> Sync for Poseidon2<P, F>where
P: Sync,
impl<P, F> Unpin for Poseidon2<P, F>where
P: Unpin,
impl<P, F> UnwindSafe for Poseidon2<P, F>where
P: UnwindSafe,
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
Mutably borrows from an owned value. Read more