Skip to content

feat: encrypt DM media with AES-256-GCM (Kind 15)#411

Merged
barrydeen merged 1 commit intomainfrom
feat/encrypted-dm-media
Apr 1, 2026
Merged

feat: encrypt DM media with AES-256-GCM (Kind 15)#411
barrydeen merged 1 commit intomainfrom
feat/encrypted-dm-media

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • Files shared in DMs are now encrypted client-side with AES-256-GCM before uploading to Blossom
  • Decryption key is distributed inside the NIP-17 gift wrap as a Kind 15 rumor, so only conversation participants can view the media
  • Single encrypted blob per file — all recipients share the same decryption key via their respective gift wraps

Changes

  • EncryptedMedia.kt (new) — AES-256-GCM encrypt/decrypt, Kind 15 tag building and parsing
  • Nip17.kt — Accept kind 15 in unwrap, auto-add p-tags, isFileMessage() helper
  • DmConversation.ktencryptedFileMetadata field on DmMessage
  • BlossomRepository.ktuploadEncryptedMedia() encrypts then uploads via /upload only (skips /media which would corrupt ciphertext)
  • EventRouter / DmListViewModel / DmConversationViewModel — Parse Kind 15 tags when processing received gift wraps
  • DmConversationViewModel.ktuploadMedia() now encrypts and sends Kind 15 via sendFileMessage() (local + remote signer)
  • DmBubble.ktEncryptedMediaContent composable: download, decrypt, display with in-memory LRU cache

Test plan

  • Send encrypted image from Wisp, verify it appears correctly on the receiver's end
  • Receive encrypted image from another Kind 15-capable client, verify Wisp decrypts and displays it
  • Verify sender can see their own sent media (self-copy via gift wrap)
  • Verify group DMs: all participants can view the encrypted media
  • Verify non-DM media uploads (compose screen) still work unencrypted
  • Verify /upload endpoint is used (not /media) for encrypted blobs

Files shared in DMs are now encrypted client-side with a random
AES-256-GCM key before uploading to Blossom. The decryption key is
distributed inside the NIP-17 gift wrap as a Kind 15 rumor, so only
conversation participants can view the media.
@barrydeen barrydeen merged commit 03410bd into main Apr 1, 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