/mt-rs

Primary LanguageRustOtherNOASSERTION

Merkle Tree

Unstable

A prototype implementation. Use at your own risk.

Example

extern crate mt;

use mt::data_storage::MemoryDataStorage;
use mt::tree_storage::MemoryTreeStorage;
use mt::merkle_tree::MerkleTree;
use mt::fun::Sha256;
use mt::fun::DoubleHash;

// ....

let mut mt: MerkleTree<MemoryDataStorage<&[u8]>, MemoryTreeStorage<DoubleHash<Sha256>>>;
mt = MerkleTree::default();

// ....

mt.push(&b"123")?;
mt.push(&b"456")?;
mt.push(&b"7890")?;

// ....

mt.check_data()?;
mt.check_tree()?;

// ....

mt.get_root()? == other_root

License

Licensed under either of

Contribution

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.