Giter Club home page Giter Club logo

srtest's Introduction

Merkle tree basics

This GO project captures how a Merkle tree basically works. It contains:

  • a package merkle with corresponding tests to deal with tree functionalities
  • a main to be able to run and play around with the package merkle

Install

You need GO (~1.17) to be installed locally

Test

Ensure the integrity of the project with:

go test ./... -v

Run

You can use the main entry point to build a tree for a list of data, for example:

go run main.go ertyu lkjh sedfgyh drftyghu

Additional questions

Using the illustration above, let’s assume I know the whole Merkle tree. Someone gives me the L2 data block, but I don’t trust them. How can I check if L2 data is valid?

-> In that case, we know the whole tree, so simply we can return (using the level method) the array of hashes corresponding to the last level (i.e. level = height of tree). Then the given hash L2 is valid if contained in that array.

I know only the L3 data block and the Merkle root. What is the minimum information needed to check that the L3 data block and the Merkle root belong to the same Merkle tree?

-> This is what is basically used in Bitcoin. The minimum information needed to check that L3 is valid and belong to that tree would be called a merkle path. Here for L3, it would consist of knowing: Hash 1-1, Hash 0 (and of course we have already the root and L3)

What are some Merkle tree use cases?

-> On top of my head, I only remember one use case now. Light clients from the Bitcoin network being able to verify selected incoming transactions belonging to a block in the blockchain by only having block headers locally and asking for a merkle path other services (i.e. full nodes) to perform the verification.

Then I will have a look at Wikipedia after that for other real life use cases, which I am sure are plenty!

srtest's People

Contributors

simonjetstack 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.