Skip to content

Commit

Permalink
Merge pull request #1734 from guggero/bip-0374-test-vector-fix
Browse files Browse the repository at this point in the history
bip-0374: fix challenge generation, use correct generator point
  • Loading branch information
jonatack authored Dec 28, 2024
2 parents 27e1394 + e141b95 commit 6c807b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bip-0374/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down 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)
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):
return False
return True

Expand Down

0 comments on commit 6c807b7

Please sign in to comment.