rcmerkle 0.1.1

Efficient Merkle tree calculation function and state machine.
Documentation
  • Coverage
  • 68.42%
    13 out of 19 items documented1 out of 15 items with examples
  • Size
  • Source code size: 25.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rust-cc/rcmerkle
    5 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • sunhuachuang

Latest Version Latest Version

rcmerkle

Merkle Tree to calculate Root.

Suppert Two Way:

  • One is traditional use MerkleTree, it need send all hashed list.
  • Two is efficient, but need to save state, like state machine. it need send new value, it will return the lastest root.

Example:

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);
}

License

This project is licensed under either of

at your option.