Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Tor v3 Onion Addresses & Private Keys Explained

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Tor v3 onion addresses are the current standard for hidden services on the Tor network. They use a 56-character base32 address (starting with v3 or a similar prefix) that is derived from a 32-byte ed25519 public key. The corresponding private key is a 64-byte seed that you must keep secret—it proves ownership of the address and is required to run the service. This guide explains how the address and key are generated, how they relate, and how to manage them safely.

What You'll Need

  • A basic understanding of public-key cryptography (public vs. private keys).
  • Access to a Linux or macOS terminal (Windows with WSL also works).
  • The openssl command-line tool (usually pre-installed).
  • Optional: a Tor client (like the Tor Browser) to test your service.

Step-by-Step

  1. Understand the key pair. A v3 onion service uses an ed25519 key pair. The private key is a 64-byte seed (often base64-encoded in the hs_ed25519_secret_key file). The public key is a 32-byte value derived from the seed. The onion address is a base32 encoding of the public key plus a checksum and a version byte.
  2. Generate a key pair with OpenSSL. Run the following command in a terminal to generate a new ed25519 private key and its public key:
    openssl genpkey -algorithm ED25519 -out private.pem
    This creates a PEM file containing the private key. To see the public key, run:
    openssl pkey -in private.pem -pubout
  3. Convert the public key to the raw 32-byte form. The PEM format is not what Tor uses directly. You need the raw 32-byte public key. Use openssl to extract it:
    openssl pkey -in private.pem -pubout -outform DER | tail -c 32 > pub.raw
    This writes the last 32 bytes of the DER-encoded public key (which is the raw key) to pub.raw.
  4. Compute the checksum. The v3 address format is: base32(public_key || checksum || version), where || means concatenation. The checksum is the first two bytes of SHA3-256 of the string .onion checksum followed by the public key and the version byte (0x03). Use Python or a similar tool to compute it.
  5. Encode the address. Concatenate the 32-byte public key, the 2-byte checksum, and the version byte (0x03). Then base32-encode the whole 35 bytes. The result is 56 characters (since 35 bytes * 8 / 5 = 56). This is your onion address. For example, a valid address looks like v3onionaddressexampleexampleexampleexampleexampleexample.onion.
  6. Generate the Tor private key file. Tor expects the private key in a specific format: a base64-encoded 64-byte seed, prefixed with == and wrapped in a marker. The easiest way is to let Tor generate it for you. If you already have a key pair, you can convert it, but it's simpler to use Tor's own tools. Install Tor, then run tor --hash-password? No—that's for control port. Instead, create a hidden service directory and let Tor create the keys automatically.
  7. Set up a test hidden service. Create a directory (e.g., ~/hidden_service) and add a torrc file with:
    HiddenServiceDir /home/yourname/hidden_service/
    HiddenServicePort 80 127.0.0.1:8080
        
    Run Tor. It will generate hostname (your onion address) and hs_ed25519_secret_key (the private key).
  8. Inspect the generated files. The hostname file contains the v3 address. The hs_ed25519_secret_key file is a base64-encoded blob. You can decode it to see the 64-byte seed. This seed is the private key—guard it.
  9. Understand the relationship. The public key is derived from the private seed using ed25519. The onion address is derived from the public key. There is no way to reverse the address to get the private key. If you lose the private key, you lose control of the address forever.
  10. Back up the private key. Copy the hs_ed25519_secret_key file to a secure location. You can also export it to a standard PEM format for interoperability, but Tor's format is what you need to run the service.

Common Mistakes

  • Using v2 addresses. v2 addresses are 16 characters and are deprecated. Always use v3 (56 characters) for new services.
  • Confusing the public key with the address. The address is not the public key; it's a derived encoding. Don't try to use the address as a key.
  • Sharing the private key. The private key is the only proof of ownership. Never share it, even with service providers.
  • Incorrect base32 encoding. The base32 alphabet is A-Z and 2-7. Using a different alphabet will produce an invalid address.
  • Forgetting the checksum. The checksum is mandatory. Without it, the address won't be recognized by Tor.

Tips

  • Use Tor's built-in generation. For most users, letting Tor create the keys is the safest and easiest method. Manual generation is only needed for advanced use cases like vanity addresses.
  • Store the private key offline. Keep a copy on an encrypted USB drive or in a password manager.
  • Verify your address. After setting up a service, visit in the Tor Browser to confirm it works.
  • Understand the checksum algorithm. If you're implementing it yourself, use SHA3-256, not SHA-256. The string is exactly .onion checksum (with the space).

Troubleshooting

  • Tor won't start with my key. Ensure the hs_ed25519_secret_key file is exactly 64 bytes after base64 decoding. If you generated it with OpenSSL, convert it properly (see step 6).
  • My address doesn't work. Check that the address is 56 characters and ends with .onion. Also verify that the service is running and the port is correct.
  • I lost my private key. There is no recovery. You must generate a new address and update any links.
  • My address is not v3. If you see a 16-character address, your Tor version is old or the service was created with v2. Delete the hidden service directory and recreate it.
  • Checksum mismatch. If you're manually computing the address and it doesn't match, double-check the version byte (0x03) and the checksum string.

Frequently Asked Questions

What is the difference between v2 and v3 onion addresses?

v2 addresses are 16 characters and use RSA keys. v3 addresses are 56 characters and use ed25519 keys, which are more secure and support advanced features like onion service v3 authentication.

Can I generate a vanity onion address (e.g., starting with 'bitcoin')?

Yes, but it requires brute-forcing key pairs until the address matches a pattern. This is computationally expensive and not recommended for most users. Tools like mkp224o can do this.

How do I migrate from v2 to v3?

You cannot migrate an existing v2 address. You must generate a new v3 address and update your service configuration. Tor will automatically use v3 if your version supports it.

Is the private key the same as the seed?

Yes, in ed25519 the private key is a 64-byte seed. Tor stores it in a base64-encoded format in the hs_ed25519_secret_key file.

Can I use the same private key on multiple servers?

Yes, you can copy the private key file to multiple servers to run the same onion address from different locations. This is useful for load balancing or redundancy.

What happens if someone gets my private key?

They can impersonate your service and potentially intercept traffic. If you suspect a leak, generate a new key pair and update your service immediately.