Giter Site home page Giter Site logo

groth-pairing's Introduction

groth-pairing

Testing "pairing function" in the context of Elliptic Curves constructed using a tower of field extensions.

Elliptic curves:

  • BN128 (file src/BN128.hs)
  • BLS12-381 (file src/BLS12381.hs)

Pairing function

Let G1 be the elliptic curve over Fp1 (the base field) and G2 the elliptic curve over Fp2 (the first extension). Then

pairing :: G1 -> G2 -> Fp12

where Fp12 is the extended field according to the curve's embedding degree 'k = 12' ("top floor" in the tower).

Points on G1 and G2

A point in G1 is constructed with ecExp g1Gen n:

ghci> :t ecExp g1Gen
ecExp g1Gen :: Integer -> G1

Likewise, a point in G2 is constructed with ecExp g2Gen n.

Here n is an integer between 0 and q, with

  • For BN128:
q = 21888242871839275222246405745257275088548364400416034343698204186575808495617
  • For BLS12-381:
q = 52435875175126190479447740508185965837690552500527637822603658699938581184513

Function ecExp is an efficient implementation of the exponential function on an elliptic curve, so that e.g. ecExp p 5 is effectively equivalent to p <> p <> p <> p <> p.

As a check, one can test that a constructed point p is on the elliptic curve with isOnCurve p,

ghci> :t isOnCurve 
isOnCurve :: Field a => EllipticCurve a -> Bool

Bilinearity

It is expected that the pairing satisfies the bilinearity property:

pairing (p1 <> p2) q == pairing p1 q * pairing p2 q
pairing p (q1 <> q2) == pairing p q1 * pairing p q2

The test of the property can be checked for the BN-128 curve with the following commands:

cabal test bilineal-property-128

And the BLS12-381 curve:

cabal test bilineal-property-381

ZK verification

To check the viability of using our pairing implementation in conjunction with an open source ZK tooling like snarkjs, we test the validation of a proof produced by such a tool; see files in src/Groth16 and corresponding log in directory logs.

groth-pairing's People

Contributors

agustinbadi avatar ajuggler avatar jmagan avatar

Stargazers

 avatar  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.