Skip to content

Commit 3b1282b

Browse files
authored
mod: go-ipa panic removal (#389)
* mod: go-ipa panic removal Signed-off-by: Ignacio Hagopian <[email protected]> * mod: use go-ipa master Signed-off-by: Ignacio Hagopian <[email protected]> --------- Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent 300c55f commit 3b1282b

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/gballet/go-verkle
33
go 1.19
44

55
require (
6-
github.com/crate-crypto/go-ipa v0.0.0-20230904185759-9f7637e8ddd0
6+
github.com/crate-crypto/go-ipa v0.0.0-20230905211650-63ccabc1a949
77
golang.org/x/sync v0.1.0
88
)
99

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/Yj
44
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
55
github.com/consensys/gnark-crypto v0.11.2 h1:GJjjtWJ+db1xGao7vTsOgAOGgjfPe7eRGPL+xxMX0qE=
66
github.com/consensys/gnark-crypto v0.11.2/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
7-
github.com/crate-crypto/go-ipa v0.0.0-20230904185759-9f7637e8ddd0 h1:MztzKYOxMeC8HlWGXvq2wizas+QT0FgITjGThfmbh/0=
8-
github.com/crate-crypto/go-ipa v0.0.0-20230904185759-9f7637e8ddd0/go.mod h1:7fZtshzGQ3dxVpDpF51K9mX8oziq8Xd5AoM/UT9fF5o=
7+
github.com/crate-crypto/go-ipa v0.0.0-20230905211650-63ccabc1a949 h1:m73KBJvYRMuaUth425v6nKeEu6GSq9Zij01+jc2r2Y0=
8+
github.com/crate-crypto/go-ipa v0.0.0-20230905211650-63ccabc1a949/go.mod h1:7fZtshzGQ3dxVpDpF51K9mX8oziq8Xd5AoM/UT9fF5o=
99
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1010
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
1111
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=

Diff for: proof_ipa.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ package verkle
2828
import (
2929
"bytes"
3030
"errors"
31+
"fmt"
3132
"sort"
3233
"unsafe"
3334

@@ -91,7 +92,7 @@ func MakeVerkleMultiProof(root VerkleNode, keys [][]byte, resolver NodeResolverF
9192

9293
pe, es, poas, err := GetCommitmentsForMultiproof(root, keys, resolver)
9394
if err != nil {
94-
return nil, nil, nil, nil, err
95+
return nil, nil, nil, nil, fmt.Errorf("get commitments for multiproof: %s", err)
9596
}
9697

9798
// NOTE this is leftover code from the time the proof was
@@ -108,7 +109,10 @@ func MakeVerkleMultiProof(root VerkleNode, keys [][]byte, resolver NodeResolverF
108109
// }
109110

110111
cfg := GetConfig()
111-
mpArg := ipa.CreateMultiProof(tr, cfg.conf, pe.Cis, pe.Fis, pe.Zis)
112+
mpArg, err := ipa.CreateMultiProof(tr, cfg.conf, pe.Cis, pe.Fis, pe.Zis)
113+
if err != nil {
114+
return nil, nil, nil, nil, fmt.Errorf("creating multiproof: %s", err)
115+
}
112116

113117
// It's wheel-reinvention time again 🎉: reimplement a basic
114118
// feature that should be part of the stdlib.
@@ -137,7 +141,7 @@ func MakeVerkleMultiProof(root VerkleNode, keys [][]byte, resolver NodeResolverF
137141
return proof, pe.Cis, pe.Zis, pe.Yis, nil
138142
}
139143

140-
func VerifyVerkleProof(proof *Proof, Cs []*Point, indices []uint8, ys []*Fr, tc *Config) bool {
144+
func VerifyVerkleProof(proof *Proof, Cs []*Point, indices []uint8, ys []*Fr, tc *Config) (bool, error) {
141145
tr := common.NewTranscript("vt")
142146
return ipa.CheckMultiProof(tr, tc.conf, proof.Multipoint, Cs, ys, indices)
143147
}

Diff for: proof_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestProofVerifyTwoLeaves(t *testing.T) {
4646
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{ffx32KeyTest}, nil)
4747

4848
cfg := GetConfig()
49-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
49+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
5050
t.Fatalf("could not verify verkle proof: %s", ToDot(root))
5151
}
5252
}
@@ -68,7 +68,7 @@ func TestProofVerifyMultipleLeaves(t *testing.T) {
6868
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{keys[0]}, nil)
6969

7070
cfg := GetConfig()
71-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
71+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
7272
t.Fatal("could not verify verkle proof")
7373
}
7474
}
@@ -94,7 +94,7 @@ func TestMultiProofVerifyMultipleLeaves(t *testing.T) {
9494
t.Fatal(err)
9595
}
9696
cfg := GetConfig()
97-
if !VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg) {
97+
if ok, err := VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg); !ok || err != nil {
9898
t.Fatal("could not verify verkle proof")
9999
}
100100
}
@@ -137,7 +137,7 @@ func TestMultiProofVerifyMultipleLeavesWithAbsentStem(t *testing.T) {
137137
}
138138

139139
cfg := GetConfig()
140-
if !VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg) {
140+
if ok, err := VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg); !ok || err != nil {
141141
t.Fatal("could not verify verkle proof")
142142
}
143143
}
@@ -159,7 +159,7 @@ func TestMultiProofVerifyMultipleLeavesCommitmentRedundancy(t *testing.T) {
159159
t.Fatal(err)
160160
}
161161
cfg := GetConfig()
162-
if !VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg) {
162+
if ok, err := VerifyVerkleProof(proof, pe.Cis, pe.Zis, pe.Yis, cfg); !ok || err != nil {
163163
t.Fatal("could not verify verkle proof")
164164
}
165165
}
@@ -174,7 +174,7 @@ func TestProofOfAbsenceInternalVerify(t *testing.T) {
174174
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{ffx32KeyTest}, nil)
175175

176176
cfg := GetConfig()
177-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
177+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
178178
t.Fatal("could not verify verkle proof")
179179
}
180180
}
@@ -189,7 +189,7 @@ func TestProofOfAbsenceLeafVerify(t *testing.T) {
189189
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{oneKeyTest}, nil)
190190

191191
cfg := GetConfig()
192-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
192+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
193193
t.Fatal("could not verify verkle proof")
194194
}
195195
}
@@ -208,7 +208,7 @@ func TestProofOfAbsenceLeafVerifyOtherSuffix(t *testing.T) {
208208
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{key}, nil)
209209

210210
cfg := GetConfig()
211-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
211+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
212212
t.Fatal("could not verify verkle proof")
213213
}
214214
}
@@ -227,7 +227,7 @@ func TestProofOfAbsenceStemVerify(t *testing.T) {
227227
proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{key}, nil)
228228

229229
cfg := GetConfig()
230-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
230+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
231231
t.Fatal("could not verify verkle proof")
232232
}
233233
}
@@ -378,7 +378,7 @@ func TestProofDeserialize(t *testing.T) {
378378
t.Fatal(err)
379379
}
380380
cfg := GetConfig()
381-
if !VerifyVerkleProof(deserialized, pe.Cis, pe.Zis, pe.Yis, cfg) {
381+
if ok, err := VerifyVerkleProof(deserialized, pe.Cis, pe.Zis, pe.Yis, cfg); !ok || err != nil {
382382
t.Fatal("could not verify verkle proof")
383383
}
384384
}
@@ -392,7 +392,7 @@ func TestProofOfAbsenceEdgeCase(t *testing.T) {
392392
ret, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030303")
393393
proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{ret}, nil)
394394
cfg := GetConfig()
395-
if !VerifyVerkleProof(proof, cs, zis, yis, cfg) {
395+
if ok, err := VerifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil {
396396
t.Fatal("could not verify proof")
397397
}
398398
}
@@ -411,7 +411,7 @@ func TestProofOfAbsenceOtherMultipleLeaves(t *testing.T) {
411411
ret2, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030301")
412412
proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{ret1, ret2}, nil)
413413
cfg := GetConfig()
414-
if !VerifyVerkleProof(proof, cs, zis, yis, cfg) {
414+
if ok, err := VerifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil {
415415
t.Fatal("could not verify proof")
416416
}
417417

@@ -432,7 +432,7 @@ func TestProofOfAbsenceNoneMultipleStems(t *testing.T) {
432432
ret2, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030200")
433433
proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, [][]byte{ret1, ret2}, nil)
434434
cfg := GetConfig()
435-
if !VerifyVerkleProof(proof, cs, zis, yis, cfg) {
435+
if ok, err := VerifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil {
436436
t.Fatal("could not verify proof")
437437
}
438438

Diff for: tree_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ func TestRustBanderwagonBlock48(t *testing.T) {
11881188
t.Logf("serialized proof=%v", vp)
11891189

11901190
cfg := GetConfig()
1191-
if !VerifyVerkleProof(proof, cis, zis, yis, cfg) {
1191+
if ok, err := VerifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil {
11921192
t.Fatal("proof didn't verify")
11931193
}
11941194

@@ -1206,7 +1206,7 @@ func TestRustBanderwagonBlock48(t *testing.T) {
12061206
t.Fatal(err)
12071207
}
12081208

1209-
if !VerifyVerkleProof(dproof, pe.Cis, pe.Zis, pe.Yis, cfg) {
1209+
if ok, err := VerifyVerkleProof(dproof, pe.Cis, pe.Zis, pe.Yis, cfg); !ok || err != nil {
12101210
t.Fatal("deserialized proof didn't verify")
12111211
}
12121212
}

0 commit comments

Comments
 (0)