Trait jmt::SimpleHasher

source ·
pub trait SimpleHasher: Sized {
    // Required methods
    fn new() -> Self;
    fn update(&mut self, data: &[u8]);
    fn finalize(self) -> [u8; 32];

    // Provided method
    fn hash(data: impl AsRef<[u8]>) -> [u8; 32] { ... }
}
Expand description

A minimal trait representing a hash function. We implement our own rather than relying on Digest for broader compatibility.

Required Methods§

source

fn new() -> Self

Creates a new hasher with default state.

source

fn update(&mut self, data: &[u8])

Ingests the provided data, updating the hasher’s state.

source

fn finalize(self) -> [u8; 32]

Consumes the hasher state to produce a digest.

Provided Methods§

source

fn hash(data: impl AsRef<[u8]>) -> [u8; 32]

Returns the digest of the provided data.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl SimpleHasher for TransparentHasher

source§

impl<T: Digest> SimpleHasher for T
where [u8; 32]: From<GenericArray<u8, <T as OutputSizeUser>::OutputSize>>,