Skip to content

Commit d91bd63

Browse files
committed
more nits
1 parent 0ac260a commit d91bd63

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

simplex/bls.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package simplex
22

33
import (
44
"encoding/asn1"
5+
"errors"
56
"fmt"
67
"simplex"
78

@@ -10,7 +11,8 @@ import (
1011
)
1112

1213
var (
13-
errSignatureVerificationFailed = fmt.Errorf("signature verification failed")
14+
errSignatureVerificationFailed = errors.New("signature verification failed")
15+
errSignerNotFound = errors.New("signer not found in the membership set")
1416
)
1517

1618
type SignFunc func(msg []byte) (*bls.Signature, error)
@@ -81,7 +83,7 @@ func (v BLSVerifier) Verify(message []byte, signature []byte, signer simplex.Nod
8183
key := ids.NodeID(signer)
8284
pk, exists := v.nodeID2PK[key]
8385
if !exists {
84-
return fmt.Errorf("signer %x is not found in the membership set", key)
86+
return fmt.Errorf("%w: signer %x", errSignerNotFound, key)
8587
}
8688

8789
sig, err := bls.SignatureFromBytes(signature)

simplex/bls_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type testValidatorInfo struct {
1818
validators map[ids.NodeID]validators.Validator
1919
}
2020

21-
func (v *testValidatorInfo) GetValidatorIDs(subnetID ids.ID) []ids.NodeID {
21+
func (v *testValidatorInfo) GetValidatorIDs(_ ids.ID) []ids.NodeID {
2222
if v.validators == nil {
2323
return nil
2424
}
@@ -30,7 +30,7 @@ func (v *testValidatorInfo) GetValidatorIDs(subnetID ids.ID) []ids.NodeID {
3030
return ids
3131
}
3232

33-
func (v *testValidatorInfo) GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*validators.Validator, bool) {
33+
func (v *testValidatorInfo) GetValidator(_ ids.ID, nodeID ids.NodeID) (*validators.Validator, bool) {
3434
if v.validators == nil {
3535
return nil, false
3636
}
@@ -64,14 +64,14 @@ func newTestValidatorInfo(nodeIds []ids.NodeID, pks []*bls.PublicKey) *testValid
6464
func newEngineConfig(ls *localsigner.LocalSigner) *Config {
6565
nodeID := ids.GenerateTestNodeID()
6666

67-
SimplexChainContext := SimplexChainContext{
67+
simplexChainContext := SimplexChainContext{
6868
NodeID: nodeID,
6969
ChainID: ids.GenerateTestID(),
7070
SubnetID: ids.GenerateTestID(),
7171
}
7272

7373
return &Config{
74-
Ctx: SimplexChainContext,
74+
Ctx: simplexChainContext,
7575
Validators: newTestValidatorInfo([]ids.NodeID{nodeID}, []*bls.PublicKey{ls.PublicKey()}),
7676
SignBLS: ls.Sign,
7777
}
@@ -108,7 +108,7 @@ func TestSignerNotInMemberSet(t *testing.T) {
108108

109109
notInMembershipSet := ids.GenerateTestNodeID()
110110
err = verifier.Verify([]byte(msg), sig, notInMembershipSet[:])
111-
require.ErrorContains(t, err, "not found in the membership set")
111+
require.ErrorIs(t, err, errSignerNotFound)
112112
}
113113

114114
func TestSignerInvalidMessageEncoding(t *testing.T) {
@@ -125,6 +125,6 @@ func TestSignerInvalidMessageEncoding(t *testing.T) {
125125
sigBytes := bls.SignatureToBytes(sig)
126126

127127
_, verifier := NewBLSAuth(config)
128-
err = verifier.Verify([]byte(dummyMsg), sigBytes, config.Ctx.NodeID[:])
128+
err = verifier.Verify(dummyMsg, sigBytes, config.Ctx.NodeID[:])
129129
require.ErrorIs(t, err, errSignatureVerificationFailed)
130130
}

0 commit comments

Comments
 (0)