diff --git a/core/src/apps/tezos/helpers.py b/core/src/apps/tezos/helpers.py index e93b49388..4640d7eb3 100644 --- a/core/src/apps/tezos/helpers.py +++ b/core/src/apps/tezos/helpers.py @@ -47,15 +47,16 @@ def validate_full_path(path: list) -> bool: where `a` is an account index from 0 to 1 000 000. """ length = len(path) + print(path) if length < 3 or length > 4: return False if path[0] != 44 | HARDENED: return False if path[1] != 1729 | HARDENED: return False - if path[2] < HARDENED or path[2] > 1000000 | HARDENED: + if length == 3 and (path[2] < HARDENED or path[2] > 1000000 | HARDENED): return False - if length > 3 and (path[3] < HARDENED or path[3] > 1000000 | HARDENED): + if length == 4 and (path[2] != 0 | HARDENED or path[3] < HARDENED or path[3] > 1000000 | HARDENED): return False return True diff --git a/core/tests/test_apps.tezos.address.py b/core/tests/test_apps.tezos.address.py index 9b093f9e0..c3870fd31 100644 --- a/core/tests/test_apps.tezos.address.py +++ b/core/tests/test_apps.tezos.address.py @@ -46,10 +46,11 @@ class TestTezosAddress(unittest.TestCase): [44 | HARDENED], [44 | HARDENED, 1729 | HARDENED], [44 | HARDENED, 1729 | HARDENED, 0], - [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 0 | HARDENED], + [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 0], [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0 | HARDENED], [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 1, 0], [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 0, 0], + [44 | HARDENED, 1729 | HARDENED, 1 | HARDENED, 1 | HARDENED], [44 | HARDENED, 1729 | HARDENED, 9999000 | HARDENED], [44 | HARDENED, 60 | HARDENED, 0 | HARDENED, 0, 0], [1 | HARDENED, 1 | HARDENED, 1 | HARDENED], @@ -58,6 +59,9 @@ class TestTezosAddress(unittest.TestCase): [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED], [44 | HARDENED, 1729 | HARDENED, 3 | HARDENED], [44 | HARDENED, 1729 | HARDENED, 9 | HARDENED], + [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 0 | HARDENED], + [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 3 | HARDENED], + [44 | HARDENED, 1729 | HARDENED, 0 | HARDENED, 9 | HARDENED], ] for path in incorrect_paths: diff --git a/core/tests/test_apps.tezos.encode.py b/core/tests/test_apps.tezos.encode.py index ee875d375..16f1142f4 100644 --- a/core/tests/test_apps.tezos.encode.py +++ b/core/tests/test_apps.tezos.encode.py @@ -4,9 +4,8 @@ from common import * from trezor.messages import TezosContractType from trezor.messages.TezosContractID import TezosContractID -from apps.tezos.helpers import base58_decode_check, base58_encode_check +from apps.tezos.helpers import base58_decode_check, base58_encode_check, write_bool from apps.tezos.sign_tx import ( - _encode_bool, _encode_contract_id, _encode_data_with_bool_prefix, _encode_zarith, @@ -35,11 +34,11 @@ class TestTezosEncoding(unittest.TestCase): def test_tezos_encode_bool(self): w = bytearray() - _encode_bool(w, True) + write_bool(w, True) self.assertEqual(bytes(w), bytes([255])) w = bytearray() - _encode_bool(w, False) + write_bool(w, False) self.assertEqual(bytes(w), bytes([0])) def test_tezos_encode_contract_id(self):