1
0
mirror of https://github.com/bitcoin/bips.git synced 2025-06-30 12:42:43 +00:00

bip-0374: fix challenge generation, use correct G

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.
This commit is contained in:
Oliver Gugger 2024-12-28 15:58:08 +01:00
parent 27e1394895
commit 8bc42a2673
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -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):
@ -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