Giter Club home page Giter Club logo

zk-identity's Introduction

zk-identity

A zero knowledge identity scheme for DeFi to unlock more use cases such as undercollaterized lending.

Getting Started

Prerequisite:

  • circom
  • snarkjs

Refer to Circom documentation to install prerequisite dependencies.

The circuit templates are located in the circuits directory. To compile a circuit, run circom <path_to_circom_file> --r1cs --wasm --sym. This will generate a directory ending with _js. In our project, the circom file is named as circuit.circom.

Generating a Witness

In the circuit_js directory, generate a witness through running the command: node generate_witness.js circuit.wasm input.json witness.wtns

The input.json file should contain the inputs for the circuits. Example scripts that could help generate this file is in the scripts directory.

Trusted Setup (Powers of Tau)

  1. snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
  2. snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="First contribution" -v
  3. snarkjs powersoftau prepare phase2 pot14_0001.ptau pot14_final.ptau -v
  4. snarkjs groth16 setup circuit.r1cs pot14_final.ptau circuit_0000.zkey
  5. snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="1st Contributor Name" -v
  6. snarkjs zkey export verificationkey circuit_0001.zkey verification_key.json

Generating a Proof

Using snarkjs, generate a proof through running the command: snarkjs groth16 prove circuit_0001.zkey witness.wtns proof.json public.json

The command generates two files. Proof.json contains the proof while public.json contains the public inputs and outputs.

Verifying a Proof

Using snarkjs, verify a proof through running the command: snarkjs groth16 verify verification_key.json public.json proof.json

zk-identity's People

Contributors

eerkaijun avatar

Stargazers

 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.