Archive repository

This commit is contained in:
arnaucube
2021-06-13 18:37:08 +02:00
parent aec3022978
commit 478006134d
22 changed files with 60 additions and 62 deletions

View File

@@ -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.
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
- `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
## 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
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
## 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
- [![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
*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)
Is possible with `go-snark` to verify proofs generated by `snarkjs`
Is possible with `go-snark-study` to verify proofs generated by `snarkjs`
Example:
```go
@@ -219,7 +217,7 @@ go test ./... -v
```
## 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
---

View File

@@ -1,5 +1,5 @@
## 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.

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,11 +11,11 @@ import (
"math/big"
"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"
)

View File

@@ -1,8 +1,8 @@
# go-snark /externalVerif
# go-snark-study /externalVerif
Utilities to verify zkSNARK proofs generated by other tools.
## 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:
```go

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"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 {

2
go.mod
View File

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

View File

@@ -6,10 +6,10 @@ import (
"fmt"
"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

View File

@@ -8,8 +8,8 @@ import (
"testing"
"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"
)

View File

@@ -1,5 +1,5 @@
## 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
- 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

View File

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

View File

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

View File

@@ -7,10 +7,10 @@ import (
"math/big"
"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)

View File

@@ -8,9 +8,9 @@ import (
"testing"
"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"
)

View File

@@ -4,9 +4,9 @@ import (
"errors"
"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

View File

@@ -5,9 +5,9 @@ import (
"fmt"
"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

View File

@@ -3,8 +3,8 @@
## Installation in vim/nvim using plug
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")

View File

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

View File

@@ -5,10 +5,10 @@ import (
"math/big"
"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() {