btcec: check if recovered pk is at point of infinity

This commit is contained in:
Marius van der Wijden 2021-09-13 21:11:26 +02:00 committed by John C. Vernaleo
parent 3e2d8464f1
commit 73f7eac903

View file

@ -353,6 +353,10 @@ func recoverKeyFromSignature(curve *KoblitzCurve, sig *Signature, msg []byte,
// step to prevent the jacobian conversion back and forth.
Qx, Qy := curve.Add(sRx, sRy, minuseGx, minuseGy)
if Qx.Sign() == 0 && Qy.Sign() == 0 {
return nil, errors.New("point (Qx, Qy) equals the point at infinity")
}
return &PublicKey{
Curve: curve,
X: Qx,