Crates.io | rcmerkle |
lib.rs | rcmerkle |
version | 0.1.1 |
source | src |
created_at | 2019-06-04 09:13:10.240111 |
updated_at | 2019-06-04 09:24:15.266633 |
description | Efficient Merkle tree calculation function and state machine. |
homepage | |
repository | https://github.com/rust-cc/rcmerkle |
max_upload_size | |
id | 138826 |
size | 22,392 |
Merkle Tree to calculate Root.
Suppert Two Way:
use rcmerkle::{BetterMerkleTreeSHA256, Hash, MerkleTreeSHA256, SHA256};
let list = [
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
];
let hashed_list: Vec<SHA256> = list.iter().map(|v| SHA256::hash(v.as_bytes())).collect();
let mut better_merkle = BetterMerkleTreeSHA256::new();
for i in 0..hashed_list.len() {
let root1 = MerkleTreeSHA256::root(hashed_list[0..i + 1].to_vec());
let root2 = better_merkle.root(hashed_list[i].clone());
assert_eq!(root1, root2);
}
This project is licensed under either of
at your option.