core: fix key recovery interops return value

It's uncompressed coordinate, both X and Y, not just X. Fix #1043.
This commit is contained in:
Roman Khimov 2020-06-10 19:15:23 +03:00
parent a6541c4514
commit 7d786fac79
2 changed files with 3 additions and 3 deletions

View file

@ -626,7 +626,7 @@ func (ic *interopContext) eccRecover(curve elliptic.Curve, v *vm.VM) error {
v.Estack().PushVal([]byte{})
return nil
}
v.Estack().PushVal(pKey.Bytes()[1:])
v.Estack().PushVal(pKey.UncompressedBytes()[1:])
return nil
}

View file

@ -474,7 +474,7 @@ func TestSecp256k1Recover(t *testing.T) {
X: privateKey.PubKey().X,
Y: privateKey.PubKey().Y,
}
expected := pubKey.Bytes()[1:]
expected := pubKey.UncompressedBytes()[1:]
// We don't know which of two recovered keys suites, so let's try both.
putOnStackGetResult := func(isEven bool) []byte {
@ -505,7 +505,7 @@ func TestSecp256r1Recover(t *testing.T) {
messageHash := hash.Sha256(message).BytesBE()
signature := privateKey.Sign(message)
require.True(t, privateKey.PublicKey().Verify(signature, messageHash))
expected := privateKey.PublicKey().Bytes()[1:]
expected := privateKey.PublicKey().UncompressedBytes()[1:]
// We don't know which of two recovered keys suites, so let's try both.
putOnStackGetResult := func(isEven bool) []byte {