Skip to main content

P3. Session establishment

Work in progress — not audited

Normative protocol documentation for the current implementation. Not independently audited.

P3.1 Preconditions​

  1. Both peers registered on signaling broker.
  2. WebRTC data channel state is open.
  3. enableEncryption is true (production default).

P3.2 Handshake order (normative)​

When EnkryptedChat-Profile-v0 cascade is enabled, peers SHOULD exchange PDUs in this order (either peer may send first where symmetric):

StepPDU typePurpose
1mls-key-package-requestRequest remote MLS key package
2mls-key-packageDeliver MLS key package
3mls-encryption-sync-requestSynchronize encryption state
4mls-encryption-sync-responseRespond to sync
5signal-key-exchange-requestStart P2P Signal material exchange
6signal-key-exchange-responseRespond to Signal exchange
7signal-session-completeSignal session ready
8mlkem-key-exchangeML-KEM public key material
9mlkem-key-exchange-responseML-KEM response
10mls-commit / mls-welcomeMLS group commits (as needed)
11mls-welcome-ackAck welcome (when applicable)

Exact ordering may include additional mls-commit rounds for groups. Implementations MUST tolerate interleaved handshake PDUs until encryptionReady is true.

P3.3 Completion criterion​

Session crypto is ready when:

  1. encryptionReadyRef is true in MLSProvider, and
  2. Remote peer ID is in encryptedConnections set.

Only then MUST encrypted message PDUs be sent (see P6).

P3.4 Sequence diagram (1:1)​

P3.5 P2P Signal deltas​

Without a central pre-key server, X3DH material is exchanged in live PDUs over the data channel. Normative deltas: Appendix B. Tutorial: P2P Signal Protocol.

P3.5.1 Trust on first use​

Peers MUST treat broker Peer IDs as routing handles only. Cryptographic trust comes from in-band Signal/MLS handshakes (TOFU). Deployments SHOULD offer safety-number or QR verification for high-risk users (product UX; not required for encryptionReady).

P3.6 Reconnection​

State persisted locallyOn reconnect
Signal ratchet stateMAY resume if both peers retain state and peer IDs unchanged
MLS epoch / group stateMAY resume for same groupId
WebRTC sessionMUST re-establish ICE/signaling

If crypto state is lost, peers MUST repeat handshake from step 1.

P3.7 Reconnection sequence​

P3.8 Key rotation sequence​

P3.9 Out-of-order chunks​

P3.10 Group sessions​

Group chat uses additional PDUs (group-member-joined, mls-welcome, etc.). Status: experimental — normative PDU shapes in P4; security claims in ch. 11.