Browse Source

Archive repository

master
arnaucube 3 years ago
parent
commit
478006134d
22 changed files with 60 additions and 62 deletions
  1. +15
    -17
      README.md
  2. +1
    -1
      bn128/README.md
  3. +1
    -1
      bn128/bn128.go
  4. +1
    -1
      bn128/g1.go
  5. +1
    -1
      bn128/g2.go
  6. +1
    -1
      circuitcompiler/circuit.go
  7. +5
    -5
      cli/main.go
  8. +2
    -2
      externalVerif/README.md
  9. +2
    -2
      externalVerif/circomVerifier.go
  10. +1
    -1
      go.mod
  11. +4
    -4
      groth16/groth16.go
  12. +2
    -2
      groth16/groth16_test.go
  13. +1
    -1
      r1csqap/README.md
  14. +1
    -1
      r1csqap/r1csqap.go
  15. +1
    -1
      r1csqap/r1csqap_test.go
  16. +4
    -4
      snark.go
  17. +3
    -3
      snark_test.go
  18. +3
    -3
      utils/base10parsers.go
  19. +3
    -3
      utils/hexparsers.go
  20. +3
    -3
      vim-syntax/README.md
  21. +1
    -1
      wasm/README.md
  22. +4
    -4
      wasm/go-snark-wasm-wrapper.go

+ 15
- 17
README.md

@ -1,18 +1,16 @@
# go-snark [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucube/go-snark)](https://goreportcard.com/report/github.com/arnaucube/go-snark) [![Build Status](https://travis-ci.org/arnaucube/go-snark.svg?branch=master)](https://travis-ci.org/arnaucube/go-snark) [![Gitter](https://badges.gitter.im/go-snark/community.svg)](https://gitter.im/go-snark/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
### Warning
Implementation of the zkSNARK [Pinocchio protocol](https://eprint.iacr.org/2013/279.pdf) and [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) from scratch in Go done in my free time to understand the concepts. Do not use in production.
zkSNARK library implementation in Go
If you want to generate proofs & verify them from Go, you can try https://github.com/vocdoni/go-snark, which is implemented using the [bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/cloudflare) for the Pairing curve operations for the Groth16 zkSNARK, and it is compatible with [circom](https://github.com/iden3/circom).
# go-snark-study [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucube/go-snark-study)](https://goreportcard.com/report/github.com/arnaucube/go-snark-study) [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study)
zkSNARK library implementation in Go
- `Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture`, Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza https://eprint.iacr.org/2013/879.pdf - `Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture`, Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza https://eprint.iacr.org/2013/879.pdf
- `Pinocchio: Nearly practical verifiable computation`, Bryan Parno, Craig Gentry, Jon Howell, Mariana Raykova https://eprint.iacr.org/2013/279.pdf - `Pinocchio: Nearly practical verifiable computation`, Bryan Parno, Craig Gentry, Jon Howell, Mariana Raykova https://eprint.iacr.org/2013/279.pdf
- `On the Size of Pairing-based Non-interactive Arguments`, Jens Groth https://eprint.iacr.org/2016/260.pdf - `On the Size of Pairing-based Non-interactive Arguments`, Jens Groth https://eprint.iacr.org/2016/260.pdf
## Caution & Warning
Implementation of the zkSNARK [Pinocchio protocol](https://eprint.iacr.org/2013/279.pdf) and [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) from scratch in Go done in my free time to understand the concepts. Do not use in production.
## zkSNARKs in Go
If you need to use zkSNARKs in Go, I would recommend to take a look at [go-circom-prover-verifier](https://github.com/iden3/go-circom-prover-verifier), which I've wrote using the [bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/cloudflare) for the Pairing curve operations for the Groth16 zkSNARK, and it is compatible with [circom](https://github.com/iden3/circom).
## Features ## Features
Currently allows to do the complete path with [Pinocchio protocol](https://eprint.iacr.org/2013/279.pdf) and [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) : Currently allows to do the complete path with [Pinocchio protocol](https://eprint.iacr.org/2013/279.pdf) and [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) :
@ -36,15 +34,15 @@ Minimal complete flow implementation:
- [x] verify proofs with BN128 pairing - [x] verify proofs with BN128 pairing
## WASM usage ## WASM usage
Experimentation with go-snark compiled to wasm: https://github.com/arnaucube/go-snark/tree/master/wasm
Experimentation with go-snark-study compiled to wasm: https://github.com/arnaucube/go-snark-study/tree/master/wasm
## Usage ## Usage
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark?status.svg)](https://godoc.org/github.com/arnaucube/go-snark) zkSnark
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/groth16?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/groth16) zkSnark Groth16
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/bn128?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/bn128) bn128 (more details: https://github.com/arnaucube/go-snark/tree/master/bn128)
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/fields?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/fields) Finite Fields operations
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/r1csqap?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/r1csqap) R1CS to QAP (more details: https://github.com/arnaucube/go-snark/tree/master/r1csqap)
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/circuitcompiler?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/circuitcompiler) Circuit Compiler
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study) zkSnark
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/groth16?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/groth16) zkSnark Groth16
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/bn128?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/bn128) bn128 (more details: https://github.com/arnaucube/go-snark-study/tree/master/bn128)
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/fields?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/fields) Finite Fields operations
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/r1csqap?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/r1csqap) R1CS to QAP (more details: https://github.com/arnaucube/go-snark-study/tree/master/r1csqap)
- [![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/circuitcompiler?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/circuitcompiler) Circuit Compiler
### CLI usage ### CLI usage
*The cli still needs some improvements, such as seting input files, etc.* *The cli still needs some improvements, such as seting input files, etc.*
@ -197,7 +195,7 @@ assert.True(t, VerifyProof(*circuit, setup, proof, publicSignalsVerif, true))
``` ```
##### Verify Proof generated from [snarkjs](https://github.com/iden3/snarkjs) ##### Verify Proof generated from [snarkjs](https://github.com/iden3/snarkjs)
Is possible with `go-snark` to verify proofs generated by `snarkjs`
Is possible with `go-snark-study` to verify proofs generated by `snarkjs`
Example: Example:
```go ```go
@ -219,7 +217,7 @@ go test ./... -v
``` ```
## vim/nvim circuit syntax highlighter ## vim/nvim circuit syntax highlighter
For more details and installation instructions see https://github.com/arnaucube/go-snark/tree/master/vim-syntax
For more details and installation instructions see https://github.com/arnaucube/go-snark-study/tree/master/vim-syntax
--- ---

+ 1
- 1
bn128/README.md

@ -1,5 +1,5 @@
## Bn128 ## Bn128
[![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/bn128?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/bn128) bn128
[![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/bn128?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/bn128) bn128
Implementation of the bn128 pairing in Go. Implementation of the bn128 pairing in Go.

+ 1
- 1
bn128/bn128.go

@ -4,7 +4,7 @@ import (
"errors" "errors"
"math/big" "math/big"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark-study/fields"
) )
// Bn128 is the data structure of the BN128 // Bn128 is the data structure of the BN128

+ 1
- 1
bn128/g1.go

@ -3,7 +3,7 @@ package bn128
import ( import (
"math/big" "math/big"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark-study/fields"
) )
type G1 struct { type G1 struct {

+ 1
- 1
bn128/g2.go

@ -3,7 +3,7 @@ package bn128
import ( import (
"math/big" "math/big"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark-study/fields"
) )
type G2 struct { type G2 struct {

+ 1
- 1
circuitcompiler/circuit.go

@ -5,7 +5,7 @@ import (
"math/big" "math/big"
"strconv" "strconv"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark-study/r1csqap"
) )
// Circuit is the data structure of the compiled circuit // Circuit is the data structure of the compiled circuit

+ 5
- 5
cli/main.go

@ -11,11 +11,11 @@ import (
"math/big" "math/big"
"os" "os"
snark "github.com/arnaucube/go-snark"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/groth16"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark/utils"
snark "github.com/arnaucube/go-snark-study"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/groth16"
"github.com/arnaucube/go-snark-study/r1csqap"
"github.com/arnaucube/go-snark-study/utils"
"github.com/urfave/cli" "github.com/urfave/cli"
) )

+ 2
- 2
externalVerif/README.md

@ -1,8 +1,8 @@
# go-snark /externalVerif
# go-snark-study /externalVerif
Utilities to verify zkSNARK proofs generated by other tools. Utilities to verify zkSNARK proofs generated by other tools.
## Verify Proof generated from [snarkjs](https://github.com/iden3/snarkjs) ## Verify Proof generated from [snarkjs](https://github.com/iden3/snarkjs)
Is possible with `go-snark` to verify proofs generated by `snarkjs`
Is possible with `go-snark-study` to verify proofs generated by `snarkjs`
Example: Example:
```go ```go

+ 2
- 2
externalVerif/circomVerifier.go

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"github.com/arnaucube/go-snark/groth16"
"github.com/arnaucube/go-snark/utils"
"github.com/arnaucube/go-snark-study/groth16"
"github.com/arnaucube/go-snark-study/utils"
) )
type CircomProof struct { type CircomProof struct {

+ 1
- 1
go.mod

@ -1,4 +1,4 @@
module github.com/arnaucube/go-snark
module github.com/arnaucube/go-snark-study
require ( require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect

+ 4
- 4
groth16/groth16.go

@ -6,10 +6,10 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/arnaucube/go-snark/bn128"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark-study/bn128"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/fields"
"github.com/arnaucube/go-snark-study/r1csqap"
) )
type Pk struct { // Proving Key type Pk struct { // Proving Key

+ 2
- 2
groth16/groth16_test.go

@ -8,8 +8,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/r1csqap"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

+ 1
- 1
r1csqap/README.md

@ -1,5 +1,5 @@
## R1CS to Quadratic Arithmetic Program ## R1CS to Quadratic Arithmetic Program
[![GoDoc](https://godoc.org/github.com/arnaucube/go-snark/r1csqap?status.svg)](https://godoc.org/github.com/arnaucube/go-snark/r1csqap) R1CS to QAP
[![GoDoc](https://godoc.org/github.com/arnaucube/go-snark-study/r1csqap?status.svg)](https://godoc.org/github.com/arnaucube/go-snark-study/r1csqap) R1CS to QAP
- `Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture`, Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza https://eprint.iacr.org/2013/879.pdf - `Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture`, Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza https://eprint.iacr.org/2013/879.pdf
- Vitalik Buterin blog post about QAP https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649 - Vitalik Buterin blog post about QAP https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649
- Ariel Gabizon in Zcash blog https://z.cash/blog/snark-explain5 - Ariel Gabizon in Zcash blog https://z.cash/blog/snark-explain5

+ 1
- 1
r1csqap/r1csqap.go

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"math/big" "math/big"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark-study/fields"
) )
// Transpose transposes the *big.Int matrix // Transpose transposes the *big.Int matrix

+ 1
- 1
r1csqap/r1csqap_test.go

@ -5,7 +5,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark-study/fields"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

+ 4
- 4
snark.go

@ -7,10 +7,10 @@ import (
"math/big" "math/big"
"os" "os"
"github.com/arnaucube/go-snark/bn128"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/fields"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark-study/bn128"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/fields"
"github.com/arnaucube/go-snark-study/r1csqap"
) )
type Pk struct { // Proving Key pk:=(pkA, pkB, pkC, pkH) type Pk struct { // Proving Key pk:=(pkA, pkB, pkC, pkH)

+ 3
- 3
snark_test.go

@ -8,9 +8,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/groth16"
"github.com/arnaucube/go-snark/r1csqap"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/groth16"
"github.com/arnaucube/go-snark-study/r1csqap"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

+ 3
- 3
utils/base10parsers.go

@ -4,9 +4,9 @@ import (
"errors" "errors"
"math/big" "math/big"
snark "github.com/arnaucube/go-snark"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/groth16"
snark "github.com/arnaucube/go-snark-study"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/groth16"
) )
// []*big.Int // []*big.Int

+ 3
- 3
utils/hexparsers.go

@ -5,9 +5,9 @@ import (
"fmt" "fmt"
"math/big" "math/big"
snark "github.com/arnaucube/go-snark"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/groth16"
snark "github.com/arnaucube/go-snark-study"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/groth16"
) )
// []*big.Int // []*big.Int

+ 3
- 3
vim-syntax/README.md

@ -3,8 +3,8 @@
## Installation in vim/nvim using plug ## Installation in vim/nvim using plug
Using [Plug](https://github.com/junegunn/vim-plug), add this lines into the `.vimrc`/`init.vim`: Using [Plug](https://github.com/junegunn/vim-plug), add this lines into the `.vimrc`/`init.vim`:
``` ```
Plug 'arnaucube/go-snark'
Plug 'arnaucube/go-snark', {'rtp': 'vim-syntax'}
Plug 'arnaucube/go-snark-study'
Plug 'arnaucube/go-snark-study', {'rtp': 'vim-syntax'}
``` ```
![screenshot-vim](https://raw.githubusercontent.com/arnaucube/go-snark/master/vim-syntax/screenshot.png "screenshot-vim")
![screenshot-vim](https://raw.githubusercontent.com/arnaucube/go-snark-study/master/vim-syntax/screenshot.png "screenshot-vim")

+ 1
- 1
wasm/README.md

@ -1,4 +1,4 @@
# go-snark wasm
# go-snark-study wasm
*Warning: this is an ongoing experimentation* *Warning: this is an ongoing experimentation*
WASM wrappers for zkSNARK Pinocchio & Groth16 protocols. WASM wrappers for zkSNARK Pinocchio & Groth16 protocols.

+ 4
- 4
wasm/go-snark-wasm-wrapper.go

@ -5,10 +5,10 @@ import (
"math/big" "math/big"
"syscall/js" "syscall/js"
"github.com/arnaucube/go-snark"
"github.com/arnaucube/go-snark/circuitcompiler"
"github.com/arnaucube/go-snark/groth16"
"github.com/arnaucube/go-snark/utils"
"github.com/arnaucube/go-snark-study"
"github.com/arnaucube/go-snark-study/circuitcompiler"
"github.com/arnaucube/go-snark-study/groth16"
"github.com/arnaucube/go-snark-study/utils"
) )
func main() { func main() {

Loading…
Cancel
Save