diff --git a/pkg/crypto/keys/publickey.go b/pkg/crypto/keys/publickey.go index edf033998..38f4a22a7 100644 --- a/pkg/crypto/keys/publickey.go +++ b/pkg/crypto/keys/publickey.go @@ -189,6 +189,7 @@ func (p *PublicKey) DecodeBinary(r *io.BinReader) { ylsb := uint(prefix & 0x1) y, err = decodeCompressedY(x, ylsb) if err != nil { + r.Err = err return } case 0x04: diff --git a/pkg/crypto/keys/publickey_test.go b/pkg/crypto/keys/publickey_test.go index c7a8f7665..38f80adc1 100644 --- a/pkg/crypto/keys/publickey_test.go +++ b/pkg/crypto/keys/publickey_test.go @@ -63,6 +63,12 @@ func TestDecodeFromString(t *testing.T) { require.Error(t, err) } +func TestDecodeFromStringBadCompressed(t *testing.T) { + str := "02ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + _, err := NewPublicKeyFromString(str) + require.Error(t, err) +} + func TestPubkeyToAddress(t *testing.T) { pubKey, err := NewPublicKeyFromString("031ee4e73a17d8f76dc02532e2620bcb12425b33c0c9f9694cc2caa8226b68cad4") require.NoError(t, err)