Skip to content

Commit

Permalink
add step2 domain separated test
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Feb 23, 2024
1 parent ac0ddd5 commit e9033f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cashu/core/crypto/b_dhke.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def verify(a: PrivateKey, C: PublicKey, secret_msg: str) -> bool:
valid = C == Y.mult(a) # type: ignore
# BEGIN: BACKWARDS COMPATIBILITY < 0.15.1
if not valid:
return verify_domain_separated(a, C, secret_msg)
valid = verify_domain_separated(a, C, secret_msg)
# END: BACKWARDS COMPATIBILITY < 0.15.1
return valid

Expand Down
23 changes: 23 additions & 0 deletions tests/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,29 @@ def test_step1_domain_separated():
)


def test_step2_domain_separated():
B_, _ = step1_alice_domain_separated(
"test_message",
blinding_factor=PrivateKey(
privkey=bytes.fromhex(
"0000000000000000000000000000000000000000000000000000000000000001"
),
raw=True,
),
)
a = PrivateKey(
privkey=bytes.fromhex(
"0000000000000000000000000000000000000000000000000000000000000001"
),
raw=True,
)
C_, e, s = step2_bob(B_, a)
assert (
C_.serialize().hex()
== "025cc16fe33b953e2ace39653efb3e7a7049711ae1d8a2f7a9108753f1cdea742b"
)


def test_dleq_carol_verify_from_bob_domain_separated():
a = PrivateKey(
privkey=bytes.fromhex(
Expand Down

0 comments on commit e9033f0

Please sign in to comment.