Skip to content

DM key backup with a passphrase - #52

Merged
Androtim merged 1 commit into
mainfrom
feat/dm-key-backup
Jul 3, 2026
Merged

Androtim merged 1 commit into
mainfrom
feat/dm-key-backup

Conversation

@Androtim

@Androtim Androtim commented Jul 3, 2026 •

Copy link
Copy Markdown
Owner

Closes the biggest debt item: message keys were per-device, so signing in on a new device meant you couldn't read your history.

From Settings → Message key backup, an account holder can:

  • Back up: enter a passphrase, download a small encrypted file containing their private key.
  • Restore: paste that file + passphrase on another device to install the key and read history there.

Crypto: the private key JWK is encrypted with AES-256-GCM under a key derived from the passphrase via PBKDF2 (200k iterations, SHA-256, random 16-byte salt, random IV). The blob is useless without the passphrase, so it's safe to store or send. The server never sees it — this is purely client-side, and on restore the public key is republished so peers encrypt to the restored identity.

Security tradeoff, made deliberately: keys are now generated extractable: true (they were false) so the export is possible at all. The private key still only ever leaves the device through this explicit, passphrase-gated action — never over the network, never to the server. Given the audit found no XSS vector and the owner asked for this feature, that's the right call; noted in the code comment so it's not silently lost.

Verified: the round-trip test (key-backup.spec.ts) exports, wipes IndexedDB, rejects a wrong passphrase, restores with the right one, and decrypts a message encrypted to the original key. The existing DM and group-DM encryption specs still pass, and the Settings panel renders.

🤖 Generated with Claude Code

DM keys are per-device, so a new device couldn't read old messages.
A user can now export their private key from Settings, encrypted with
a passphrase (PBKDF2 200k + AES-256-GCM), and restore it on another
device to read history there. Keys are now generated extractable to
make this possible; the private key still only leaves the device
through this explicit, passphrase-gated export — never to the server.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Androtim
Androtim merged commit 542721d into main Jul 3, 2026
1 check passed
@Androtim
Androtim deleted the feat/dm-key-backup branch July 3, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant