You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
arnaucube 88c3e98cae polynomial Division, SolPolynomials, DivisorPolynomial 5 years ago
bn128 r1cs to qap over finite field 5 years ago
fields r1cs to qap over finite field 5 years ago
r1csqap polynomial Division, SolPolynomials, DivisorPolynomial 5 years ago
r1csqapFloat polynomial Division, SolPolynomials, DivisorPolynomial 5 years ago
LICENSE Initial commit 5 years ago
README.md r1cs to qap over finite field 5 years ago
go.mod bn128 pairing, r1cs to qap 5 years ago
go.sum bn128 pairing, r1cs to qap 5 years ago

README.md

go-snark Go Report Card

zk-SNARK library implementation in Go

Not finished, work in progress (doing this in my free time, so I don't have much time).

Test

go test ./... -v

R1CS to Quadratic Arithmetic Program

Usage

  • R1CS to QAP
b0 := big.NewFloat(float64(0))
b1 := big.NewFloat(float64(1))
b5 := big.NewFloat(float64(5))
a := [][]*big.Float{
  []*big.Float{b0, b1, b0, b0, b0, b0},
  []*big.Float{b0, b0, b0, b1, b0, b0},
  []*big.Float{b0, b1, b0, b0, b1, b0},
  []*big.Float{b5, b0, b0, b0, b0, b1},
}
b := [][]*big.Float{
  []*big.Float{b0, b1, b0, b0, b0, b0},
  []*big.Float{b0, b1, b0, b0, b0, b0},
  []*big.Float{b1, b0, b0, b0, b0, b0},
  []*big.Float{b1, b0, b0, b0, b0, b0},
}
c := [][]*big.Float{
  []*big.Float{b0, b0, b0, b1, b0, b0},
  []*big.Float{b0, b0, b0, b0, b1, b0},
  []*big.Float{b0, b0, b0, b0, b0, b1},
  []*big.Float{b0, b0, b1, b0, b0, b0},
}
alpha, beta, gamma, z := R1CSToQAP(a, b, c)
fmt.Println(alpha)
fmt.Println(beta)
fmt.Println(gamma)
fmt.Println(z)
/*
out:
alpha: [[-5 9.166666666666666 -5 0.8333333333333334] [8 -11.333333333333332 5 -0.6666666666666666] [0 0 0 0] [-6 9.5 -4 0.5] [4 -7 3.5 -0.5] [-1 1.8333333333333333 -1 0.16666666666666666]]
beta: [[3 -5.166666666666667 2.5 -0.33333333333333337] [-2 5.166666666666667 -2.5 0.33333333333333337] [0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]
gamma: [[0 0 0 0] [0 0 0 0] [-1 1.8333333333333333 -1 0.16666666666666666] [4 -4.333333333333333 1.5 -0.16666666666666666] [-6 9.5 -4 0.5] [4 -7 3.5 -0.5]]
z: [24 -50 35 -10 1]
*/

Bn128

Implementation of the bn128 pairing in Go.

Implementation followng the information and the implementations from:

Usage

  • Pairing
bn128, err := NewBn128()
assert.Nil(t, err)

big25 := big.NewInt(int64(25))
big30 := big.NewInt(int64(30))

g1a := bn128.G1.MulScalar(bn128.G1.G, big25)
g2a := bn128.G2.MulScalar(bn128.G2.G, big30)

g1b := bn128.G1.MulScalar(bn128.G1.G, big30)
g2b := bn128.G2.MulScalar(bn128.G2.G, big25)

pA, err := bn128.Pairing(g1a, g2a)
assert.Nil(t, err)
pB, err := bn128.Pairing(g1b, g2b)
assert.Nil(t, err)
assert.True(t, bn128.Fq12.Equal(pA, pB))