1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-19 12:58:13 +00:00

fix(core): show correct word count in more info

Make translated strings describing recovery shares templated so that we
can show correct number of words (i.e. 20 or 33) in more info.
This commit is contained in:
obrusvit 2024-07-18 11:30:45 +02:00 committed by Vít Obrusník
parent 0d987a68f4
commit c6df2179d6
15 changed files with 78 additions and 47 deletions

View File

@ -506,9 +506,9 @@ static void _librust_qstrs(void) {
MP_QSTR_reset__never_make_digital_copy;
MP_QSTR_reset__num_of_share_holders_template;
MP_QSTR_reset__num_of_shares_advanced_info_template;
MP_QSTR_reset__num_of_shares_basic_info;
MP_QSTR_reset__num_of_shares_basic_info_template;
MP_QSTR_reset__num_of_shares_how_many;
MP_QSTR_reset__num_of_shares_long_info;
MP_QSTR_reset__num_of_shares_long_info_template;
MP_QSTR_reset__num_shares_for_group_template;
MP_QSTR_reset__number_of_shares_info;
MP_QSTR_reset__one_share;

View File

@ -845,8 +845,8 @@ pub enum TranslatedString {
reset__needed_to_recover_your_wallet = 557, // "needed to recover your wallet. "
reset__never_make_digital_copy = 558, // "Never put your backup anywhere digital."
reset__num_of_share_holders_template = 559, // "{0} people or locations will each hold one share."
reset__num_of_shares_advanced_info_template = 560, // "Each recovery share is a sequence of 20 words. Next you will choose the threshold number of shares needed to form Group {0}."
reset__num_of_shares_basic_info = 561, // "Each recovery share is a sequence of 20 words. Next you will choose how many shares you need to recover your wallet."
reset__num_of_shares_advanced_info_template = 560, // "Each recovery share is a sequence of {0} words. Next you will choose the threshold number of shares needed to form Group {1}."
reset__num_of_shares_basic_info_template = 561, // "Each recovery share is a sequence of {0} words. Next you will choose how many shares you need to recover your wallet."
reset__num_shares_for_group_template = 562, // "The required number of shares to form Group {0}."
reset__number_of_shares_info = 563, // "= total number of unique word lists used for wallet backup."
reset__one_share = 564, // "1 share"
@ -1308,7 +1308,7 @@ pub enum TranslatedString {
reset__incorrect_word_selected = 907, // "Incorrect word selected"
reset__more_at = 908, // "More at"
reset__num_of_shares_how_many = 909, // "How many wallet backup shares do you want to create?"
reset__num_of_shares_long_info = 910, // "Each backup share is a sequence of 20 words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet."
reset__num_of_shares_long_info_template = 910, // "Each backup share is a sequence of {0} words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet."
reset__select_threshold = 911, // "Select the minimum shares required to recover your wallet."
reset__share_completed_template = 912, // "Share #{0} completed"
reset__slip39_checklist_num_shares_x_template = 913, // "Number of shares: {0}"
@ -2196,8 +2196,8 @@ impl TranslatedString {
Self::reset__needed_to_recover_your_wallet => "needed to recover your wallet. ",
Self::reset__never_make_digital_copy => "Never put your backup anywhere digital.",
Self::reset__num_of_share_holders_template => "{0} people or locations will each hold one share.",
Self::reset__num_of_shares_advanced_info_template => "Each recovery share is a sequence of 20 words. Next you will choose the threshold number of shares needed to form Group {0}.",
Self::reset__num_of_shares_basic_info => "Each recovery share is a sequence of 20 words. Next you will choose how many shares you need to recover your wallet.",
Self::reset__num_of_shares_advanced_info_template => "Each recovery share is a sequence of {0} words. Next you will choose the threshold number of shares needed to form Group {1}.",
Self::reset__num_of_shares_basic_info_template => "Each recovery share is a sequence of {0} words. Next you will choose how many shares you need to recover your wallet.",
Self::reset__num_shares_for_group_template => "The required number of shares to form Group {0}.",
Self::reset__number_of_shares_info => "= total number of unique word lists used for wallet backup.",
Self::reset__one_share => "1 share",
@ -2659,7 +2659,7 @@ impl TranslatedString {
Self::reset__incorrect_word_selected => "Incorrect word selected",
Self::reset__more_at => "More at",
Self::reset__num_of_shares_how_many => "How many wallet backup shares do you want to create?",
Self::reset__num_of_shares_long_info => "Each backup share is a sequence of 20 words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet.",
Self::reset__num_of_shares_long_info_template => "Each backup share is a sequence of {0} words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet.",
Self::reset__select_threshold => "Select the minimum shares required to recover your wallet.",
Self::reset__share_completed_template => "Share #{0} completed",
Self::reset__slip39_checklist_num_shares_x_template => "Number of shares: {0}",
@ -3549,7 +3549,7 @@ impl TranslatedString {
Qstr::MP_QSTR_reset__never_make_digital_copy => Some(Self::reset__never_make_digital_copy),
Qstr::MP_QSTR_reset__num_of_share_holders_template => Some(Self::reset__num_of_share_holders_template),
Qstr::MP_QSTR_reset__num_of_shares_advanced_info_template => Some(Self::reset__num_of_shares_advanced_info_template),
Qstr::MP_QSTR_reset__num_of_shares_basic_info => Some(Self::reset__num_of_shares_basic_info),
Qstr::MP_QSTR_reset__num_of_shares_basic_info_template => Some(Self::reset__num_of_shares_basic_info_template),
Qstr::MP_QSTR_reset__num_shares_for_group_template => Some(Self::reset__num_shares_for_group_template),
Qstr::MP_QSTR_reset__number_of_shares_info => Some(Self::reset__number_of_shares_info),
Qstr::MP_QSTR_reset__one_share => Some(Self::reset__one_share),
@ -4011,7 +4011,7 @@ impl TranslatedString {
Qstr::MP_QSTR_reset__incorrect_word_selected => Some(Self::reset__incorrect_word_selected),
Qstr::MP_QSTR_reset__more_at => Some(Self::reset__more_at),
Qstr::MP_QSTR_reset__num_of_shares_how_many => Some(Self::reset__num_of_shares_how_many),
Qstr::MP_QSTR_reset__num_of_shares_long_info => Some(Self::reset__num_of_shares_long_info),
Qstr::MP_QSTR_reset__num_of_shares_long_info_template => Some(Self::reset__num_of_shares_long_info_template),
Qstr::MP_QSTR_reset__select_threshold => Some(Self::reset__select_threshold),
Qstr::MP_QSTR_reset__share_completed_template => Some(Self::reset__share_completed_template),
Qstr::MP_QSTR_reset__slip39_checklist_num_shares_x_template => Some(Self::reset__slip39_checklist_num_shares_x_template),

View File

@ -632,10 +632,10 @@ class TR:
reset__needed_to_recover_your_wallet: str = "needed to recover your wallet. "
reset__never_make_digital_copy: str = "Never put your backup anywhere digital."
reset__num_of_share_holders_template: str = "{0} people or locations will each hold one share."
reset__num_of_shares_advanced_info_template: str = "Each recovery share is a sequence of 20 words. Next you will choose the threshold number of shares needed to form Group {0}."
reset__num_of_shares_basic_info: str = "Each recovery share is a sequence of 20 words. Next you will choose how many shares you need to recover your wallet."
reset__num_of_shares_advanced_info_template: str = "Each recovery share is a sequence of {0} words. Next you will choose the threshold number of shares needed to form Group {1}."
reset__num_of_shares_basic_info_template: str = "Each recovery share is a sequence of {0} words. Next you will choose how many shares you need to recover your wallet."
reset__num_of_shares_how_many: str = "How many wallet backup shares do you want to create?"
reset__num_of_shares_long_info: str = "Each backup share is a sequence of 20 words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet."
reset__num_of_shares_long_info_template: str = "Each backup share is a sequence of {0} words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet."
reset__num_shares_for_group_template: str = "The required number of shares to form Group {0}."
reset__number_of_shares_info: str = "= total number of unique word lists used for wallet backup."
reset__one_share: str = "1 share"

View File

@ -65,3 +65,22 @@ def infer_backup_type(is_slip39: bool, share: Share | None = None) -> BackupType
return BackupType.Slip39_Advanced_Extendable
else:
return BackupType.Slip39_Advanced
def get_num_of_words_per_share(
backup_type: BackupType, secret_length_bytes: int
) -> int:
if is_slip39_backup_type(backup_type):
if secret_length_bytes == 16:
return 20
elif secret_length_bytes == 32:
return 33
else:
if secret_length_bytes == 16:
return 12
elif secret_length_bytes == 24:
return 18
elif secret_length_bytes == 32:
return 24
# Invalid backup type and secret length combination
raise RuntimeError

View File

@ -144,7 +144,7 @@ async def _backup_slip39_single(
async def _backup_slip39_basic(
encrypted_master_secret: bytes, extendable: bool
encrypted_master_secret: bytes, num_of_words: int, extendable: bool
) -> None:
group_threshold = 1
@ -152,7 +152,7 @@ async def _backup_slip39_basic(
# get number of shares
await layout.slip39_show_checklist(0, advanced=False)
share_count = await layout.slip39_prompt_number_of_shares()
share_count = await layout.slip39_prompt_number_of_shares(num_of_words)
# get threshold
await layout.slip39_show_checklist(1, advanced=False, count=share_count)
@ -173,9 +173,8 @@ async def _backup_slip39_basic(
async def _backup_slip39_advanced(
encrypted_master_secret: bytes, extendable: bool
encrypted_master_secret: bytes, num_of_words: int, extendable: bool
) -> None:
await layout.show_backup_intro(single_share=False)
# get number of groups
@ -192,7 +191,7 @@ async def _backup_slip39_advanced(
)
groups = []
for i in range(groups_count):
share_count = await layout.slip39_prompt_number_of_shares(i)
share_count = await layout.slip39_prompt_number_of_shares(num_of_words, i)
share_threshold = await layout.slip39_prompt_threshold(share_count, i)
groups.append((share_threshold, share_count))
@ -294,12 +293,15 @@ def _compute_secret_from_entropy(
async def backup_seed(backup_type: BackupType, mnemonic_secret: bytes) -> None:
if backup_types.is_slip39_backup_type(backup_type):
num_of_words = backup_types.get_num_of_words_per_share(
backup_type, len(mnemonic_secret)
)
extendable = backup_types.is_extendable_backup_type(backup_type)
if backup_types.is_slip39_advanced_backup_type(backup_type):
await _backup_slip39_advanced(mnemonic_secret, extendable)
await _backup_slip39_advanced(mnemonic_secret, num_of_words, extendable)
elif backup_type == BAK_T_SLIP39_SINGLE_EXT:
await _backup_slip39_single(mnemonic_secret, extendable)
else:
await _backup_slip39_basic(mnemonic_secret, extendable)
await _backup_slip39_basic(mnemonic_secret, num_of_words, extendable)
else:
await _backup_bip39(mnemonic_secret.decode())

View File

@ -226,7 +226,9 @@ async def slip39_prompt_threshold(
)
async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
async def slip39_prompt_number_of_shares(
num_words: int, group_id: int | None = None
) -> int:
count = 5
min_count = 1
max_count = 16
@ -238,9 +240,11 @@ async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
)
if group_id is None:
info = TR.reset__num_of_shares_long_info
info = TR.reset__num_of_shares_long_info_template.format(num_words)
else:
info = TR.reset__num_of_shares_advanced_info_template.format(group_id + 1)
info = TR.reset__num_of_shares_advanced_info_template.format(
num_words, group_id + 1
)
return await _prompt_number(
TR.reset__title_set_number_of_shares,

View File

@ -196,7 +196,9 @@ async def slip39_prompt_threshold(
)
async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
async def slip39_prompt_number_of_shares(
_num_words: int, group_id: int | None = None
) -> int:
await confirm_action(
"slip39_shares",
TR.reset__title_number_of_shares,

View File

@ -241,7 +241,9 @@ async def slip39_prompt_threshold(
)
async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
async def slip39_prompt_number_of_shares(
num_words: int, group_id: int | None = None
) -> int:
count = 5
min_count = 1
max_count = 16
@ -258,9 +260,11 @@ async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
)
if group_id is None:
info = TR.reset__num_of_shares_basic_info
info = TR.reset__num_of_shares_basic_info_template.format(num_words)
else:
info = TR.reset__num_of_shares_advanced_info_template.format(group_id + 1)
info = TR.reset__num_of_shares_advanced_info_template.format(
num_words, group_id + 1
)
return await _prompt_number(
TR.reset__title_set_number_of_shares,

View File

@ -663,10 +663,10 @@
"reset__needed_to_recover_your_wallet": "potřeba k obnovení peněženky. ",
"reset__never_make_digital_copy": "Nevytvářejte digitální kopii zálohy ani ji nenahrávejte na internet!",
"reset__num_of_share_holders_template": "Každý z {0} lidí nebo míst bude mít jednu část.",
"reset__num_of_shares_advanced_info_template": "Každá část zálohy je sekvence 20 slov. Dále zvolíte počet částí pro obnovu potřebných k vytvoření skupiny {0}.",
"reset__num_of_shares_basic_info": "Každá část zálohy je sekvence 20 slov. Dále zvolíte, kolik částí potřebujete k obnovení peněženky.",
"reset__num_of_shares_advanced_info_template": "Každá část zálohy je sekvence {0} slov. Dále zvolíte počet částí pro obnovu potřebných k vytvoření skupiny {1}.",
"reset__num_of_shares_basic_info_template": "Každá část zálohy je sekvence {0} slov. Dále zvolíte, kolik částí potřebujete k obnovení peněženky.",
"reset__num_of_shares_how_many": "Kolik částí zálohy peněženky chcete vytvořit?",
"reset__num_of_shares_long_info": "Každá část zálohy je sekvence 20 slov. Každý seznam slov si uložte na jiné, bezpečné místo nebo ho sdělte někomu, komu důvěřujete. Poté je použijte v případě potřeby obnovení peněženky.",
"reset__num_of_shares_long_info_template": "Každá část zálohy je sekvence {0} slov. Každý seznam slov si uložte na jiné, bezpečné místo nebo ho sdělte někomu, komu důvěřujete. Poté je použijte v případě potřeby obnovení peněženky.",
"reset__num_shares_for_group_template": "Potřebný počet částí k vytvoření skupiny {0}.",
"reset__number_of_shares_info": "= počet seznamů jedinečných slov u zálohy peněženky.",
"reset__one_share": "1 část",

View File

@ -663,10 +663,10 @@
"reset__needed_to_recover_your_wallet": "zur Wallet Wiederh. nötig. ",
"reset__never_make_digital_copy": "Erstelle niemals eine digitale Kopie deines Backups oder lade es online hoch!",
"reset__num_of_share_holders_template": "{0} Personen oder Standorte halten jeweils einen Share.",
"reset__num_of_shares_advanced_info_template": "Jeder Recovery Share besteht aus 20 Wörtern. Wähle jetzt die Schwelle für die Anzahl der Shares zur Bildung von Gruppe {0}.",
"reset__num_of_shares_basic_info": "Jeder Recovery Share besteht aus 20 Wörtern. Wähle, wie viele Shares du zur Wallet-Wiederherstell. benötigst.",
"reset__num_of_shares_advanced_info_template": "Jeder Recovery Share besteht aus {0} Wörtern. Wähle jetzt die Schwelle für die Anzahl der Shares zur Bildung von Gruppe {1}.",
"reset__num_of_shares_basic_info_template": "Jeder Recovery Share besteht aus {0} Wörtern. Wähle, wie viele Shares du zur Wallet-Wiederherstell. benötigst.",
"reset__num_of_shares_how_many": "Wie viele Wallet-Backup-Shares möchtest du erstellen?",
"reset__num_of_shares_long_info": "Jeder Recovery Share besteht aus 20 Wörtern. Speichere jede Wortliste an einem anderen, sicheren Ort oder teile sie mit vertrauenswürdigen Personen. Nutze sie je nach Bedarf, um dein Wallet wiederherzustellen.",
"reset__num_of_shares_long_info_template": "Jeder Recovery Share besteht aus {0} Wörtern. Speichere jede Wortliste an einem anderen, sicheren Ort oder teile sie mit vertrauenswürdigen Personen. Nutze sie je nach Bedarf, um dein Wallet wiederherzustellen.",
"reset__num_shares_for_group_template": "Die erforderliche Anzahl an Shares zur Bildung der Gruppe {0}.",
"reset__number_of_shares_info": "= Gesamtzahl eindeutiger Wortlisten für Wallet-Backup.",
"reset__one_share": "1 Share",

View File

@ -634,10 +634,10 @@
"reset__needed_to_recover_your_wallet": "needed to recover your wallet. ",
"reset__never_make_digital_copy": "Never put your backup anywhere digital.",
"reset__num_of_share_holders_template": "{0} people or locations will each hold one share.",
"reset__num_of_shares_advanced_info_template": "Each recovery share is a sequence of 20 words. Next you will choose the threshold number of shares needed to form Group {0}.",
"reset__num_of_shares_basic_info": "Each recovery share is a sequence of 20 words. Next you will choose how many shares you need to recover your wallet.",
"reset__num_of_shares_advanced_info_template": "Each recovery share is a sequence of {0} words. Next you will choose the threshold number of shares needed to form Group {1}.",
"reset__num_of_shares_basic_info_template": "Each recovery share is a sequence of {0} words. Next you will choose how many shares you need to recover your wallet.",
"reset__num_of_shares_how_many": "How many wallet backup shares do you want to create?",
"reset__num_of_shares_long_info": "Each backup share is a sequence of 20 words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet.",
"reset__num_of_shares_long_info_template": "Each backup share is a sequence of {0} words. Store each wordlist in a separate, safe location or share with trusted individuals. Collect as needed to recover your wallet.",
"reset__num_shares_for_group_template": "The required number of shares to form Group {0}.",
"reset__number_of_shares_info": "= total number of unique word lists used for wallet backup.",
"reset__one_share": "1 share",

View File

@ -663,10 +663,10 @@
"reset__needed_to_recover_your_wallet": "para recuperar el monedero. ",
"reset__never_make_digital_copy": "No hagas nunca una copia digital de la copia de seguridad ni la cargues en línea.",
"reset__num_of_share_holders_template": "{0} persona/s o ubicación/es tendrá/n un recurso compartido.",
"reset__num_of_shares_advanced_info_template": "Cada rec. comp. de recuperación es una cadena de 20 palabras. Elige el umbral necesario para formar el grupo {0}.",
"reset__num_of_shares_basic_info": "Cada rec. comp. de recuperación es una cadena de 20 palabras. Elige cuántos necesitas para recuperar el monedero.",
"reset__num_of_shares_advanced_info_template": "Cada rec. comp. de recuperación es una cadena de {0} palabras. Elige el umbral necesario para formar el grupo {1}.",
"reset__num_of_shares_basic_info_template": "Cada rec. comp. de recuperación es una cadena de {0} palabras. Elige cuántos necesitas para recuperar el monedero.",
"reset__num_of_shares_how_many": "¿Cuántos recursos de copia de seguridad quieres crear?",
"reset__num_of_shares_long_info": "Cada recurso compartido de recuperación es una secuencia de 20 palabras. Guarda cada lista de palabras en un lugar separado y seguro o compártela con personas de confianza. Recopila lo necesario para recuperar el monedero.",
"reset__num_of_shares_long_info_template": "Cada recurso compartido de recuperación es una secuencia de {0} palabras. Guarda cada lista de palabras en un lugar separado y seguro o compártela con personas de confianza. Recopila lo necesario para recuperar el monedero.",
"reset__num_shares_for_group_template": "Nro.necesario de rec. comp. para formar el grupo {0}.",
"reset__number_of_shares_info": "= total de listas de palabras únicas para la copia de seguridad.",
"reset__one_share": "1 recurso compartido",

View File

@ -663,10 +663,10 @@
"reset__needed_to_recover_your_wallet": "requis pour récup. votre portef. ",
"reset__never_make_digital_copy": "Ne pas créer de copie numérique ni en ligne de votre sauv. !",
"reset__num_of_share_holders_template": "{0} personnes ou emp. détiendront chacun un fragm.",
"reset__num_of_shares_advanced_info_template": "Chaque fragm. de récup. se compose de 20 mots. Vous choisirez le nbr seuil de fragm. néc. pour former le Groupe {0}.",
"reset__num_of_shares_basic_info": "Chaque fragm. de récup. se compose de 20 mots. Vous choisirez le nbr de fragm. néc. pour récup. votre portef.",
"reset__num_of_shares_advanced_info_template": "Chaque fragm. de récup. se compose de {0} mots. Vous choisirez le nbr seuil de fragm. néc. pour former le Groupe {1}.",
"reset__num_of_shares_basic_info_template": "Chaque fragm. de récup. se compose de {0} mots. Vous choisirez le nbr de fragm. néc. pour récup. votre portef.",
"reset__num_of_shares_how_many": "Combien de fragments de sauvegarde de portefeuille voulez-vous créer ?",
"reset__num_of_shares_long_info": "Chaque fragment de récupération se compose de 20 mots. Stockez chaque liste de mots dans un emplacement séparé et sûr ou partagez-la à des personnes de confiance. Recueillir si nécessaire pour récupérer votre portefeuille.",
"reset__num_of_shares_long_info_template": "Chaque fragment de récupération se compose de {0} mots. Stockez chaque liste de mots dans un emplacement séparé et sûr ou partagez-la à des personnes de confiance. Recueillir si nécessaire pour récupérer votre portefeuille.",
"reset__num_shares_for_group_template": "Le nbre de fragm. requis pour former le Groupe {0}.",
"reset__number_of_shares_info": "= nbre total de listes de mots uniques pour la sauv. du portef.",
"reset__one_share": "1 fragm.",

View File

@ -560,7 +560,7 @@
"558": "reset__never_make_digital_copy",
"559": "reset__num_of_share_holders_template",
"560": "reset__num_of_shares_advanced_info_template",
"561": "reset__num_of_shares_basic_info",
"561": "reset__num_of_shares_basic_info_template",
"562": "reset__num_shares_for_group_template",
"563": "reset__number_of_shares_info",
"564": "reset__one_share",
@ -909,7 +909,7 @@
"907": "reset__incorrect_word_selected",
"908": "reset__more_at",
"909": "reset__num_of_shares_how_many",
"910": "reset__num_of_shares_long_info",
"910": "reset__num_of_shares_long_info_template",
"911": "reset__select_threshold",
"912": "reset__share_completed_template",
"913": "reset__slip39_checklist_num_shares_x_template",

View File

@ -1,8 +1,8 @@
{
"current": {
"merkle_root": "8208aebbeec2ab19c0ee5e4298752597ff1b151d56482c877891097b9b72464b",
"datetime": "2024-07-18T13:04:23.054546",
"commit": "6280ef2e4266dca1080d549a9c2a7f1a74616527"
"merkle_root": "5fc3e1a642df97568b380cb551bbf809faceed0c9e5c196d4f92b87f51b840c6",
"datetime": "2024-07-18T09:35:46.769791",
"commit": "3ee259636d33b7fea7b1a841685f610c7b52bf73"
},
"history": [
{