Skip to content
LogoLogo
Authenticated data structures for Rust

Binary, Sparse, and Ethereum-compatible Patricia Merkle trees behind one API, with pluggable hash functions and stateless proof verification.

cargo add merkle-core merkleforge-hash merkle-variants
versionv0.5.0
unsafeforbidden
licenseMIT/Apache
One API, three trees
Binary, Sparse, and Patricia trees all implement the same MerkleTree<H> trait. Choose a tree
Pluggable hashes
Swap SHA-256, Keccak-256, and BLAKE3 with one type parameter. Generics compile away.
Stateless proofs
Verify a leaf with only the trusted root, the proof, and the leaf bytes. No tree required.
Ethereum-compatible
MerklePatriciaTrie<Keccak256> matches Ethereum state roots and passes the official trie test vectors.
Example
Build a root, prove a leaf, verify anywhere

Insert raw bytes, get a 32-byte root, and hand a light client an O(log n) proof. The verifier never sees the rest of the data.

src/main.rs
use merkle_core::prelude::*;
use merkle_variants::BinaryMerkleTree;
use merkleforge_hash::Sha256;
 
fn main() -> Result<(), MerkleError> {
    let tree = BinaryMerkleTree::<Sha256>::from_leaves([
        "alice:100", "bob:250", "carol:75",
    ])?;
 
    let root = tree.root().expect("tree is non-empty");
    let proof = tree.generate_proof(LeafIndex(1))?;
 
    // Stateless: only the root, the leaf bytes, and the proof.
    assert!(BinaryMerkleTree::<Sha256>::verify(root, b"bob:250", &proof));
    Ok(())
}
Built for verifiable systems
Pick the structure that fits your data
BinaryMerkleTree
Ordered lists, transaction batches, file chunks, and logs. Compact inclusion proofs by leaf index. Guide
SparseMerkleTree
A 2256 key space for account state and rollups, with membership and non-membership proofs. Guide
MerklePatriciaTrie
Ethereum-style nibble paths, RLP-encoded nodes, and EIP-1186-style witnesses. Guide
Used by
ProofStream
Turns live indexed DEX activity into portable proof receipts. Rows are committed with a MerkleForge BinaryMerkleTree<Keccak256> and verified in the browser from a single row, its proof, and the dataset root.
Your project?
Building with MerkleForge? Open a pull request to add it to the projects page.