From 7999f8aa1c77741faf46b75037800da707024127 Mon Sep 17 00:00:00 2001 From: Bruce0X <109469941+Bruce039@users.noreply.github.com> Date: Fri, 25 Sep 2026 15:55:49 +0400 Subject: [PATCH] bip375: sync vendored DLEQ code with BIP-374 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 (#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. --- bip-0375/deps/dleq.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bip-0375/deps/dleq.py b/bip-0375/deps/dleq.py index 81540356..f1060ee9 100644 --- a/bip-0375/deps/dleq.py +++ b/bip-0375/deps/dleq.py @@ -32,7 +32,7 @@ def dleq_challenge( + m, ), "big", - ) + ) % GE.ORDER def dleq_generate_proof( @@ -72,6 +72,8 @@ def dleq_verify_proof( return False assert len(proof) == 64 e = int.from_bytes(proof[:32], "big") + if e >= GE.ORDER: + return False s = int.from_bytes(proof[32:], "big") if s >= GE.ORDER: return False