Skip to content

Commit af3124f

Browse files
committed
Disable batch verifier
1 parent 6720231 commit af3124f

File tree

2 files changed

+2
-49
lines changed

2 files changed

+2
-49
lines changed

protocol/v2/types/batch_verifier.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package types
22

33
import (
44
"fmt"
5-
"runtime"
65
"sync"
76
"sync/atomic"
87
"time"
@@ -13,11 +12,7 @@ import (
1312
"golang.org/x/exp/maps"
1413
)
1514

16-
var Verifier = NewBatchVerifier(runtime.NumCPU(), 10, time.Millisecond*5)
17-
18-
func init() {
19-
go Verifier.Start()
20-
}
15+
// TODO: remove the file after switching to RSA
2116

2217
const messageSize = 32
2318

protocol/v2/types/crypto.go

+1-43
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ import (
1515
//
1616
// TODO: rethink this function and consider moving/refactoring it.
1717
func VerifyByOperators(s spectypes.Signature, data spectypes.MessageSignature, domain spectypes.DomainType, sigType spectypes.SignatureType, operators []*spectypes.Operator) error {
18-
// decode sig
1918
sign := &bls.Sign{}
2019
if err := sign.Deserialize(s); err != nil {
2120
return errors.Wrap(err, "failed to deserialize signature")
2221
}
2322

24-
// find operators
2523
pks := make([]bls.PublicKey, 0)
2624
for _, id := range data.GetSigners() {
2725
found := false
@@ -41,50 +39,11 @@ func VerifyByOperators(s spectypes.Signature, data spectypes.MessageSignature, d
4139
}
4240
}
4341

44-
// compute root
4542
computedRoot, err := spectypes.ComputeSigningRoot(data, spectypes.ComputeSignatureDomain(domain, sigType))
4643
if err != nil {
4744
return errors.Wrap(err, "could not compute signing root")
4845
}
4946

50-
// verify
51-
// if res := sign.FastAggregateVerify(pks, computedRoot[:]); !res {
52-
// return errors.New("failed to verify signature")
53-
// }
54-
if res := Verifier.AggregateVerify(sign, pks, computedRoot); !res {
55-
return SingleVerifyByOperators(sign, data, domain, sigType, operators)
56-
}
57-
return nil
58-
}
59-
60-
func SingleVerifyByOperators(sign *bls.Sign, data spectypes.MessageSignature, domain spectypes.DomainType, sigType spectypes.SignatureType, operators []*spectypes.Operator) error {
61-
// find operators
62-
pks := make([]bls.PublicKey, 0)
63-
for _, id := range data.GetSigners() {
64-
found := false
65-
for _, n := range operators {
66-
if id == n.GetID() {
67-
pk, err := DeserializeBLSPublicKey(n.GetPublicKey())
68-
if err != nil {
69-
return errors.Wrap(err, "failed to deserialize public key")
70-
}
71-
72-
pks = append(pks, pk)
73-
found = true
74-
}
75-
}
76-
if !found {
77-
return errors.New("unknown signer")
78-
}
79-
}
80-
81-
// compute root
82-
computedRoot, err := spectypes.ComputeSigningRoot(data, spectypes.ComputeSignatureDomain(domain, sigType))
83-
if err != nil {
84-
return errors.Wrap(err, "could not compute signing root")
85-
}
86-
87-
// verify
8847
if res := sign.FastAggregateVerify(pks, computedRoot[:]); !res {
8948
return errors.New("failed to verify signature")
9049
}
@@ -109,8 +68,7 @@ func VerifyReconstructedSignature(sig *bls.Sign, validatorPubKey []byte, root [3
10968
return errors.Wrap(err, "could not deserialize validator pk")
11069
}
11170

112-
// verify reconstructed sig
113-
if res := Verifier.AggregateVerify(sig, []bls.PublicKey{pk}, root); !res {
71+
if res := sig.VerifyByte(&pk, root[:]); !res {
11472
return errors.New("could not reconstruct a valid signature")
11573
}
11674
return nil

0 commit comments

Comments
 (0)