Skip to content

Commit fe10103

Browse files
committed
Test x-only ECDH
1 parent a9c2165 commit fe10103

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

test/functional/test_framework/ellswift.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Do not use for anything but tests."""
99

1010
import random
11+
import unittest
1112

1213
from .key import FE, GE, SECP256K1_G
1314

@@ -76,3 +77,12 @@ def ellswift_ecdh_xonly(pubkey_theirs, privkey):
7677
t = FE(int.from_bytes(pubkey_theirs[32:], 'big'))
7778
d = int.from_bytes(privkey, 'big')
7879
return (d * GE.lift_x(xswiftec(u, t))).x.to_bytes()
80+
81+
class TestFrameworkEllSwift(unittest.TestCase):
82+
def test_ellswift_ecdh_xonly(self):
83+
for _ in range(32):
84+
privkey1, encoding1 = ellswift_create()
85+
privkey2, encoding2 = ellswift_create()
86+
shared_secret1 = ellswift_ecdh_xonly(encoding1, privkey2)
87+
shared_secret2 = ellswift_ecdh_xonly(encoding2, privkey1)
88+
assert shared_secret1 == shared_secret2

test/functional/test_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
TEST_FRAMEWORK_MODULES = [
7171
"address",
7272
"blocktools",
73-
"muhash",
73+
"ellswift",
7474
"key",
75+
"muhash",
7576
"script",
7677
"segwit_addr",
7778
"util",

0 commit comments

Comments
 (0)