Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bip-0374: fix challenge generation, use correct generator point #1734

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading