pub struct BHP<E: Environment, const NUM_WINDOWS: u8, const WINDOW_SIZE: u8> { /* private fields */ }
Expand description

BHP is a collision-resistant hash function that takes a variable-length input. The BHP hash function does not behave like a random oracle, see Poseidon for one.

Design

The BHP hash function splits the given input into blocks, and processes them iteratively.

The first iteration is initialized as follows:

DIGEST_0 = BHP([ 0...0 || DOMAIN || LENGTH(INPUT) || INPUT[0..BLOCK_SIZE] ]);

Each subsequent iteration is initialized as follows:

DIGEST_N+1 = BHP([ DIGEST_N[0..DATA_BITS] || INPUT[(N+1)*BLOCK_SIZE..(N+2)*BLOCK_SIZE] ]);

Implementations

Initializes a new instance of BHP with the given domain.

Returns the domain separator for the BHP hash function.

Returns the bases.

Returns the random base window.

Returns the number of windows.

Returns the window size.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the BHP commitment of the given input and randomizer as a field element.

Returns the BHP commitment of the given input and randomizer as an affine group element.

Returns the BHP hash of the given input as a field element.

Returns the BHP hash of the given input as an affine group element.

This uncompressed variant of the BHP hash function is provided to support the BHP commitment scheme, as it is typically not used by applications.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.