def test_key_exchange_random(self): a_private_secret, a_public_secret = monocypher.generate_key_exchange_key_pair( ) b_private_secret, b_public_secret = monocypher.generate_key_exchange_key_pair( ) b_shared_secret = monocypher.key_exchange(b_private_secret, a_public_secret) a_shared_secret = monocypher.key_exchange(a_private_secret, b_public_secret) self.assertEqual(a_shared_secret, b_shared_secret)
def test_key_exchange(self): expect = b'\xd0\x0f\x80\x8b\xf5\xcc\x0f\x85w\xa2\xdad\x88\xa3l\xf1\xf3(p\xd1MMo\xe95\x01\r\x983b\xae\xb7' your_secret_key = bytes(range(32)) their_public_key = bytes(range(32, 64)) shared_key = monocypher.key_exchange(your_secret_key, their_public_key) self.assertEqual(expect, shared_key)
def test_key_exchange_static(self): expect = b'\xd0\x0f\x80\x8b\xf5\xcc\x0f\x85w\xa2\xdad\x88\xa3l\xf1\xf3(p\xd1MMo\xe95\x01\r\x983b\xae\xb7' your_secret_key = bytes(range(32)) their_public_key = bytes(range(32, 64)) shared_key = monocypher.key_exchange(your_secret_key, their_public_key) self.assertEqual(expect, shared_key)