`verify()` raises `TypeError` instead of rejecting when `u1*G + u2*Q` is the point at infinity
まだ誰も着手していません。
評価
- 難易度
- 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分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
-
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 件 ·
メンテナーはふだん 1 日以内に返信
-
[Resource]: Flavianオープン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 日以内に返信