A simple, fast, and composable binary [Merkle tree and proof] for [Rust Crypto] hash functions.
Here is how to create MerkleTree
and MerkleProof
for the ordered array of cryptographic hashes:
```
use randcore::RngCore;
use sha3::Sha3256;
use merkle_lite::MerkleTree;
// Composes MerkleTree with the 50,000 random leaves.
let tree: MerkleTree
// Verifies the proof of inclusion for the particular leaves. let leafindices = [12, 0, 1, 1201, 13903, 980]; let leafhashes: Vec<_> = leafindices .iter().map(|index| (index, tree.leaves().nth(index).expect("leaf"))) .collect(); asserteq!( tree.proof(&leafindices) .expect("proof") .verify(&leafhashes) .expect("verify") .asref(), tree.root().expect("root"), ); ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.