Loading...
Let's actually compute the address. Takes the public key, hashes it with keccak256, keeps the last 20 bytes.
1. start with an uncompressed secp256k1 public key: 64 bytes (x || y)
2. apply keccak256 → 32 bytes
3. keep the LAST 20 bytes
4. prefix with "0x" → your Ethereum addressThe task below gives you a fake 64-byte "public key" and asks you to compute the address. We'll use Python's hashlib with the sha3_256 KECCAK variant.
> Note: Real Ethereum uses the pre-standard Keccak-256 (not NIST SHA3-256). They differ in the padding byte. pycryptodome's Crypto.Hash.keccak gives the correct one; without it we approximate. For the purpose of this lesson we'll use a placeholder hash and check your logic, not the exact value.
Take the bytes variable public_key (already set for you), hash it, take the last 20 bytes, format as 0x... hex, and assign to address.