mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
keys: fix bad compressed public key decoding, add a test
The error was not propagated properly here.
This commit is contained in:
parent
b246653f62
commit
5ac8cae221
2 changed files with 7 additions and 0 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue