From 96c7f9e7cbc0176ce14017491cbfb1d58d8386f2 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 26 Dec 2015 12:23:35 +0900 Subject: [PATCH] Partially revert prior --- plugins/keepkey/keepkey.py | 12 +++++++++--- plugins/trezor/trezor.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/keepkey/keepkey.py b/plugins/keepkey/keepkey.py index e76dc6c2..72d77c5c 100644 --- a/plugins/keepkey/keepkey.py +++ b/plugins/keepkey/keepkey.py @@ -93,9 +93,15 @@ class KeepKeyWallet(BIP32_HD_Wallet): return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64) def derive_xkeys(self, root, derivation, password): - derivation = derivation.replace(self.root_name,"44'/0'/") - xpub = self.get_public_key(derivation) - return xpub, None + x = self.master_private_keys.get(root) + if x: + root_xprv = pw_decode(x, password) + xprv, xpub = bip32_private_derivation(root_xprv, root, derivation) + return xpub, xprv + else: + derivation = derivation.replace(self.root_name,"44'/0'/") + xpub = self.get_public_key(derivation) + return xpub, None def get_public_key(self, bip32_path): address_n = self.plugin.get_client().expand_path(bip32_path) diff --git a/plugins/trezor/trezor.py b/plugins/trezor/trezor.py index 4ae22b7b..1d51e9cc 100644 --- a/plugins/trezor/trezor.py +++ b/plugins/trezor/trezor.py @@ -92,9 +92,15 @@ class TrezorWallet(BIP32_HD_Wallet): return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64) def derive_xkeys(self, root, derivation, password): - derivation = derivation.replace(self.root_name,"44'/0'/") - xpub = self.get_public_key(derivation) - return xpub, None + x = self.master_private_keys.get(root) + if x: + root_xprv = pw_decode(x, password) + xprv, xpub = bip32_private_derivation(root_xprv, root, derivation) + return xpub, xprv + else: + derivation = derivation.replace(self.root_name,"44'/0'/") + xpub = self.get_public_key(derivation) + return xpub, None def get_public_key(self, bip32_path): address_n = self.plugin.get_client().expand_path(bip32_path)