Skip to content

Commit

Permalink
btcec: check if recovered pk is at point of infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden authored and jcvernaleo committed Sep 13, 2021
1 parent 3e2d846 commit 73f7eac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions btcec/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 73f7eac

Please sign in to comment.