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:
commit
6c807b7502
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue