Skip to main content

PseudoCompressionFunction

Trait PseudoCompressionFunction 

Source
pub trait PseudoCompressionFunction<T, const N: usize>: Clone {
    const LANES: usize = 1;

    // Required method
    fn compress(&self, input: [T; N]) -> T;

    // Provided method
    fn compress_many(&self, inputs: &[[T; N]], out: &mut [T])
       where T: Clone { ... }
}
Expand description

An N-to-1 compression function collision-resistant in a hash tree setting.

Unlike CompressionFunction, it may not be collision-resistant in general. Instead it is only collision-resistant in hash-tree like settings where the preimage of a non-leaf node must consist of compression outputs.

Provided Associated Constants§

Source

const LANES: usize = 1

Number of independent compressions this implementation performs most efficiently in one call.

One means every group is compressed on its own, which is the behaviour of a plain scalar permutation. A vectorized implementation reports how many independent states its permutation advances at once.

Callers read this only to decide whether grouping compressions is worth the bookkeeping.

Required Methods§

Source

fn compress(&self, input: [T; N]) -> T

Provided Methods§

Source

fn compress_many(&self, inputs: &[[T; N]], out: &mut [T])
where T: Clone,

Compress a batch of input groups, one output per group.

    inputs: [ grp_0 | grp_1 | ... | grp_{m-1} ]   m groups of N inputs
    out:    [ dig_0 | dig_1 | ... | dig_{m-1} ]   m outputs

The default compresses the groups one at a time. An override exists purely to exploit vector hardware and must return the very same outputs.

§Panics

Panics if the batch is ragged: the group count must equal the output count.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, H, const N: usize, const CHUNK: usize> PseudoCompressionFunction<[T; CHUNK], N> for CompressionFunctionFromHasher<H, N, CHUNK>

Source§

impl<T, InnerP, const N: usize, const CHUNK: usize, const WIDTH: usize> PseudoCompressionFunction<[T; CHUNK], N> for TruncatedPermutation<InnerP, N, CHUNK, WIDTH>