Whisper and PSS are two messaging procotols currently being developed in the Ethereum stack - here's a side-by-side comparison that can help guide your choice between them.
Feature | Whisper | PSS |
---|---|---|
Routing | Gossip | Kademlia |
DoS protection | Proof of work | Swap incentives |
Bandwidth vs darkness | Topic-based bloom filters - intermediary / recipient decides | Partial addressing - sender decides |
Encryption in API | Mandatory | Optional |
Key exchange | N/A | Optional Diffie-Hellman |
Message lifetime | Time-to-live (sender decides) | One pass through each intended node |
Whisper is a gossip-based combination of a messaging protocol and ephemeral value store - values circulate in the system until expiry. The value store view is perhaps more apt - you throw messages into the cloud of participating nodes and they keep getting replicated until expiry, even when new nodes join.
expiry, ttl, topic, data, nonce
meaning that you need both a timestamp and contents of message to create the PoWpow = (2^BestBit) / (size * TTL)
meaning that large messages or those with long TTL are penalizedPSS wraps whisper and adds the swarm routing protocol to add deteministic routing. With PSS, routing is done along the kademlia path up to the partial address that was supplied - then gossip takes over.
Unlike Whisper, there is no DHT-like functionality where new nodes are updated on the "current" database of messages.
https://swarm-guide.readthedocs.io/en/latest/pss.html
https://swarm-guide.readthedocs.io/en/latest/resources.html
graph nodes {
00 -- 01; 00 -- 10 ; 10 -- 11; 01 -- 11;
01 -- 10;
{rank=same; 00 01} {rank=same; 10 11}
}
digraph step1 {
00 -> 01; 00 -> 10;
{rank=same; 00 01} {rank=same; 10 11}
}
digraph step2 {
00; 01 -> 10; 10 -> 11; 01 -> 11; 10 -> 01;
{rank=same; 00 01} {rank=same; 10 11}
}
Notice how 10
, 01
potentially receive message twice (depending on timing) and 11
is guaranteed to recieve twice (in this setup, due to locally limited knowledge in 01
, 10
nodes)
Example propagation to address 1*
:
graph nodes {
00 -- 01; 00 -- 10 ; 10 -- 11; 01 -- 11;
01 -- 10;
{rank=same; 00 01} {rank=same; 10 11}
}
digraph step1 {
00 -> 10;
{rank=same; 00 01} {rank=same; 10 11}
}
digraph step1 {
00; 10 -> 11;
{rank=same; 00 01} {rank=same; 10 11}
}
Either of 10
, 11
could be recipient, message reaches both!