bip32: refactor whole module. clean-up.
This commit is contained in:
@@ -6,7 +6,7 @@ from struct import pack, unpack
|
||||
import os, sys, time, io
|
||||
import traceback
|
||||
|
||||
from electrum.bip32 import serialize_xpub, deserialize_xpub, InvalidMasterKeyVersionBytes
|
||||
from electrum.bip32 import BIP32Node, InvalidMasterKeyVersionBytes
|
||||
from electrum.i18n import _
|
||||
from electrum.plugin import Device
|
||||
from electrum.keystore import Hardware_KeyStore, xpubkey_to_pubkey, Xpub
|
||||
@@ -40,12 +40,7 @@ try:
|
||||
def mitm_verify(self, sig, expect_xpub):
|
||||
# verify a signature (65 bytes) over the session key, using the master bip32 node
|
||||
# - customized to use specific EC library of Electrum.
|
||||
from electrum.ecc import ECPubkey
|
||||
|
||||
xtype, depth, parent_fingerprint, child_number, chain_code, K_or_k \
|
||||
= deserialize_xpub(expect_xpub)
|
||||
|
||||
pubkey = ECPubkey(K_or_k)
|
||||
pubkey = BIP32Node.from_xkey(expect_xpub).eckey
|
||||
try:
|
||||
pubkey.verify_message_hash(sig[1:65], self.session_key)
|
||||
return True
|
||||
@@ -191,12 +186,12 @@ class CKCCClient:
|
||||
# TODO handle timeout?
|
||||
# change type of xpub to the requested type
|
||||
try:
|
||||
__, depth, fingerprint, child_number, c, cK = deserialize_xpub(xpub)
|
||||
node = BIP32Node.from_xkey(xpub)
|
||||
except InvalidMasterKeyVersionBytes:
|
||||
raise UserFacingException(_('Invalid xpub magic. Make sure your {} device is set to the correct chain.')
|
||||
.format(self.device)) from None
|
||||
if xtype != 'standard':
|
||||
xpub = serialize_xpub(xtype, c, cK, depth, fingerprint, child_number)
|
||||
xpub = node._replace(xtype=xtype).to_xpub()
|
||||
return xpub
|
||||
|
||||
def ping_check(self):
|
||||
|
||||
Reference in New Issue
Block a user