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:
parent
c7651b3c94
commit
ce362103ae
@ -8,21 +8,19 @@ async def get_address(ctx, msg):
|
|||||||
from trezor.crypto.hashlib import sha3_256
|
from trezor.crypto.hashlib import sha3_256
|
||||||
from apps.common import seed
|
from apps.common import seed
|
||||||
|
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n)
|
||||||
|
|
||||||
node = await seed.derive_node(ctx, address_n)
|
|
||||||
|
|
||||||
seckey = node.private_key()
|
seckey = node.private_key()
|
||||||
public_key = secp256k1.publickey(seckey, False) # uncompressed
|
public_key = secp256k1.publickey(seckey, False) # uncompressed
|
||||||
address = sha3_256(public_key[1:], keccak=True).digest()[12:]
|
address = sha3_256(public_key[1:], keccak=True).digest()[12:]
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
if len(address_n) > 1: # path has slip44 network identifier
|
if len(msg.address_n) > 1: # path has slip44 network identifier
|
||||||
network = networks.by_slip44(address_n[1] & 0x7FFFFFFF)
|
network = networks.by_slip44(msg.address_n[1] & 0x7FFFFFFF)
|
||||||
else:
|
else:
|
||||||
network = None
|
network = None
|
||||||
hex_addr = _ethereum_address_hex(address, network)
|
hex_addr = _ethereum_address_hex(address, network)
|
||||||
desc = address_n_to_str(address_n)
|
desc = address_n_to_str(msg.address_n)
|
||||||
while True:
|
while True:
|
||||||
if await show_address(ctx, hex_addr, desc=desc):
|
if await show_address(ctx, hex_addr, desc=desc):
|
||||||
break
|
break
|
||||||
|
@ -21,8 +21,7 @@ def message_digest(message):
|
|||||||
async def sign_message(ctx, msg):
|
async def sign_message(ctx, msg):
|
||||||
await require_confirm_sign_message(ctx, msg.message)
|
await require_confirm_sign_message(ctx, msg.message)
|
||||||
|
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n)
|
||||||
node = await seed.derive_node(ctx, address_n)
|
|
||||||
|
|
||||||
signature = secp256k1.sign(
|
signature = secp256k1.sign(
|
||||||
node.private_key(),
|
node.private_key(),
|
||||||
|
@ -128,8 +128,7 @@ async def send_request_chunk(ctx, data_left: int):
|
|||||||
|
|
||||||
|
|
||||||
async def send_signature(ctx, msg: EthereumSignTx, digest):
|
async def send_signature(ctx, msg: EthereumSignTx, digest):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n)
|
||||||
node = await seed.derive_node(ctx, address_n)
|
|
||||||
|
|
||||||
signature = secp256k1.sign(
|
signature = secp256k1.sign(
|
||||||
node.private_key(), digest, False, secp256k1.CANONICAL_SIG_ETHEREUM
|
node.private_key(), digest, False, secp256k1.CANONICAL_SIG_ETHEREUM
|
||||||
|
@ -7,15 +7,13 @@ from apps.common.layout import address_n_to_str, show_address, show_qr
|
|||||||
|
|
||||||
|
|
||||||
async def get_address(ctx, msg):
|
async def get_address(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
|
||||||
|
|
||||||
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
|
|
||||||
pubkey = node.public_key()
|
pubkey = node.public_key()
|
||||||
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
||||||
address = get_address_from_public_key(pubkey)
|
address = get_address_from_public_key(pubkey)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(address_n)
|
desc = address_n_to_str(msg.address_n)
|
||||||
while True:
|
while True:
|
||||||
if await show_address(ctx, address, desc=desc):
|
if await show_address(ctx, address, desc=desc):
|
||||||
break
|
break
|
||||||
|
@ -6,9 +6,7 @@ from apps.common import layout, seed
|
|||||||
|
|
||||||
|
|
||||||
async def get_public_key(ctx, msg):
|
async def get_public_key(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
|
||||||
|
|
||||||
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
|
|
||||||
pubkey = node.public_key()
|
pubkey = node.public_key()
|
||||||
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def message_digest(message):
|
|||||||
|
|
||||||
async def sign_message(ctx, msg):
|
async def sign_message(ctx, msg):
|
||||||
message = msg.message
|
message = msg.message
|
||||||
address_n = msg.address_n or ()
|
address_n = msg.address_n
|
||||||
|
|
||||||
await require_confirm_sign_message(ctx, message)
|
await require_confirm_sign_message(ctx, message)
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ async def sign_tx(ctx, msg):
|
|||||||
|
|
||||||
|
|
||||||
async def _get_keys(ctx, msg):
|
async def _get_keys(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, LISK_CURVE)
|
||||||
node = await seed.derive_node(ctx, address_n, LISK_CURVE)
|
|
||||||
|
|
||||||
seckey = node.private_key()
|
seckey = node.private_key()
|
||||||
pubkey = node.public_key()
|
pubkey = node.public_key()
|
||||||
|
@ -11,8 +11,7 @@ from apps.tezos.helpers import (
|
|||||||
|
|
||||||
|
|
||||||
async def get_address(ctx, msg):
|
async def get_address(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
|
||||||
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
|
|
||||||
|
|
||||||
pk = seed.remove_ed25519_prefix(node.public_key())
|
pk = seed.remove_ed25519_prefix(node.public_key())
|
||||||
pkh = hashlib.blake2b(pk, outlen=20).digest()
|
pkh = hashlib.blake2b(pk, outlen=20).digest()
|
||||||
|
@ -10,8 +10,7 @@ from apps.tezos.helpers import TEZOS_CURVE, TEZOS_PUBLICKEY_PREFIX, base58_encod
|
|||||||
|
|
||||||
|
|
||||||
async def get_public_key(ctx, msg):
|
async def get_public_key(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
|
||||||
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
|
|
||||||
|
|
||||||
pk = seed.remove_ed25519_prefix(node.public_key())
|
pk = seed.remove_ed25519_prefix(node.public_key())
|
||||||
pk_prefixed = base58_encode_check(pk, prefix=TEZOS_PUBLICKEY_PREFIX)
|
pk_prefixed = base58_encode_check(pk, prefix=TEZOS_PUBLICKEY_PREFIX)
|
||||||
|
@ -16,8 +16,7 @@ from apps.tezos.helpers import (
|
|||||||
|
|
||||||
|
|
||||||
async def sign_tx(ctx, msg):
|
async def sign_tx(ctx, msg):
|
||||||
address_n = msg.address_n or ()
|
node = await seed.derive_node(ctx, msg.address_n, TEZOS_CURVE)
|
||||||
node = await seed.derive_node(ctx, address_n, TEZOS_CURVE)
|
|
||||||
|
|
||||||
if msg.transaction is not None:
|
if msg.transaction is not None:
|
||||||
to = _get_address_from_contract(msg.transaction.destination)
|
to = _get_address_from_contract(msg.transaction.destination)
|
||||||
|
Loading…
Reference in New Issue
Block a user