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 Roasbeef committed Oct 10, 2022
1 parent 4f64fe9 commit 7446802
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 7446802

Please sign in to comment.