1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 00:28:10 +00:00

Restore progress_bar parameter in mnemonic.seed (#297)

Restore progress_bar parameter in mnemonic.seed
This commit is contained in:
Tomas Susanka 2019-07-02 12:14:46 +02:00 committed by GitHub
commit 049c5211f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View File

@ -22,12 +22,12 @@ def get() -> (bytes, int):
return mnemonic_secret, mnemonic_type
def get_seed(passphrase: str = ""):
def get_seed(passphrase: str = "", progress_bar=True):
mnemonic_secret, mnemonic_type = get()
if mnemonic_type == TYPE_BIP39:
return bip39.get_seed(mnemonic_secret, passphrase)
return bip39.get_seed(mnemonic_secret, passphrase, progress_bar)
elif mnemonic_type == TYPE_SLIP39:
return slip39.get_seed(mnemonic_secret, passphrase)
return slip39.get_seed(mnemonic_secret, passphrase, progress_bar)
def dry_run(secret: bytes):

View File

@ -27,10 +27,14 @@ def store(secret: bytes, needs_backup: bool, no_backup: bool):
storage.store_mnemonic(secret, mnemonic.TYPE_BIP39, needs_backup, no_backup)
def get_seed(secret: bytes, passphrase: str):
mnemonic._start_progress()
seed = bip39.seed(secret.decode(), passphrase, mnemonic._render_progress)
mnemonic._stop_progress()
def get_seed(secret: bytes, passphrase: str, progress_bar=True):
if progress_bar:
mnemonic._start_progress()
seed = bip39.seed(secret.decode(), passphrase, mnemonic._render_progress)
mnemonic._stop_progress()
else:
seed = bip39.seed(secret.decode(), passphrase)
return seed

View File

@ -77,14 +77,16 @@ def store(secret: bytes, needs_backup: bool, no_backup: bool):
storage.clear_slip39_data()
def get_seed(encrypted_master_secret: bytes, passphrase: str):
mnemonic._start_progress()
def get_seed(encrypted_master_secret: bytes, passphrase: str, progress_bar=True):
if progress_bar:
mnemonic._start_progress()
identifier = storage.get_slip39_identifier()
iteration_exponent = storage.get_slip39_iteration_exponent()
master_secret = slip39.decrypt(
identifier, iteration_exponent, encrypted_master_secret, passphrase
)
mnemonic._stop_progress()
if progress_bar:
mnemonic._stop_progress()
return master_secret