Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wrap plonky2 proof to groth16 #93

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3c36b82
wrapper initial commiy
tamirhemo Aug 27, 2023
3b9ce45
init hash circuit
tamirhemo Aug 28, 2023
b446ecd
Merge branch 'main' into tamir/gnark_wrapper
tamirhemo Aug 28, 2023
0a0fdc9
hash circuit
tamirhemo Aug 28, 2023
883f7da
go circuit
tamirhemo Aug 28, 2023
2d3805f
go cli skeleton
tamirhemo Aug 28, 2023
d9aa09d
ignore data files
tamirhemo Aug 28, 2023
cd1cd73
add compile func
tamirhemo Aug 28, 2023
a9fd78a
Merge remote-tracking branch 'origin/main' into tamir/gnark_wrapper
tamirhemo Aug 28, 2023
e0488a4
upstream changes
tamirhemo Aug 28, 2023
f465177
compile and save methods
tamirhemo Aug 28, 2023
9d2d6b7
compile
tamirhemo Aug 28, 2023
69dca0d
remove unnecessary feature
tamirhemo Aug 28, 2023
027cc4f
create path method
tamirhemo Aug 28, 2023
103d3e9
fix path
tamirhemo Aug 28, 2023
f404818
log messages and create dir
tamirhemo Aug 28, 2023
c91a2c0
proof generation
tamirhemo Aug 28, 2023
1a311b0
timing messages for deserialization
tamirhemo Aug 28, 2023
b915e8c
change proof flag
tamirhemo Aug 28, 2023
a832f5e
separate verification method
tamirhemo Aug 29, 2023
6bebcc8
verify after proving
tamirhemo Aug 29, 2023
8b1d86a
embed bytes
tamirhemo Aug 29, 2023
59692ca
testing
tamirhemo Aug 29, 2023
f7a5918
fix path
tamirhemo Aug 29, 2023
0594e24
read from buffer
tamirhemo Aug 29, 2023
dcba9cb
buffer read, verifier
tamirhemo Aug 29, 2023
dda517c
write binary witness
tamirhemo Aug 29, 2023
8f942e4
test proof read
tamirhemo Aug 29, 2023
a8648c3
error
tamirhemo Aug 29, 2023
c566773
json saving
tamirhemo Aug 29, 2023
850c22b
json deserialization
tamirhemo Aug 29, 2023
951ff13
err
tamirhemo Aug 29, 2023
cb3faf0
change to json
tamirhemo Aug 29, 2023
6f1675c
input/output and digest
tamirhemo Aug 30, 2023
e790775
input/output and digest
tamirhemo Aug 30, 2023
d39b67e
add var init
tamirhemo Aug 30, 2023
f0b21ae
fmt
tamirhemo Aug 30, 2023
9032901
pk writing bug
tamirhemo Aug 30, 2023
549e567
witness bug
tamirhemo Aug 30, 2023
a9675cc
truncate and save vk without buffer
tamirhemo Aug 30, 2023
67f7f3c
add zero to have 256 bits
tamirhemo Aug 30, 2023
e86cb12
prover test
tamirhemo Aug 30, 2023
7131796
save witness in binary
tamirhemo Aug 30, 2023
7c17c5d
fix .json to .bin for witnessfile
tamirhemo Aug 30, 2023
d760b0f
fix: make verifier data constant
tamirhemo Aug 31, 2023
6e0e4a0
cleanup, fmt
tamirhemo Aug 31, 2023
5aaef37
Merge remote-tracking branch 'origin/main' into tamir/gnark_wrapper
tamirhemo Aug 31, 2023
79562e4
constant circuit data
tamirhemo Sep 1, 2023
0d8894e
update upstream changes
tamirhemo Sep 7, 2023
245d5b1
Merge branch 'main' into tamir/gnark_wrapper
tamirhemo Sep 7, 2023
a35e682
Merge branch 'main' into tamir/gnark_wrapper
ctian1 Sep 11, 2023
19496bf
build fixes
ctian1 Sep 11, 2023
7f69912
tweak gnark verifier io
ctian1 Sep 11, 2023
ba335e8
integrate plonky2x cli with gnark verifier
ctian1 Sep 12, 2023
8eb7658
fix
ctian1 Sep 12, 2023
4dcc32d
debug
ctian1 Sep 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ keystore
**/*.bin
**/target
**/build
**/data

**/__pycache__
**/Verifier.sol
**/FunctionVerifier.sol


.idea/
.idea/
proof.json
output.json
49 changes: 46 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ succinct prove
To create a new SDK release:

```sh
./build/release.sh <X.Y.Z>
./scripts/release.sh <X.Y.Z>
```

## Building ABIs and Bindings

To build the ABIs:

```sh
./build/abi.sh
./scripts/abi.sh
```

Then to build the bindings:

```sh
./build/binding.sh
./scripts/binding.sh
```

If you need to add a binding for a different contract, edit `build/binding.sh` and modify the `CONTRACTS` array.
If you need to add a binding for a different contract, edit `scripts/binding.sh` and modify the `CONTRACTS` array.
9 changes: 7 additions & 2 deletions gnarkx/types/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type Groth16Proof struct {
A [2]*big.Int `json:"a"`
B [2][2]*big.Int `json:"b"`
C [2]*big.Int `json:"c"`
Input hexutil.Bytes `json:"input"`
Output hexutil.Bytes `json:"output"`
Input hexutil.Bytes `json:"input,omitempty"`
Output hexutil.Bytes `json:"output,omitempty"`
}

// Export saves the proof to a file.
Expand Down Expand Up @@ -42,3 +42,8 @@ func (g *Groth16Proof) Export(file string) error {

return nil
}

type FunctionResult struct {
Proof hexutil.Bytes `json:"proof"`
Output hexutil.Bytes `json:"output"`
}
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/consensys/gnark v0.8.1-0.20230803132917-bd4a39719a96
github.com/consensys/gnark-crypto v0.11.1-0.20230724160225-800ddb59f51b
github.com/consensys/gnark-crypto v0.11.2
github.com/ethereum/go-ethereum v1.12.0
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.4
Expand All @@ -20,10 +20,10 @@ require (
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
Expand All @@ -35,11 +35,13 @@ require (
github.com/rs/zerolog v1.30.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/succinctlabs/gnark-plonky2-verifier v0.0.0-20230724231837-7bd0035e65e3 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/sys v0.11.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/consensys/gnark v0.8.1-0.20230803132917-bd4a39719a96 h1:BtDmnURu+BjTQ
github.com/consensys/gnark v0.8.1-0.20230803132917-bd4a39719a96/go.mod h1:Y70OuyMjYNvmTUL/sNKhehLOgByRYSOR8X6WMo7GmGQ=
github.com/consensys/gnark-crypto v0.11.1-0.20230724160225-800ddb59f51b h1:tlxRLAcCOcdC3TcP5uqrKaK+OF7eBy1YB5AYUUhOayM=
github.com/consensys/gnark-crypto v0.11.1-0.20230724160225-800ddb59f51b/go.mod h1:6C2ytC8zmP8uH2GKVfPOjf0Vw3KwMAaUxlCPK5WQqmw=
github.com/consensys/gnark-crypto v0.11.2 h1:GJjjtWJ+db1xGao7vTsOgAOGgjfPe7eRGPL+xxMX0qE=
github.com/consensys/gnark-crypto v0.11.2/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -38,6 +40,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
Expand All @@ -52,6 +56,8 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXi
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 h1:ZgoomqkdjGbQ3+qQXCkvYMCDvGDNg2k5JJDjjdTB6jY=
github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA=
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ=
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -104,6 +110,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/succinctlabs/gnark-plonky2-verifier v0.0.0-20230724231837-7bd0035e65e3 h1:2UL4wMVXtuGnE7f+Bt7gTtMg3bU8Bh3xjNMiR7wzrT0=
github.com/succinctlabs/gnark-plonky2-verifier v0.0.0-20230724231837-7bd0035e65e3/go.mod h1:5jUXJKCi/CwL0U2YWvwKR39mvLH5yV9f7ql+skd0eC8=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
Expand All @@ -114,7 +122,11 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -124,7 +136,10 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
Loading