A simple, fast, and composable binary [Merkle tree and proof] for [Rust Crypto] hash functions.
It's super simple to compose MerkleTree
from the ordered array
of hashes and verify the proof of inclusion with MerkleProof
:
``` use merklelite::MerkleTree; use randcore::RngCore;
// Composes MerkleTree from the 50,000 random hashes.
let tree: MerkleTree
// Verifies the proof of inclusion for the arbitrary 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.