TypeError instead of InvalidPointError on VerifyingKey.from_public_point(INFINITY)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- cryptography
Research direction
Start at VerifyingKey.from_public_point in ecdsa/keys.py and follow the Public_key validation in ecdsa/ecdsa.py shown in the traceback. Reproduce the call with INFINITY and verify that point validation raises the intended malformed-point exception instead of TypeError; the related question also concerns how the infinity point is identified.
Written by the indexing model from the issue text.
Description
I was experimenting to understand how the library handles failures. I don't expect the following line to work but I do expect it to raise a different error (MalformedPoint, not Type).
VerifyingKey.from_public_point(INFINITY)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 VerifyingKey.from_public_point(INFINITY)
File ~/miniconda3/envs/de/lib/python3.9/site-packages/ecdsa/keys.py:170, in VerifyingKey.from_public_point(cls, point, curve, hashfunc, validate_point)
168 self.default_hashfunc = hashfunc
169 try:
--> 170 self.pubkey = ecdsa.Public_key(
171 curve.generator, point, validate_point
172 )
173 except ecdsa.InvalidPointError:
174 raise MalformedPointError("Point does not lay on the curve")
File ~/miniconda3/envs/de/lib/python3.9/site-packages/ecdsa/ecdsa.py:151, in Public_key.__init__(self, generator, point, verify)
149 n = generator.order()
150 p = self.curve.p()
--> 151 if not (0 <= point.x() < p) or not (0 <= point.y() < p):
152 raise InvalidPointError(
153 "The public point has x or y out of range."
154 )
155 if verify and not self.curve.contains_point(point.x(), point.y()):
TypeError: '<=' not supported between instances of 'int' and 'NoneType'
Related: for cases where one wishes to avoid the point at infinity is this the right way to detect it if point == ellipticcurve.INFINITY? I kind of expected infinity to vary by the curve family but there's nothing under eg SECKP256k1 that I can find.
- Dominant language
- Python
- Stars
- 973
- Forks
- 343
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tlsfuzzer/python-ecdsa
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tlsfuzzer/python-ecdsa#381 ·
-
bug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
tlsfuzzer/python-ecdsa#349 · 1 comment ·
-
feature help wanted
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tlsfuzzer/python-ecdsa#348 · 1 comment ·
-
Add type annotations Openmaintenance
Difficulty 5/5 Over a week Newbie friendliness 25/100
tlsfuzzer/python-ecdsa#340 · 4 comments · 1 reaction ·
-
remove `hmac_compat` Openmaintenance
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
tlsfuzzer/python-ecdsa#316 ·
All issues in tlsfuzzer/python-ecdsa
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100