mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
crypto/secp256r1: remove check for (0, 0)
This commit is contained in:
parent
e8c3207261
commit
881459ff5e
1 changed files with 3 additions and 13 deletions
|
|
@ -23,21 +23,11 @@ import (
|
||||||
"math/big"
|
"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).
|
// 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 {
|
func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
||||||
publicKey := newPublicKey(x, y)
|
if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) {
|
||||||
if publicKey == nil {
|
|
||||||
return false
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue