mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-15 12:08:59 +00:00
31f987e988
Based on SLIP-44 ids and other checks. See docs/coins/README for info.
47 lines
2.2 KiB
Python
47 lines
2.2 KiB
Python
from common import *
|
|
from apps.common import HARDENED
|
|
from apps.common.paths import validate_path_for_get_public_key, is_hardened
|
|
|
|
|
|
class TestPaths(unittest.TestCase):
|
|
|
|
def test_is_hardened(self):
|
|
self.assertTrue(is_hardened(44 | HARDENED))
|
|
self.assertTrue(is_hardened(0 | HARDENED))
|
|
self.assertTrue(is_hardened(99999 | HARDENED))
|
|
|
|
self.assertFalse(is_hardened(44))
|
|
self.assertFalse(is_hardened(0))
|
|
self.assertFalse(is_hardened(99999))
|
|
|
|
def test_path_for_get_public_key(self):
|
|
# 44'/41'/0'
|
|
self.assertTrue(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED], 41))
|
|
# 44'/111'/0'
|
|
self.assertTrue(validate_path_for_get_public_key([44 | HARDENED, 111 | HARDENED, 0 | HARDENED], 111))
|
|
# 44'/0'/0'/0
|
|
self.assertTrue(validate_path_for_get_public_key([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0], 0))
|
|
# 44'/0'/0'/0/0
|
|
self.assertTrue(validate_path_for_get_public_key([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], 0))
|
|
|
|
# 44'/41'
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED], 41))
|
|
# 44'/41'/0
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0], 41))
|
|
# 44'/41'/0' slip44 mismatch
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED], 99))
|
|
# # 44'/41'/0'/0'
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED, 0 | HARDENED], 41))
|
|
# # 44'/41'/0'/0'/0
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0], 41))
|
|
# # 44'/41'/0'/0'/0'
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0 | HARDENED], 41))
|
|
# # 44'/41'/0'/0/0/0
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED, 0, 0, 0], 41))
|
|
# # 44'/41'/0'/0/0'
|
|
self.assertFalse(validate_path_for_get_public_key([44 | HARDENED, 41 | HARDENED, 0 | HARDENED, 0, 0 | HARDENED], 41))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|