Files
BigBodyCobainandClaude Opus 5.5 591645992b Keep secure mail sessions working across backend restarts
A node that restarted lost the private half of the MLS key package in its
published bundle, so a welcome built from it could never be joined and the
sender's session stayed stuck with no way to reset it. Restarts also wiped
working sessions in two more ways. Fixes, each covered by a test:

- privacy-core: the saved DM state (v2) now carries every DM alias identity
  and its newest unused key packages (at most 16, unexpired), not only
  identities that already have a session. v1 state still loads. A new
  export call takes the identity list; older library builds fall back to the
  old export.
- The key package is saved as soon as it is created for the bundle.
- A session joined as the node's DM identity records that identity, so
  loading no longer drops it for lacking a per-contact identity.
- Re-reading mail already read (spent key) or mail from another group fails
  that message only; it no longer marks a restored session stale and wipes
  the conversation. A restored session that works is no longer suspect.
- A sender whose session is still unanswered checks the peer's bundle (at
  most every 5 minutes) and starts over if the key package changed; the
  peer rejoins from the welcome that rides along, keeping the new session
  only if it reads the message. Welcomes already joined are refused, so an
  old one replayed cannot roll a session back.
- /api/wormhole/dm/reset for a contact also drops its MLS session.

Verified with two fresh Docker nodes: mail sent after the receiver
restarted, a reply after the receiver restarted again, and mail after the
sender restarted all arrived readable on the original session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 08:11:42 -07:00
..