Skip to content

Commit

Permalink
feat: Remove display_random feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkozlik committed Aug 27, 2024
1 parent 0a0c100 commit 1655c53
Show file tree
Hide file tree
Showing 38 changed files with 117 additions and 390 deletions.
2 changes: 1 addition & 1 deletion common/protob/messages-management.proto
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ message LoadDevice {
* @next Failure
*/
message ResetDevice {
optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
reserved 1; // unused display_random
optional uint32 strength = 2 [default=256]; // strength of seed in bits
optional bool passphrase_protection = 3; // enable master node encryption using passphrase
optional bool pin_protection = 4; // enable PIN protection
Expand Down
1 change: 1 addition & 0 deletions core/.changelog.d/4119.removed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed display_random feature.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/mocks/trezortranslate_keys.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ class TR:
device_name__change_template: str = "Change device name to {0}?"
device_name__title: str = "Device name"
entropy__send: str = "Do you really want to send entropy?"
entropy__title: str = "Internal entropy"
entropy__title_confirm: str = "Confirm entropy"
eos__about_to_sign_template: str = "You are about to sign {0}."
eos__action_name: str = "Action Name:"
Expand Down
4 changes: 0 additions & 4 deletions core/src/apps/management/reset_device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ async def reset_device(msg: ResetDevice) -> Success:
int_entropy = random.bytes(32, True)
if __debug__:
storage.debug.reset_internal_entropy = int_entropy
if msg.display_random:
await layout.show_internal_entropy(int_entropy)

# request external entropy and compute the master secret
entropy_ack = await call(EntropyRequest(), EntropyAck)
Expand Down Expand Up @@ -269,8 +267,6 @@ def _validate_reset_device(msg: ResetDevice) -> None:
else:
raise ProcessError("Backup type not implemented")

if msg.display_random and (msg.skip_backup or msg.no_backup):
raise ProcessError("Can't show internal entropy when backup is skipped")
if storage_device.is_initialized():
raise UnexpectedMessage("Already initialized")

Expand Down
13 changes: 0 additions & 13 deletions core/src/apps/management/reset_device/layout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from micropython import const
from typing import Sequence

from trezor import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts.reset import ( # noqa: F401
show_share_words,
slip39_advanced_prompt_group_threshold,
Expand All @@ -15,17 +13,6 @@
_NUM_OF_CHOICES = const(3)


async def show_internal_entropy(entropy: bytes) -> None:
from trezor.ui.layouts import confirm_blob

await confirm_blob(
"entropy",
TR.entropy__title,
entropy,
br_code=ButtonRequestType.ResetDevice,
)


async def _confirm_word(
share_index: int | None,
share_words: Sequence[str],
Expand Down
2 changes: 0 additions & 2 deletions core/src/trezor/messages.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/tools/translations/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
"device_name__change_template": "text,3",
"device_name__title": "title,1",
"entropy__send": "text,2",
"entropy__title": "title,1",
"entropy__title_confirm": "title,1",
"eos__about_to_sign_template": "text,2",
"eos__action_name": "text,1",
Expand Down
1 change: 0 additions & 1 deletion core/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
"device_name__change_template": "Změnit název zařízení na {0}?",
"device_name__title": "Název zařízení",
"entropy__send": "Opravdu chcete odeslat entropii?",
"entropy__title": "Interní entropie",
"entropy__title_confirm": "Potvrdit entropii",
"eos__about_to_sign_template": "Chystáte se podepsat {0}.",
"eos__action_name": "Název akce:",
Expand Down
1 change: 0 additions & 1 deletion core/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
"device_name__change_template": "Gerätename in {0} ändern?",
"device_name__title": "Gerätename",
"entropy__send": "Entropie wirklich senden?",
"entropy__title": "Interne entropie",
"entropy__title_confirm": "Entropie bestätigen",
"eos__about_to_sign_template": "Du bist dabei, {0} zu signieren.",
"eos__action_name": "Aktionsname:",
Expand Down
1 change: 0 additions & 1 deletion core/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
"device_name__change_template": "Change device name to {0}?",
"device_name__title": "Device name",
"entropy__send": "Do you really want to send entropy?",
"entropy__title": "Internal entropy",
"entropy__title_confirm": "Confirm entropy",
"eos__about_to_sign_template": "You are about to sign {0}.",
"eos__action_name": "Action Name:",
Expand Down
1 change: 0 additions & 1 deletion core/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
"device_name__change_template": "¿Cambiar el nombre del dispositivo a {0}?",
"device_name__title": "Nombre dispositivo",
"entropy__send": "¿Quieres enviar la entropía?",
"entropy__title": "Entropía interna",
"entropy__title_confirm": "Validar entropía",
"eos__about_to_sign_template": "Estás a punto de firmar {0}.",
"eos__action_name": "Nombre de acción:",
Expand Down
1 change: 0 additions & 1 deletion core/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
"device_name__change_template": "Modifier le nom du disp. pour {0} ?",
"device_name__title": "Nom du disp.",
"entropy__send": "Voulez-vous vraiment envoyer l'entropie ?",
"entropy__title": "Entropie interne",
"entropy__title_confirm": "Conf. entropie",
"eos__about_to_sign_template": "Vous êtes sur le point de signer {0}.",
"eos__action_name": "Nom de l'action :",
Expand Down
6 changes: 3 additions & 3 deletions core/translations/signatures.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"current": {
"merkle_root": "96fd6399d7631ec16b02f8794aa75ddc5e42152ffcf5acf528206298e9998bb3",
"datetime": "2024-08-26T11:18:49.662110",
"commit": "26436ef6aa930f019e85acf0d0b48e22838b91b3"
"merkle_root": "6803ea2d1eb1555ae32a5b32689cdf40d7626a8b3717f6ae9418e0948f9da746",
"datetime": "2024-08-27T15:18:26.530958",
"commit": "6ebe850fe24f5ec894328d82eec97aacccb3d3f5"
},
"history": [
{
Expand Down
1 change: 1 addition & 0 deletions legacy/firmware/.changelog.d/4119.removed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed display_random feature.
3 changes: 1 addition & 2 deletions legacy/firmware/fsm_msg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ void fsm_msgResetDevice(const ResetDevice *msg) {
msg->strength == 192 || msg->strength == 256,
_("Invalid seed strength"));

reset_init(msg->has_display_random && msg->display_random,
msg->has_strength ? msg->strength : 128,
reset_init(msg->has_strength ? msg->strength : 128,
msg->has_passphrase_protection && msg->passphrase_protection,
msg->has_pin_protection && msg->pin_protection,
msg->has_language ? msg->language : 0,
Expand Down
47 changes: 3 additions & 44 deletions legacy/firmware/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,15 @@ static bool awaiting_entropy = false;
static bool skip_backup = false;
static bool no_backup = false;

void reset_init(bool display_random, uint32_t _strength,
bool passphrase_protection, bool pin_protection,
const char *language, const char *label, uint32_t u2f_counter,
bool _skip_backup, bool _no_backup) {
void reset_init(uint32_t _strength, bool passphrase_protection,
bool pin_protection, const char *language, const char *label,
uint32_t u2f_counter, bool _skip_backup, bool _no_backup) {
if (_strength != 128 && _strength != 192 && _strength != 256) return;

strength = _strength;
skip_backup = _skip_backup;
no_backup = _no_backup;

if (display_random && (skip_backup || no_backup)) {
fsm_sendFailure(FailureType_Failure_ProcessError,
"Can't show internal entropy when backup is skipped");
layoutHome();
return;
}

layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
_("Do you really want to"), _("create a new wallet?"), NULL,
_("By continuing you"), _("agree to trezor.io/tos"), NULL);
Expand All @@ -66,39 +58,6 @@ void reset_init(bool display_random, uint32_t _strength,

random_buffer(int_entropy, 32);

if (display_random) {
for (int start = 0; start < 2; start++) {
char ent_str[4][17] = {0};
char desc[] = "Internal entropy _/2:";
data2hex(int_entropy + start * 16, 4, ent_str[0]);
data2hex(int_entropy + start * 16 + 4, 4, ent_str[1]);
data2hex(int_entropy + start * 16 + 8, 4, ent_str[2]);
data2hex(int_entropy + start * 16 + 12, 4, ent_str[3]);
layoutLast = layoutDialogSwipe;
layoutSwipe();
desc[17] = '1' + start;
oledDrawStringCenter(OLED_WIDTH / 2, 0, desc, FONT_STANDARD);
oledDrawStringCenter(OLED_WIDTH / 2, 2 + 1 * 9, ent_str[0], FONT_FIXED);
oledDrawStringCenter(OLED_WIDTH / 2, 2 + 2 * 9, ent_str[1], FONT_FIXED);
oledDrawStringCenter(OLED_WIDTH / 2, 2 + 3 * 9, ent_str[2], FONT_FIXED);
oledDrawStringCenter(OLED_WIDTH / 2, 2 + 4 * 9, ent_str[3], FONT_FIXED);
oledHLine(OLED_HEIGHT - 13);
layoutButtonNo(_("Cancel"), &bmp_btn_cancel);
layoutButtonYes(_("Continue"), &bmp_btn_confirm);
// 40 is the maximum pixels used for a row
oledSCA(2 + 1 * 9, 2 + 1 * 9 + 6, 40);
oledSCA(2 + 2 * 9, 2 + 2 * 9 + 6, 40);
oledSCA(2 + 3 * 9, 2 + 3 * 9 + 6, 40);
oledSCA(2 + 4 * 9, 2 + 4 * 9 + 6, 40);
oledRefresh();
if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
}

if (pin_protection && !protectChangePin(false)) {
layoutHome();
return;
Expand Down
7 changes: 3 additions & 4 deletions legacy/firmware/reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
#include <stdbool.h>
#include <stdint.h>

void reset_init(bool display_random, uint32_t _strength,
bool passphrase_protection, bool pin_protection,
const char *language, const char *label, uint32_t u2f_counter,
bool _skip_backup, bool _no_backup);
void reset_init(uint32_t _strength, bool passphrase_protection,
bool pin_protection, const char *language, const char *label,
uint32_t u2f_counter, bool _skip_backup, bool _no_backup);
void reset_entropy(const uint8_t *ext_entropy, uint32_t len);
void reset_backup(bool separated, const char *mnemonic);
uint32_t reset_get_int_entropy(uint8_t *entropy);
Expand Down
1 change: 1 addition & 0 deletions python/.changelog.d/4119.removed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed display_random feature.
3 changes: 0 additions & 3 deletions python/src/trezorlib/cli/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def recover(


@cli.command()
@click.option("-e", "--show-entropy", is_flag=True)
@click.option("-t", "--strength", type=click.Choice(["128", "192", "256"]))
@click.option("-r", "--passphrase-protection", is_flag=True)
@click.option("-p", "--pin-protection", is_flag=True)
Expand All @@ -218,7 +217,6 @@ def recover(
@with_client
def setup(
client: "TrezorClient",
show_entropy: bool,
strength: int | None,
passphrase_protection: bool,
pin_protection: bool,
Expand Down Expand Up @@ -257,7 +255,6 @@ def setup(

return device.reset(
client,
display_random=show_entropy,
strength=strength,
passphrase_protection=passphrase_protection,
pin_protection=pin_protection,
Expand Down
7 changes: 6 additions & 1 deletion python/src/trezorlib/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ def reset(
no_backup: bool = False,
backup_type: messages.BackupType = messages.BackupType.Bip39,
) -> "MessageType":
if display_random:
warnings.warn(
"display_random ignored. The feature is deprecated.",
DeprecationWarning,
)

if language is not None:
warnings.warn(
"language ignored. Use change_language() to set device language.",
Expand All @@ -263,7 +269,6 @@ def reset(

# Begin with device reset workflow
msg = messages.ResetDevice(
display_random=bool(display_random),
strength=strength,
passphrase_protection=bool(passphrase_protection),
pin_protection=bool(pin_protection),
Expand Down
3 changes: 0 additions & 3 deletions python/src/trezorlib/messages.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1655c53

Please sign in to comment.