-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench_test.go
73 lines (62 loc) · 1.81 KB
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"math/rand"
"testing"
multiproof "github.com/crate-crypto/go-ipa"
"github.com/crate-crypto/go-ipa/bandersnatch/fr"
"github.com/crate-crypto/go-ipa/common"
"github.com/gballet/go-verkle"
)
func BenchmarkTreeProofGeneration(b *testing.B) {
const numKeyValues = 10_000
const numRandKeyValues = 1_000_000
keyValues, tree := genRandomTree(rand.New(rand.NewSource(42)), numRandKeyValues)
tree.Commit()
keyvals := map[string][]byte{}
keys := make([][]byte, 0, numKeyValues)
for i, kv := range keyValues {
if i == numKeyValues {
break
}
keys = append(keys, kv.key)
keyvals[string(kv.key)] = kv.value
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, _, _, err := verkle.MakeVerkleMultiProof(tree, keys, keyvals)
if err != nil {
panic("failed to generate proof")
}
}
}
func BenchmarkProofCreation(b *testing.B) {
const numPolynomials = 128_000
conf := genOrLoadConfig("precomp")
cs, fs, zs := generateNRandomPolysEvals(conf, numPolynomials)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
transcriptProving := common.NewTranscript("bench")
multiproof.CreateMultiProof(transcriptProving, conf, cs, fs, zs)
}
}
func BenchmarkProofVerification(b *testing.B) {
const numPolynomials = 10_000
conf := genOrLoadConfig("precomp")
cs, fs, zs := generateNRandomPolysEvals(conf, numPolynomials)
transcriptProving := common.NewTranscript("bench")
proof := multiproof.CreateMultiProof(transcriptProving, conf, cs, fs, zs)
ys := make([]*fr.Element, len(zs))
for i, z := range zs {
ys[i] = &fs[i][z]
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
transcriptVerification := common.NewTranscript("bench")
if ok := multiproof.CheckMultiProof(transcriptVerification, conf, proof, cs, ys, zs); !ok {
panic("verification failed")
}
}
}