Skip to content

bip375: sync vendored DLEQ code with BIP-374 - #2304

Merged
jonatack merged 1 commit into
bitcoin:masterfrom
Bruce039:bip375-sync-dleq
Sep 25, 2026
Merged

jonatack merged 1 commit into
bitcoin:masterfrom
Bruce039:bip375-sync-dleq

Conversation

@Bruce039

Copy link
Copy Markdown
Contributor

bip-0375/deps/dleq.py is a copy of the BIP-374 reference code, used by the BIP-375 validator to check PSBT_GLOBAL_SP_DLEQ / PSBT_IN_SP_DLEQ proofs. It was taken before #2262, so it still uses the raw challenge hash as e and doesn't reject proofs with e >= n.

This applies the same two changes to the copy. After this the functions match bip-0374/reference.py line for line (apart from the unit tests). A challenge hash >= n has negligible probability, so nothing changes in practice: test_runner.py still passes all 42 vectors, and the 17 BIP-374 verify vectors give the same results before and after. It just keeps the copy from drifting from the spec.

bip-0375/deps/dleq.py is adapted from the BIP-374 reference code but
predates the change that treats the challenge e as a scalar (bitcoin#2262).
Reduce the challenge hash mod n and reject proofs with e >= n, so the
copy used by the BIP-375 validator matches the current BIP-374
reference.
@jonatack jonatack added the Fixups Minor fixups not worth bothering the BIP author(s) for label Sep 25, 2026

@jonatack jonatack left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK

These may go out of sync again. Out of scope for this PR, but better long-term options might be:

  • import from bip-0374/reference.py to have one source of truth, or
  • comment in dleq.py to keep in lockstep with bip-0374/reference.py

@jonatack
jonatack merged commit f4353ba into bitcoin:master Sep 25, 2026
4 checks passed
@jonatack

Copy link
Copy Markdown
Member

import from bip-0374/reference.py to have one source of truth

Done in #2309.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fixups Minor fixups not worth bothering the BIP author(s) for

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants