Skip to content

Commit de36f94

Browse files
committed
Linter
1 parent 9ce4cbd commit de36f94

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

keystore/kms/asn1.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ func ASN1ToSEC1PublicKey(asn1PublicKey []byte) ([]byte, error) {
7171
if len(pubKeyBytes) == 64 {
7272
// BitString is 64 bytes (X || Y), prepend 0x04
7373
pubKeyBytes = append([]byte{0x04}, pubKeyBytes...)
74-
} else if len(pubKeyBytes) == 65 && pubKeyBytes[0] == 0x04 {
75-
// BitString already has 0x04 prefix (KMS format), use as-is
76-
} else {
74+
} else if len(pubKeyBytes) != 65 || pubKeyBytes[0] != 0x04 {
7775
return nil, fmt.Errorf("invalid public key length in BitString: expected 64 or 65 bytes, got %d", len(pubKeyBytes))
7876
}
77+
// BitString already has 0x04 prefix (KMS format), use as-is
7978

8079
pubKey, err := crypto.UnmarshalPubkey(pubKeyBytes)
8180
if err != nil {

keystore/kms/asn1_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"testing"
55

66
"github.com/ethereum/go-ethereum/crypto"
7-
kms "github.com/smartcontractkit/chainlink-common/keystore/kms"
87
"github.com/stretchr/testify/require"
8+
9+
kms "github.com/smartcontractkit/chainlink-common/keystore/kms"
910
)
1011

1112
func TestSEC1ToASN1PublicKey(t *testing.T) {
@@ -26,8 +27,9 @@ func TestSEC1ToASN1PublicKey(t *testing.T) {
2627
require.NoError(t, err)
2728
require.Len(t, sec1PubKey2, 65)
2829
require.Equal(t, byte(0x04), sec1PubKey2[0])
29-
require.Equal(t, privateKey.PublicKey.X.Bytes(), sec1PubKey2[1:33])
30-
require.Equal(t, privateKey.PublicKey.Y.Bytes(), sec1PubKey2[33:65])
30+
pubKey := privateKey.PublicKey
31+
require.Equal(t, pubKey.X.Bytes(), sec1PubKey2[1:33])
32+
require.Equal(t, pubKey.Y.Bytes(), sec1PubKey2[33:65])
3133
}
3234

3335
func TestASN1SignatureToSEC1Signature(t *testing.T) {

keystore/kms/keystore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/aws/aws-sdk-go/aws"
99
kmslib "github.com/aws/aws-sdk-go/service/kms"
10+
1011
"github.com/smartcontractkit/chainlink-common/keystore"
1112
)
1213

@@ -146,7 +147,6 @@ func (k *keystoreSignerReader) Sign(ctx context.Context, req keystore.SignReques
146147
default:
147148
return keystore.SignResponse{}, fmt.Errorf("key %s: %w", req.KeyName, keystore.ErrInvalidSignRequest)
148149
}
149-
150150
}
151151

152152
func (k *keystoreSignerReader) Verify(ctx context.Context, req keystore.VerifyRequest) (keystore.VerifyResponse, error) {

keystore/kms/keystore_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"testing"
55

66
"github.com/ethereum/go-ethereum/crypto"
7+
"github.com/stretchr/testify/require"
8+
79
"github.com/smartcontractkit/chainlink-common/keystore"
810
kms "github.com/smartcontractkit/chainlink-common/keystore/kms"
9-
"github.com/stretchr/testify/require"
1011
)
1112

1213
func TestKMSKeystore(t *testing.T) {

0 commit comments

Comments
 (0)