Coder Social home page Coder Social logo

rust-merkle's Introduction

rust-merkle

A Rust implementation of Streaming Merkle Roots within Binary Numeral Trees.

Getting Started

You will need to have Rust and Cargo installed.

# Build the project
$ cargo build --release

# Run all tests
$ cargo test

# Run the examples
$ cargo run --example merkle_tree
$ cargo run --example merkle_proof

Usage

Merkle tree example

$ cargo run --example merkle_tree

# Sample response
Root hash: [62, 46, 173, 253, 186, 61, 168, 141, 75, 120, 173, 174, 83, 231, 152, 174, 239, 123, 191, 145, 195, 31, 237, 163, 145, 241, 68, 178, 111, 252, 114, 152]
Subroot hash: [3, 144, 88, 198, 242, 192, 203, 73, 44, 83, 59, 10, 77, 20, 239, 119, 204, 15, 120, 171, 204, 206, 213, 40, 125, 132, 161, 162, 1, 28, 251, 129]
Subroot hash at index 2: [62, 46, 173, 253, 186, 61, 168, 141, 75, 120, 173, 174, 83, 231, 152, 174, 239, 123, 191, 145, 195, 31, 237, 163, 145, 241, 68, 178, 111, 252, 114, 152]
Limited root hash: [246, 136, 245, 181, 133, 162, 224, 228, 184, 183, 155, 67, 76, 181, 95, 4, 69, 2, 210, 85, 124, 192, 255, 116, 4, 0, 25, 224, 119, 207, 215, 93]
Time elapsed: 100ns

Merkle proof example

$ cargo run --example merkle_proof

# Sample response
Leaf exists in Merkle tree: true
Computed root: [148, 116, 171, 150, 234, 181, 6, 118, 128, 13, 166, 250, 147, 231, 112, 159, 151, 214, 9, 224, 6, 54, 211, 103, 161, 31, 161, 121, 251, 31, 152, 244]
Known root: [148, 116, 171, 150, 234, 181, 6, 118, 128, 13, 166, 250, 147, 231, 112, 159, 151, 214, 9, 224, 6, 54, 211, 103, 161, 31, 161, 121, 251, 31, 152, 244]
Roots match: true
Time elapsed: 100ns

To-do

Add the remaining proofs from the whitepaper:

  • Single-leaf Proofs
  • Single-range Proofs
  • Multi-range Proofs

References

  • Streaming Merkle Proofs within Binary Numeral Trees, by Luke Champine

License

rust-merkle is distributed under the MIT license.

rust-merkle's People

Contributors

waddaboo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.