I have the below, trying to derive the Ethereum Address from public key (working) using keccak and to_checksum_address on eth_util, but doesn't match up with derivation on iancoleman.io or miguelmota.com
# Derive the public key from the BIP32 extended key (working ✅)
public_key_bytes = binascii.unhexlify(bip32_extended_key.PublicKey().hex())
# Compute the Keccak-256 hash of the public key
public_key_hash = keccak(public_key_bytes)
# Take the last 20 bytes of the public key hash (the Ethereum address)
address_bytes = public_key_hash[-20:]
# Convert the address bytes to a hex string
address_hex = address_bytes.hex()
# Convert the hex address to a checksummed Ethereum address
EthereumAddress = to_checksum_address('0x' + address_hex)
if EthereumAddress == target_address:
print("Seed phrase:", seed_phrase)
print("Address:", target_address)
print("Target address reached!")
exit()
else:
print("Public key: ", public_key_bytes.hex())
print("Ethereum address: ", EthereumAddress)
In the process of attempting to cleanly deriving the public key in uncompressed format..
– mull Apr 20 '23 at 10:03