diff --git a/neoutils/btckey/btckey.go b/neoutils/btckey/btckey.go index b1c1a0e..32f4ed7 100644 --- a/neoutils/btckey/btckey.go +++ b/neoutils/btckey/btckey.go @@ -645,6 +645,9 @@ func Verify(publicKey []byte, signature []byte, hash []byte) bool { p.Curve = elliptic.P256() p.X = pub.X p.Y = pub.Y + if p.X == nil || p.Y == nil { + return false + } rBytes := new(big.Int).SetBytes(signature[0:32]) sBytes := new(big.Int).SetBytes(signature[32:64]) return ecdsa.Verify(p, hash, rBytes, sBytes) diff --git a/neoutils/neowallet.go b/neoutils/neowallet.go index d5b1055..1383457 100644 --- a/neoutils/neowallet.go +++ b/neoutils/neowallet.go @@ -136,3 +136,8 @@ func (w *Wallet) ComputeSharedSecret(publicKey []byte) []byte { func Sign(data []byte, key string) ([]byte, error) { return btckey.Sign(data, key) } + +// Verify signed hash using public key +func Verify(publicKey []byte, signature []byte, hash []byte) bool { + return btckey.Verify(publicKey, signature, hash) +} diff --git a/neoutils/smartcontract/parser_test.go b/neoutils/smartcontract/parser_test.go index b879864..27186b9 100644 --- a/neoutils/smartcontract/parser_test.go +++ b/neoutils/smartcontract/parser_test.go @@ -172,7 +172,7 @@ func TestParserNEP5Transfer(t *testing.T) { func TestParserNEP5TransferAnother(t *testing.T) { - p := smartcontract.NewParserWithScript("08bc3469730500000014f7eb6fc7827b6f56b92eae3610d041f93e34515214cf319d51f799ce27677782f599d154623c7abf0653c1087472616e7366657267187fc13bec8ff0906c079e7f4cc8276709472913") + p := smartcontract.NewParserWithScript("0500f902950014d7d92d13e360f3e8040b572a7d665951bf1ab7fb14b0b382920911028a2f90fcc93a69372375cbb89b53c1087472616e7366657267187fc13bec8ff0906c079e7f4cc8276709472913") //the order of your method signature has the be exact to the one //in your deployed smart contract diff --git a/neoutils/version.go b/neoutils/version.go index af35026..442e5a3 100644 --- a/neoutils/version.go +++ b/neoutils/version.go @@ -1,9 +1,13 @@ package neoutils const ( - VERSION = "1.0.5" + VERSION = "1.0.6" ) +//RELEASE NOTES +// V. 1.0.6 +// - Added Verify method to verify signed data + //RELEASE NOTES // V. 1.0.5 // - Added NEP6 Wallet format