I'm making an onion (v3) address generator in Python. Here is the part that generates the keypair:
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import x25519
def v3KeyGen():
private_key = x25519.X25519PrivateKey.generate()
private_bytes = private_key.private_bytes(encoding=serialization.Encoding.Raw, format=serialization.PrivateFormat.Raw, encryption_algorithm=serialization.NoEncryption())
public_key = private_key.public_key()
public_bytes = public_key.public_bytes(encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw)
return public_bytes, private_bytes
What file format do I put the keys in (e.g. the format of the hs_ed25519_secret_key
file), to get them to actually work with something like a Tor hidden service? Right now I have these keys, but have no idea how I actually get Tor to use them.
Edit: This is what an example private key file generated by Tor itself looks like, with some sort of binary data, I have no idea how to interpret it: