Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24 from O3Labs/verify-signature
Browse files Browse the repository at this point in the history
added verify
  • Loading branch information
apisit committed Jun 4, 2018
2 parents da5524b + 748947e commit 781844b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions neoutils/btckey/btckey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions neoutils/neowallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion neoutils/smartcontract/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion neoutils/version.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 781844b

Please sign in to comment.