BIP-374 DLEQ Proofs#126
Open
notTanveer wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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.pyprovidinggenerate_dleq_proof/verify_dleq_proofplus aDLEQErrorexception, built on top of the existingutil.secp256k1bindings andtagged_hash. - New
tests/tests/test_dleq.pyrunning 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 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). |
| _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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added support for BIP-374 DLEQ proofs.
adapted from: https://github.com/bitcoin/bips/blob/master/bip-0374/reference.py