You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
arnaucube 073d9fe6c9 add print tree methods 5 years ago
src add print tree methods 5 years ago
.gitignore add node & utils, init repo 5 years ago
Cargo.toml v.hi() & ht(), add harcoded tests, update readme 5 years ago
LICENSE add node & utils, init repo 5 years ago
README.md v.hi() & ht(), add harcoded tests, update readme 5 years ago

README.md

merkletree-rs

Sparse MerkleTree implementation in Rust.

The MerkleTree is optimized in the design and concepts, to have a faster and lighter MerkleTree, maintaining compatibility with a non optimized MerkleTree. In this way, the MerkleRoot of the optimized MerkleTree will be the same that the MerkleRoot of the non optimized MerkleTree.

Usage

Create new tree:

let mut mt: MerkleTree = new(140);

Add value to leaf:

let val = TestValue {
  bytes: "this is a test leaf".as_bytes().to_vec(),
  index_length: 15,
};
mt.add(&val);

Get proof:

let mp = mt.generate_proof(val.hi());

Verify proof:

// check if the value exist
let v = verify_proof(mt.root, mp, val.hi(), val.ht(), mt.num_levels);

// check if the don't value exist
let v = verify_proof(mt.root, mp, val.hi(), EMPTYNODEVALUE, mt.num_levels);