1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

app.lisk: Add lisk_sign_message

This commit is contained in:
Aleksey Popov 2018-04-16 23:09:32 +03:00 committed by Jan Pochyla
parent a37493a861
commit dc5115055f
2 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from trezor.wire import register, protobuf_workflow from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \ from trezor.messages.wire_types import \
LiskGetAddress, LiskGetPublicKey LiskGetAddress, LiskSignMessage, LiskGetPublicKey
def dispatch_LiskGetAddress(*args, **kwargs): def dispatch_LiskGetAddress(*args, **kwargs):
@ -13,6 +13,12 @@ def dispatch_LiskGetPublicKey(*args, **kwargs):
return lisk_get_public_key(*args, **kwargs) return lisk_get_public_key(*args, **kwargs)
def dispatch_LiskSignMessage(*args, **kwargs):
from .sign_message import lisk_sign_message
return lisk_sign_message(*args, **kwargs)
def boot(): def boot():
register(LiskGetPublicKey, protobuf_workflow, dispatch_LiskGetPublicKey) register(LiskGetPublicKey, protobuf_workflow, dispatch_LiskGetPublicKey)
register(LiskGetAddress, protobuf_workflow, dispatch_LiskGetAddress) register(LiskGetAddress, protobuf_workflow, dispatch_LiskGetAddress)
register(LiskSignMessage, protobuf_workflow, dispatch_LiskSignMessage)

View File

@ -0,0 +1,17 @@
from .helpers import LISK_CURVE, get_address_from_public_key
async def lisk_sign_message(ctx, msg):
from trezor.messages.LiskMessageSignature import LiskMessageSignature
from trezor.crypto.curve import ed25519
from ..common import seed
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
seckey = node.private_key()
public_key = ed25519.publickey(seckey)
address = get_address_from_public_key(public_key)
signature = ed25519.sign(seckey, msg.message)
return LiskMessageSignature(address=address, signature=signature)