mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-12 09:38:08 +00:00
22 lines
810 B
Python
22 lines
810 B
Python
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from trezor.messages import EthereumGetPublicKey, EthereumPublicKey
|
|
from trezor.wire import Context
|
|
|
|
|
|
async def get_public_key(ctx: Context, msg: EthereumGetPublicKey) -> EthereumPublicKey:
|
|
from ubinascii import hexlify
|
|
from trezor.messages import EthereumPublicKey, GetPublicKey
|
|
from trezor.ui.layouts import show_pubkey
|
|
from apps.bitcoin import get_public_key as bitcoin_get_public_key
|
|
|
|
# we use the Bitcoin format for Ethereum xpubs
|
|
btc_pubkey_msg = GetPublicKey(address_n=msg.address_n)
|
|
resp = await bitcoin_get_public_key.get_public_key(ctx, btc_pubkey_msg)
|
|
|
|
if msg.show_display:
|
|
await show_pubkey(ctx, hexlify(resp.node.public_key).decode())
|
|
|
|
return EthereumPublicKey(node=resp.node, xpub=resp.xpub)
|