1
0
Fork 0
mirror of https://github.com/bitcoin/bips.git synced 2025-02-22 15:04:46 +01:00

Merge pull request #1734 from guggero/bip-0374-test-vector-fix

bip-0374: fix challenge generation, use correct generator point
This commit is contained in:
Jon Atack 2024-12-28 13:17:58 -08:00 committed by GitHub
commit 6c807b7502
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,7 +25,7 @@ def xor_bytes(lhs: bytes, rhs: bytes) -> bytes:
def dleq_challenge(
A: GE, B: GE, C: GE, R1: GE, R2: GE, m: bytes | None, G: GE = G,
A: GE, B: GE, C: GE, R1: GE, R2: GE, m: bytes | None, G: GE,
) -> int:
if m is not None:
assert len(m) == 32
@ -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)
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):
return False
return True