Giter Club home page Giter Club logo

a0kzg's Introduction

learning-kate

CI Crates.io docs.rs

Kate-Zaverucha-Goldberg polynomial commitments in rust playground

This is just-for-learning, so do not use in production of KZG commitments in rust, the idea is to extend it with other functions like plonk or verkle trees.

It uses the fantastic bls12_381 crate

KZG Example

use a0kzg::{Scalar, Kzg};
// Create a trustd setup that allows maximum 4 points (degree+1)
let kzg = Kzg::trusted_setup(5);

// define the set of points (the "population"), and create a polynomial
// for them, as well its polynomial commitment, see the polynomial commitment
// like the "hash" of the polynomial
let set = vec![
  (Scalar::from(1), Scalar::from(2)),
  (Scalar::from(2), Scalar::from(3)),
  (Scalar::from(3), Scalar::from(4)),
  (Scalar::from(4), Scalar::from(57)),
];
let (p, c) = kzg.poly_commitment_from_set(&set);

// generate a proof that (1,2) and (2,3) are in the set
let proof01 = kzg.prove(&p, &vec![set[0].clone(), set[1].clone()]);

// prove that (1,2) and (2,3) are in the set
assert!(kzg.verify(&c, &vec![set[0].clone(), set[1].clone()], &proof01));
// other proofs will fail since the proof only works for exactly (1,2) AND (2,3)
assert!(!kzg.verify(&c, &vec![set[0].clone()], &proof01));
assert!(!kzg.verify(&c, &vec![set[0].clone(), set[2].clone()], &proof01));

// prove and verify that the whole set exists in the whole set
let proof0123 = kzg.prove(&p, &set);
assert!(kzg.verify(&c, &set, &proof0123));

a0kzg's People

Contributors

adria0 avatar daniel-aaron-bloom avatar

Forkers

keplervital

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.