Expand description
Compact Sparse Merkle Tree library.
Fixed-depth binary tree where empty subtrees are replaced by precomputed zero hashes, so you only store what you actually insert.
use merkle_helix_rs::{MerkleTree, Sha256Hasher};
let mut tree = MerkleTree::<Sha256Hasher>::new(32).unwrap();
let leaves: Vec<Vec<u8>> = (0u32..8).map(|i| i.to_le_bytes().to_vec()).collect();
tree.insert_batch(&leaves).unwrap();
let proof = tree.get_proof(3).unwrap();
assert!(proof.verify::<Sha256Hasher>(tree.root()));Re-exports§
pub use error::Error;pub use error::Result;pub use hasher::Hasher;pub use proof::HashPath;pub use proof::InclusionProof;pub use proof::MultiNonMembershipProof;pub use proof::MultiProof;pub use proof::NonMembershipProof;pub use storage::LeafStore;pub use storage::StoreError;pub use storage::VecStore;pub use tree::MerkleTree;pub use hasher::Sha256Hasher;
Modules§
- error
- Error types for
merkle-helix-rs. - hasher
- Pluggable hasher trait and built-in implementations.
- proof
- Merkle proof types: inclusion proofs, hash paths, and multi-proofs.
- storage
- Pluggable leaf storage. The default is
VecStore(two Vecs in memory). Swap it out by implementingLeafStore— e.g. for RocksDB or SQLite. - tree
- Core
MerkleTreeimplementation.