async def get_address(ctx, msg): from trezor.messages.EthereumAddress import EthereumAddress from trezor.crypto.curve import secp256k1 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) 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) else: network = None hex_addr = _ethereum_address_hex(address, network) while True: if await show_address(ctx, hex_addr, address_n): break if await show_qr(ctx, hex_addr): break return EthereumAddress(address=address)
async def ethereum_get_address(ctx, msg): from trezor.messages.EthereumAddress import EthereumAddress from trezor.crypto.curve import secp256k1 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) seckey = node.private_key() public_key = secp256k1.publickey(seckey, False) # uncompressed address = sha3_256(public_key[1:]).digest(True)[12:] # Keccak if msg.show_display: network = networks.by_slip44(address_n[1] & 0x7fffffff) hex_addr = _ethereum_address_hex(address, network) while True: if await _show_address(ctx, hex_addr): break if await _show_qr(ctx, hex_addr): break return EthereumAddress(address=address)
async def get_address(ctx, msg, keychain): await paths.validate_path(ctx, validate_full_path, path=msg.address_n) node = keychain.derive(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(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(msg.address_n) while True: if await show_address(ctx, hex_addr, desc=desc): break if await show_qr(ctx, hex_addr, desc=desc): break return EthereumAddress(address=address)
async def handler_chain_id(ctx, msg, keychain): network = by_slip44(msg.address_n[1] & ~HARDENED) # standard tests self._check_keychain(keychain, network.slip44) # provided address should succeed too keychain.derive(msg.address_n)