|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
from typing import TYPE_CHECKING, Collection
|
|
|
|
|
from typing import TYPE_CHECKING, Sequence
|
|
|
|
|
|
|
|
|
|
import storage
|
|
|
|
|
import storage.device as storage_device
|
|
|
|
@ -121,7 +121,7 @@ async def _backup_slip39_basic(encrypted_master_secret: bytes) -> None:
|
|
|
|
|
await layout.slip39_show_checklist(1, BAK_T_SLIP39_BASIC)
|
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count)
|
|
|
|
|
|
|
|
|
|
mnemonics = await _backup_slip39(
|
|
|
|
|
mnemonics = _get_slip39_mnemonics(
|
|
|
|
|
encrypted_master_secret, group_threshold, [(share_threshold, share_count)]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -147,7 +147,7 @@ async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count, i)
|
|
|
|
|
groups.append((share_threshold, share_count))
|
|
|
|
|
|
|
|
|
|
mnemonics = await _backup_slip39(encrypted_master_secret, group_threshold, groups)
|
|
|
|
|
mnemonics = _get_slip39_mnemonics(encrypted_master_secret, group_threshold, groups)
|
|
|
|
|
|
|
|
|
|
# show and confirm individual shares
|
|
|
|
|
await layout.slip39_advanced_show_and_confirm_shares(mnemonics)
|
|
|
|
@ -156,9 +156,9 @@ async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|
|
|
|
async def _backup_slip39_custom(
|
|
|
|
|
encrypted_master_secret: bytes,
|
|
|
|
|
group_threshold: int,
|
|
|
|
|
groups: Collection[tuple[int, int]],
|
|
|
|
|
groups: Sequence[tuple[int, int]],
|
|
|
|
|
):
|
|
|
|
|
mnemonics = await _backup_slip39(encrypted_master_secret, group_threshold, groups)
|
|
|
|
|
mnemonics = _get_slip39_mnemonics(encrypted_master_secret, group_threshold, groups)
|
|
|
|
|
|
|
|
|
|
# show and confirm individual shares
|
|
|
|
|
if len(groups) == 1 and groups[0][0] == 1 and groups[0][1] == 1:
|
|
|
|
@ -171,10 +171,10 @@ async def _backup_slip39_custom(
|
|
|
|
|
else:
|
|
|
|
|
await layout.slip39_advanced_show_and_confirm_shares(mnemonics)
|
|
|
|
|
|
|
|
|
|
async def _backup_slip39(
|
|
|
|
|
def _get_slip39_mnemonics(
|
|
|
|
|
encrypted_master_secret: bytes,
|
|
|
|
|
group_threshold: int,
|
|
|
|
|
groups: Collection[tuple[int, int]],
|
|
|
|
|
groups: Sequence[tuple[int, int]],
|
|
|
|
|
):
|
|
|
|
|
identifier = storage_device.get_slip39_identifier()
|
|
|
|
|
iteration_exponent = storage_device.get_slip39_iteration_exponent()
|
|
|
|
@ -235,7 +235,7 @@ async def backup_seed(
|
|
|
|
|
backup_type: BackupType,
|
|
|
|
|
mnemonic_secret: bytes,
|
|
|
|
|
group_threshold: int | None = None,
|
|
|
|
|
groups: Collection[tuple[int, int]] = (),
|
|
|
|
|
groups: Sequence[tuple[int, int]] = (),
|
|
|
|
|
) -> None:
|
|
|
|
|
# Either both should be defined or both should be missing: group_threshold, groups
|
|
|
|
|
assert (group_threshold is None) == (len(groups) == 0)
|
|
|
|
|