From 881459ff5e146a9c3c0a1824998af7eab7c71503 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 11 Jun 2025 14:55:25 +0200 Subject: [PATCH] crypto/secp256r1: remove check for (0, 0) --- crypto/secp256r1/verifier.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/crypto/secp256r1/verifier.go b/crypto/secp256r1/verifier.go index 9943000764..3378af2b21 100644 --- a/crypto/secp256r1/verifier.go +++ b/crypto/secp256r1/verifier.go @@ -23,21 +23,11 @@ import ( "math/big" ) -func newPublicKey(x, y *big.Int) *ecdsa.PublicKey { - if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) { - return nil - } - if x.Sign() == 0 && y.Sign() == 0 { - return nil - } - return &ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y} -} - // Verify checks the given signature (r, s) for the given hash and public key (x, y). func Verify(hash []byte, r, s, x, y *big.Int) bool { - publicKey := newPublicKey(x, y) - if publicKey == nil { + if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) { return false } - return ecdsa.Verify(publicKey, hash, r, s) + pk := &ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y} + return ecdsa.Verify(pk, hash, r, s) }