The present document specifies the Waku v2 message format, a way to encapsulate the messages sent with specific information security goals, and Whisper/Waku v1 backward compatibility.">
The present document specifies the Waku v2 message format, a way to encapsulate the messages sent with specific information security goals, and Whisper/Waku v1 backward compatibility." />
Lorenzo Delgado <ahref="mailto:lorenzo@status.im">lorenzo@status.im</a>
</li>
</ul><h1id="abstract">
Abstract
<aclass="anchor"href="#abstract">#</a>
</h1>
<p>Waku v2 is a family of modular peer-to-peer protocols for secure communication.
These protocols are designed to be secure, privacy-preserving, and censorship-resistant and can run in resource-restricted environments.
At a high level, Waku v2 implements a Pub/Sub messaging pattern over libp2p and adds capabilities.</p>
<p>The present document specifies the Waku v2 message format, a way to encapsulate the messages sent with specific information security goals, and Whisper/Waku v1 backward compatibility.</p>
<h1id="motivation">
Motivation
<aclass="anchor"href="#motivation">#</a>
</h1>
<p>When sending messages over Waku, there are multiple requirements:</p>
<ul>
<li>One may have a separate encryption layer as part of the application.</li>
<li>One may want to provide efficient routing for resource-restricted devices.</li>
<li>One may want to provide compatibility with <ahref="/spec/6/">Waku v1 envelopes</a>.</li>
<li>One may want encrypted payloads by default.</li>
<li>One may want to provide unlinkability to get metadata protection.</li>
</ul>
<p>This specification attempts to provide for these various requirements.</p>
<h1id="semantics">
Semantics
<aclass="anchor"href="#semantics">#</a>
</h1>
<h2id="waku-message">
Waku Message
<aclass="anchor"href="#waku-message">#</a>
</h2>
<p>A Waku message is constituted by the combination of data payload and attributes that, for example, a <em>publisher</em> sends to a <em>topic</em> and is eventually delivered to <em>subscribers</em>.</p>
<p>Waku message attributes are key-value pairs of metadata associated with a message.
And the message data payload is the part of the transmitted Waku message that is the actual message information.
The data payload is also treated as a Waku message attribute for convenience.</p>
<h2id="message-attributes">
Message Attributes
<aclass="anchor"href="#message-attributes">#</a>
</h2>
<ul>
<li>
<p>The <code>payload</code> attribute MUST contain the message data payload to be sent.</p>
</li>
<li>
<p>The <code>content_topic</code> attribute MUST specify a string identifier that can be used for content-based filtering.</p>
<p>The <code>meta</code> attribute, if present, contains an arbitrary application-specific variable-length byte array with a maximum length limit of 64 bytes.
This attribute can be utilized to convey supplementary details to various Waku protocols, thereby enabling customized processing based on its contents.</p>
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#66d9ef">optional</span><spanstyle="color:#66d9ef">uint32</span> version <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">3</span>;<spanstyle="color:#960050;background-color:#1e0010">
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#66d9ef">optional</span><spanstyle="color:#66d9ef">bytes</span> meta <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">11</span>;<spanstyle="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><p>An example proto file following this specification can be found <ahref="https://github.com/vacp2p/waku/blob/main/waku/message/v1/message.proto">here (vacp2p/waku)</a>.</p>
The message <code>version</code> attribute indicates the schema used to encrypt the payload data.</p>
<ul>
<li>
<p><strong>Version 0:</strong>
The payload SHOULD be interpreted as unencrypted; additionally, it CAN indicate that the message payload has been encrypted at the application layer.</p>
</li>
<li>
<p><strong>Version 1:</strong>
The payload SHOULD be encrypted using Waku v1 payload encryption specified in <ahref="/spec/26">26/WAKU-PAYLOAD</a>.
This provides asymmetric and symmetric encryption.
The key agreement is performed out of band.
And provides an encrypted signature and padding for some form of unlinkability.</p>
</li>
<li>
<p><strong>Version 2:</strong>
The payload SHOULD be encoded according to <ahref="/spec/35">35/WAKU2-NOISE</a>.
Waku Noise protocol provides symmetric encryption and asymmetric key exchange.</p>
</li>
</ul>
<p>Any <code>version</code> value not included in this list is reserved for future specification.
And, in this case, the payload SHOULD be interpreted as unencrypted by the Waku layer.</p>
<p>Whisper/Waku v1 envelopes are compatible with Waku v2 messages format.</p>
<ul>
<li>Whisper/Waku v1 <code>topic</code> field SHOULD be mapped to Waku v2 message’s <code>content_topic</code> attribute.</li>
<li>Whisper/Waku v1 <code>data</code> field SHOULD be mapped to Waku v2 message’s <code>payload</code> attribute.</li>
</ul>
<p>Waku v2 implements a pub/sub messaging pattern over libp2p.
This makes redundant some Whisper/Waku v1 envelope fields (e.g., <code>expiry</code>, <code>ttl</code>, <code>topic</code>, etc.), so they can be ignored.</p>
</code></pre><p>If an optional attribute, such as <code>meta</code>, is absent, the concatenation of attributes SHOULD exclude it. This recommendation is made to ensure that the concatenation process proceeds smoothly when certain attributes are missing and to maintain backward compatibility.</p>
<p>This hashing schema is deemed appropriate for use cases where a cross-implementation deterministic hash is needed, such as message deduplication and integrity validation. The collision probability offered by this hashing schema can be considered negligible. This is due to the deterministic concatenation order of the message attributes, coupled with using a SHA-2 (256-bit) hashing algorithm.</p>
<p>The level of confidentiality, integrity, and authenticity of the Waku message payload is discretionary.
Accordingly, the application layer shall utilize the encryption and signature schemes supported by Waku v2 to meet the application-specific privacy needs.</p>
<h2id="reliability-of-the-timestamp-attribute">
Reliability of the <code>timestamp</code> attribute
<p>The Waku message <code>timestamp</code> attribute is set by the sender.
Therefore, because message timestamps aren’t independently verified, this attribute is prone to exploitation and misuse.
It should not solely be relied upon for operations such as message ordering.
For example, a malicious actor can arbitrarily set the <code>timestamp</code> of a Waku message to a high value so that it always shows up as the most recent message in a chat application.
Applications using Waku messages’<code>timestamp</code> attribute are recommended to use additional methods for more robust message ordering.
An example of how to deal with message ordering against adversarial message timestamps can be found in the Status protocol, see <ahref="https://specs.status.im/spec/6#clock-vs-timestamp-and-message-ordering">6/PAYLOADS</a>.</p>
<h2id="reliability-of-the-ephemeral-attribute">
Reliability of the <code>ephemeral</code> attribute
<p>The Waku message <code>ephemeral</code> attribute is set by the sender.
Since there is currently no incentive mechanism for network participants to behave correctly, this attribute is inherently insecure.
A malicious actor can tamper with the value of a Waku message’s <code>ephemeral</code> attribute, and the receiver would not be able to verify the integrity of the message.</p>
<h2id="copyright">
Copyright
<aclass="anchor"href="#copyright">#</a>
</h2>
<p>Copyright and related rights waived via <ahref="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>