Reading — step 1 of 5
Read
~1 min readSessions & Group Chat
Session State Management
Long-running conversations require careful state management. Per session:
python
Persist to local DB (SQLCipher in Signal). Encrypted at rest with device passphrase.
Concurrency: multiple devices, multiple conversations, can be tricky. Signal uses per-session locks.
Recovery scenarios:
- App crash mid-encrypt: state may be advanced; if not yet sent, peer never sees the message and will fall behind. Mitigation: only commit state AFTER successful network send.
- Lost device: new device has no state. Either ask peer to "reset session" or use Signal's "linked device" mechanism that shares some state via QR.
- Key compromise: hard to recover. Signal's "safety number changed" warning prompts users to re-verify out-of-band.
Multi-device:
- Each device has its own identity key.
- Messages encrypted N times (once per recipient device).
- Sender keys (server-side) help reduce O(N) encryption cost in groups.
State explosion: a daily-chat user with 5 devices, 50 contacts: 250 active sessions. Each session has root/chain/cached mks.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…