pub struct KeccakSponge<T, const RATE: usize, const OUTPUT_SIZE: usize>where
    T: Default + Copy,{ /* private fields */ }
Expand description

The KeccakSponge struct implements a generic sponge construction based on the Keccak permutation.

Sponge construction

The sponge construction is a cryptographic primitive that can be used to build hash functions, stream cipher_functions, and more. It is based on an internal state and two operations: absorbing and squeezing. The internal state is divided into two parts: a public part called the rate and a secret part called the capacity. The Keccak sponge construction uses the Keccak-f permutation as its underlying function.

The Keccak-f permutation is a family of permutations parameterized by the width of the state. The most commonly used instance is Keccak-f[1600], with a state width of 1600 bits.

Implementations§

source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> KeccakSponge<T, RATE, OUTPUT_SIZE>where T: BitAnd + BitAndAssign + BitOr<NBitWord<T>, Output = NBitWord<T>> + BitXor<Output = T> + BitXorAssign + Copy + Default + Not<Output = T>, NBitWord<T>: From<u64> + LittleEndianBytes + Rotate + TSize<T>, u32: Sub<NBitWord<T>, Output = NBitWord<T>>,

source

pub fn absorb(&mut self, input: &[u8])

Absorbs the input data into the sponge The absorb method takes an input byte slice and processes it through the sponge construction. It first pads the input using the padding rule, then divides the padded input into blocks of size N. Each block is XORed with the rate portion of the state, followed by the application of the Keccak-f permutation

Trait Implementations§

source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Clone for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Clone,

source§

fn clone(&self) -> KeccakSponge<T, RATE, OUTPUT_SIZE>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Debug for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Default for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Default,

source§

fn default() -> KeccakSponge<T, RATE, OUTPUT_SIZE>

Returns the “default value” for a type. Read more
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> ExtendedOutputFunction<OUTPUT_SIZE> for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: BitAnd + BitAndAssign + BitOr<NBitWord<T>, Output = NBitWord<T>> + BitXor<Output = T> + BitXorAssign + Copy + Default + Not<Output = T>, NBitWord<T>: From<u64> + LittleEndianBytes + Rotate + TSize<T>, u32: Sub<NBitWord<T>, Output = NBitWord<T>>,

source§

fn squeeze_u64(&self) -> u64

source§

fn squeeze(&mut self) -> [u8; OUTPUT_SIZE]

Squeezes the output data from the sponge
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Hash for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> PartialEq<KeccakSponge<T, RATE, OUTPUT_SIZE>> for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + PartialEq,

source§

fn eq(&self, other: &KeccakSponge<T, RATE, OUTPUT_SIZE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Eq for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Eq,

source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> StructuralEq for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy,

source§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> StructuralPartialEq for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy,

Auto Trait Implementations§

§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> RefUnwindSafe for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: RefUnwindSafe,

§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Send for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Send,

§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Sync for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Sync,

§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Unpin for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Unpin,

§

impl<T, const RATE: usize, const OUTPUT_SIZE: usize> UnwindSafe for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.