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:
parent
27e1394895
commit
8bc42a2673
@ -64,7 +64,7 @@ def dleq_generate_proof(
|
|||||||
return None
|
return None
|
||||||
R1 = k * G
|
R1 = k * G
|
||||||
R2 = k * B
|
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
|
s = (k + e * a) % GE.ORDER
|
||||||
proof = e.to_bytes(32, "big") + s.to_bytes(32, "big")
|
proof = e.to_bytes(32, "big") + s.to_bytes(32, "big")
|
||||||
if not dleq_verify_proof(A, B, C, proof, G=G, m=m):
|
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)
|
R2 = s * B + (-e * C)
|
||||||
if R2.infinity:
|
if R2.infinity:
|
||||||
return False
|
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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user