Coder Social home page Coder Social logo

m0bi5 / bulletproofs-r1cs-gadgets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lovesh/bulletproofs-r1cs-gadgets

0.0 0.0 0.0 137 KB

Arithmatic circuits convertible to R1CS based on Bulletproofs

License: Apache License 2.0

Rust 72.87% Jupyter Notebook 27.13%

bulletproofs-r1cs-gadgets's Introduction

Creating zero knowledge proofs using the Bulletproofs implementation from dalek-cryptography. This repo contains several examples that show how various statements can be represented as arithmetic circuits which can be converted to R1CS. A blog post was written that explains the Bulletproofs API with several examples, though the API has changed slightly.

Circuits

  1. Prove a number is in certain range
  2. Prove value is non-zero
  3. Prove value is not equal to a given value
  4. Proof of set membership, 2 implementations 1, 2
  5. Proof of set non-membership
  6. Proof knowledge of preimage given image of MiMC hash function
  7. Poseidon permutation, a 2:1 (2 inputs, 1 output) and 4:1 (4 inputs, 1 output) hash function based on it. 2 kinds of S-boxes, cube and inverse. Described in this paper. The parameters are generated using a sage worksheet supplied by Dmitry Khovratovich and a Jupyter notebook for that worksheet is present in the repo called Poseidon_Ristretto.ipynb.
  8. Proof of knowledge of leaf in a sparse merkle tree of width 2, i.e. each node has 2 children. Uses Poseidon 2:1 hash function.
  9. Proof of knowledge of leaf in a sparse merkle tree of width 4, i.e. each node has 4 children. Uses Poseidon 4:1 hash function.

Building

This project uses a slightly modified implementation of Bulletproofs's develop branch. The difference is addition of the methods num_constraints and num_multipliers to Prover to return the number of constraints and multipliers respectively and addition of some new methods in constraint system and linear combinations

  1. evaluate_lc: to evaluate a linear constraint
  2. allocate_single: to return output variable when allocating right multiplier.
  3. simplify: to simplify a linear combination, eg. simplify a linear combination like 2*x + 3*y + 4*x to 6*x + 3*y.

Use the nightly compiler to run tests like
cargo +nightly test --all-features
OR in release mode to run faster
cargo +nightly test --release --all-features

bulletproofs-r1cs-gadgets's People

Contributors

hansieodendaal avatar lovesh avatar m0bi5 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.