1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-15 09:50:57 +00:00

apps: msg.address_n is always a list

This commit is contained in:
Jan Pochyla 2018-11-09 13:59:10 +01:00
parent c7651b3c94
commit ce362103ae
10 changed files with 14 additions and 26 deletions

View File

@ -8,21 +8,19 @@ async def get_address(ctx, msg):
from trezor.crypto.hashlib import sha3_256
from apps.common import seed
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n)
node = await seed.derive_node(ctx, msg.address_n)
seckey = node.private_key()
public_key = secp256k1.publickey(seckey, False) # uncompressed
address = sha3_256(public_key[1:], keccak=True).digest()[12:]
if msg.show_display:
if len(address_n) > 1: # path has slip44 network identifier
network = networks.by_slip44(address_n[1] & 0x7FFFFFFF)
if len(msg.address_n) > 1: # path has slip44 network identifier
network = networks.by_slip44(msg.address_n[1] & 0x7FFFFFFF)
else:
network = None
hex_addr = _ethereum_address_hex(address, network)
desc = address_n_to_str(address_n)
desc = address_n_to_str(msg.address_n)
while True:
if await show_address(ctx, hex_addr, desc=desc):
break

View File

@ -21,8 +21,7 @@ def message_digest(message):
async def sign_message(ctx, msg):
await require_confirm_sign_message(ctx, msg.message)
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n)
node = await seed.derive_node(ctx, msg.address_n)
signature = secp256k1.sign(
node.private_key(),

View File

@ -128,8 +128,7 @@ async def send_request_chunk(ctx, data_left: int):
async def send_signature(ctx, msg: EthereumSignTx, digest):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n)
node = await seed.derive_node(ctx, msg.address_n)
signature = secp256k1.sign(
node.private_key(), digest, False, secp256k1.CANONICAL_SIG_ETHEREUM

View File

@ -7,15 +7,13 @@ from apps.common.layout import address_n_to_str, show_address, show_qr
async def get_address(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
pubkey = node.public_key()
pubkey = pubkey[1:] # skip ed25519 pubkey marker
address = get_address_from_public_key(pubkey)
if msg.show_display:
desc = address_n_to_str(address_n)
desc = address_n_to_str(msg.address_n)
while True:
if await show_address(ctx, address, desc=desc):
break

View File

@ -6,9 +6,7 @@ from apps.common import layout, seed
async def get_public_key(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
pubkey = node.public_key()
pubkey = pubkey[1:] # skip ed25519 pubkey marker

View File

@ -24,7 +24,7 @@ def message_digest(message):
async def sign_message(ctx, msg):
message = msg.message
address_n = msg.address_n or ()
address_n = msg.address_n
await require_confirm_sign_message(ctx, message)

View File

@ -36,8 +36,7 @@ async def sign_tx(ctx, msg):
async def _get_keys(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
seckey = node.private_key()
pubkey = node.public_key()

View File

@ -11,8 +11,7 @@ from apps.tezos.helpers import (
async def get_address(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
pk = seed.remove_ed25519_prefix(node.public_key())
pkh = hashlib.blake2b(pk, outlen=20).digest()

View File

@ -10,8 +10,7 @@ from apps.tezos.helpers import TEZOS_CURVE, TEZOS_PUBLICKEY_PREFIX, base58_encod
async def get_public_key(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
pk = seed.remove_ed25519_prefix(node.public_key())
pk_prefixed = base58_encode_check(pk, prefix=TEZOS_PUBLICKEY_PREFIX)

View File

@ -16,8 +16,7 @@ from apps.tezos.helpers import (
async def sign_tx(ctx, msg):
address_n = msg.address_n or ()
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
if msg.transaction is not None:
to = _get_address_from_contract(msg.transaction.destination)