pub trait Hasher {
type Digest: Digest;
const COLLISION_RESISTANCE: u32;
// Required methods
fn hash(bytes: &[u8]) -> Self::Digest;
fn merge(values: &[Self::Digest; 2]) -> Self::Digest;
fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest;
}
Expand description
Defines a cryptographic hash function.
This trait defines hash procedures for the following inputs:
- A sequence of bytes.
- Two digests - this is intended for use in Merkle tree constructions.
- A digests and a u64 value - this intended for use in PRNG or PoW contexts.
Required Associated Constants§
sourceconst COLLISION_RESISTANCE: u32
const COLLISION_RESISTANCE: u32
Collision resistance of the hash function measured in bits.
Required Associated Types§
Required Methods§
sourcefn merge(values: &[Self::Digest; 2]) -> Self::Digest
fn merge(values: &[Self::Digest; 2]) -> Self::Digest
Returns a hash of two digests. This method is intended for use in construction of Merkle trees.
sourcefn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest
fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest
Returns hash(seed
|| value
). This method is intended for use in PRNG and PoW contexts.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.