Coder Social home page Coder Social logo

kzg-verifier's Introduction

About

A KZG commitment verifier written in Noir.

Installation

Add this in your Nargo.toml

kzg_verifier = { tag = "v0.1.0", git = "https://github.com/RajeshRk18/kzg-verifier.git" }

Usage

Required inputs:

  • Structured Reference String (obtained from trusted setup)
  • $x$ - Evaluation Point
  • $y$ - Evaluation of $P(x)$
  • Commitment $C$
  • Evaluation Proof $\pi$
use dep::kzg_verifier::verify_kzg_commit;
use dep::kzg_verifier::utils::{create_g1_point, create_g2_point};
use dep::kzg_verifier::srs::SRS;
use dep::bls12_381::field::prime_field::PrimeField as Fp;

    fn main(srs_g1_x: [u8; 48], srs_g1_y: [u8; 48], srs_g2_1_x_c0: [u8; 48], srs_g2_1_x_c1: [u8; 48], srs_g2_1_y_c0: [u8; 48], srs_g2_1_y_c1: [u8; 48], srs_g2_2_x_c0: [u8; 48], srs_g2_2_x_c1: [u8; 48], srs_g2_2_y_c0: [u8; 48], srs_g2_2_y_c1: [u8; 48], x: [u8; 48], y: [u8; 48], commitment_x: [u8; 48], commitment_y: [u8; 48], proof_x: [u8; 48], proof_y: [u8; 48]) -> bool {
        let srs_g1 = create_g1_point(srs_g1_x, srs_g1_y);

        let srs_g2_1 = create_g2_point(srs_g2_1_x_c0, srs_g2_1_x_c1, srs_g2_1_y_c0, srs_g2_1_y_c1);

        let srs_g2_2 = create_g2_point(srs_g2_2_x_c0, srs_g2_2_x_c1, srs_g2_2_y_c0, srs_g2_2_y_c1);

        let mut srs_g1_points = Vec::new();
        srs_g1_points.push(srs_g1);

        let srs = SRS::new(srs_g1_points, [srs_g2_1, srs_g2_2]);

        let x = Fp::from_bytes(x);

        let y = Fp::from_bytes(y);
    
        let commitment = create_g1_point(commitment_x, commitment_y);

        let proof = create_g1_point(proof_x, proof_y);

        assert(verify_kzg_commit(srs, x, y, commitment, proof))
    }

Limitations

  • Only BLS12_381 curve is supported currently.

  • Only commitment verification is available. Other operations such as commit, and open are yet to be supported.

Acknowledgements

Lamdaworks

Disclaimer

This is experimental software and is provided on an "as is" and "as available" basis. We do not give any warranties and will not be liable for any losses incurred through any use of this code base.

kzg-verifier's People

Contributors

rajeshrk18 avatar

Stargazers

Nick Dimitriou avatar wiasliaw avatar Elwin avatar sukrucildirr avatar Chen Kai 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.