Merkle Sum Sparse Merkle Tree
A Rust implementation of the Merkle Sum Sparse Merkle Tree (MSSMT) based on Lightning Labs' implementation.
Overview
The Merkle Sum Sparse Merkle Tree combines the properties of both Merkle Sum Trees and Sparse Merkle Trees, providing:
- Efficient sparse storage
- Sum aggregation at each level
- Cryptographic verification
- Flexible storage backend through the
Dbtrait
Features
- Generic over hash size and hasher type
- Thread-safe with optional multi-threading support
- Memory-efficient storage with compact leaf nodes
- Comprehensive test coverage
- CI/CD pipeline with code coverage reporting
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic example:
use ;
use Sha256;
// Create a new tree with 32-byte hashes using SHA256
let db = Boxnew;
let mut tree = MSSMT::new.unwrap;
// Insert a leaf
let leaf = new;
tree.insert.unwrap;
// Get the root hash
let root = tree.root.unwrap;
Development
Building
Testing
Code Coverage