P6. Processing rules
Work in progress — not audited
Normative protocol documentation for the current implementation. Not independently audited.
P6.1 Terminology
Keywords MUST, MUST NOT, SHOULD, and MAY are used per RFC 2119.
P6.2 Outbound encrypt path
Given application PDU data with type and payload fields:
- If
enableEncryptionis false → senddataunchanged; STOP. - If remote peer ∉
encryptedConnections→ send cleartext or queue handshake; implementation-defined; MUST NOT claim E2EE. - Serialize inner payload to bytes (typically UTF-8 JSON of message fields).
- If
enableCascadingCipherand cascade ready: - Else → MLS-only
envelopeper P4. - Set
data.encryptedMessage= result; preservedata.type. JSON.stringify→ send on data channel via PeerJS.
On any encrypt failure at step 4, implementation MAY fall back to step 5 and SHOULD log.
P6.3 Inbound decrypt path
On data channel data event:
- Parse JSON; if parse fails → MUST drop.
- If
type === "__mls_chunk__"→ buffer; if complete → reconstructencryptedMessage; goto 4. - If
encryptedMessageabsent → dispatch cleartext PDU to action router; STOP. - If
encryptedMessage.chunked→ reassemble chunks → single payload. - If
encryptedMessage.cascaded:- Rebuild
Uint8ArrayfromfinalCiphertextor chunks. cascadingCipher.decrypt(cascadedPayload, keys)reverse layer order.- On error → MUST NOT deliver plaintext; MUST drop or surface error.
- Rebuild
- Else MLS-only →
mlsManager.decryptMessage(envelope). - Parse decrypted bytes to inner fields (
message, etc.). - Dispatch to handler for original
type(e.g.messageaction).
P6.4 Handshake dispatch
PDUs listed in P3 MUST be processed even when encryptionReady is false. Handlers MUST update local crypto state before replying.
P6.5 Ordering
- JSON PDUs have no global sequence number at application layer.
- Signal ratchet MUST handle out-of-order ciphertext within a session.
- Chunk PDUs MUST be ordered by
chunkIndexbefore decrypt.
P6.6 Fast file transfer profile
When fast transfer active:
file-chunk/byte-range-*PDUs MAY carry binary withoutencryptedMessage.- Protection is DTLS + optional path security only.
- UI MUST indicate reduced protection (product requirement).
P6.7 Debug / disabled encryption
When encryption disabled for development:
- Senders MUST NOT set
encryptedMessage. - Receivers MUST accept cleartext
messagefields. - Deployments MUST NOT disable encryption in production.