Skip to content

Simple implementation of a Merkle Tree built using Rust

Notifications You must be signed in to change notification settings

LeanSerra/rusty-merkle-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rusty-merkle-tree

Simple implementation of a Merkle Tree built using Rust

Running

Clone repository

git clone https://github.com/LeanSerra/rusty-merkle-tree && cd rusty-merkle-tree

Run

make

Run release mode

make run_release

Run tests

make test

Examples

// Create an empty tree make it mut to add more elements

let mut tree = MerkleTree::default();

// Add elements to the tree
tree.add_element(&"1");
tree.add_element(&"2");
tree.add_element(&"3");
tree.add_element(&"4");

// Generate a proof that an element exists and verify it

if let Some((proof, idx)) = tree.generate_proof(&"1") {
    assert!(tree.verify_proof(&"1", &proof, idx));
}

// Get the root of the tree

let root = tree.get_root();

About

Simple implementation of a Merkle Tree built using Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published