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:
parent
dc5115055f
commit
3334163e85
@ -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)
|
||||
|
21
src/apps/lisk/verify_message.py
Normal file
21
src/apps/lisk/verify_message.py
Normal 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')
|
Loading…
Reference in New Issue
Block a user