Module mrkl::digest [] [src]

Support for cryptographic hash functions.

This module provides an implementation of the trait hash::Hasher that is backed by cryptographic hash functions conformant to the traits defined in crate digest, optionally augmented with generic, byte order aware hashing provided by crate digest-hash.

This implementation follows the Merkle tree hash definition given in IETF RFC 6962 and provides protection against potential second-preimage attacks: a 0 byte is prepended to the hash input of each leaf node, and a 1 byte is prepended to the concatenation of children's hash values when calculating the hash of an internal node. Note that while RFC 6962 only uses unbalanced full binary trees, the implementation of the Merkle tree provided by this crate permits single-child nodes to achieve uniform leaf depth. Such nodes are not treated equivalent to their child by DefaultNodeHasher, to avoid potentially surprising behavior when any trees that are single-node chains over a subtree with the same hash value are considered equivalent to that subtree.

This module is only available if the crate has been compiled with the digest feature, which is enabled by default.

Reexports

pub extern crate digest_hash;
pub extern crate generic_array;

Structs

ByteDigestHasher

Provides a cryptographic hash function implementation for hashing Merkle trees with byte slice convertible input.

DefaultNodeHasher

The NodeHasher implementation used by default in this module.

DigestHasher

Provides a cryptographic hash function implementation for hashing Merkle trees with byte order sensitive input.