Skip to content

Fix TypeError when passing INFINITY to VerifyingKey.from_public_point()#378

Open
gaoflow wants to merge 1 commit into
tlsfuzzer:masterfrom
gaoflow:fix-infinity-type-error-341
Open

Fix TypeError when passing INFINITY to VerifyingKey.from_public_point()#378
gaoflow wants to merge 1 commit into
tlsfuzzer:masterfrom
gaoflow:fix-infinity-type-error-341

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 25, 2026

Copy link
Copy Markdown

Problem

Passing ellipticcurve.INFINITY to VerifyingKey.from_public_point() raises a TypeError instead of the documented MalformedPointError:

>>> from ecdsa.keys import VerifyingKey
>>> from ecdsa.ellipticcurve import INFINITY
>>> VerifyingKey.from_public_point(INFINITY)
TypeError: '<=' not supported between instances of 'int' and 'NoneType'

Reported in #341.

Root cause

INFINITY is Point(None, None, None), so INFINITY.x() returns None. Public_key.__init__ evaluated 0 <= point.x() < p before checking for the point at infinity, producing a TypeError. Additionally, PointJacobi.from_affine(INFINITY) wraps INFINITY into a PointJacobi with x=None, so the TypeError happened before the except ecdsa.InvalidPointError handler in from_public_point could convert it to MalformedPointError.

Fix

Two guard lines — one in each layer:

  1. ecdsa.pyPublic_key.__init__: check point == ellipticcurve.INFINITY and raise InvalidPointError before any coordinate access.
  2. keys.pyVerifyingKey.from_public_point: check point == ellipticcurve.INFINITY and raise MalformedPointError before the from_affine conversion.

A regression test is included.


This pull request was prepared with the assistance of AI, under my direction and review.

Passing `ellipticcurve.INFINITY` to `VerifyingKey.from_public_point()`
raised a `TypeError` ('<=' not supported between instances of 'int' and
'NoneType') instead of the documented `MalformedPointError`.

The root cause: `INFINITY.x()` returns `None`, and `Public_key.__init__`
compared `0 <= point.x() < p` before checking for the point at infinity.
`PointJacobi.from_affine(INFINITY)` also produced a PointJacobi with
`x=None`, so the TypeError occurred inside `Public_key.__init__` rather
than being caught and re-raised as `MalformedPointError`.

Fix by adding an explicit INFINITY guard in both `Public_key.__init__`
(raises `InvalidPointError`) and `VerifyingKey.from_public_point`
(raises `MalformedPointError`) before any coordinate access.

Fixes tlsfuzzer#341.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant