`Point.double()` gives infinity for a valid point on NIST192p
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- cryptography
Research direction
The affine doubling is Point.double() in the elliptic-curve module (src/ecdsa/ellipticcurve.py), and PointJacobi in the same file is the reference that gives the right answer. Start by reproducing the four-line snippet from the issue, then find where double() decides the result is infinity and check whether that test uses y or the slope. Done when P.double(), P + P and 2 * P return (2, p - y) for this point, match PointJacobi, and a regression test covering a zero slope with nonzero y is added.
Written by the indexing model from the issue text.
Description
Hi,
I've been using python-ecdsa as a reference while writing some test vectors for my own curve code, and ran into something odd with the affine Point class on NIST192p: doubling this point gives INFINITY.
from ecdsa.curves import NIST192p
from ecdsa.ellipticcurve import Point, PointJacobi
curve = NIST192p.curve
p, a, b = curve.p(), curve.a(), curve.b()
x = p - 1
y = pow(x**3 + a*x + b, (p + 1) // 4, p)
P = Point(curve, x, y) # on the curve, the constructor accepts it
print("P.double()", P.double())
print("P + P ", P + P)
print("2 * P ", 2 * P)
print("Jacobi ", PointJacobi.from_affine(P).double().to_affine())
Output:
P.double() infinity
P + P infinity
2 * P infinity
Jacobi (2,5150145059219101967911223597381767395814993794044679600504)
$y$ isn't 0 here, so the double shouldn't be infinity; it should be $(2,\ p - y)$, which is what PointJacobi gives. P + P and 2 * P are wrong the same way. This is with ecdsa 0.19.2 from pip.
Some potential clues: for this point $3x^2 + a \equiv 0 \pmod{p}$, so the slope in double() is 0 even though $y \neq 0$. I guess the zero slope ends up being treated as the infinity case, which is only right when $y = 0$.
Thank you!
- Dominant language
- Python
- Stars
- 976
- Forks
- 345
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 · 1 comment · 5 reactions ·
-
ecdsa.keys.VerifyingKey.verify_digest should fail for CurveEdTwPossibly taken @apoorvdarshan claimed this 139 days ago. Openbug 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 ·
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 35/100
tlsfuzzer/python-ecdsa#341 · 1 comment ·
-
Add type annotationsOpenmaintenance
Difficulty 5/5 Over a week Newbie friendliness 25/100
tlsfuzzer/python-ecdsa#340 · 4 comments · 1 reaction ·
All issues in tlsfuzzer/python-ecdsa
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug (unverified)
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
scikit-hep/awkward#4581 · 1 comment ·
Maintainers usually reply within 1 day
-
ci-cd priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
LearningCircuit/local-deep-research#9163 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
supersonic-lumina/ENM156#50 ·
Maintainers usually reply within 2 days