Trait merkle_light::hash::Algorithm
[−]
[src]
pub trait Algorithm<T>: Hasher where
T: Ord + Clone + Default + Debug, { fn write_t(&mut self, i: T); fn hash(&self) -> T; fn reset(&mut self); fn empty(&mut self) -> T { ... } fn leaf(&mut self, leaf: T) -> T { ... } fn node(&mut self, left: T, right: T) -> T { ... } }
Hashing algorithm type.
Algorithm conforms standard [Hasher
] trait and provides methods to return
hash and resetting current state.
T is a hash item must be of known size at compile time, globally ordered, with default value as a neutral element of the hash space. Neutral element is interpreted as 0 or nil and required for evaluation of merkle tree.
TODO: #[inline]
Required Methods
fn write_t(&mut self, i: T)
Writes a single T
into this hasher.
fn hash(&self) -> T
Returns the hash value for the data stream written so far.
fn reset(&mut self)
Reset Hasher state.
Provided Methods
fn empty(&mut self) -> T
Returns digest of the empty thing.
fn leaf(&mut self, leaf: T) -> T
Returns the hash value for MT leaf (prefix 0x00).
fn node(&mut self, left: T, right: T) -> T
Returns the hash value for MT interior node (prefix 0x01).