merkletree-rs
Sparse MerkleTree implementation in Rust.
The MerkleTree is optimized in the design and concepts, to have a faster and lighter MerkleTree, maintaining compatibility with a non optimized MerkleTree. In this way, the MerkleRoot of the optimized MerkleTree will be the same that the MerkleRoot of the non optimized MerkleTree.
Compatible with the Go version: https://github.com/arnaucube/go-merkletree
Usage
Import lib:
extern crate merkletree_rs;
use ;
Create new tree:
// to build the storage, the first parameter is the path and the second parameter specifies if wants to use a in_memory database or a directory of the filesystem
let mut sto = new;
let mut mt = new;
Add value to leaf:
let val: TestValue = TestValue ;
mt.add.unwrap;
Get proof:
let mp = mt.generate_proof;
println!;
Verify proof:
// check if the value exist
let v =
verify_proof;
println!;
// check if the don't value exist (in that case, the 'ht' will be an empty value)
let v = verify_proof;
println!;
Print current MerkleRoot:
println!;