pub struct Keccak {}
Expand description
Naive Keccak structure
Implementations§
source§impl Keccak
impl Keccak
Trait containing common operations for optimized Keccak
sourcepub fn compose(quarters: &[u64]) -> u64
pub fn compose(quarters: &[u64]) -> u64
Composes a vector of 4 dense quarters into the dense full u64 word
sourcepub fn decompose(word: u64) -> Vec<u64>
pub fn decompose(word: u64) -> Vec<u64>
Takes a dense u64 word and decomposes it into a vector of 4 dense quarters. The first element of the vector corresponds to the 16 least significant bits.
sourcepub fn expand(quarter: u64) -> u64
pub fn expand(quarter: u64) -> u64
Expands a quarter of a word into the sparse representation as a u64
sourcepub fn expand_word<F: PrimeField, T: ExprOps<F, BerkeleyChallengeTerm>>(
word: u64
) -> Vec<T>
pub fn expand_word<F: PrimeField, T: ExprOps<F, BerkeleyChallengeTerm>>( word: u64 ) -> Vec<T>
Expands a u64 word into a vector of 4 sparse u64 quarters
sourcepub fn sparse(word: u64) -> Vec<u64>
pub fn sparse(word: u64) -> Vec<u64>
Returns the expansion of the 4 dense decomposed quarters of a word where the first expanded element corresponds to the 16 least significant bits of the word.
sourcepub fn shift(state: &[u64]) -> Vec<u64>
pub fn shift(state: &[u64]) -> Vec<u64>
From each quarter in sparse representation, it computes its 4 resets. The resulting vector contains 4 times as many elements as the input. The output is placed in the vector as [shift0, shift1, shift2, shift3]
sourcepub fn reset(shifts: &[u64]) -> Vec<u64>
pub fn reset(shifts: &[u64]) -> Vec<u64>
From a vector of shifts, resets the underlying value returning only shift0 Note that shifts is always a vector whose length is a multiple of 4.
sourcepub fn collapse(state: &[u64]) -> Vec<u64>
pub fn collapse(state: &[u64]) -> Vec<u64>
From a canonical expanded state, obtain the corresponding 16-bit dense terms
sourcepub fn quarters(state: &[u8]) -> Vec<u64>
pub fn quarters(state: &[u8]) -> Vec<u64>
Outputs the state into dense quarters of 16-bits each in little endian order
sourcepub fn bytestring(dense: &[u64]) -> Vec<u64>
pub fn bytestring(dense: &[u64]) -> Vec<u64>
On input a vector of 16-bit dense quarters, outputs a vector of 8-bit bytes in the right order for Keccak
sourcepub fn expand_state(state: &[u8]) -> Vec<u64>
pub fn expand_state(state: &[u8]) -> Vec<u64>
On input a 200-byte vector, generates a vector of 100 expanded quarters representing the 1600-bit state
sourcepub fn padded_length(bytelength: usize) -> usize
pub fn padded_length(bytelength: usize) -> usize
On input a length, returns the smallest multiple of RATE_IN_BYTES that is greater than the bytelength. That means that if the input has a length that is a multiple of the RATE_IN_BYTES, then it needs to add one whole block of RATE_IN_BYTES bytes just for padding purposes.
sourcepub fn pad(message: &[u8]) -> Vec<u8>
pub fn pad(message: &[u8]) -> Vec<u8>
Pads the message with the 10*1 rule until reaching a length that is a multiple of the rate
sourcepub fn num_blocks(bytelength: usize) -> usize
pub fn num_blocks(bytelength: usize) -> usize
Number of blocks to be absorbed on input a given preimage bytelength