SpongeAPI

Trait SpongeAPI 

Source
pub trait SpongeAPI {
    type Acc;
    type Value;

    // Required methods
    fn start(
        &mut self,
        p: IOPattern,
        domain_separator: Option<u32>,
        acc: &mut Self::Acc,
    );
    fn absorb(
        &mut self,
        length: u32,
        elements: &[Self::Value],
        acc: &mut Self::Acc,
    );
    fn squeeze(
        &mut self,
        length: u32,
        elements: &mut [Self::Value],
        acc: &mut Self::Acc,
    );
    fn finish(&mut self) -> Result<(), Error>;
}
Expand description

This is the SpongeAPI trait as you can find it in Neptune, see <https://github.com/filecoin-project/neptune/blob/master/src/sponge/api.rs> Slightly modified so that the squeeze function takes an argument as a mutable slice instead of returning a Vec.

Required Associated Types§

Source

type Acc

The type of the sponge state

Source

type Value

The type of the elements froming the I/O of the sponge

Required Methods§

Source

fn start( &mut self, p: IOPattern, domain_separator: Option<u32>, acc: &mut Self::Acc, )

This initializes the internal state of the sponge, modifying up to c/2 field elements of the state. It’s done once in the lifetime of a sponge.

Source

fn absorb(&mut self, length: u32, elements: &[Self::Value], acc: &mut Self::Acc)

This injects length field elements to the state from the array elements, interleaving calls to the permutation It also checks if the current call matches the IO pattern.

Source

fn squeeze( &mut self, length: u32, elements: &mut [Self::Value], acc: &mut Self::Acc, )

This extracts length field elements from the state to the array elements, interleaving calls to the permutation It also checks if the current call matches the IO pattern.

Source

fn finish(&mut self) -> Result<(), Error>

This marks the end of the sponge life, preventing any further operation. In particular, the state is erased from memory. The result is OK, or an error

Implementors§