Skip to main content

Module merkle

Module merkle 

Source
Available on crate feature unstable only.
Expand description

Blake2b256 Merkle tree.

This module implements a binary Merkle tree using Blake2b256 and the RFC-6962-style domain-separation scheme:

  • leaves are hashed as BLAKE2b-256(0x00 || leaf_bytes),
  • inner nodes are hashed as BLAKE2b-256(0x01 || left_bytes || right_bytes),
  • empty subtrees are represented as the all-zero 32-byte node.

Levels with an odd number of nodes are padded with one Node::Empty sibling on the right.

None of the types in this module implement Serialize or Deserialize: the Merkle tree and its proofs are in-memory constructs. Code that needs to transport a proof across a process boundary should define its own wire representation and convert at the boundary.

Structs§

MerkleNonInclusionProof
A non-inclusion proof for a tree built over sorted leaves.
MerkleProof
An inclusion proof for a leaf in a MerkleTree.
MerkleTree
A Blake2b256 Merkle tree.

Enums§

MerkleError
An error returned by Merkle tree construction or proof verification.
Node
A node in the Merkle tree.

Constants§

DIGEST_LEN
Byte length of a Merkle digest (32 bytes; Blake2b256).
EMPTY_NODE
The 32-byte representation of an empty subtree.
INNER_PREFIX
Domain-separation prefix applied to every inner node before hashing.
LEAF_PREFIX
Domain-separation prefix applied to every leaf before hashing.