mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-06 12:51:21 +00:00
core/slip39: remove partial persistance in Shamir recovery
This commit is contained in:
parent
bc70fe0604
commit
4f8022c5cd
@ -34,7 +34,7 @@ def get_seed(secret: bytes, passphrase: str):
|
|||||||
return seed
|
return seed
|
||||||
|
|
||||||
|
|
||||||
def get_mnemonic_count(mnemonic: str) -> int:
|
def get_mnemonic_threshold(mnemonic: str) -> int:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,9 @@ def process_all(mnemonics: list) -> bytes:
|
|||||||
Receives all mnemonics and processes it into pre-master secret which is usually then
|
Receives all mnemonics and processes it into pre-master secret which is usually then
|
||||||
stored in the storage.
|
stored in the storage.
|
||||||
"""
|
"""
|
||||||
_, _, secret = slip39.combine_mnemonics(mnemonics)
|
identifier, iteration_exponent, secret = slip39.combine_mnemonics(mnemonics)
|
||||||
|
storage.set_slip39_iteration_exponent(iteration_exponent)
|
||||||
|
storage.set_slip39_identifier(identifier)
|
||||||
return secret
|
return secret
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +88,6 @@ def get_seed(encrypted_master_secret: bytes, passphrase: str):
|
|||||||
return master_secret
|
return master_secret
|
||||||
|
|
||||||
|
|
||||||
def get_mnemonic_count(mnemonic: str) -> int:
|
def get_mnemonic_threshold(mnemonic: str) -> int:
|
||||||
_, _, _, _, _, _, threshold, _ = slip39.decode_mnemonic(mnemonic)
|
_, _, _, _, _, _, threshold, _ = slip39.decode_mnemonic(mnemonic)
|
||||||
return threshold
|
return threshold
|
||||||
|
@ -60,9 +60,8 @@ async def recovery_device(ctx, msg):
|
|||||||
wordcount = storage.get_slip39_words_count()
|
wordcount = storage.get_slip39_words_count()
|
||||||
mnemonic_module = mnemonic.slip39
|
mnemonic_module = mnemonic.slip39
|
||||||
|
|
||||||
if msg.dry_run:
|
mnemonic_threshold = None
|
||||||
dry_run_mnemonics = []
|
mnemonics = []
|
||||||
dry_run_mnemonic_count = None
|
|
||||||
|
|
||||||
secret = None
|
secret = None
|
||||||
while secret is None:
|
while secret is None:
|
||||||
@ -70,21 +69,15 @@ async def recovery_device(ctx, msg):
|
|||||||
words = await request_mnemonic(
|
words = await request_mnemonic(
|
||||||
ctx, wordcount, mnemonic_module == mnemonic.slip39
|
ctx, wordcount, mnemonic_module == mnemonic.slip39
|
||||||
)
|
)
|
||||||
try:
|
if mnemonic_threshold is None:
|
||||||
if msg.dry_run:
|
mnemonic_threshold = mnemonic_module.get_mnemonic_threshold(words)
|
||||||
if dry_run_mnemonic_count is None:
|
mnemonics.append(words)
|
||||||
dry_run_mnemonic_count = mnemonic_module.get_mnemonic_count(words)
|
remaining = mnemonic_threshold - len(mnemonics)
|
||||||
dry_run_mnemonics.append(words)
|
if remaining == 0:
|
||||||
else:
|
try:
|
||||||
secret = mnemonic_module.process_single(words)
|
secret = mnemonic_module.process_all(mnemonics)
|
||||||
except slip39.MnemonicError as e:
|
except slip39.MnemonicError as e:
|
||||||
raise wire.ProcessError("Mnemonic is not valid: " + str(e))
|
raise wire.ProcessError("Mnemonic is not valid: " + str(e))
|
||||||
if msg.dry_run:
|
|
||||||
remaining = dry_run_mnemonic_count - len(dry_run_mnemonics)
|
|
||||||
if remaining == 0:
|
|
||||||
secret = mnemonic_module.process_all(dry_run_mnemonics)
|
|
||||||
else:
|
|
||||||
remaining = storage.get_slip39_remaining()
|
|
||||||
# show a number of remaining mnemonics for SLIP39
|
# show a number of remaining mnemonics for SLIP39
|
||||||
if secret is None and mnemonic_module == mnemonic.slip39:
|
if secret is None and mnemonic_module == mnemonic.slip39:
|
||||||
await show_remaining_slip39_mnemonics(ctx, title, remaining)
|
await show_remaining_slip39_mnemonics(ctx, title, remaining)
|
||||||
|
Loading…
Reference in New Issue
Block a user