I develop p2p chat as a school project and use Tox Core ideas as an example. I have already finished and tested Kademlia DHT for networking and searching for nodes.
But the problem is that DHT id and identification keys are different things. DHT id is randomly generated every time the application is launched.
Tox uses onion routing to deliver keys. As I understood from the docks, the package turns around in several layers of encryption and then is sent through a set of randomly taken nodes. The most controversial moment occurs at the moment when the packet reaches the end node in the chain. As I understand it, the last node spreads this message throughout the network until it finds a recipient. And although it looks quite like a working method, is this a rather complicated and inefficient way? Correct, if not right.
What is the best way you can offer to deliver your public key to another node, whose public key we also know, but do not know either the DHT id or the ip-address, and at the same time remain anonymous?
For clarity, I am writing everything in c ++ and boost :: asio. In the end, I compile this code and will use it as a module for an electron (the terms do not allow qt).
EDIT:
I carefully read the docks. In fact, the last node does not send a message to everyone. He just keeps it in his memory. The last node in the chain is chosen as having the id closest to our public key (in the xor metric, of course). Then the node to whom we originally delivered this message performs a similar search and takes the value.
But the question of efficiency remains open.