getAddress method

EthereumAddress getAddress()

Gets the Ethereum address for this wallet.

Implementation

EthereumAddress getAddress() {
  // Get uncompressed public key (remove 0x04 prefix)
  final uncompressedPublicKey = Secp256k1.getPublicKey(privateKey);
  final publicKeyBytes =
      uncompressedPublicKey.sublist(1); // Remove 0x04 prefix

  // Hash the public key and take last 20 bytes
  final hash = Keccak256.hash(publicKeyBytes);
  final addressBytes = hash.sublist(12, 32);

  return EthereumAddress.fromHex(HexUtils.encode(addressBytes));
}