From a38e57a31f1c4e16ea980d009e7a1b6a0cb7c186 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 28 Feb 2018 15:12:00 +0100 Subject: [PATCH] src/app/wallet: sign identity ui --- src/apps/wallet/sign_identity.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/apps/wallet/sign_identity.py b/src/apps/wallet/sign_identity.py index d44db8f370..f57f0fcf8e 100644 --- a/src/apps/wallet/sign_identity.py +++ b/src/apps/wallet/sign_identity.py @@ -2,6 +2,9 @@ from trezor import ui from trezor.crypto.hashlib import sha256 from trezor.messages.SignedIdentity import SignedIdentity from ustruct import pack, unpack +from trezor.utils import chunks +from apps.common.confirm import require_confirm +from trezor.ui.text import Text from ..common import coins, seed @@ -11,7 +14,8 @@ async def sign_identity(ctx, msg): msg.ecdsa_curve_name = 'secp256k1' identity = serialize_identity(msg.identity) - display_identity(identity, msg.challenge_visual) + + await confirm_sign_identity(ctx, identity, msg.challenge_visual) address_n = get_identity_path(identity, msg.identity.index or 0) node = await seed.derive_node(ctx, address_n, msg.ecdsa_curve_name) @@ -39,6 +43,14 @@ async def sign_identity(ctx, msg): return SignedIdentity(address=address, public_key=pubkey, signature=signature) +async def confirm_sign_identity(ctx, identity, challenge_visual): + lines = chunks(identity, 18) + content = Text('Sign identity', ui.ICON_DEFAULT, + challenge_visual, + ui.MONO, *lines, max_lines=5) + await require_confirm(ctx, content) + + def serialize_identity(identity): s = '' if identity.proto: @@ -54,14 +66,6 @@ def serialize_identity(identity): return s -def display_identity(identity: str, challenge_visual: str): - ui.display.clear() - ui.display.text(10, 30, 'Identity:', - ui.BOLD, ui.LIGHT_GREEN, ui.BG) - ui.display.text(10, 60, challenge_visual, ui.MONO, ui.FG, ui.BG) - ui.display.text(10, 80, identity, ui.MONO, ui.FG, ui.BG) - - def get_identity_path(identity: str, index: int): identity_hash = sha256(pack('