|
|
@ -121,10 +121,14 @@ async def _backup_slip39_basic(encrypted_master_secret: bytes) -> None:
|
|
|
|
await layout.slip39_show_checklist(1, BAK_T_SLIP39_BASIC)
|
|
|
|
await layout.slip39_show_checklist(1, BAK_T_SLIP39_BASIC)
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count)
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count)
|
|
|
|
|
|
|
|
|
|
|
|
await _backup_slip39(
|
|
|
|
mnemonics = await _backup_slip39(
|
|
|
|
encrypted_master_secret, group_threshold, [(share_threshold, share_count)]
|
|
|
|
encrypted_master_secret, group_threshold, [(share_threshold, share_count)]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# show and confirm individual shares
|
|
|
|
|
|
|
|
await layout.slip39_show_checklist(2, BAK_T_SLIP39_BASIC)
|
|
|
|
|
|
|
|
await layout.slip39_basic_show_and_confirm_shares(mnemonics[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|
|
|
async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|
|
|
# get number of groups
|
|
|
|
# get number of groups
|
|
|
@ -143,9 +147,30 @@ async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count, i)
|
|
|
|
share_threshold = await layout.slip39_prompt_threshold(share_count, i)
|
|
|
|
groups.append((share_threshold, share_count))
|
|
|
|
groups.append((share_threshold, share_count))
|
|
|
|
|
|
|
|
|
|
|
|
await _backup_slip39(encrypted_master_secret, group_threshold, groups)
|
|
|
|
mnemonics = await _backup_slip39(encrypted_master_secret, group_threshold, groups)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# show and confirm individual shares
|
|
|
|
|
|
|
|
await layout.slip39_advanced_show_and_confirm_shares(mnemonics)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _backup_slip39_custom(
|
|
|
|
|
|
|
|
encrypted_master_secret: bytes,
|
|
|
|
|
|
|
|
group_threshold: int,
|
|
|
|
|
|
|
|
groups: Collection[tuple[int, int]],
|
|
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
mnemonics = await _backup_slip39(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:
|
|
|
|
|
|
|
|
# for a single 1-of-1 group, we use the same layouts as for BIP39
|
|
|
|
|
|
|
|
await layout.show_and_confirm_mnemonic(mnemonics[0][0])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# TODO: a confirmation screen will be shown: "do you want to create a -of- Shamir backup?"
|
|
|
|
|
|
|
|
if len(groups) == 1:
|
|
|
|
|
|
|
|
await layout.slip39_basic_show_and_confirm_shares(mnemonics[0])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await layout.slip39_advanced_show_and_confirm_shares(mnemonics)
|
|
|
|
|
|
|
|
|
|
|
|
async def _backup_slip39(
|
|
|
|
async def _backup_slip39(
|
|
|
|
encrypted_master_secret: bytes,
|
|
|
|
encrypted_master_secret: bytes,
|
|
|
|
group_threshold: int,
|
|
|
|
group_threshold: int,
|
|
|
@ -157,7 +182,7 @@ async def _backup_slip39(
|
|
|
|
raise ValueError
|
|
|
|
raise ValueError
|
|
|
|
|
|
|
|
|
|
|
|
# generate the mnemonics
|
|
|
|
# generate the mnemonics
|
|
|
|
mnemonics = slip39.split_ems(
|
|
|
|
return slip39.split_ems(
|
|
|
|
group_threshold,
|
|
|
|
group_threshold,
|
|
|
|
groups,
|
|
|
|
groups,
|
|
|
|
identifier,
|
|
|
|
identifier,
|
|
|
@ -165,13 +190,6 @@ async def _backup_slip39(
|
|
|
|
encrypted_master_secret,
|
|
|
|
encrypted_master_secret,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# show and confirm individual shares
|
|
|
|
|
|
|
|
if len(groups) == 1:
|
|
|
|
|
|
|
|
await layout.slip39_show_checklist(2, BAK_T_SLIP39_BASIC)
|
|
|
|
|
|
|
|
await layout.slip39_basic_show_and_confirm_shares(mnemonics[0])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await layout.slip39_advanced_show_and_confirm_shares(mnemonics)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _validate_reset_device(msg: ResetDevice) -> None:
|
|
|
|
def _validate_reset_device(msg: ResetDevice) -> None:
|
|
|
|
from trezor.wire import UnexpectedMessage
|
|
|
|
from trezor.wire import UnexpectedMessage
|
|
|
@ -225,10 +243,10 @@ async def backup_seed(
|
|
|
|
assert backup_type != BAK_T_BIP39 or group_threshold is None
|
|
|
|
assert backup_type != BAK_T_BIP39 or group_threshold is None
|
|
|
|
|
|
|
|
|
|
|
|
if group_threshold is not None:
|
|
|
|
if group_threshold is not None:
|
|
|
|
await _backup_slip39(mnemonic_secret, group_threshold, groups)
|
|
|
|
await _backup_slip39_custom(mnemonic_secret, group_threshold, groups)
|
|
|
|
elif backup_type == BAK_T_SLIP39_BASIC:
|
|
|
|
elif backup_type == BAK_T_SLIP39_BASIC:
|
|
|
|
await _backup_slip39_basic(mnemonic_secret)
|
|
|
|
await _backup_slip39_basic(mnemonic_secret)
|
|
|
|
elif backup_type == BAK_T_SLIP39_ADVANCED:
|
|
|
|
elif backup_type == BAK_T_SLIP39_ADVANCED:
|
|
|
|
await _backup_slip39_advanced(mnemonic_secret)
|
|
|
|
await _backup_slip39_advanced(mnemonic_secret)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
await layout.bip39_show_and_confirm_mnemonic(mnemonic_secret.decode())
|
|
|
|
await layout.show_and_confirm_mnemonic(mnemonic_secret.decode())
|
|
|
|