1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-27 01:48:17 +00:00

app.lisk: Add lisk_verify_message

This commit is contained in:
Aleksey Popov 2018-04-16 23:13:38 +03:00 committed by Jan Pochyla
parent dc5115055f
commit 3334163e85
2 changed files with 28 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \
LiskGetAddress, LiskSignMessage, LiskGetPublicKey
LiskGetAddress, LiskSignMessage, LiskVerifyMessage, LiskGetPublicKey
def dispatch_LiskGetAddress(*args, **kwargs):
@ -18,7 +18,13 @@ def dispatch_LiskSignMessage(*args, **kwargs):
return lisk_sign_message(*args, **kwargs)
def dispatch_LiskVerifyMessage(*args, **kwargs):
from .verify_message import lisk_verify_message
return lisk_verify_message(*args, **kwargs)
def boot():
register(LiskGetPublicKey, protobuf_workflow, dispatch_LiskGetPublicKey)
register(LiskGetAddress, protobuf_workflow, dispatch_LiskGetAddress)
register(LiskSignMessage, protobuf_workflow, dispatch_LiskSignMessage)
register(LiskVerifyMessage, protobuf_workflow, dispatch_LiskVerifyMessage)

View File

@ -0,0 +1,21 @@
async def lisk_verify_message(ctx, msg):
from trezor.crypto.curve import ed25519
from .helpers import get_address_from_public_key
from trezor import wire
from trezor.messages.Success import Success
from trezor.messages.FailureType import ProcessError
from apps.wallet.verify_message import require_confirm_verify_message
# Lisk signature can be more than 64 bytes
sig = msg.signature[:64]
verify = ed25519.verify(msg.public_key, sig, msg.message)
if not verify:
raise wire.FailureError(ProcessError, 'Invalid signature')
address = get_address_from_public_key(msg.public_key)
await require_confirm_verify_message(ctx, address, msg.message)
return Success(message='Message verified')