Skip to content

Commit

Permalink
bip-0374: fix challenge generation, use correct G
Browse files Browse the repository at this point in the history
Both generating and verifying a proof allows for specifying a custom
generator point G. But that custom generator point was not passed into
the dleq_challenge function, resulting in the default (secp256k1)
generator point to be used. This lead to the test vectors being
incorrect.
  • Loading branch information
guggero committed Dec 28, 2024
1 parent 27e1394 commit 8bc42a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bip-0374/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def dleq_generate_proof(
return None
R1 = k * G
R2 = k * B
e = dleq_challenge(A, B, C, R1, R2, m)
e = dleq_challenge(A, B, C, R1, R2, m, G=G)
s = (k + e * a) % GE.ORDER
proof = e.to_bytes(32, "big") + s.to_bytes(32, "big")
if not dleq_verify_proof(A, B, C, proof, G=G, m=m):
Expand All @@ -89,7 +89,7 @@ def dleq_verify_proof(
R2 = s * B + (-e * C)
if R2.infinity:
return False
if e != dleq_challenge(A, B, C, R1, R2, m):
if e != dleq_challenge(A, B, C, R1, R2, m, G=G):
return False
return True

Expand Down

0 comments on commit 8bc42a2

Please sign in to comment.