Esempio n. 1
0
 def test_verify_path_empty_namespace(self):
     k = Keychain(b"", "secp256k1", [[]])
     correct = (
         [],
         [1, 2, 3, 4],
         [44 | HARDENED, 11 | HARDENED],
         [44 | HARDENED, 11 | HARDENED, 12],
     )
     for c in correct:
         k.verify_path(c)
Esempio n. 2
0
    def test_verify_path_special_ed25519(self):
        n = [[44 | HARDENED, 134 | HARDENED]]
        k = Keychain(b"", "ed25519-keccak", n)

        # OK case
        k.verify_path([44 | HARDENED, 134 | HARDENED])

        # failing case: non-hardened component with ed25519-like derivation
        with self.assertRaises(wire.DataError):
            k.verify_path([44 | HARDENED, 134 | HARDENED, 1])
    def test_verify_path_special_ed25519(self):
        schema = PathSchema("m/44'/coin_type'/*", slip44_id=134)
        k = Keychain(b"", "ed25519-keccak", [schema])

        # OK case
        k.verify_path([H_(44), H_(134)])

        # failing case: non-hardened component with ed25519-like derivation
        with self.assertRaises(wire.DataError):
            k.verify_path([H_(44), H_(134), 1])
Esempio n. 4
0
    def test_verify_path(self):
        n = [
            [44 | HARDENED, 134 | HARDENED],
            [44 | HARDENED, 11 | HARDENED],
        ]
        keychain = Keychain(b"", "secp256k1", n)

        correct = (
            [44 | HARDENED, 134 | HARDENED],
            [44 | HARDENED, 11 | HARDENED],
            [44 | HARDENED, 11 | HARDENED, 12],
        )
        for path in correct:
            keychain.verify_path(path)

        fails = (
            [44 | HARDENED, 134],  # path does not match
            [44, 134],  # path does not match (non-hardened items)
            [44 | HARDENED, 13 | HARDENED],  # invalid second item
        )
        for f in fails:
            with self.assertRaises(wire.DataError):
                keychain.verify_path(f)

        # turn off restrictions
        safety_checks.apply_setting(SafetyCheckLevel.PromptTemporarily)
        for path in correct + fails:
            keychain.verify_path(path)
        # turn on restrictions
        safety_checks.apply_setting(SafetyCheckLevel.Strict)
    def test_verify_path(self):
        n = [
            [44 | HARDENED, 134 | HARDENED],
            [44 | HARDENED, 11 | HARDENED],
        ]
        keychain = Keychain(b"", "secp256k1", n)

        correct = (
            [44 | HARDENED, 134 | HARDENED],
            [44 | HARDENED, 11 | HARDENED],
            [44 | HARDENED, 11 | HARDENED, 12],
        )
        for path in correct:
            keychain.verify_path(path)

        fails = (
            [44 | HARDENED, 134],  # path does not match
            [44, 134],  # path does not match (non-hardened items)
            [44 | HARDENED, 13 | HARDENED],  # invalid second item
        )
        for f in fails:
            with self.assertRaises(wire.DataError):
                keychain.verify_path(f)

        # turn off restrictions
        storage.device.set_unsafe_prompts_allowed(True)
        for path in correct + fails:
            keychain.verify_path(path)
    def test_verify_path(self):
        schemas = (
            PathSchema("m/44'/coin_type'", slip44_id=134),
            PathSchema("m/44'/coin_type'", slip44_id=11),
        )
        keychain = Keychain(b"", "secp256k1", schemas)

        correct = (
            [H_(44), H_(134)],
            [H_(44), H_(11)],
        )
        for path in correct:
            keychain.verify_path(path)

        fails = (
            [H_(44), 134],  # path does not match
            [44, 134],  # path does not match (non-hardened items)
            [H_(44), H_(13)],  # invalid second item
        )
        for f in fails:
            with self.assertRaises(wire.DataError):
                keychain.verify_path(f)

        # turn off restrictions
        safety_checks.apply_setting(SafetyCheckLevel.PromptTemporarily)
        for path in correct + fails:
            keychain.verify_path(path)