Generating secret key of hidden service

Hi,
Does anyone know how exactly secretKey and onionUrl are generated? I’m trying to find information if generating custom secretKeys is possible? By custom I mean secretKeys that are generated based on some value so two different machines can generate the same secretKey based on that value.
If anyone have any information about that or know where to look for it, please leave a comment.
Have a great day!

I’ve used this [1] to generate vanity addresses. It takes an optional seed parameter which should initialise key generation to a predictable sequence.

[1] GitHub - cathugger/mkp224o: vanity address generator for tor onion v3 (ed25519) hidden services