Skip to content

damiramirez/merkle-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

merkle-tree

Implementation of Merkle Tree in Rust.

Usage

git clone [email protected]:damiramirez/merkle-tree.git && cd merkle-tree
make run

Functions

  • Create a new Merkle Tree with a vector of bytes
  • Add elements to the tree
  • Get the root hash of the Merkle Tree
  • Get the proof of existence of a leaf node and verify it

Example

use tree::{add_element, create_merkle_tree, create_proof, print_tree, verify_proof};

mod tree;

fn main() {
    let empty: &[String] = &[];
    let mut tree = create_merkle_tree(empty);
    tree = add_element(&mut tree, b"4");
    print_tree(&tree);

    if let Some(proof) = create_proof(&tree, b"4") {
        assert!(verify_proof(&tree, &proof, b"4"));
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published