Skip to content

Add file encryption for conversation attachments - #2204

Closed
joepio wants to merge 1 commit into
developfrom
dm-file-crypto
Closed

joepio wants to merge 1 commit into
developfrom
dm-file-crypto

Conversation

@joepio

@joepio joepio commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Before: Encrypted conversations could seal text, but there was no way to encrypt a file, so a file could not be attached without the host seeing it.

After: A file can be encrypted on the device with its own random key. The key never leaves the sealed message, and a ciphertext cannot be moved into another conversation. Nothing in the app uses it yet; the next PR adds attachments to the chat.

How: seal_file and open_file in lib/src/conversation.rs use XChaCha20-Poly1305 with a random 32-byte key and a random 24-byte nonce per file, laid out as version, nonce, ciphertext and tag. The associated data holds a fixed label plus the conversation subject. The wasm crate exports conversationSealFile and conversationOpenFile, with sealFile and openFile wrappers in conversationCrypto.ts. Seven new Rust tests cover a round trip, a wrong conversation, a wrong key, a flipped byte in each part, two seals of the same bytes differing, an empty file and a 25 MiB file (19 conversation tests pass, clippy and fmt are clean for lib and the wasm32 target). Step 1 of the DM hosting plan.

Requested by Joep

joepio commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

Landed in develop through the batch #2210 (squash f39e460), tested together on Mancave run 5204.


Generated by Claude Code

@joepio joepio closed this Oct 11, 2026
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