Test for secret derivation

This commit is contained in:
Kovid Goyal
2022-08-04 20:05:19 +05:30
parent 4fe5211ed7
commit 89854cca8b
2 changed files with 45 additions and 4 deletions

18
kitty_tests/crypto.py Normal file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
from . import BaseTest
class TestCrypto(BaseTest):
def test_elliptic_curve_data_exchange(self):
from kitty.fast_data_types import EllipticCurveKey
alice = EllipticCurveKey()
bob = EllipticCurveKey()
alice_secret = alice.derive_secret(bob.public)
bob_secret = bob.derive_secret(alice.public)
self.assertEqual(len(alice_secret), 32)
self.assertEqual(len(bob_secret), 32)
self.assertEqual(alice_secret, bob_secret)