1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 05:03:07 +00:00
trezor-firmware/src/apps/wallet/sign_message.py
Jan Pochyla 710306495e apps: reduce unimport usage
unimport should be used only on the workflow dispatchers.
2018-01-30 18:50:59 +01:00

30 lines
871 B
Python

from trezor import ui
async def layout_sign_message(ctx, msg):
from trezor.messages.MessageSignature import MessageSignature
from trezor.crypto.curve import secp256k1
from ..common import coins
from ..common import seed
from ..common.signverify import message_digest
ui.display.clear()
ui.display.text(10, 30, 'Signing message',
ui.BOLD, ui.LIGHT_GREEN, ui.BG)
ui.display.text(10, 60, msg.message, ui.MONO, ui.FG, ui.BG)
coin_name = msg.coin_name or 'Bitcoin'
coin = coins.by_name(coin_name)
node = await seed.get_root(ctx)
node.derive_path(msg.address_n)
seckey = node.private_key()
address = node.address(coin.address_type)
digest = message_digest(coin, msg.message)
signature = secp256k1.sign(seckey, digest)
return MessageSignature(address=address, signature=signature)