Skip to main content

DuplexSpongeInterface

Trait DuplexSpongeInterface 

Source
pub trait DuplexSpongeInterface: Clone {
    type U: Unit;

    // Required methods
    fn absorb(&mut self, input: &[Self::U]) -> &mut Self;
    fn squeeze(&mut self, output: &mut [Self::U]) -> &mut Self;
    fn ratchet(&mut self) -> &mut Self;

    // Provided methods
    fn squeeze_array<const LEN: usize>(&mut self) -> [Self::U; LEN] { ... }
    fn squeeze_boxed(&mut self, len: usize) -> Box<[Self::U]> { ... }
}
Expand description

A DuplexSpongeInterface is an abstract interface for absorbing and squeezing elements implementing Unit.

HAZARD: Don’t implement this trait unless you know what you are doing. Consider using the sponges already provided by this library.

Required Associated Types§

Source

type U: Unit

The type of elements over which this duplex sponge operates.

In [CO25], this is called “alphabet”. The alphabet must be a non-empty set.

Required Methods§

Source

fn absorb(&mut self, input: &[Self::U]) -> &mut Self

Absorbs new elements in the sponge.

Calls to absorb are meant to be associative: calling this function multiple times is equivalent to calling it once on the concatenated inputs.

Source

fn squeeze(&mut self, output: &mut [Self::U]) -> &mut Self

Squeezes out new elements.

Calls to this function are meant to be associative: calling this function multiple times is equivalent to calling it once on a larger output array.

Source

fn ratchet(&mut self) -> &mut Self

Ratchet the sponge.

This function performs a one-way ratchet of its internal state, so that it cannot be inverted. By default, this function will re-initialize a sponge using 256 Units squeezed from the current instance.

Provided Methods§

Source

fn squeeze_array<const LEN: usize>(&mut self) -> [Self::U; LEN]

Squeeze a fixed-length array of size LEN.

Source

fn squeeze_boxed(&mut self, len: usize) -> Box<[Self::U]>

Squeeze len elements into a fresh-allocated array.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<D: BlockSizeUser + Digest + Clone + FixedOutputReset> DuplexSpongeInterface for Hash<D>

Source§

type U = u8

Source§

impl<H> DuplexSpongeInterface for XOF<H>

Source§

type U = u8

Source§

impl<P, const WIDTH: usize, const RATE: usize> DuplexSpongeInterface for DuplexSponge<P, WIDTH, RATE>
where P: Permutation<WIDTH>,

Source§

type U = <P as Permutation<WIDTH>>::U