From c78c6616f65f81451264b8b6866f0d1bffc48942 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Thu, 17 May 2018 16:12:02 +0200 Subject: [PATCH] app.lisk: simplify pubkey computation --- src/apps/lisk/get_address.py | 8 +++----- src/apps/lisk/get_public_key.py | 10 ++++------ src/apps/lisk/sign_message.py | 7 ++++--- src/apps/lisk/sign_tx.py | 6 +++--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/apps/lisk/get_address.py b/src/apps/lisk/get_address.py index ae3da52c7b..b5228ec2ad 100644 --- a/src/apps/lisk/get_address.py +++ b/src/apps/lisk/get_address.py @@ -4,16 +4,14 @@ from .helpers import LISK_CURVE, get_address_from_public_key async def layout_lisk_get_address(ctx, msg): from trezor.messages.LiskAddress import LiskAddress - 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) + pubkey = node.public_key() + pubkey = pubkey[1:] # skip ed25519 pubkey marker + address = get_address_from_public_key(pubkey) if msg.show_display: while True: diff --git a/src/apps/lisk/get_public_key.py b/src/apps/lisk/get_public_key.py index 7880999046..6973ac1246 100644 --- a/src/apps/lisk/get_public_key.py +++ b/src/apps/lisk/get_public_key.py @@ -4,17 +4,15 @@ from .helpers import LISK_CURVE async def lisk_get_public_key(ctx, msg): from trezor.messages.LiskPublicKey import LiskPublicKey - 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) + pubkey = node.public_key() + pubkey = pubkey[1:] # skip ed25519 pubkey marker if msg.show_display: - await _show_pubkey(ctx, public_key) + await _show_pubkey(ctx, pubkey) - return LiskPublicKey(public_key=public_key) + return LiskPublicKey(public_key=pubkey) diff --git a/src/apps/lisk/sign_message.py b/src/apps/lisk/sign_message.py index 22aa255c49..2acfd3e573 100644 --- a/src/apps/lisk/sign_message.py +++ b/src/apps/lisk/sign_message.py @@ -11,11 +11,12 @@ async def lisk_sign_message(ctx, msg): await require_confirm_sign_message(ctx, message) address_n = msg.address_n or () - node = await seed.derive_node(ctx, address_n, LISK_CURVE) + 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) + pubkey = node.public_key() + pubkey = pubkey[1:] # skip ed25519 pubkey marker + address = get_address_from_public_key(pubkey) signature = ed25519.sign(seckey, message) diff --git a/src/apps/lisk/sign_tx.py b/src/apps/lisk/sign_tx.py index fcb69c988f..523b5f2639 100644 --- a/src/apps/lisk/sign_tx.py +++ b/src/apps/lisk/sign_tx.py @@ -104,7 +104,6 @@ def _get_asset_data_bytes(msg): return data async def _get_keys(ctx, msg): - from trezor.crypto.curve import ed25519 from ..common import seed from .helpers import LISK_CURVE @@ -112,9 +111,10 @@ async def _get_keys(ctx, msg): node = await seed.derive_node(ctx, address_n, LISK_CURVE) seckey = node.private_key() - public_key = ed25519.publickey(seckey) + pubkey = node.public_key() + pubkey = pubkey[1:] # skip ed25519 pubkey marker - return public_key, seckey + return pubkey, seckey def update_raw_tx(transaction, public_key): from .helpers import get_address_from_public_key