Code Monkey home page Code Monkey logo

giftlist's Introduction

Gift List - A Merkle Tree Implementation

This is a client-server connection with Zero Knowledge Architecture implementation to verify data.

Zero Knowledge Proof is a way for a prover to prove a thing to a verifier without showing the secret. Example: A verifier will verify if a prover has access to an email and the prover login into the email and shows it to the verifier but doesn't reveal the credentials, i.e. the prover gives zero information to the validator and shows that the information is correct.

Zero Knowledge Architecture is a pattern that allow to build applications where all data is stored and exchanged in an encrypted way. It enforces end-to-end encryption and client-side (prover) operations only.

What is the connection between a Merkle Tree and the Zero Knowledge Proof?

Merkle tree algorithm creates the ability to prove certain data is valid without sharing all the data. This makes it zero-knowledge proof.

When verifying data using a Merkle tree, there is a Prover and a Verifier:

  • A Prover: Do all the calculations to create the Merkle root (just a hash!)
  • A Verifier: Does not need to know all the values to know for certain one value is in the tree

Merkle trees are a huge benefit to the Verifier. You either produce a proof successfully, meaning data verification passes, or you don't, meaning your piece of data was not present when the Merkle root hash was calculated (or you performed the calculation wrong!).

Install and run the project

To get started with the repository, clone it and then run npm install in the top-level directory to install the depedencies.

There are three folders in this repository:

Server

You can run the server from the top-level directory with node server/index. This file is an express server which will be hosted on port 1225 and respond to the client's request.

Think of the server as the verifier here. It needs to verify that the name passed by the client is in the MERKLE_ROOT. If it is, then we can send the gift!

Client

You can run the client from the top-level directory with node client/index {name}. This file is a script which will send an HTTP request to the server.

Think of the client as the prover here. It needs to prove to the server that some name is in the MERKLE_ROOT on the server.

Utils

There are a few files in utils:

  • The niceList.json which contains all the names of the people who deserve a gift this year (this is randomly generated, feel free to add yourself and others to this list!)
  • The example.js script shows how we can generate a root, generate a proof and verify that some value is in the root using the proof. Try it out from the top-level folder with node/example.js
  • The MerkleTree.js should look familiar from the Merkle Tree module! This one has been modified so you should not have to deal with any crypto type conversion. You can import this in your client/server
  • The verifyProof.js should also look familiar. This was the last stage in the module. You can use this function to prove a name is in the merkle root, as show in the example.

giftlist's People

Contributors

dan-nolan avatar paulobordignon avatar

Forkers

luanpersini

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.