mirror of
https://github.com/arnaucube/go-bellman-verifier.git
synced 2026-02-06 19:06:46 +01:00
Add Travis, update README.md & doc
This commit is contained in:
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.13"
|
||||
|
||||
22
README.md
22
README.md
@@ -1,6 +1,20 @@
|
||||
# go-bellman-verifier
|
||||
# go-bellman-verifier [](https://goreportcard.com/report/github.com/arnaucube/go-bellman-verifier) [](https://travis-ci.org/arnaucube/go-bellman-verifier)
|
||||
|
||||
Groth16 zkSnark bellman proof verifier
|
||||
Groth16 zkSNARK bellman proof verifier
|
||||
|
||||
Verify [Groth16](https://eprint.iacr.org/2016/260.pdf) proofs generated from [bellman](https://github.com/zkcrypto/bellman), using [cloudflare/bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/cloudflare) (used by [go-ethereum](https://github.com/ethereum/go-ethereum)) for the Pairing.
|
||||
|
||||
|
||||
## Usage
|
||||
```go
|
||||
public, err := ParsePublicRaw(publicJson)
|
||||
require.Nil(t, err)
|
||||
proof, err := ParseProofRaw(proofJson)
|
||||
require.Nil(t, err)
|
||||
vk, err := ParseVkRaw(vkJson)
|
||||
require.Nil(t, err)
|
||||
|
||||
v := Verify(vk, proof, public)
|
||||
assert.True(t, v)
|
||||
```
|
||||
|
||||
- Verify proofs generated from [bellman](https://github.com/zkcrypto/bellman)
|
||||
- Using [cloudflare/bn256](https://github.com/cloudflare/bn256) for the Pairing.
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
bn256 "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
||||
)
|
||||
|
||||
// Vk is the Verification Key data structure
|
||||
type Vk struct {
|
||||
Alpha *bn256.G1
|
||||
Beta *bn256.G2
|
||||
@@ -19,6 +20,7 @@ type Vk struct {
|
||||
GammaABC []*bn256.G1
|
||||
}
|
||||
|
||||
// VkRaw is the Verification Key data structure in string format (from json)
|
||||
type VkRaw struct {
|
||||
Alpha []string `json:"alpha_g1"`
|
||||
Beta [][]string `json:"beta_g2"`
|
||||
@@ -27,12 +29,14 @@ type VkRaw struct {
|
||||
GammaABC [][]string `json:"ic"`
|
||||
}
|
||||
|
||||
// Proof is the Groth16 Proof data structure
|
||||
type Proof struct {
|
||||
A *bn256.G1
|
||||
B *bn256.G2
|
||||
C *bn256.G1
|
||||
}
|
||||
|
||||
// ProofRaw is the Groth16 Proof data structure in string format (from json)
|
||||
type ProofRaw struct {
|
||||
A []string `json:"a"`
|
||||
B [][]string `json:"b"`
|
||||
|
||||
@@ -15,11 +15,11 @@ func TestParsePoints(t *testing.T) {
|
||||
assert.Equal(t, "bn256.G1(2cdfab288afda1ba399d60951423e76445754b7d2e7827634732988373c8e0ff, 1bb2e3543dfdd373610db3ea82703bc70e4d6f01b5c0e10709e27545670824f4)", a.String())
|
||||
|
||||
bHex := [][]string{
|
||||
[]string{
|
||||
{
|
||||
"0x0f9cd75cae408d3b6d2731035dbb6aa6f66cf900c1d64b46510cbbcd7cf94f64",
|
||||
"0x165997362d7c2bf5672d16206fbee620ad8eb54f609b98c49c7c6287c9979077",
|
||||
},
|
||||
[]string{
|
||||
{
|
||||
"0x0392982b7cd7bdbbee79d5f808c67ead8ef3e2347810b546b419da5f738aab92",
|
||||
"0x0f94d6781b9de113b86abd1930accd2260d0c979d520bc1a0e79dec3c8ce76a3",
|
||||
},
|
||||
@@ -29,11 +29,11 @@ func TestParsePoints(t *testing.T) {
|
||||
assert.Equal(t, "bn256.G2((165997362d7c2bf5672d16206fbee620ad8eb54f609b98c49c7c6287c9979077, 0f9cd75cae408d3b6d2731035dbb6aa6f66cf900c1d64b46510cbbcd7cf94f64), (0f94d6781b9de113b86abd1930accd2260d0c979d520bc1a0e79dec3c8ce76a3, 0392982b7cd7bdbbee79d5f808c67ead8ef3e2347810b546b419da5f738aab92))", b.String())
|
||||
|
||||
gHex := [][]string{
|
||||
[]string{
|
||||
{
|
||||
"0x2d0c4fa1239184802aeda1f206e49104940aa3eccc1b3e0141c25b2dba8e7caf",
|
||||
"0x15c9b1123841897787badbe858eb00943fc8a99454666f21acf4e79e13547471",
|
||||
},
|
||||
[]string{
|
||||
{
|
||||
"0x256ad09ecb0abc15fd48f20c37d28ffcf0f8eb3b23cb10cdeee7365b598963ac",
|
||||
"0x2bc9bc381cf68badd992338c637b36b54936b69cb8560eaf5a8cbe2c20ff8522",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user