Struct rs_internal_state::KeccakSponge
source · 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>>,
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>>,
sourcepub fn absorb(&mut self, input: &[u8])
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,
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>
fn clone(&self) -> KeccakSponge<T, RATE, OUTPUT_SIZE>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Debug for KeccakSponge<T, RATE, OUTPUT_SIZE>where
T: Default + Copy + Debug,
impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Debug for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Debug,
source§impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Default for KeccakSponge<T, RATE, OUTPUT_SIZE>where
T: Default + Copy + Default,
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>
fn default() -> KeccakSponge<T, RATE, OUTPUT_SIZE>
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>>,
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>>,
fn squeeze_u64(&self) -> u64
source§fn squeeze(&mut self) -> [u8; OUTPUT_SIZE]
fn squeeze(&mut self) -> [u8; OUTPUT_SIZE]
source§impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Hash for KeccakSponge<T, RATE, OUTPUT_SIZE>where
T: Default + Copy + Hash,
impl<T, const RATE: usize, const OUTPUT_SIZE: usize> Hash for KeccakSponge<T, RATE, OUTPUT_SIZE>where T: Default + Copy + Hash,
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,
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
fn eq(&self, other: &KeccakSponge<T, RATE, OUTPUT_SIZE>) -> bool
self
and other
values to be equal, and is used
by ==
.