MASTERING-BITCOIN · Unit 4 · Video 3
| Concept | Value / Formula | Notes |
|---|---|---|
| Base58 alphabet size | Excludes 0, O, l, I, +, / |
|
| Base58Check structure | [version (1B)] [payload (20B)] [checksum (4B)] |
25 bytes before encoding |
| Checksum | Typo detection | |
| Elliptic curve (secp256k1) | Symmetric about x-axis | |
| Uncompressed pubkey | 04 ‖ x (32B) ‖ y (32B) = 65 bytes |
Full point |
| Compressed pubkey | 02 or 03 ‖ x (32B) = 33 bytes |
02 if y even, 03 if y odd |
Version byte → leading character:
| Version | Purpose | Leading character |
|---|---|---|
0x00 |
P2PKH mainnet | 1 |
0x05 |
P2SH mainnet | 3 |
0x80 |
WIF private key | 5, K, or L |
0x6F |
P2PKH testnet | m or n |
0xC4 |
P2SH testnet | 2 |
Any integer can be written in different number bases. Higher bases pack the same value into fewer characters. Slide the value below and watch how the string length shrinks as the base grows. This is why Bitcoin uses base58 — it is compact and readable.
⚙ interactive visualization — coming to this page format soon
The first byte before base58 encoding is called the version byte. Because base58 encoding preserves the leading bits of the payload, the value of the version byte deterministically controls the leading character of the final address. Pick a version byte and see what prefix it produces.
⚙ interactive visualization — coming to this page format soon
Bitcoin's public keys live on the elliptic curve . For any valid , there are exactly two values of — one "even" (upper), one "odd" (lower). Since knowing plus one bit of parity uniquely determines the point, we can shrink a 65-byte public key down to 33 bytes. Slide below and see the two candidate values.
⚙ interactive visualization — coming to this page format soon
Notice: The curve is perfectly symmetric across the x-axis. A compressed
public key stores only plus a single parity bit (expressed as a 0x02
or 0x03 prefix byte). The underlying point on the curve is identical to the
uncompressed form — just half the storage.
Caveat: Compressed and uncompressed encodings are different byte strings, so hashing them produces different addresses. One private key, two valid addresses. This is why WIF private keys carry a compression flag.
Test your understanding with the questions below.
Question 1
A Bitcoin address is encoded with version byte 0x00. What character does the
address begin with?
✅ Correct! Version byte 0x00 always produces a leading 1.
❌ Not quite. 0x00 is a leading zero byte, and base58 maps leading zero bytes to leading '1' characters.
Solution:
Base58 encoding preserves leading zero bytes as leading '1' characters in the
output. Since version byte 0x00 is a leading zero byte, every P2PKH mainnet
address begins with 1.
| Version | Leading character |
|---|---|
0x00 |
1 (P2PKH mainnet) |
0x05 |
3 (P2SH) |
0x80 |
5, K, or L (WIF) |
0x6F |
m or n (testnet) |
The answer is 1.
Question 2
True or False: The same private key will always generate the same Bitcoin address, regardless of whether the public key is encoded in compressed or uncompressed form.
✅ Correct! Hashing the bytes of the public key — not the abstract point — means different encodings give different addresses.
❌ Not quite. Think about what the address hash is computed from — it's the byte string of the public key, not the mathematical point itself.
Solution:
The Bitcoin address is the HASH160 of the public key bytes, not the abstract curve point. Compressed and uncompressed encodings are different byte strings:
04 ‖ x (32B) ‖ y (32B) → 65 bytes02 or 03 ‖ x (32B) → 33 bytesDifferent input bytes give different hashes, hence different addresses. One private key therefore has two valid addresses, and funds sent to one cannot be spent from the other without knowing the correct encoding.
The answer is False.
Question 3
In Base58Check encoding for a P2PKH Bitcoin address, how many raw bytes are assembled before the final base58 conversion (version + payload + checksum)?
✅ Correct! 1 (version) + 20 (HASH160 payload) + 4 (checksum) = 25 bytes.
❌ Not quite. Add up all three pieces: the version byte, the 20-byte HASH160 payload, and the 4-byte checksum.
Solution:
The Base58Check structure for a P2PKH address has three pieces:
| Piece | Size |
|---|---|
| Version byte | 1 byte |
| Payload (HASH160 of pubkey) | 20 bytes |
| Checksum (first 4 bytes of double-SHA256) | 4 bytes |
| Total | 25 bytes |
Those 25 bytes are then base58-encoded into the ~34-character human-readable address you see.
The answer is 25 bytes.
Question 4
A compressed public key you received begins with the prefix byte 0x03.
What does this tell you about the point on the elliptic curve?
✅ Correct! Prefix 0x03 signals odd y; 0x02 signals even y.
❌ Not quite. The prefix byte encodes the parity of y, since the curve's symmetry means x alone is ambiguous between two candidates.
Solution:
Because the curve is symmetric about the x-axis, each valid has two possible -values. In secp256k1's finite field, one is even and the other is odd. A single parity bit suffices to distinguish them, and it is encoded in the prefix byte:
0x02 → is even0x03 → is oddBoth store only the 32-byte x-coordinate afterward, totaling 33 bytes instead of 65. A receiver recomputes by solving the curve equation and picks the root matching the parity flag.
The answer is the y-coordinate is odd.
Solved: 0 / 4