Kevalin - Message Routing

Kevalin routing architecture

Messages are routed between nodes using a number of techniques.

The simplest fallback option is a centralised relay server at a known address. This is used for bootstrapping the network and allows peers to establish a direct connection by signalling their ICE candidates. It also serves as a fallback if a direct connection cannot be established.

Kademlia Overlay

The preferred option is to route messages through an overlay network established through direct connections between nodes. This network uses the Kademlia1 routing algorithm to maintain a ‘small-world’ network through which messages can be routed in log(N) hops, where N is the size of the network.

In order to deliver a message through the overlay network, messages are delivered only to nodes closer to the destination address than the current node, allowing the message to converge on the target node. Intermediate nodes maintain a cache of recently delivered message IDs to allow duplicates to be dropped if delivered by multiple routes.

New network links can be established by requesting a direct connection, either via the central peer relay or by routing through the existing overlay.

Caveats:

In-browser peer-to-peer WebRTC connections are limited in number (around 100). This means that the connectivity of nodes needs to be carefully managed.

One difference between WebRTC connections and the original Kademlia protocol is that WebRTC is a connection-oriented protocol whereas Kademlia is based on UDP.

Assuming that we can’t make unlimited direct connections to other peers suggests that Kevalin may need to rely on cooperative relaying of messages by other nodes rather than sending messages directly.

Mail

An offline ‘Mailbox’ protocol runs on top of this stack, allowing messages for offline nodes to be cached for a period of time pending delivery. A system of establishing delivery permission through pre-signed ‘postage’ proofs is TBC, but this would allow offline verification that a node has opted-in to receive mail from a particular sender, without revealing the sender’s identity.

It’s also possible that the receiver’s identity could be concealed by allowing arbitrary rendezvous mailbox addresses to be used instead of directly addressing the mail to the recipient.

The recipient would periodically request mail from the nodes closest to the rendezvous address, providing some cryptographic proof that they are the intended recipient, or perhaps just knowledge of the recipient address is sufficient to retrieve the messages.

Footnotes

  1. Maymounkov, P., & Mazières, D. ( 2002). Kademlia: A Peer-to-Peer Information System Based on the XOR Metric. International Workshop on Peer-to-Peer Systems.