pub trait CryptographicHasher<Item: Clone, Out>: Clone {
const LANES: usize = 1;
const PREFER_CONTIGUOUS_INPUT: bool = false;
// Required method
fn hash_iter<I>(&self, input: I) -> Out
where I: IntoIterator<Item = Item>;
// Provided methods
fn hash_iter_slices<'a, I>(&self, input: I) -> Out
where I: IntoIterator<Item = &'a [Item]>,
Item: 'a { ... }
fn hash_slice(&self, input: &[Item]) -> Out { ... }
fn hash_item(&self, input: Item) -> Out { ... }
fn hash_many(&self, input: &[Item], out: &mut [Out]) { ... }
}Expand description
A generic trait for cryptographic hashers that consume an arbitrary sequence of input items and produce a fixed-size output.
This trait abstracts over hash functions in a flexible way, supporting both field elements,
scalars, or any other data type that implements Clone.
Provided Associated Constants§
Sourceconst LANES: usize = 1
const LANES: usize = 1
Number of equal-length messages this implementation hashes most efficiently in one call.
One means every message is hashed on its own, which is the behaviour of a plain scalar sponge. A vectorized implementation reports how many independent states its permutation advances at once.
Callers read this only to decide whether grouping messages is worth the bookkeeping.
Sourceconst PREFER_CONTIGUOUS_INPUT: bool = false
const PREFER_CONTIGUOUS_INPUT: bool = false
Whether materializing a compound input iterator can improve hashing throughput.
Callers concatenating disjoint inputs may use this hint to reuse a contiguous
staging buffer and pass its simple iterator to Self::hash_iter. It is not
a request to copy inputs that already have an efficient iterator, nor does it
affect the digest: the input sequence and message boundaries must stay identical.
Required Methods§
Sourcefn hash_iter<I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = Item>,
fn hash_iter<I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = Item>,
Provided Methods§
Sourcefn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
Sourcefn hash_slice(&self, input: &[Item]) -> Out
fn hash_slice(&self, input: &[Item]) -> Out
Sourcefn hash_many(&self, input: &[Item], out: &mut [Out])
fn hash_many(&self, input: &[Item], out: &mut [Out])
Hash a batch of equal-length messages, one digest per message.
All messages sit back to back in a single slice. The common message length is the input length divided by the digest count:
input: [ msg_0 | msg_1 | ... | msg_{m-1} ] m * len items
out: [ dig_0 | dig_1 | ... | dig_{m-1} ] m digestsThe default hashes the messages one at a time. An override exists purely to exploit vector hardware and must return the very same digests.
§Panics
Panics if the batch is ragged: the input length must be a whole multiple of the digest count.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".