diff --git a/src/apps/wallet/__init__.py b/src/apps/wallet/__init__.py index e9797d57b..571aaf3ff 100644 --- a/src/apps/wallet/__init__.py +++ b/src/apps/wallet/__init__.py @@ -1,7 +1,9 @@ from trezor.wire import register_type, protobuf_handler from trezor.utils import unimport from trezor.messages.wire_types import \ - GetPublicKey, GetAddress, SignTx, EstimateTxSize, SignMessage, VerifyMessage + GetPublicKey, GetAddress, SignTx, EstimateTxSize, \ + SignMessage, VerifyMessage, \ + SignIdentity @unimport @@ -43,6 +45,12 @@ def dispatch_VerifyMessage(*args, **kwargs): return layout_verify_message(*args, **kwargs) +@unimport +def dispatch_SignIdentity(*args, **kwargs): + from .layout_sign_identity import layout_sign_identity + return layout_sign_identity(*args, **kwargs) + + def boot(): register_type(GetPublicKey, protobuf_handler, dispatch_GetPublicKey) register_type(GetAddress, protobuf_handler, dispatch_GetAddress) @@ -50,3 +58,4 @@ def boot(): register_type(EstimateTxSize, protobuf_handler, dispatch_EstimateTxSize) register_type(SignMessage, protobuf_handler, dispatch_SignMessage) register_type(VerifyMessage, protobuf_handler, dispatch_VerifyMessage) + register_type(SignIdentity, protobuf_handler, dispatch_SignIdentity) diff --git a/src/apps/wallet/layout_sign_identity.py b/src/apps/wallet/layout_sign_identity.py new file mode 100644 index 000000000..f221ad2b3 --- /dev/null +++ b/src/apps/wallet/layout_sign_identity.py @@ -0,0 +1,52 @@ +from trezor import wire, ui +from trezor.utils import unimport + +@unimport +async def layout_sign_identity(msg, session_id): + from trezor.messages.SignedIdentity import SignedIdentity + from trezor.crypto.curve import secp256k1 + from trezor.crypto.hashlib import sha256 + from ustruct import pack, unpack + from ..common.seed import get_node + from ..common import coins + from ..common.signverify import message_digest + + identity = '' + if hasattr(msg.identity, 'proto') and msg.identity.proto: + identity += msg.identity.proto + '://' + if hasattr(msg.identity, 'user') and msg.identity.user: + identity += msg.identity.user + '@' + if hasattr(msg.identity, 'host') and msg.identity.host: + identity += msg.identity.host + if hasattr(msg.identity, 'port') and msg.identity.port: + identity += ':' + msg.identity.port + if hasattr(msg.identity, 'path') and msg.identity.path: + identity += msg.identity.path + + index = getattr(msg.identity, 'index', 0) + identity_hash = sha256(pack('