{"id":"72e91164b226a9ee961d394b69fb7d3761f45e6c82fb912daedd4f992a46bb18","pubkey":"b22b06b051fd5232966a9344a634d956c3dc33a7f5ecdcad9ed11ddc4120a7f2","created_at":1773742926,"kind":30817,"tags":[["d","nostr-mail-large-mime-support"],["title","Nostr mail large MIME support"],["client","nostrhub.io"]],"content":"# Nostr Mail large MIME support\n\n## Overview\n\nThis specification defines how to handle large emails (MIME > 65KB) by storing encrypted MIME messages on Blossom servers. Small emails remain stored inline in the kind 1301 event content.\n\n## Motivation\n\nNIP-44 encryption has a hard limit of **65535 bytes** for plaintext messages.\n\nTraditional emails can easily exceed this limit. This spec provides a hybrid approach:\n\n- **Small emails (< 60KB)**: MIME stored inline in kind 1301 `content` field\n- **Large emails (≥ 60KB)**: MIME encrypted with AES-GCM and stored on Blossom, kind 1301 contains reference + decryption key\n\nThis allows Nostr Mail to support emails of any size.\n\n## Event Kind 1301: Email\n\n### Inline MIME (small emails < 65KB)\n\n```json\n{\n  \"kind\": 1301,\n  \"pubkey\": \"<sender_npub>\",\n  \"tags\": [\n    [\"p\", \"<recipient_npub>\"],\n    [\"subject\", \"Hello\"],\n    [\"from\", \"alice@nostr.mail\"],\n    [\"to\", \"bob@example.com\"],\n    [\"date\", \"1735401600\"]\n  ],\n  \"content\": \"From: alice@nostr.mail\\nTo: bob@example.com\\nSubject: Hello\\nDate: Sat, 28 Dec 2024 12:00:00 +0000\\n\\nHey Bob!\"\n}\n```\n\n### Blossom MIME (large emails ≥ 65KB)\n\n```json\n{\n  \"kind\": 1301,\n  \"pubkey\": \"<sender_npub>\",\n  \"tags\": [\n    [\"p\", \"<recipient_npub>\"],\n    [\"encryption-algorithm\", \"aes-gcm\"],\n    [\"decryption-key\", \"<base64_key>\"],\n    [\"decryption-nonce\", \"<base64_nonce>\"],\n    [\"x\", \"<sha256_hash>\"],\n    [\"subject\", \"Hello\"],\n    [\"from\", \"alice@nostr.mail\"],\n    [\"to\", \"bob@example.com\"],\n    [\"date\", \"1735401600\"]\n  ],\n  \"content\": \"\"\n}\n```\n\n### Tags\n\n| Tag | Required | Description |\n|-----|----------|-------------|\n| `p` | Yes | Recipient pubkey (or bridge pubkey) |\n| `encryption-algorithm` | Conditional | Encryption algorithm `aes-gcm` (only for Blossom MIME) |\n| `decryption-key` | Conditional | The decryption key (only for Blossom MIME) |\n| `decryption-nonce` | Conditional | The decryption nonce (only for Blossom MIME) |\n| `x` | Conditional | SHA-256 hex of encrypted MIME (only for Blossom MIME) |\n| `subject` | No | Email subject |\n| `from` | No | From address |\n| `to` | No | To address |\n| `date` | No | Email timestamp (Unix epoch) |\n\n### Detection\n\nClients detect the storage mode:\n\n| Condition | Mode | Action |\n|-----------|------|--------|\n| `content` non-empty | Inline MIME | Parse content directly |\n| `content` empty, `x` tag exists | Blossom MIME | Download from Blossom, then decrypt |\n\n## Encryption Scheme\n\n### Inline MIME (small emails)\n\nMIME is stored in plaintext in the `content` field.\n\n### Blossom MIME (large emails)\n\nThe MIME content is encrypted using AES-GCM.\n\n```txt\nRFC 2822 MIME message\n    ↓\nGenerate random 256-bit key and 96-bit nonce\n    ↓\nAES-GCM Encrypt (key, nonce, mime_bytes)\n    ↓\nEncrypted MIME blob\n    ↓\nUpload to recipient Blossom servers\n    ↓\nCreate kind 1301 with x tag + decryption key + nonce\n```","sig":"4375044dfa0763088abd5a5d349ece159a00e2ad04b80760269f64fbc68de270c9fd666f8bd2df3e084d4eb91b7fc00adac3ac2e555b470bfa0cc51a4ddd41b1"}