Onion service public key file

I created an onion v3 service and Tor made three files for it: private and public keys and hostname.
The private key actually contains the public key internally. So why do we need the public key file?
Usually the splitting makes sense to share the public key. But for Tor it doesn’t make sense.
The actual pubkey sharing is the onion domain itself.

I checked sources and found a big function ed_key_init_from_file().
Internally it will load the pubkey and compare it with a pubkey from the secret key.
If the pubkey does not exist then it will “repair” it from a secret file.

This looks to me as an overcomplicating.
Basically if the pubkey is not needed then we can skip its loading, repairing, comparison.

On line 511 we are loading the pubkey even if a secret doesn’t exist with a comment “We only have the public key; better use that”.
I can’t understand why to do that because without a secret key nothing should work anyway.

Will you accept a PR that will remove the creation of a pubkey file? This will simplify logic and make less code.

2 Likes