Skip to content

BIP-374 DLEQ Proofs#126

Open
notTanveer wants to merge 2 commits into
diybitcoinhardware:masterfrom
notTanveer:BIP-374
Open

BIP-374 DLEQ Proofs#126
notTanveer wants to merge 2 commits into
diybitcoinhardware:masterfrom
notTanveer:BIP-374

Conversation

@notTanveer

Copy link
Copy Markdown

added support for BIP-374 DLEQ proofs.
adapted from: https://github.com/bitcoin/bips/blob/master/bip-0374/reference.py

Copilot AI review requested due to automatic review settings May 15, 2026 21:05
@notTanveer notTanveer requested review from miketlk and odudex as code owners May 15, 2026 21:05

Copilot AI 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.

Pull request overview

Adds a new embit.dleq module implementing BIP-374 DLEQ (Discrete Log Equality) proof generation and verification, together with the official BIP-374 generate/verify test vectors and a test runner.

Changes:

  • New src/embit/dleq.py providing generate_dleq_proof/verify_dleq_proof plus a DLEQError exception, built on top of the existing util.secp256k1 bindings and tagged_hash.
  • New tests/tests/test_dleq.py running the official BIP-374 generate-proof and verify-proof vectors from CSV files.
  • New CSV data files (test_vectors_generate_proof.csv, test_vectors_verify_proof.csv) containing the BIP-374 reference vectors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/embit/dleq.py Core BIP-374 generate/verify implementation, with helper to support arbitrary base G via parse+tweak_mul.
tests/tests/test_dleq.py Drives both BIP-374 vector sets, mapping INFINITY to a fake malformed pubkey for the generate case.
tests/tests/data/test_vectors_generate_proof.csv Official BIP-374 generate-proof vectors.
tests/tests/data/test_vectors_verify_proof.csv Official BIP-374 verify-proof vectors (success, swapped points, tampered proof/message).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/embit/dleq.py Outdated
Comment on lines +59 to +61
with the same (a, B) and no m leaks a (fn.1). Since
v0.2.0, m is also mixed in, removing the leak when m differs
(fn.4), but fresh r is still required. Defaults to os.urandom(32).
Comment thread tests/tests/test_dleq.py
_DATA_DIR = Path(__file__).parent / "data"
_GENERATE_CSV = _DATA_DIR / "test_vectors_generate_proof.csv"
_VERIFY_CSV = _DATA_DIR / "test_vectors_verify_proof.csv"
_FAKE_INFINITY = b"\x02" + b"\x00" * 32 # x=0 is not on secp256k1
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.

2 participants