Repository navigation
DM key backup with a passphrase - #52
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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 werefalse) 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