The three parts
What gets encoded
- Public key
- 32 bytes · the whole point of the address
- Checksum
- 2 bytes · derived from the key, catches typing errors
- Version marker
- 1 byte · constant for this generation
- Total
- 35 bytes · 280 bits
- Encoded as
- base32 · 5 bits per character
- Result
- 280 divided by 5, which is 56 characters
Why the key is the address
The 32 bytes at the front are a public key. Not a reference to one, not a hash of one, the key itself. That single design decision is responsible for nearly everything unusual about these strings.
On the ordinary web, a name is a label and a separate system establishes which machine holds it, with certificates layered on afterwards to prove the machine is the right one. Here there is no label, no lookup and no certificate. A client reading the address already holds the public key of the service it wants, so when something answers, the client can require it to prove possession of the matching private key before anything else happens.
This is why an onion address cannot be pointed at a different machine by a third party. There is nothing to point. The address is a statement about which key must answer, and only whoever holds that key can satisfy it.
It is also why the address is 56 characters of noise instead of a word. A key cannot be shortened without ceasing to be the key, and a key does not spell anything, so the address does not either. The one address in this set that opens with the market name got there by generating keys until one encoded that way, which is covered on the vanity cost page.
Why 56 and not 55 or 57
Base32 turns five bits into one character. Thirty-five bytes is 280 bits, and 280 divides by five exactly, giving 56 characters with nothing left over and no padding. That is a tidy result and it is not an accident, because the format was designed with the encoding in mind.
This is also why a length check is a real check. A version 3 address is 56 characters. It is never 55 and never 57, and a string of any other length is malformed rather than merely unfamiliar. All 12 addresses in this set pass, and if one did not, its record page would say so in red.
The older generation of onion addresses was 16 characters, encoding a truncated hash rather than a full key. It was retired because 80 bits of hash is not enough to rely on. Anyone who remembers short onion addresses is remembering a format that no longer resolves.
Why the alphabet has 32 symbols
Questions
Why is an onion address so much longer than a domain name?
Because it contains a full public key rather than a name somebody registered. The length is what 35 bytes encodes to and cannot be reduced without losing the property that makes the address work.
Can two services have the same onion address?
Only if they hold the same private key, which means they are the same service or somebody copied the key. Two independently generated addresses colliding is not something that happens.