Giter VIP home page Giter VIP logo

lightning_circuit's Introduction

This is a SNARK implementation using libsnark for the following:

ZkPoK{ (R1, R2, R3): Hi = sha256(Ri) and R3 = R1 + R2 }

Read: given H1, H2, H3, prove you know R1, R2, R3 such that R1 is the preimage of H1, R2 is the preimage of H2, R3 is the preimage of H3, and R3 is R1 + R2.

This is an implementation and benchmark of the "Receive" zk-SNARK in the Confidential Transaction scheme from this article: https://media.consensys.net/introduction-to-zksnarks-with-examples-3283b554fc3b.

Code based on https://github.com/ebfull/lightning_circuit.

performance

on my computer (MacBook Pro Early 2015):

  • key generation time: 22.1s
  • proof generation time: 5.14s
  • verification time: 0.1445ss
  • proof size: 2294 bits
  • proving key size: 153200114 bits
  • verifying key size: 4586 bits
  • R1CS constraints: 83766 (mostly sha256-related)

howto

./get-libsnark && make && ./test

anatomy

  • src/gadget.hpp exposes the gadget, which is an abstraction of related constraint and witness behavior in a circuit. This gadget uses other gadgets, creates its own constraints, and exposes an interface for building input maps.

  • src/snark.hpp exposes a loose wrapper around the constraint system and key generation used by test.cpp to construct proofs and verify them as necessary.

lightning_circuit's People

Contributors

ebfull avatar coder5876 avatar amiller avatar petermunnings avatar

Watchers

James Cloos avatar Coenie Beyers 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.