[][src]Trait iota_crypto_preview::Sponge

pub trait Sponge {
    type Error;

    const IN_LEN: usize;
    const OUT_LEN: usize;

    fn absorb(&mut self, input: &Trits) -> Result<(), Self::Error>;
fn reset(&mut self);
fn squeeze_into(&mut self, buf: &mut Trits) -> Result<(), Self::Error>; fn squeeze(&mut self) -> Result<TritBuf, Self::Error> { ... }
fn digest_into(
        &mut self,
        input: &Trits,
        buf: &mut Trits
    ) -> Result<(), Self::Error> { ... }
fn digest(&mut self, input: &Trits) -> Result<TritBuf, Self::Error> { ... } }

The common interface of cryptographic hash functions that follow the sponge construction, and that absorb and return binary-coded, balanced ternary.

Associated Types

type Error

An error indicating a that a failure has occured during absorb.

Loading content...

Associated Constants

const IN_LEN: usize

The expected length of the input to the sponge.

const OUT_LEN: usize

The length of the hash squeezed from the sponge.

Loading content...

Required methods

fn absorb(&mut self, input: &Trits) -> Result<(), Self::Error>

Absorb input into the sponge.

fn reset(&mut self)

Reset the inner state of the sponge.

fn squeeze_into(&mut self, buf: &mut Trits) -> Result<(), Self::Error>

Squeeze the sponge into a buffer

Loading content...

Provided methods

fn squeeze(&mut self) -> Result<TritBuf, Self::Error>

Convenience function using Sponge::squeeze_into to to return an owned version of the hash.

fn digest_into(
    &mut self,
    input: &Trits,
    buf: &mut Trits
) -> Result<(), Self::Error>

Convenience function to absorb input, squeeze the sponge into a buffer, and reset the sponge in one go.

fn digest(&mut self, input: &Trits) -> Result<TritBuf, Self::Error>

Convenience function to absorb input, squeeze the sponge, and reset the sponge in one go. Returns an owned versin of the hash.

Loading content...

Implementors

impl Sponge for CurlP[src]

type Error = Infallible

fn absorb(&mut self, input: &Trits) -> Result<(), Self::Error>[src]

Absorb input into the sponge by copying HASH_LEN chunks of it into its internal state and transforming the state before moving on to the next chunk.

If input is not a multiple of HASH_LEN with the last chunk having n < HASH_LEN trits, the last chunk will be copied to the first n slots of the internal state. The remaining data in the internal state is then just the result of the last transformation before the data was copied, and will be reused for the next transformation.

fn reset(&mut self)[src]

Reset the internal state by overwriting it with zeros.

fn squeeze_into(&mut self, buf: &mut Trits) -> Result<(), Self::Error>[src]

Squeeze the sponge by copying the calculated hash into the provided buf. This will fill the buffer in chunks of HASH_LEN at a time.

If the last chunk is smaller than HASH_LEN, then only the fraction that fits is written into it.

impl Sponge for CurlP27[src]

type Error = Infallible

impl Sponge for CurlP81[src]

type Error = Infallible

impl Sponge for Kerl[src]

type Error = Error

fn absorb(&mut self, input: &Trits) -> Result<(), Self::Error>[src]

Absorb input into the sponge by copying HASH_LEN chunks of it into its internal state and transforming the state before moving on to the next chunk.

If input is not a multiple of HASH_LEN with the last chunk having n < HASH_LEN trits, the last chunk will be copied to the first n slots of the internal state. The remaining data in the internal state is then just the result of the last transformation before the data was copied, and will be reused for the next transformation.

fn reset(&mut self)[src]

Reset the internal state by overwriting it with zeros.

fn squeeze_into(&mut self, buf: &mut Trits<T1B1>) -> Result<(), Self::Error>[src]

Squeeze the sponge by copying the calculated hash into the provided buf. This will fill the buffer in chunks of HASH_LEN at a time.

If the last chunk is smaller than HASH_LEN, then only the fraction that fits is written into it.

Loading content...