`verify()` raises `TypeError` instead of rejecting when `u1*G + u2*Q` is the point at infinity
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 90/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cryptography, python
- 领域
- cryptography, security
调研方向
从 src/ecdsa/ecdsa.py 中的 Public_key.verifies 开始,其中 xy 是在 mul_add 和 plain 分支之后计算的。使用 r = s = 1 和公钥 Q = -e*G 运行提供的复现程序,以确认 TypeError,然后修改验证路径,使其拒绝无穷远点,而不是计算其 x 坐标。使用提到的 Wycheproof ecdsa_brainpool*_test.json 用例添加或更新回归测试,并确认验证会抛出 BadSignatureError。
由索引模型根据 Issue 内容生成。
描述
Versions: python-ecdsa 0.19.2 (latest release), CPython 3.13.15. The code path is unchanged on master as of
2026-11-28 (src/ecdsa/ecdsa.py, Public_key.verifies).
What happens
When the verification sum u1*G + u2*Q is the point at infinity, Public_key.verifies evaluates
v = xy.x() % n with xy.x() returning None, so VerifyingKey.verify() raises
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
instead of BadSignatureError. This happens for a valid public key and a signature with r and s in [1, n-1],
on every curve (reproduced on NIST P-256 and brainpoolP256r1). A caller that catches only BadSignatureError, as the
documentation suggests, gets an unhandled exception on attacker-chosen input.
No forgery: the signature is never accepted.
Reproducer (no test vectors needed)
Choose r = s = 1 and the public key Q = -e*G, so u1*G + u2*Q = e*G - e*G = O:
import hashlib, ecdsa
from ecdsa import VerifyingKey, BadSignatureError
from ecdsa.curves import NIST256p
from ecdsa.util import sigencode_der, sigdecode_der
msg = b"point at infinity during verify"
n, G = NIST256p.order, NIST256p.generator
e = int.from_bytes(hashlib.sha256(msg).digest(), "big")
vk = VerifyingKey.from_public_point(G * ((-e) % n), curve=NIST256p, hashfunc=hashlib.sha256)
try:
vk.verify(sigencode_der(1, 1, n), msg, sigdecode=sigdecode_der)
except BadSignatureError:
print("rejected (expected)")
# actual on 0.19.2: TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
pyca/cryptography rejects the same key, signature and message with InvalidSignature.
The same exception is raised on the Wycheproof testvectors_v1 cases flagged PointDuplication /
ArithmeticError ("duplication bug", "point at infinity during verify", "comparison with point at infinity"):
67 test cases across the five ecdsa_brainpool*_test.json files.
Suggested fix
In Public_key.verifies, after computing xy (both the mul_add and the plain branch):
if xy == ellipticcurve.INFINITY:
return False
Related, but a different path: #341 (TypeError instead of InvalidPointError from
VerifyingKey.from_public_point(INFINITY)).
- 主要语言
- Python
- 星标
- 975
- 派生
- 346
- 平均合并
- 26 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tlsfuzzer/python-ecdsa 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
tlsfuzzer/python-ecdsa#387 ·
-
难度 3/5 1-2 天 新手友好度 76/100
tlsfuzzer/python-ecdsa#390 ·
-
难度 4/5 3-5 天 新手友好度 35/100
tlsfuzzer/python-ecdsa#381 · 1 条评论 · 5 个 reaction ·
-
ecdsa.keys.VerifyingKey.verify_digest should fail for CurveEdTw可能已有人在做 @apoorvdarshan 于 143 天前认领。 未关闭bug help wanted
难度 2/5 1-3 小时 新手友好度 45/100
tlsfuzzer/python-ecdsa#349 · 1 条评论 ·
-
feature help wanted
难度 4/5 3-5 天 新手友好度 35/100
tlsfuzzer/python-ecdsa#348 · 1 条评论 ·
查看 tlsfuzzer/python-ecdsa 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
comet-ml/opik#9877 · 1 个 reaction ·
维护者通常 1 天内回复
-
resource-submission validation-passed
难度 1/5 1 小时以内 新手友好度 80/100
hesreallyhim/awesome-claude-code#3736 · 1 条评论 ·
-
area: trackers bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Review: WordPress copy/snapshot download media with no size cap and a hostname-only origin check未关闭performance product:quill
难度 2/5 1-3 小时 新手友好度 72/100
Community-Access/quill#2634 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复