diff --git a/tests/test_ecies.py b/tests/test_ecies.py new file mode 100644 index 0000000000..376231cf22 --- /dev/null +++ b/tests/test_ecies.py @@ -0,0 +1,36 @@ +import unittest +import common +import binascii + +from trezorlib.client import CallException + +class TestEcies(common.TrezorTest): + + def test_ecies(self): + self.setup_mnemonic_nopin_nopassphrase() + + pubkey = self.client.get_public_node([1]).node.public_key + + # encrypt without signature + enc = self.client.encrypt_message(pubkey, 'testing message!', display_only=False, coin_name='Bitcoin', n=[]) + dec = self.client.decrypt_message([1], enc) + self.assertEqual(dec, 'testing message!') + + # encrypt with signature + enc = self.client.encrypt_message(pubkey, 'testing message!', display_only=False, coin_name='Bitcoin', n=[2]) + dec = self.client.decrypt_message([1], enc) + self.assertEqual(dec, 'testing message!') + + # encrypt without signature, show only on display + enc = self.client.encrypt_message(pubkey, 'testing message!', display_only=True, coin_name='Bitcoin', n=[]) + dec = self.client.decrypt_message([1], enc) + self.assertEqual(dec, '') + + # encrypt with signature, show only on display + enc = self.client.encrypt_message(pubkey, 'testing message!', display_only=True, coin_name='Bitcoin', n=[2]) + dec = self.client.decrypt_message([1], enc) + self.assertEqual(dec, '') + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_msg_decryptmessage.py b/tests/test_msg_decryptmessage.py deleted file mode 100644 index c5fd53fb19..0000000000 --- a/tests/test_msg_decryptmessage.py +++ /dev/null @@ -1,25 +0,0 @@ -import unittest -import common -import binascii - -from trezorlib.client import CallException - -class TestMsgDecryptmessage(common.TrezorTest): - - def test_decrypt(self): - self.setup_mnemonic_nopin_nopassphrase() - - dec = self.client.decrypt_message([1], binascii.unhexlify('42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe020c6c67028130601022ec45ec7b34c8eb47ee785922c308c9ad25da259aa59ec21a89e327af30e4213da31f3fc70ff5ae')) - self.assertEqual(dec, 'testing message!') - - dec = self.client.decrypt_message([1], binascii.unhexlify('42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe02f14a9778cbb1c5b75f8cef70581ad2c34acb7f9eb7918b17ea323123148251d8eb6d63d16ac8a86f3623855450b70d95')) - self.assertEqual(dec, '') # display only - - dec = self.client.decrypt_message([1, -2], binascii.unhexlify('424945310238cba33fd1ed1d2adebd4cc4bbd89913ecb34922c1b387c3a10d70d9de6d9ea627b49044ce1dbf26cca8a727a40366dcb1f9c9a2d5eafa90817fd0d967ca25127bea98a5e93c150544bf457b48fdd667c72b8c9c31ccd0ad2aea2f1b50ec0ce6')) - self.assertEqual(dec, 'testing message!') - - dec = self.client.decrypt_message([1, -2], binascii.unhexlify('424945310238cba33fd1ed1d2adebd4cc4bbd89913ecb34922c1b387c3a10d70d9de6d9ea627b49044ce1dbf26cca8a727a40366dc1b16f7f6acb09645d91c73619baf458ed3262da40ff25f8f64db3fd5ff19bf50fb589db3ae6cfb5b546af720aa711d81')) - self.assertEqual(dec, '') # display only - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_msg_encryptmessage.py b/tests/test_msg_encryptmessage.py deleted file mode 100644 index a6729d9034..0000000000 --- a/tests/test_msg_encryptmessage.py +++ /dev/null @@ -1,29 +0,0 @@ -import unittest -import common -import binascii - -from trezorlib.client import CallException - -class TestMsgEncryptmessage(common.TrezorTest): - - def test_encrypt(self): - self.setup_mnemonic_nopin_nopassphrase() - - pubkey1 = self.client.get_public_node([1]).node.public_key - - enc = self.client.encrypt_message(pubkey1, 'testing message!', display_only=False) - self.assertEqual(binascii.hexlify(enc), '42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe020c6c67028130601022ec45ec7b34c8eb47ee785922c308c9ad25da259aa59ec21a89e327af30e4213da31f3fc70ff5ae') - - enc = self.client.encrypt_message(pubkey1, 'testing message!', display_only=True) - self.assertEqual(binascii.hexlify(enc), '42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe02f14a9778cbb1c5b75f8cef70581ad2c34acb7f9eb7918b17ea323123148251d8eb6d63d16ac8a86f3623855450b70d95') - - pubkey2 = self.client.get_public_node([1, -2]).node.public_key - - enc = self.client.encrypt_message(pubkey2, 'testing message!', display_only=False) - self.assertEqual(binascii.hexlify(enc), '424945310238cba33fd1ed1d2adebd4cc4bbd89913ecb34922c1b387c3a10d70d9de6d9ea627b49044ce1dbf26cca8a727a40366dcb1f9c9a2d5eafa90817fd0d967ca25127bea98a5e93c150544bf457b48fdd667c72b8c9c31ccd0ad2aea2f1b50ec0ce6') - - enc = self.client.encrypt_message(pubkey2, 'testing message!', display_only=True) - self.assertEqual(binascii.hexlify(enc), '424945310238cba33fd1ed1d2adebd4cc4bbd89913ecb34922c1b387c3a10d70d9de6d9ea627b49044ce1dbf26cca8a727a40366dc1b16f7f6acb09645d91c73619baf458ed3262da40ff25f8f64db3fd5ff19bf50fb589db3ae6cfb5b546af720aa711d81') - -if __name__ == '__main__': - unittest.main()