MAGIC - consider performance, just base zero check

This commit is contained in:
Emman 2021-02-25 13:55:40 +08:00
parent 586ab84f33
commit 798dbe465e

View File

@ -193,7 +193,7 @@ func Encrypt(random io.Reader, pub *ecdsa.PublicKey, msg []byte, opts *Encrypter
opts = &defaultEncrypterOpts opts = &defaultEncrypterOpts
} }
//A3, requirement is to check if h*P is infinite point, h is 1 //A3, requirement is to check if h*P is infinite point, h is 1
if (pub.X.Sign() == 0 && pub.Y.Sign() == 0) || !curve.IsOnCurve(pub.X, pub.Y) { if pub.X.Sign() == 0 && pub.Y.Sign() == 0 {
return nil, errors.New("SM2: invalid public key") return nil, errors.New("SM2: invalid public key")
} }
for { for {