Skip to content

Commit

Permalink
Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
danyalprout committed Apr 23, 2024
1 parent 6503f50 commit 91b12c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions core/vm/testdata/precompiles/p256Verify.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
2 changes: 1 addition & 1 deletion crypto/secp256r1/publickey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion crypto/secp256r1/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 91b12c0

Please sign in to comment.