🪧Ethereum Addresses
Ethereum Addresses
Ethereum addresses are 40 hexadecimal characters long, excluding the "0x" prefix. This makes each address 20 bytes (160 bits) in length.
20 Bytes Long: An Ethereum address is derived from the last 20 bytes of the Keccak-256 hash of the public key.
160 Bits: This length provides a vast address space, which helps avoid address collisions and enhances security.
How to get a Private Key
When you got your first Ethereum address, you mostly likely used a tool like MetaMask or a Ledger which gave you a Seed Phrase
. But that Seed Phrase
is a string of 12-24 words, so how does that relate to your address?
The specific words chosen matter, and the details of how they work can be found here:
A single Seed Phrase
can be used to generate a nearly infinite number of Ethereum addresses. Those addresses are generated using a specific hierarchical deterministic derivation path explained in great detail here.
What if you want to generate your own Private Key
? Well since a Private Key
is simply a binary number 256 digits long, you could flip a coin 256 times counting heads as 1 and tails as 0.
Step-by-Step Example
Generate a Private Key. This is a random 256-bit number. For simplicity, let's use a hexadecimal representation:
Generate the Public Key. The public key is derived from the private key using Elliptic Curve Cryptography (ECC), specifically the secp256k1 curve. The resulting public key is a 512-bit number (128 hexadecimal characters):
Keccak-256 Hash of the Public Key. Ethereum uses the Keccak-256 hash function (a variant of SHA-3) to hash the public key. Note that only the x and y coordinates of the public key (excluding the initial '0x04' byte) are hashed.
The initial '0x04' byte is a prefix used in the uncompressed format of an elliptic curve public key. This prefix indicates that the public key is represented in an uncompressed form, which includes both the x and y coordinates of the point on the elliptic curve.
Uncompressed Format:
The public key consists of a prefix '0x04' followed by the x coordinate and the y coordinate of the elliptic curve point.
The format is:
0x04 <x-coordinate> <y-coordinate>
Compressed Format:
The public key consists of a prefix '0x02' or '0x03' followed by only the x coordinate.
The prefix '0x02' is used if the y coordinate is even, and '0x03' is used if the y coordinate is odd.
The '0x04' prefix is removed because it is not part of the essential elliptic curve point data (x and y coordinates). It merely indicates that the data following it is an uncompressed public key. For the purpose of hashing and deriving the Ethereum address, only the actual coordinates of the elliptic curve point are relevant, and thus the prefix is excluded.
Ethereum Address. The Ethereum address is derived from the last 20 bytes of the Keccak-256 hash.
Last updated