From 8ff492914be582dd795c2c640e83ee295aa96855 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 5 Jan 2023 23:47:53 +0800 Subject: [PATCH] remove bip_utils dependency from usb_update.py --- tools/usb_update.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/usb_update.py b/tools/usb_update.py index 017310029..fb073829a 100644 --- a/tools/usb_update.py +++ b/tools/usb_update.py @@ -12,12 +12,10 @@ import urllib.request import re from progressbar.bar import ProgressBar -from bip_utils import ( - Bip39MnemonicValidator, Bip39MnemonicDecoder -) from Crypto.Cipher import AES from Crypto.Hash import SHA256 from Crypto.Random import get_random_bytes +from pddbcommon import bip39_to_bits class PrecursorUsb: def __init__(self, dev): @@ -446,10 +444,7 @@ def xor_bytes(a, b): def try_key_to_bytes(input): if len(input.split(' ')) == 24: # 24 words is BIP-39 - # Get if a mnemonic is valid with automatic language detection, return bool - assert(Bip39MnemonicValidator().IsValid(input)) - # Like before with automatic language detection - key_bytes = Bip39MnemonicDecoder().Decode(input) + key_bytes = bip39_to_bits(input) else: key_bytes = int(input, 16).to_bytes(32, byteorder='big') return key_bytes