GithubHelp home page GithubHelp logo

roynalnaruto / range_proof Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 4.0 35 KB

PoC implementation of polynomial commitment scheme based Range Proofs

License: GNU General Public License v3.0

Rust 100.00%
polynomial-commitments range-proofs zero-knowledge-proofs rust-lang

range_proof's Introduction

Range Proof

The code in this repository is a implementation of the range proof protocol described here.

This work is only proof of concept, it is not audited or does not come with any claims.

Example

  • To prove that z = 100 lies in the range [0, 2^8)
  • Trusted setup
use commitment_scheme;
// range: [0, 2^n)
let n = 8usize;
// trusted setup
let (pk, vk) = commitment_scheme::trusted_setup(4usize * n).unwrap();
  • [Prover] Create range proof
use algebra::bls12_381::Fr;
use merlin::Transcript;
// number in the above range
let z = Fr::from(100u8);
// merlin transcript will be used to
// transform an interactive protocol
// into a non-interactive protocol
let mut proof_transcript = Transcript::new(b"range_proof");
// generate range proof
let proof = RangeProof::prove(&pk, n, &z, &mut proof_transcript);
  • [Verifier] Verify range proof
// verification transcript
let mut verification_transcript = Transcript::new(b"range_proof");
// verify the above range proof
let result = RangeProof::verify(&proof, &vk, n, &mut verification_transcript);
// assert that the result is ok
assert!(result.is_ok());

License

In detail here

range_proof's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

range_proof's Issues

Add zero knowledge to the range proof

As describe in the last section of the protocol:

  • The modification is to construct g as an n+1 degree polynomial (instead of the original n-1 degree polynomial). This means, the evaluation domain for g will be of size next_power_of_two(n+1).
  • The proving scheme should fetch two new challenge scalars from the Merlin transcript, namely, alpha and beta, and add them as two new random evaluations to g in this extended domain.
  • This doesn't change the point evaluations at the roots of unity in the original domain, hence all original relations are still valid.
  • One caveat to be checked is, rho (evaluation challenge) cannot belong to the set of roots of unity of the original domain. This utility function can be referred while generating a random rho.

Fix the max degree in trusted setup

The max_degree supplied at the time of trusted setup should be the maximum degree of any polynomial that can be verified using the KZG10 scheme. It is not equal to n, where 0 <= z < 2^n.

This is because the polynomial q is of a higher degree.

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.