Skip to content

DLEQ follows BIP374 0.3.0: reduce the challenge, refuse e >= n (closes #149) - #153

Merged
fametrano merged 1 commit into
mainfrom
ecc-149-dleq-bip374-0.3
Oct 7, 2026
Merged

fametrano merged 1 commit into
mainfrom
ecc-149-dleq-bip374-0.3

Conversation

@fametrano

@fametrano fametrano commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

DLEQ proofs now follow BIP374 0.3.0. The challenge is the tagged hash reduced modulo n, and a proof with e >= n is refused with its own error, as the BIP's reference does since bitcoin/bips#2262.

The answer changes only for an honest 0.2.0 proof whose hash is n or more, about once in 2^128. A forged e >= n was already refused, by the challenge comparison. The new tests force the challenge hash above n, and try e = n, n + 1 and the largest 32-byte value.

Closes #149

🤖 Generated with Claude Code

Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 btclib-ecc | 🛠️ Build #34981457 | 📁 Comparing 7a11cbf against latest (11f2741)

  🔍 Preview build  

2 files changed
± changelog_link.html
± _modules/btclib_ecc/ecc/dleq.html

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7a11cbf. This job ran no gates; the workflows on this sha are what stands. Neither the pull request nor the commit says what the author ran.

No findings. The change does everything #149 asks, including the correction in its comments that limits this pull request to the code. Both new tests fail without the change. On main, an e of n or more fails with "invalid challenge", not "e not in 0..n-1". An unreduced challenge would put n + 5, not 5, in the generated proof. Verification uses only public values, and no computation moves between the bindings and the Python arithmetic.

Not checked: BIP374 0.3.0 and its reference.py were not opened from bitcoin/bips. The e >= GE.ORDER line cited in _assert_structurally_valid_ was checked against #149's account of the reference, not the reference itself.

Not about this pull request (a wording note, not filed): tests/_data/README.md:590-592 says s >= n has no vector in either BIP374 file. Rows 17 and 18 of test_vectors_verify_proof.csv are the e = n and s = n cases, and the new docstring at tests/ecc/dleq_test.py:154 says so correctly.

ACK 7a11cbf

@fametrano
fametrano enabled auto-merge (squash) October 6, 2026 23:20
@fametrano
fametrano force-pushed the ecc-149-dleq-bip374-0.3 branch from 7a11cbf to 3bf8c0a Compare October 7, 2026 08:28
…#149)

The challenge hash is reduced modulo n and verification refuses an e of
n or more, as BIP374 0.3.0 says (bips#2262). The tests make both
observable: a verify with e = n, n + 1 and 2^256 - 1, and a challenge
hash forced above n.

Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net>
@fametrano
fametrano force-pushed the ecc-149-dleq-bip374-0.3 branch from 3bf8c0a to 9ac8928 Compare October 7, 2026 08:29
@fametrano
fametrano merged commit 3052e7a into main Oct 7, 2026
1 of 11 checks passed
@fametrano
fametrano deleted the ecc-149-dleq-bip374-0.3 branch October 7, 2026 08:30
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.

DLEQ follows BIP374 0.2: the challenge is not reduced mod n and e >= n is not refused

1 participant