Giter Site home page Giter Site logo

merkle_fun's Introduction

MerkleFun

Merkle tree implementation using the excellent and fast rust-powered ex_keccak library under the hood. If you'd like to know more about the basic algorithm, check out this great introductory talk.

CircleCI

Installation

The package can be installed by adding merkle_fun to your list of dependencies in mix.exs:

def deps do
  [
    {:merkle_fun, "~> 0.6.0"}
  ]
end

Design

binary tree

There are multiple ways to implement a binary tree. We decided to use an array format approach to minimize storage requirements and make the sibling lookup easy. If it's been a while since you've done a basic data structures course, check out this refresher.

Wait a minute you say! Elixir doesn't have arrays? Well there is an Erlang implementation as well as a nice Elixir library. However, after thinking about the problem our use case didn't need updates. We build the tree and don't need to append further nodes. In such a case a tuple suits our read only needs perfectly. If we decide to add Merkle Mountain Ranges (in the future) we will need something with better append performance.

leaf lookup

Initial leaf lookup is currently looking through the entire tree. Yeah I need to fix that.

Warning

  • second pre-image attack
  • unbalanced trees attack

Todo's

  • Make tree
  • Make proof
  • Validate proof
  • Pretty Print tree
  • Fast leaf look up

Thanks

Thanks goes out to Rodger Maarfi (@acrite22) for pairing with me on this.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/merkle_fun.

merkle_fun's People

Contributors

acrite22 avatar gregors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

acrite22

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.