The Basics of How P2P Messaging Works on Waku
Waku is building a peer-to-peer (P2P) alternative to the centralised communications model omnipresent in modern digital applications. It comprises a family of open-source, modular protocols designed to deliver a decentralised, P2P communications network that preserves user privacy.
Under Waku's model, users have complete control over their data and can communicate with each other without fear of censorship.
While it is designed to facilitate decentralised communication, Waku is not a blockchain. It is a way to communicate that does not rely on third parties, encompassing everything from basic messaging to complex applications that require secure and private data transmission.
Let’s take a look at P2P messaging and how it works on Waku.
What is peer-to-peer (P2P) communication?
Most of the world’s online communication, whether it is people messaging their friends or machines transmitting data to other machines, is facilitated by centralised service providers. If you send a message to someone on WhatsApp, for example, you are sending it to be stored on and forwarded by a server ultimately operated by a single entity.
This might be convenient, but it comes with implicit risks: centralised infrastructure means a single point of failure or a single target for an attack. Centralised communications also imply concerns over censorship and privacy, with users required to trust third parties not to censor, expose, or exploit their data.
A solution to this problem is peer-to-peer communication, where people and devices (peers) can talk privately and directly with each other, without having to trust a third party to relay the message accurately and without manipulation or data loss.
P2P communication relies on a network of distributed nodes operating a shared communication protocol. In P2P networks, each peer functions as both a client and a server, sharing resources and data independently.
This model enhances privacy, resilience, and scalability, as there is no central point of control or failure, and redundancy for the loss of a proportion of the total nodes operating on a network is built into the protocol.
Of course, building a P2P communications protocol is not without its challenges. Waku is developing a family of open-source, modular protocols to deliver this private and censorship-resistant communication in a way that is scalable and preserves the privacy and liberties of its users.
Sending, receiving, and storing messages
Waku’s publish-subscribe model is a secure method for peer-to-peer messaging that keeps the identities of message senders and receivers private. In this system, users can post messages on specific “topics”, and others can subscribe to those “topics” to receive updates without revealing what topics they are interested in.
Messages are not sent directly to a recipient via a single server. Instead, each node on the Waku network relays the messages it receives to other nodes, with connected recipients processing the messages they would like to receive.
This protocol facilitates both one-on-one and group messaging, and it supports end-to-end encryption, which prevents messages from being read by anyone other than the intended recipient.
Waku nodes can also store messages they receive, which allows them to be accessed later by other nodes that were offline at the time of publication. By flagging messages not to be stored by nodes, message publishers can send “disappearing” messages over the network.
Waku’s P2P messaging protocol includes protections against spam and denial-of-service (DoS) by limiting the maximum number of messages a user can send in a given time through the use of Rate-Limit Nullifers (RLNs).
For more on Waku’s protection against spam and denial-of-service attacks, read our blog post on RLN Relay.
Waku’s protocols enable a scalable and adaptive network that operates this P2P communications infrastructure, allowing for nodes to be configured for specific applications to improve decentralisation.
Edge nodes and end-user devices
In a straightforward P2P communications network, users must operate a node that receives all messages and relays them to the rest of the network to participate in communication.
However, this can come with significant hardware and bandwidth requirements that some devices might not be able to meet. This is where the Waku network's adaptable design comes in.
Instead of running a relay node that needs to be constantly connected and relaying messages, lightweight devices such as smartphones can run an edge node by taking advantage of Waku’s light protocols.
These edge nodes have limited functionality and specific utility. They can use the Waku protocol permissionlessly, retrieving missed messages and publishing their own, but they do not receive and transmit messages the way relay nodes do.
This solution is ideal for running Waku on mobile applications or in a web browser, where resources and bandwidth are at a premium, and where the user will likely be disconnected from the network for extended periods.
It is important to note that this and other features of Waku remain under active open-source development. Part of this includes creating incentive mechanisms to reward operators for storing and serving messages for edge nodes and other devices that are regularly offline.
Read our technical overview of the network for a deeper look into the Waku network and how these protocols work together to deliver a privacy-preserving and censorship-resistant P2P communications platform.
Subscribe to our newsletter to get the latest updates from Waku directly in your inbox.