[][src]Trait merkletree::hash::Algorithm

pub trait Algorithm<T>: Hasher + Default where
    T: Clone + AsRef<[u8]>, 
{ fn hash(&mut self) -> T; fn reset(&mut self) { ... }
fn leaf(&mut self, leaf: T) -> T { ... }
fn node(&mut self, left: T, right: T, _height: usize) -> T { ... }
fn multi_node(&mut self, nodes: &[T], _height: usize) -> T { ... } }

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.

Loading content...

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).

fn multi_node(&mut self, nodes: &[T], _height: usize) -> T

Returns hash value for MT interior node (prefix 0x01).

Loading content...

Implementors

impl Algorithm<[u8; 16]> for XOR128[src]

Loading content...