[−][src]Trait mohan::merkle::Algorithm
A trait for hashing an arbitrary stream of bytes for calculating merkle tree nodes.
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.
Algorithm
breaks the Hasher
contract at finish()
, but that is intended.
This trait extends Hasher
with hash -> T
and reset
state methods,
plus implements default behavior of evaluation of MT interior nodes.
Required methods
fn hash(&mut self) -> T
Returns the hash value for the data stream written so far.
Provided methods
fn reset(&mut self)
Reset Hasher state.
fn leaf(&mut self, leaf: T) -> T
Returns hash value for MT leaf (prefix 0x00).
fn node(&mut self, left: T, right: T, _height: usize) -> T
Returns hash value for MT interior node (prefix 0x01).