@@ -15,13 +15,11 @@ import (
15
15
//
16
16
// TODO: rethink this function and consider moving/refactoring it.
17
17
func VerifyByOperators (s spectypes.Signature , data spectypes.MessageSignature , domain spectypes.DomainType , sigType spectypes.SignatureType , operators []* spectypes.Operator ) error {
18
- // decode sig
19
18
sign := & bls.Sign {}
20
19
if err := sign .Deserialize (s ); err != nil {
21
20
return errors .Wrap (err , "failed to deserialize signature" )
22
21
}
23
22
24
- // find operators
25
23
pks := make ([]bls.PublicKey , 0 )
26
24
for _ , id := range data .GetSigners () {
27
25
found := false
@@ -41,50 +39,11 @@ func VerifyByOperators(s spectypes.Signature, data spectypes.MessageSignature, d
41
39
}
42
40
}
43
41
44
- // compute root
45
42
computedRoot , err := spectypes .ComputeSigningRoot (data , spectypes .ComputeSignatureDomain (domain , sigType ))
46
43
if err != nil {
47
44
return errors .Wrap (err , "could not compute signing root" )
48
45
}
49
46
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
88
47
if res := sign .FastAggregateVerify (pks , computedRoot [:]); ! res {
89
48
return errors .New ("failed to verify signature" )
90
49
}
@@ -109,8 +68,7 @@ func VerifyReconstructedSignature(sig *bls.Sign, validatorPubKey []byte, root [3
109
68
return errors .Wrap (err , "could not deserialize validator pk" )
110
69
}
111
70
112
- // verify reconstructed sig
113
- if res := Verifier .AggregateVerify (sig , []bls.PublicKey {pk }, root ); ! res {
71
+ if res := sig .VerifyByte (& pk , root [:]); ! res {
114
72
return errors .New ("could not reconstruct a valid signature" )
115
73
}
116
74
return nil
0 commit comments