{"id":"b8fadaabd0fb45bdff13c869c84c1b62a2806c899d3dfb8bf42c090346dc03a2","pubkey":"a22dbe51e3c719ad8b2cdc3e4ffc2176f20373f3027b67a1dc6c6e976fbcd6d8","created_at":1783950976,"kind":30817,"tags":[["d","user-metadata"],["title","Decoupled Encryption Key"],["k","34578","User Metadata Event"],["client","better-nips"]],"content":"`draft` `optional`\n\nDefines a protocol for decoupling the encryption key per NIP-4E using user metadata events per NIP-Metadata.\n\n---\n\n## Kind 34578 — User Metadata Event\n\nStores the secret metadata information about the user(encryption key) inside the content field. It is identified by the `d` tag\n\n**Tags:**\n\n| tag | value |\n|-----|-------|\n| `d` | `\"0:<author-pubkey>\"` |\n\n**Content:** NIP-44 encrypted to the author's own pubkey (via identity signer). Plaintext is a JSON string. Currently, the proposal is that the data contains a `encryptionKey` attribute which will have the key used for decrypting/encrypting messages, files and other entities owned by the user.\n\n```json\n{\n  \"encryptionKey\": \"<hex-encoded drive private key>\"\n}\n```\n\nThe **conversation key** used for all file metadata is:\n\n```\nconversationKey = getConversationKey(driveSecretKey, getPublicKey(driveSecretKey))\n```\n\n## Directives\n\n- The user metadata event must have a d tag `\"0:<author-pubkey>\"`.\n- Clients MUST encrypt and decrypt the user metadata event using the identity signer (`nip44Decrypt(authorPubkey, content)/nip44Encrypt(authorPubkey, content)`).\n- Clients MAY generate and publish a new metadata event warning the user that previous events may be lost.\n- When multiple events share the same `d` tag, clients MUST use the one with the highest `created_at`. Clients MAY inform the user that they found multiple metadata events\n\n---\n\n## Examples\n\nUser metadata event:\n\n```jsonc\n{\n  \"kind\": 34578,\n  \"pubkey\": \"abc123...\",\n  \"created_at\": 1700000000,\n  \"tags\": [\n    [\"d\", \"0:abc123...\"],\n  ],\n  \"content\": \"<nip44-ciphertext of {\\\"encryptionKey\\\",\\\"deadbeef...\\\"}>\",\n  \"sig\": \"...\"\n}\n```\n","sig":"8f72cc6862bf1e15403428d122655239e948673fedd82fd8d79a976a20b1e5a5867414ac4e766fcfbf35399954360c9684731c532536d557a422f622064a1309"}