2016-11-23 13:51:05 +00:00
|
|
|
from trezor import ui
|
2016-09-21 12:24:12 +00:00
|
|
|
from trezor.utils import unimport
|
2016-06-09 15:34:43 +00:00
|
|
|
|
2016-09-21 12:24:12 +00:00
|
|
|
|
|
|
|
@unimport
|
2016-12-08 15:18:12 +00:00
|
|
|
async def layout_sign_message(session_id, msg):
|
2016-11-16 20:28:27 +00:00
|
|
|
from trezor.messages.MessageSignature import MessageSignature
|
|
|
|
from trezor.crypto.curve import secp256k1
|
|
|
|
from ..common import coins
|
2016-12-08 15:18:12 +00:00
|
|
|
from ..common import seed
|
2016-11-16 22:08:41 +00:00
|
|
|
from ..common.signverify import message_digest
|
2016-09-26 11:07:53 +00:00
|
|
|
|
2016-09-28 15:00:27 +00:00
|
|
|
ui.display.clear()
|
2016-09-21 12:24:12 +00:00
|
|
|
ui.display.text(10, 30, 'Signing message',
|
|
|
|
ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
2016-11-16 20:28:27 +00:00
|
|
|
ui.display.text(10, 60, msg.message, ui.MONO, ui.WHITE, ui.BLACK)
|
2016-09-21 12:24:12 +00:00
|
|
|
|
2016-11-23 13:51:05 +00:00
|
|
|
coin_name = msg.coin_name or 'Bitcoin'
|
2016-11-16 20:28:27 +00:00
|
|
|
coin = coins.by_name(coin_name)
|
2016-09-26 11:07:53 +00:00
|
|
|
|
2016-12-08 15:18:12 +00:00
|
|
|
node = await seed.get_node(session_id, msg.address_n)
|
2016-11-16 20:28:27 +00:00
|
|
|
seckey = node.private_key()
|
|
|
|
address = node.address(coin.address_type)
|
|
|
|
|
2016-11-17 12:40:05 +00:00
|
|
|
digest = message_digest(coin, msg.message)
|
2016-11-16 20:28:27 +00:00
|
|
|
|
|
|
|
signature = secp256k1.sign(seckey, digest)
|
|
|
|
|
|
|
|
return MessageSignature(address=address, signature=signature)
|