tox_core/onion/
mod.rs

1/*! Onion module allows nodes to announce their long term public keys and find
2friends by their long term public keys.
3
4There are two basic onion requests - `OnionAnnounceRequest` and
5`OnionDataRequest`. They are enclosed to OnionRequest packets and sent though
6the onion path to prevent nodes finding out long term public key when they know
7only temporary DHT public key. There are three types of OnionRequest packets:
8`OnionRequest0`, `OnionRequest1` and `OnionRequest2`. `OnionAnnounceRequest` and
9`OnionDataRequest` when created are enclosed to `OnionRequest2`, `OnionRequest2`
10is enclosed to `OnionRequest1` and `OnionRequest1` is enclosed to
11`OnionRequest0`. When DHT node receives OnionRequest packet it decrypts inner
12packet and sends it to the next node.
13
14<pre style="white-space:pre;">
15+--------+                       +--------+                       +--------+                       +--------+   +----------------------+   +------------+
16|        |   +---------------+   |        |   +---------------+   |        |   +---------------+   |        |   | OnionAnnounceRequest |   |            |
17| Sender |---| OnionRequest0 |-->| Node 1 |---| OnionRequest1 |-->| Node 2 |---| OnionRequest2 |-->| Node 3 |---+----------------------+-->| Onion node |
18|        |   +---------------+   |        |   +---------------+   |        |   +---------------+   |        |   | OnionDataRequest     |   |            |
19+--------+                       +--------+                       +--------+                       +--------+   +----------------------+   +------------+
20</pre>
21
22Similarly to requests there are responses `OnionAnnounceResponse` and
23`OnionDataResponse` that enclosed to three kind of OnionRespose packets:
24`OnionResponse3`, `OnionResponse2` and `OnionResponse1`. OnionResponse
25packets are processed in the same way but with reverse ordering.
26
27<pre style="white-space:pre;">
28+------------+                        +--------+                        +--------+                        +--------+   +-----------------------+   +----------+
29|            |   +----------------+   |        |   +----------------+   |        |   +----------------+   |        |   | OnionAnnounceResponse |   |          |
30| Onion node |---| OnionResponse3 |-->| Node 3 |---| OnionResponse2 |-->| Node 2 |---| OnionResponse1 |-->| Node 1 |---+-----------------------+-->| Receiver |
31|            |   +----------------+   |        |   +----------------+   |        |   +----------------+   |        |   | OnionDataResponse     |   |          |
32+------------+                        +--------+                        +--------+                        +--------+   +-----------------------+   +----------+
33</pre>
34
35When onion node handles `OnionAnnounceRequest` packet it sends answer to
36original sender using the same onion path with the help of received onion return
37addresses. But when it handles `OnionDataRequest` packet it should send response
38packet to another destination node by its long term public key. That means that
39when onion node should store long term public keys of announced node along with
40onion return addresses.
41
42*/
43
44pub mod client;
45pub mod onion_announce;