diff --git a/core/vm/testdata/precompiles/p256Verify.json b/core/vm/testdata/precompiles/p256Verify.json index 662c55fb12..cbd64de6db 100644 --- a/core/vm/testdata/precompiles/p256Verify.json +++ b/core/vm/testdata/precompiles/p256Verify.json @@ -5444,5 +5444,26 @@ "Gas": 3450, "Name": "wycheproof/ecdsa_webcrypto_test.json EcdsaP1363Verify SHA-256 #311: y-coordinate of the public key is large", "NoBenchmark": false + }, + { + "Input": "2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f9170bebe684cdcb5ca72a42f0d873879359bd1781a591809947628d313a3814f67aec03aca8f5587a4d535fa31027bbe9cc0e464b1c3577f4c2dcde6b2094798a90000000000000000000000000000000000000000000000000000000000000000fffffffeecad44b6f05d15b33146549c2297b522a5eed8430cff596758e6c43d", + "Expected": "", + "Gas": 3450, + "Name": "invalid public key x param errors", + "NoBenchmark": false + }, + { + "Input": "2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f9170bebe684cdcb5ca72a42f0d873879359bd1781a591809947628d313a3814f67aec03aca8f5587a4d535fa31027bbe9cc0e464b1c3577f4c2dcde6b2094798a9bcbb2914c79f045eaa6ecbbc612816b3be5d2d6796707d8125e9f851c18af0150000000000000000000000000000000000000000000000000000000000000000", + "Expected": "", + "Gas": 3450, + "Name": "invalid public key y param errors", + "NoBenchmark": false + }, + { + "Input": "2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f9170bebe684cdcb5ca72a42f0d873879359bd1781a591809947628d313a3814f67aec03aca8f5587a4d535fa31027bbe9cc0e464b1c3577f4c2dcde6b2094798a900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Expected": "", + "Gas": 3450, + "Name": "reference point errors", + "NoBenchmark": false } ] \ No newline at end of file diff --git a/crypto/secp256r1/publickey.go b/crypto/secp256r1/publickey.go index 9b84044efa..8445f4f348 100644 --- a/crypto/secp256r1/publickey.go +++ b/crypto/secp256r1/publickey.go @@ -6,7 +6,7 @@ import ( "math/big" ) -// Generates approptiate public key format from given coordinates +// Generates appropriate public key format from given coordinates func newPublicKey(x, y *big.Int) *ecdsa.PublicKey { // Check if the given coordinates are valid if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) { diff --git a/crypto/secp256r1/verifier.go b/crypto/secp256r1/verifier.go index ccc0786610..ffb4839d8d 100644 --- a/crypto/secp256r1/verifier.go +++ b/crypto/secp256r1/verifier.go @@ -5,7 +5,8 @@ import ( "math/big" ) -// Verifies the given signature (r, s) for the given hash and public key (x, y). +// Verify verifies the given signature (r, s) for the given hash and public key (x, y). +// It returns true if the signature is valid, false otherwise. func Verify(hash []byte, r, s, x, y *big.Int) bool { // Create the public key format publicKey := newPublicKey(x, y)