pub struct PoseidonSponge(/* private fields */);Expand description
Poseidon sponge in the absorb phase (before padding).
Call Self::finish_absorbing when all input has been absorbed to obtain a
PoseidonSpongeSqueeze. Further absorption is rejected by the type system:
the sponge state after padding is not a valid absorb continuation.
Implementations§
Source§impl PoseidonSponge
impl PoseidonSponge
Sourcepub fn new(params: PoseidonParams) -> Self
pub fn new(params: PoseidonParams) -> Self
Create a new Poseidon sponge with the given parameters
Sourcepub fn absorb(&mut self, elements: &[PoseidonField])
pub fn absorb(&mut self, elements: &[PoseidonField])
Sourcepub fn finish_absorbing(self) -> PoseidonSpongeSqueeze
pub fn finish_absorbing(self) -> PoseidonSpongeSqueeze
Finish absorbing and apply padding (10*1 in rate only)
Should be called after all input has been absorbed. Returns a value that
only supports PoseidonSpongeSqueeze::squeeze, so additional PoseidonSponge::absorb
calls are impossible after padding (they would define a non-standard sponge).
Standard sponge padding: add 1 at state[absorbed]; if that does not fill
the rate block (absorbed + 1 < rate), add 1 at state[rate - 1] to
distinguish single-block from multi-block inputs. Capacity is not written.
§Compile-time safety
After this call, PoseidonSponge is consumed; PoseidonSpongeSqueeze has no
absorb, so further input cannot be appended after padding:
use lib_q_poseidon::{Poseidon128, PoseidonSponge};
let params = Poseidon128::params();
let sponge = PoseidonSponge::new(params);
let mut sponge = sponge.finish_absorbing();
sponge.absorb(&[]);Sourcepub fn finalize(self) -> Vec<PoseidonField> ⓘ
pub fn finalize(self) -> Vec<PoseidonField> ⓘ
Finalize the sponge (apply padding and final permutation)
Convenience for callers that need the full width state after padding without
squeezing. Otherwise use Self::finish_absorbing followed by
PoseidonSpongeSqueeze::squeeze.
Trait Implementations§
Source§impl Clone for PoseidonSponge
impl Clone for PoseidonSponge
Source§fn clone(&self) -> PoseidonSponge
fn clone(&self) -> PoseidonSponge
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PoseidonSponge
impl RefUnwindSafe for PoseidonSponge
impl Send for PoseidonSponge
impl Sync for PoseidonSponge
impl Unpin for PoseidonSponge
impl UnsafeUnpin for PoseidonSponge
impl UnwindSafe for PoseidonSponge
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