From 9d29952a15484506fccb115cd7d8c5dcb78583fa Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 4 Mar 2020 15:12:30 +0100 Subject: [PATCH] python: move out deprecated ckd_public --- python/CHANGELOG.md | 3 ++ python/tests/test_ckd_public.py | 34 ------------------- .../trezorlib/ckd_public.py => tests/bip32.py | 9 +---- tests/device_tests/test_msg_getaddress.py | 3 +- .../device_tests/test_msg_getaddress_show.py | 3 +- tests/device_tests/test_msg_getpublickey.py | 3 +- .../test_msg_signtx_segwit_native.py | 2 +- tests/device_tests/test_multisig.py | 3 +- tests/device_tests/test_multisig_change.py | 3 +- 9 files changed, 15 insertions(+), 48 deletions(-) delete mode 100644 python/tests/test_ckd_public.py rename python/src/trezorlib/ckd_public.py => tests/bip32.py (95%) diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 0ccd07453..521b023e6 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -38,11 +38,13 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/ - `trezorlib.tx_api` was removed - `trezorlib.coins` and coin data was removed +- `trezorlib.ckd_public`, which was deprecated in 0.10, was now removed. - `btc.sign_tx` will not preload transaction data from `prev_txes`, as usage with TxApi is being removed - PIN protection and passphrase protection for `ping()` command was removed - compatibility no-op code from trezorlib 0.9 was removed from `trezorlib.client` + ## [0.11.6] - 2019-12-30 [0.11.6]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.5...python/v0.11.6 @@ -69,6 +71,7 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/ for details. - support for "load device by xprv" was removed from firmware and trezorlib + ## [0.11.5] - 2019-09-26 [0.11.5]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.4...python/v0.11.5 diff --git a/python/tests/test_ckd_public.py b/python/tests/test_ckd_public.py deleted file mode 100644 index 4da8c80f3..000000000 --- a/python/tests/test_ckd_public.py +++ /dev/null @@ -1,34 +0,0 @@ -# This file is part of the Trezor project. -# -# Copyright (C) 2012-2019 SatoshiLabs and contributors -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the License along with this library. -# If not, see . - -from trezorlib import ckd_public - - -def test_ckd_public(): - xpub1 = "xpub661MyMwAqRbcEnKbXcCqD2GT1di5zQxVqoHPAgHNe8dv5JP8gWmDproS6kFHJnLZd23tWevhdn4urGJ6b264DfTGKr8zjmYDjyDTi9U7iyT" - node1 = ckd_public.deserialize(xpub1) - node2 = ckd_public.public_ckd(node1, [0]) - node3 = ckd_public.public_ckd(node1, [0, 0]) - xpub2 = ckd_public.serialize(node2) - xpub3 = ckd_public.serialize(node3) - assert ( - xpub2 - == "xpub67ymn1YTdE2iSGXitxUEZeUdHF2FsejJATroeAxVMtzTAK9o3vjmFLrE7TqE1X76iobkVc3p8h3gNzNRTwPeQGYW3CCmYCG8n5ThVkXaQzs" - ) - assert ( - xpub3 - == "xpub6BD2MwdEg5PJPqiGetL9DJs7oDo6zP3XwAABX2vAQb5eLpY3QhHGUEm25V4nkQhnFMsqEVfTwtax2gKz8EFrt1PnBN6xQjE9jGmWDR6modu" - ) diff --git a/python/src/trezorlib/ckd_public.py b/tests/bip32.py similarity index 95% rename from python/src/trezorlib/ckd_public.py rename to tests/bip32.py index aed9d52de..c243dfd82 100644 --- a/python/src/trezorlib/ckd_public.py +++ b/tests/bip32.py @@ -17,7 +17,6 @@ import hashlib import hmac import struct -import warnings import ecdsa from ecdsa.curves import SECP256k1 @@ -26,8 +25,6 @@ from ecdsa.util import number_to_string, string_to_number from trezorlib import messages, tools -warnings.warn("ckd_public module is deprecated and will be removed", DeprecationWarning) - def point_to_pubkey(point): order = SECP256k1.order @@ -58,10 +55,6 @@ def sec_to_public_pair(pubkey): ) -def is_prime(n): - return bool(n & tools.HARDENED_FLAG) - - def fingerprint(pubkey): return string_to_number(tools.hash_160(pubkey)[:4]) @@ -86,7 +79,7 @@ def get_subnode(node, i): # Public Child key derivation (CKD) algorithm of BIP32 i_as_bytes = struct.pack(">L", i) - if is_prime(i): + if i & tools.HARDENED_FLAG: raise ValueError("Prime derivation not supported") # Public derivation diff --git a/tests/device_tests/test_msg_getaddress.py b/tests/device_tests/test_msg_getaddress.py index 170823727..8791f1ff9 100644 --- a/tests/device_tests/test_msg_getaddress.py +++ b/tests/device_tests/test_msg_getaddress.py @@ -16,9 +16,10 @@ import pytest -from trezorlib import btc, ckd_public as bip32, messages as proto +from trezorlib import btc, messages as proto from trezorlib.tools import H_, CallException, parse_path +from .. import bip32 from ..common import MNEMONIC12 diff --git a/tests/device_tests/test_msg_getaddress_show.py b/tests/device_tests/test_msg_getaddress_show.py index 1719e526f..4d0525682 100644 --- a/tests/device_tests/test_msg_getaddress_show.py +++ b/tests/device_tests/test_msg_getaddress_show.py @@ -16,8 +16,9 @@ import pytest -from trezorlib import btc, ckd_public as bip32, messages, tools +from trezorlib import btc, messages, tools +from .. import bip32 from ..common import MNEMONIC12 diff --git a/tests/device_tests/test_msg_getpublickey.py b/tests/device_tests/test_msg_getpublickey.py index 78d7d81d1..eae943c22 100644 --- a/tests/device_tests/test_msg_getpublickey.py +++ b/tests/device_tests/test_msg_getpublickey.py @@ -16,9 +16,10 @@ import pytest -from trezorlib import btc, ckd_public as bip32, messages as proto +from trezorlib import btc, messages as proto from trezorlib.tools import H_ +from .. import bip32 from ..common import MNEMONIC12 diff --git a/tests/device_tests/test_msg_signtx_segwit_native.py b/tests/device_tests/test_msg_signtx_segwit_native.py index 3a18c994e..1d5332125 100644 --- a/tests/device_tests/test_msg_signtx_segwit_native.py +++ b/tests/device_tests/test_msg_signtx_segwit_native.py @@ -17,9 +17,9 @@ import pytest from trezorlib import btc, messages as proto -from trezorlib.ckd_public import deserialize from trezorlib.tools import H_, parse_path +from ..bip32 import deserialize from ..tx_cache import TxCache TX_API = TxCache("Testnet") diff --git a/tests/device_tests/test_multisig.py b/tests/device_tests/test_multisig.py index f43b83d1d..1cb89b6c0 100644 --- a/tests/device_tests/test_multisig.py +++ b/tests/device_tests/test_multisig.py @@ -16,9 +16,10 @@ import pytest -from trezorlib import btc, ckd_public as bip32, messages as proto +from trezorlib import btc, messages as proto from trezorlib.tools import CallException, parse_path +from .. import bip32 from ..common import MNEMONIC12 from ..tx_cache import TxCache diff --git a/tests/device_tests/test_multisig_change.py b/tests/device_tests/test_multisig_change.py index e57c16f0b..163a6dfa5 100644 --- a/tests/device_tests/test_multisig_change.py +++ b/tests/device_tests/test_multisig_change.py @@ -16,9 +16,10 @@ import pytest -from trezorlib import btc, ckd_public as bip32, messages as proto +from trezorlib import btc, messages as proto from trezorlib.tools import H_, parse_path +from .. import bip32 from ..common import MNEMONIC12 from ..tx_cache import TxCache