{"id":"2fd952885955db80a9ce779848a8e35fab2f5bb016590cda71c07984fca406bb","pubkey":"b22b06b051fd5232966a9344a634d956c3dc33a7f5ecdcad9ed11ddc4120a7f2","created_at":1759690789,"kind":30817,"tags":[["d","nostr-drive"],["title","Nostr drive"],["k","9500"],["client","nostrhub.io"]],"content":"# NIP-XX\n\n## Nostr drive\n\n`draft` `optional`\n\nThis NIP defines file tree storage on Nostr using Blossom servers for files and Nostr events for folder structure.\n\n### Event Structure\n\nUses kind `9500` for both files and folders.\n\n#### File Event\n```json\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt({\n        \"type\": \"file\",\n        \"hash\": \"<sha256>\",\n        \"path\": \"<absolute-path>\",\n        \"size\": \"<size-in-bytes>\",\n        \"file-type\": \"<file-mime-type>\", // optional\n        \"encryption-algorithm\": \"<encryption-algorithm>\",\n        \"decryption-key\": \"<decryption-key>\",\n        \"decryption-nonce\": \"<decryption-nonce>\"\n    })\n}\n```\n\n- `file-type` (optional): Specifies the MIME type of the attached file (e.g., `image/jpeg`, `audio/mpeg`, `application/pdf`, etc.) before encryption.\n- `encryption-algorithm`: Indicates the encryption algorithm used for encrypting the file. Supported algorithms: `aes-gcm`.\n- `decryption-key`: The decryption key that will be used by the recipient to decrypt the file.\n- `decryption-nonce`: The decryption nonce that will be used by the recipient to decrypt the file.\n\n#### Folder Event\n```json\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt({\n        \"type\": \"folder\",\n        \"path\": \"<absolute-path>\"\n    })\n}\n```\n\n### Rules\n\n- All paths MUST be absolute (start with \"/\")\n- Content objects MUST be encrypted using NIP-44\n- Files are stored on Blossom servers, addressable by SHA-256\n- Delete using NIP-09 deletion events\n\n### File Sharing\n\nTo share files with other users, create a shared file event with the recipient's public key as a `P` tag:\n\n#### Shared File Event\n```jsonc\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt(<file-object>),\n    \"tags\": [[\"p\", \"<recipient-pubkey>\"]]\n}\n```\n\n- The `shared-with` field contains an array of public keys that have access\n- The `p` tag allows recipients to discover shared files\n- Recipients decrypt the content using NIP-44 with the sender's public key\n\n### File Versioning\n\nFile versions are handled by creating new events with the same path but different hashes. The most recent event is the most recent version of the file.\n\n#### Version Event\n```jsonc\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt({\n        \"type\": \"file\",\n        \"hash\": \"c886c67942...\", // new version hash\n        \"path\": \"/docs/report.pdf\", // same path as original\n        \"size\": 1148576,\n        \"file-type\": \"application/pdf\", // optional\n    }),\n}\n```\n\n- Multiple events with the same path represent different versions\n- The `previous-hash` field optionally links to the previous file version\n- The `e` tag can reference the previous event for version history\n- Clients MUST use the most recent event (highest `created_at`) as the current version\n\n### Examples\n\n#### Folder Event\n```jsonc\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt({\n        \"type\": \"folder\",\n        \"path\": \"/docs\"\n    }),\n}\n```\n\n#### File Event (Encrypted)\n```jsonc\n{\n    \"kind\": 9500,\n    \"content\": nip44Encrypt({\n        \"type\": \"file\",\n        \"hash\": \"b775b56931...\", // hash of encrypted blob\n        \"path\": \"/docs/secret.pdf\",\n        \"size\": 1048592, // size of encrypted blob\n        \"file-type\": \"application/pdf\", // optional\n        \"encryption-algorithm\": \"aes-gcm\",\n        \"decryption-key\": \"base64encodedkey...\",\n        \"decryption-nonce\": \"base64encodednonce...\"\n    }),\n}\n```","sig":"9cb3b53f150229b798b5b767c009b1454300e1b6d24f39271bac46ce5b193db2a5a38488e9f92628c465b9f1a0893f72e36882bea0f60a3fe73899481eb781c2"}