Compare commits

..

2 Commits

Author SHA1 Message Date
fiatjaf_
b8782df594 fix typo 2025-05-05 21:13:18 -03:00
fiatjaf
4de6a69931 allow NIP-44 to encrypt more than 65535 bytes. 2025-05-04 07:00:09 -03:00
12 changed files with 166 additions and 401 deletions

8
01.md
View File

@@ -14,7 +14,7 @@ Each user has a keypair. Signatures, public key, and encodings are done accordin
The only object type that exists is the `event`, which has the following format on the wire: The only object type that exists is the `event`, which has the following format on the wire:
```yaml ```jsonc
{ {
"id": <32-bytes lowercase hex-encoded sha256 of the serialized event data>, "id": <32-bytes lowercase hex-encoded sha256 of the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the event creator>, "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
@@ -85,7 +85,7 @@ As a convention, all single-letter (only english alphabet letters: a-z, A-Z) key
### Kinds ### Kinds
Kinds specify how clients should interpret the meaning of each event and the other fields of each event (e.g. an `"r"` tag may have a meaning in an event of kind 1 and an entirely different meaning in an event of kind 10002). Each NIP may define the meaning of a set of kinds that weren't defined elsewhere. [NIP-10](10.md), for instance, specifies the `kind:1` text note for social media applications. Kinds specify how clients should interpret the meaning of each event and the other fields of each event (e.g. an `"r"` tag may have a meaning in an event of kind 1 and an entirely different meaning in an event of kind 10002). Each NIP may define the meaning of a set of kinds that weren't defined elsewhere. [NIP-10](10.md), for instance, especifies the `kind:1` text note for social media applications.
This NIP defines one basic kind: This NIP defines one basic kind:
@@ -120,7 +120,7 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
`<filtersX>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes: `<filtersX>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes:
```yaml ```json
{ {
"ids": <a list of event ids>, "ids": <a list of event ids>,
"authors": <a list of lowercase pubkeys, the pubkey of an event must be one of these>, "authors": <a list of lowercase pubkeys, the pubkey of an event must be one of these>,
@@ -144,7 +144,7 @@ All conditions of a filter that are specified must match for an event for it to
A `REQ` message may contain multiple filters. In this case, events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions. A `REQ` message may contain multiple filters. In this case, events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions.
The `limit` property of a filter is only valid for the initial query and MUST be ignored afterwards. When `limit: n` is present it is assumed that the events returned in the initial query will be the last `n` events ordered by the `created_at`. Newer events should appear first, and in the case of ties the event with the lowest id (first in lexical order) should be first. Relays SHOULD use the `limit` value to guide how many events are returned in the initial response. Returning fewer events is acceptable, but returning (much) more should be avoided to prevent overwhelming clients. The `limit` property of a filter is only valid for the initial query and MUST be ignored afterwards. When `limit: n` is present it is assumed that the events returned in the initial query will be the last `n` events ordered by the `created_at`. Newer events should appear first, and in the case of ties the event with the lowest id (first in lexical order) should be first. It is safe to return less events than `limit` specifies, but it is expected that relays do not return (much) more events than requested so clients don't get unnecessarily overwhelmed by data.
### From relay to client: sending events and notices ### From relay to client: sending events and notices

79
17.md
View File

@@ -15,17 +15,17 @@ Kind `14` is a chat message. `p` tags identify one or more receivers of the mess
```jsonc ```jsonc
{ {
"id": "<usual hash>", "id": "<usual hash>",
"pubkey": "<sender-pubkey>",   "pubkey": "<sender-pubkey>",
"created_at": "<current-time>", "created_at": "<current-time>",
"kind": 14,   "kind": 14,
"tags": [   "tags": [
["p", "<receiver-1-pubkey>", "<relay-url>"],     ["p", "<receiver-1-pubkey>", "<relay-url>"],
["p", "<receiver-2-pubkey>", "<relay-url>"],     ["p", "<receiver-2-pubkey>", "<relay-url>"],
["e", "<kind-14-id>", "<relay-url>"] // if this is a reply     ["e", "<kind-14-id>", "<relay-url>"] // if this is a reply
["subject", "<conversation-title>"], ["subject", "<conversation-title>"],
// rest of tags...     // rest of tags...
],   ],
"content": "<message-in-plain-text>",   "content": "<message-in-plain-text>",
} }
``` ```
@@ -65,22 +65,21 @@ Kind `14`s MUST never be signed. If it is signed, the message might leak to rela
} }
``` ```
Kind `15` is used for sending encrypted file event messages: Kind 15 is used for sending encrypted file event messages:
- `file-type`: Specifies the MIME type of the attached file (e.g., `image/jpeg`, `audio/mpeg`, etc.) before encryption. - `file-type`: Specifies the MIME type of the attached file (e.g., `image/jpeg`, `audio/mpeg`, etc.).
- `encryption-algorithm`: Indicates the encryption algorithm used for encrypting the file. Supported algorithms: `aes-gcm`. - `encryption-algorithm`: Indicates the encryption algorithm used for encrypting the file. Supported algorithms may include `aes-gcm`, `chacha20-poly1305`,`aes-cbc` etc.
- `decryption-key`: The decryption key that will be used by the recipient to decrypt the file. - `decryption-key`: The decryption key that will be used by the recipient to decrypt the file.
- `decryption-nonce`: The decryption nonce that will be used by the recipient to decrypt the file. - `decryption-nonce`: The decryption nonce that will be used by the recipient to decrypt the file.
- `content`: The URL of the file (`<file-url>`). - `content`: The URL of the file (`<file-url>`).
- `x` containing the SHA-256 hexencoded string of the encrypted file. - `x` containing the SHA-256 hexencoded string of the file.
- `ox` containing the SHA-256 hexencoded string of the file before encryption. - `size` (optional) size of file in bytes
- `size` (optional) size of the encrypted file in bytes - `dim` (optional) size of the file in pixels in the form `<width>x<height>`
- `dim` (optional) size in pixels in the form `<width>x<height>`
- `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the client is loading the file - `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the client is loading the file
- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce) - `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce)
- `fallback` (optional) zero or more fallback file sources in case `url` fails (encrypted with the same key, nonce) - `fallback` (optional) zero or more fallback file sources in case `url` fails
Just like kind `14`, kind `15`s MUST never be signed. Just like kind 14, kind `15`s MUST never be signed.
## Chat Rooms ## Chat Rooms
@@ -88,34 +87,34 @@ The set of `pubkey` + `p` tags defines a chat room. If a new `p` tag is added or
Clients SHOULD render messages of the same room in a continuous thread. Clients SHOULD render messages of the same room in a continuous thread.
An optional `subject` tag defines the current name/topic of the conversation. Any member can change the topic by simply submitting a new `subject` to an existing `pubkey` + `p` tags room. There is no need to send `subject` in every message. The newest `subject` in the chat room is the subject of the conversation. An optional `subject` tag defines the current name/topic of the conversation. Any member can change the topic by simply submitting a new `subject` to an existing `pubkey` + `p`-tags room. There is no need to send `subject` in every message. The newest `subject` in the thread is the subject of the conversation.
## Encrypting ## Encrypting
Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat messages must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually. Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat messages must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually.
```js ```jsonc
{ {
"id": "<usual hash>", "id": "<usual hash>",
"pubkey": randomPublicKey,   "pubkey": randomPublicKey,
"created_at": randomTimeUpTo2DaysInThePast(),   "created_at": randomTimeUpTo2DaysInThePast(),
"kind": 1059, // gift wrap "kind": 1059, // gift wrap
"tags": [   "tags": [
["p", receiverPublicKey, "<relay-url>"] // receiver     ["p", receiverPublicKey, "<relay-url>"] // receiver
],   ],
"content": nip44Encrypt(   "content": nip44Encrypt(
{     {
"id": "<usual hash>", "id": "<usual hash>",
"pubkey": senderPublicKey,       "pubkey": senderPublicKey,
"created_at": randomTimeUpTo2DaysInThePast(),       "created_at": randomTimeUpTo2DaysInThePast(),
"kind": 13, // seal       "kind": 13, // seal
"tags": [], // no tags       "tags": [], // no tags
"content": nip44Encrypt(unsignedKind14, senderPrivateKey, receiverPublicKey),       "content": nip44Encrypt(unsignedKind14, senderPrivateKey, receiverPublicKey),
"sig": "<signed by senderPrivateKey>"       "sig": "<signed by senderPrivateKey>"
},     },
randomPrivateKey, receiverPublicKey     randomPrivateKey, receiverPublicKey
),   ),
"sig": "<signed by randomPrivateKey>"   "sig": "<signed by randomPrivateKey>"
} }
``` ```
@@ -125,7 +124,7 @@ Clients MUST verify if pubkey of the `kind:13` is the same pubkey on the `kind:1
Clients SHOULD randomize `created_at` in up to two days in the past in both the seal and the gift wrap to make sure grouping by `created_at` doesn't reveal any metadata. Clients SHOULD randomize `created_at` in up to two days in the past in both the seal and the gift wrap to make sure grouping by `created_at` doesn't reveal any metadata.
The gift wrap's `p` tag can be the receiver's main pubkey or an alias key created to receive DMs without exposing the receiver's identity. The gift wrap's `p`-tag can be the receiver's main pubkey or an alias key created to receive DMs without exposing the receiver's identity.
Clients CAN offer disappearing messages by setting an `expiration` tag in the gift wrap of each receiver or by not generating a gift wrap to the sender's public key Clients CAN offer disappearing messages by setting an `expiration` tag in the gift wrap of each receiver or by not generating a gift wrap to the sender's public key
@@ -189,7 +188,7 @@ The two final GiftWraps, one to the receiver and the other to the sender, respec
"created_at":1703128320, "created_at":1703128320,
"kind":1059, "kind":1059,
"tags":[ "tags":[
["p", "918e2da906df4ccd12c8ac672d8335add131a4cf9d27ce42b3bb3625755f0788"] [ "p", "918e2da906df4ccd12c8ac672d8335add131a4cf9d27ce42b3bb3625755f0788"]
], ],
"content":"AsqzdlMsG304G8h08bE67dhAR1gFTzTckUUyuvndZ8LrGCvwI4pgC3d6hyAK0Wo9gtkLqSr2rT2RyHlE5wRqbCOlQ8WvJEKwqwIJwT5PO3l2RxvGCHDbd1b1o40ZgIVwwLCfOWJ86I5upXe8K5AgpxYTOM1BD+SbgI5jOMA8tgpRoitJedVSvBZsmwAxXM7o7sbOON4MXHzOqOZpALpS2zgBDXSAaYAsTdEM4qqFeik+zTk3+L6NYuftGidqVluicwSGS2viYWr5OiJ1zrj1ERhYSGLpQnPKrqDaDi7R1KrHGFGyLgkJveY/45y0rv9aVIw9IWF11u53cf2CP7akACel2WvZdl1htEwFu/v9cFXD06fNVZjfx3OssKM/uHPE9XvZttQboAvP5UoK6lv9o3d+0GM4/3zP+yO3C0NExz1ZgFmbGFz703YJzM+zpKCOXaZyzPjADXp8qBBeVc5lmJqiCL4solZpxA1865yPigPAZcc9acSUlg23J1dptFK4n3Tl5HfSHP+oZ/QS/SHWbVFCtq7ZMQSRxLgEitfglTNz9P1CnpMwmW/Y4Gm5zdkv0JrdUVrn2UO9ARdHlPsW5ARgDmzaxnJypkfoHXNfxGGXWRk0sKLbz/ipnaQP/eFJv/ibNuSfqL6E4BnN/tHJSHYEaTQ/PdrA2i9laG3vJti3kAl5Ih87ct0w/tzYfp4SRPhEF1zzue9G/16eJEMzwmhQ5Ec7jJVcVGa4RltqnuF8unUu3iSRTQ+/MNNUkK6Mk+YuaJJs6Fjw6tRHuWi57SdKKv7GGkr0zlBUU2Dyo1MwpAqzsCcCTeQSv+8qt4wLf4uhU9Br7F/L0ZY9bFgh6iLDCdB+4iABXyZwT7Ufn762195hrSHcU4Okt0Zns9EeiBOFxnmpXEslYkYBpXw70GmymQfJlFOfoEp93QKCMS2DAEVeI51dJV1e+6t3pCSsQN69Vg6jUCsm1TMxSs2VX4BRbq562+VffchvW2BB4gMjsvHVUSRl8i5/ZSDlfzSPXcSGALLHBRzy+gn0oXXJ/447VHYZJDL3Ig8+QW5oFMgnWYhuwI5QSLEyflUrfSz+Pdwn/5eyjybXKJftePBD9Q+8NQ8zulU5sqvsMeIx/bBUx0fmOXsS3vjqCXW5IjkmSUV7q54GewZqTQBlcx+90xh/LSUxXex7UwZwRnifvyCbZ+zwNTHNb12chYeNjMV7kAIr3cGQv8vlOMM8ajyaZ5KVy7HpSXQjz4PGT2/nXbL5jKt8Lx0erGXsSsazkdoYDG3U", "content":"AsqzdlMsG304G8h08bE67dhAR1gFTzTckUUyuvndZ8LrGCvwI4pgC3d6hyAK0Wo9gtkLqSr2rT2RyHlE5wRqbCOlQ8WvJEKwqwIJwT5PO3l2RxvGCHDbd1b1o40ZgIVwwLCfOWJ86I5upXe8K5AgpxYTOM1BD+SbgI5jOMA8tgpRoitJedVSvBZsmwAxXM7o7sbOON4MXHzOqOZpALpS2zgBDXSAaYAsTdEM4qqFeik+zTk3+L6NYuftGidqVluicwSGS2viYWr5OiJ1zrj1ERhYSGLpQnPKrqDaDi7R1KrHGFGyLgkJveY/45y0rv9aVIw9IWF11u53cf2CP7akACel2WvZdl1htEwFu/v9cFXD06fNVZjfx3OssKM/uHPE9XvZttQboAvP5UoK6lv9o3d+0GM4/3zP+yO3C0NExz1ZgFmbGFz703YJzM+zpKCOXaZyzPjADXp8qBBeVc5lmJqiCL4solZpxA1865yPigPAZcc9acSUlg23J1dptFK4n3Tl5HfSHP+oZ/QS/SHWbVFCtq7ZMQSRxLgEitfglTNz9P1CnpMwmW/Y4Gm5zdkv0JrdUVrn2UO9ARdHlPsW5ARgDmzaxnJypkfoHXNfxGGXWRk0sKLbz/ipnaQP/eFJv/ibNuSfqL6E4BnN/tHJSHYEaTQ/PdrA2i9laG3vJti3kAl5Ih87ct0w/tzYfp4SRPhEF1zzue9G/16eJEMzwmhQ5Ec7jJVcVGa4RltqnuF8unUu3iSRTQ+/MNNUkK6Mk+YuaJJs6Fjw6tRHuWi57SdKKv7GGkr0zlBUU2Dyo1MwpAqzsCcCTeQSv+8qt4wLf4uhU9Br7F/L0ZY9bFgh6iLDCdB+4iABXyZwT7Ufn762195hrSHcU4Okt0Zns9EeiBOFxnmpXEslYkYBpXw70GmymQfJlFOfoEp93QKCMS2DAEVeI51dJV1e+6t3pCSsQN69Vg6jUCsm1TMxSs2VX4BRbq562+VffchvW2BB4gMjsvHVUSRl8i5/ZSDlfzSPXcSGALLHBRzy+gn0oXXJ/447VHYZJDL3Ig8+QW5oFMgnWYhuwI5QSLEyflUrfSz+Pdwn/5eyjybXKJftePBD9Q+8NQ8zulU5sqvsMeIx/bBUx0fmOXsS3vjqCXW5IjkmSUV7q54GewZqTQBlcx+90xh/LSUxXex7UwZwRnifvyCbZ+zwNTHNb12chYeNjMV7kAIr3cGQv8vlOMM8ajyaZ5KVy7HpSXQjz4PGT2/nXbL5jKt8Lx0erGXsSsazkdoYDG3U",
"sig":"a3c6ce632b145c0869423c1afaff4a6d764a9b64dedaf15f170b944ead67227518a72e455567ca1c2a0d187832cecbde7ed478395ec4c95dd3e71749ed66c480" "sig":"a3c6ce632b145c0869423c1afaff4a6d764a9b64dedaf15f170b944ead67227518a72e455567ca1c2a0d187832cecbde7ed478395ec4c95dd3e71749ed66c480"
@@ -203,7 +202,7 @@ The two final GiftWraps, one to the receiver and the other to the sender, respec
"created_at":1702711587, "created_at":1702711587,
"kind":1059, "kind":1059,
"tags":[ "tags":[
["p", "44900586091b284416a0c001f677f9c49f7639a55c3f1e2ec130a8e1a7998e1b"] [ "p", "44900586091b284416a0c001f677f9c49f7639a55c3f1e2ec130a8e1a7998e1b"]
], ],
"content":"AsTClTzr0gzXXji7uye5UB6LYrx3HDjWGdkNaBS6BAX9CpHa+Vvtt5oI2xJrmWLen+Fo2NBOFazvl285Gb3HSM82gVycrzx1HUAaQDUG6HI7XBEGqBhQMUNwNMiN2dnilBMFC3Yc8ehCJT/gkbiNKOpwd2rFibMFRMDKai2mq2lBtPJF18oszKOjA+XlOJV8JRbmcAanTbEK5nA/GnG3eGUiUzhiYBoHomj3vztYYxc0QYHOx0WxiHY8dsC6jPsXC7f6k4P+Hv5ZiyTfzvjkSJOckel1lZuE5SfeZ0nduqTlxREGeBJ8amOykgEIKdH2VZBZB+qtOMc7ez9dz4wffGwBDA7912NFS2dPBr6txHNxBUkDZKFbuD5wijvonZDvfWq43tZspO4NutSokZB99uEiRH8NAUdGTiNb25m9JcDhVfdmABqTg5fIwwTwlem5aXIy8b66lmqqz2LBzJtnJDu36bDwkILph3kmvaKPD8qJXmPQ4yGpxIbYSTCohgt2/I0TKJNmqNvSN+IVoUuC7ZOfUV9lOV8Ri0AMfSr2YsdZ9ofV5o82ClZWlWiSWZwy6ypa7CuT1PEGHzywB4CZ5ucpO60Z7hnBQxHLiAQIO/QhiBp1rmrdQZFN6PUEjFDloykoeHe345Yqy9Ke95HIKUCS9yJurD+nZjjgOxZjoFCsB1hQAwINTIS3FbYOibZnQwv8PXvcSOqVZxC9U0+WuagK7IwxzhGZY3vLRrX01oujiRrevB4xbW7Oxi/Agp7CQGlJXCgmRE8Rhm+Vj2s+wc/4VLNZRHDcwtfejogjrjdi8p6nfUyqoQRRPARzRGUnnCbh+LqhigT6gQf3sVilnydMRScEc0/YYNLWnaw9nbyBa7wFBAiGbJwO40k39wj+xT6HTSbSUgFZzopxroO3f/o4+ubx2+IL3fkev22mEN38+dFmYF3zE+hpE7jVxrJpC3EP9PLoFgFPKCuctMnjXmeHoiGs756N5r1Mm1ffZu4H19MSuALJlxQR7VXE/LzxRXDuaB2u9days/6muP6gbGX1ASxbJd/ou8+viHmSC/ioHzNjItVCPaJjDyc6bv+gs1NPCt0qZ69G+JmgHW/PsMMeL4n5bh74g0fJSHqiI9ewEmOG/8bedSREv2XXtKV39STxPweceIOh0k23s3N6+wvuSUAJE7u1LkDo14cobtZ/MCw/QhimYPd1u5HnEJvRhPxz0nVPz0QqL/YQeOkAYk7uzgeb2yPzJ6DBtnTnGDkglekhVzQBFRJdk740LEj6swkJ", "content":"AsTClTzr0gzXXji7uye5UB6LYrx3HDjWGdkNaBS6BAX9CpHa+Vvtt5oI2xJrmWLen+Fo2NBOFazvl285Gb3HSM82gVycrzx1HUAaQDUG6HI7XBEGqBhQMUNwNMiN2dnilBMFC3Yc8ehCJT/gkbiNKOpwd2rFibMFRMDKai2mq2lBtPJF18oszKOjA+XlOJV8JRbmcAanTbEK5nA/GnG3eGUiUzhiYBoHomj3vztYYxc0QYHOx0WxiHY8dsC6jPsXC7f6k4P+Hv5ZiyTfzvjkSJOckel1lZuE5SfeZ0nduqTlxREGeBJ8amOykgEIKdH2VZBZB+qtOMc7ez9dz4wffGwBDA7912NFS2dPBr6txHNxBUkDZKFbuD5wijvonZDvfWq43tZspO4NutSokZB99uEiRH8NAUdGTiNb25m9JcDhVfdmABqTg5fIwwTwlem5aXIy8b66lmqqz2LBzJtnJDu36bDwkILph3kmvaKPD8qJXmPQ4yGpxIbYSTCohgt2/I0TKJNmqNvSN+IVoUuC7ZOfUV9lOV8Ri0AMfSr2YsdZ9ofV5o82ClZWlWiSWZwy6ypa7CuT1PEGHzywB4CZ5ucpO60Z7hnBQxHLiAQIO/QhiBp1rmrdQZFN6PUEjFDloykoeHe345Yqy9Ke95HIKUCS9yJurD+nZjjgOxZjoFCsB1hQAwINTIS3FbYOibZnQwv8PXvcSOqVZxC9U0+WuagK7IwxzhGZY3vLRrX01oujiRrevB4xbW7Oxi/Agp7CQGlJXCgmRE8Rhm+Vj2s+wc/4VLNZRHDcwtfejogjrjdi8p6nfUyqoQRRPARzRGUnnCbh+LqhigT6gQf3sVilnydMRScEc0/YYNLWnaw9nbyBa7wFBAiGbJwO40k39wj+xT6HTSbSUgFZzopxroO3f/o4+ubx2+IL3fkev22mEN38+dFmYF3zE+hpE7jVxrJpC3EP9PLoFgFPKCuctMnjXmeHoiGs756N5r1Mm1ffZu4H19MSuALJlxQR7VXE/LzxRXDuaB2u9days/6muP6gbGX1ASxbJd/ou8+viHmSC/ioHzNjItVCPaJjDyc6bv+gs1NPCt0qZ69G+JmgHW/PsMMeL4n5bh74g0fJSHqiI9ewEmOG/8bedSREv2XXtKV39STxPweceIOh0k23s3N6+wvuSUAJE7u1LkDo14cobtZ/MCw/QhimYPd1u5HnEJvRhPxz0nVPz0QqL/YQeOkAYk7uzgeb2yPzJ6DBtnTnGDkglekhVzQBFRJdk740LEj6swkJ",
"sig":"c94e74533b482aa8eeeb54ae72a5303e0b21f62909ca43c8ef06b0357412d6f8a92f96e1a205102753777fd25321a58fba3fb384eee114bd53ce6c06a1c22bab" "sig":"c94e74533b482aa8eeeb54ae72a5303e0b21f62909ca43c8ef06b0357412d6f8a92f96e1a205102753777fd25321a58fba3fb384eee114bd53ce6c06a1c22bab"

2
19.md
View File

@@ -34,7 +34,7 @@ These are the possible bech32 prefixes with `TLV`:
- `nprofile`: a nostr profile - `nprofile`: a nostr profile
- `nevent`: a nostr event - `nevent`: a nostr event
- `naddr`: a nostr _addressable event_ coordinate - `naddr`: a nostr _replaceable event_ coordinate
- `nrelay`: a nostr relay (deprecated) - `nrelay`: a nostr relay (deprecated)
These possible standardized `TLV` types are indicated here: These possible standardized `TLV` types are indicated here:

20
21.md
View File

@@ -12,27 +12,9 @@ The scheme is `nostr:`.
The identifiers that come after are expected to be the same as those defined in [NIP-19](19.md) (except `nsec`). The identifiers that come after are expected to be the same as those defined in [NIP-19](19.md) (except `nsec`).
#### Examples ## Examples
- `nostr:npub1sn0wdenkukak0d9dfczzeacvhkrgz92ak56egt7vdgzn8pv2wfqqhrjdv9` - `nostr:npub1sn0wdenkukak0d9dfczzeacvhkrgz92ak56egt7vdgzn8pv2wfqqhrjdv9`
- `nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p` - `nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p`
- `nostr:note1fntxtkcy9pjwucqwa9mddn7v03wwwsu9j330jj350nvhpky2tuaspk6nqc` - `nostr:note1fntxtkcy9pjwucqwa9mddn7v03wwwsu9j330jj350nvhpky2tuaspk6nqc`
- `nostr:nevent1qqstna2yrezu5wghjvswqqculvvwxsrcvu7uc0f78gan4xqhvz49d9spr3mhxue69uhkummnw3ez6un9d3shjtn4de6x2argwghx6egpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5nxnepm` - `nostr:nevent1qqstna2yrezu5wghjvswqqculvvwxsrcvu7uc0f78gan4xqhvz49d9spr3mhxue69uhkummnw3ez6un9d3shjtn4de6x2argwghx6egpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5nxnepm`
### Linking HTML pages to Nostr entities
`<link>` tags with `rel="alternate"` can be used to associate webpages to Nostr events, in cases where the same content is served via the two mediums (for example, a web server that exposes Markdown articles both as HTML pages and as `kind:30023' events served under itself as a relay or through some other relay). For example:
```
<head>
<link rel="alternate" href="nostr:naddr1qqyrzwrxvc6ngvfkqyghwumn8ghj7enfv96x5ctx9e3k7mgzyqalp33lewf5vdq847t6te0wvnags0gs0mu72kz8938tn24wlfze6qcyqqq823cph95ag" />
</head>
```
Likewise, `<link>` tags with `rel="me"` or `rel="author"` can be used to assign authorship of webpages to Nostr profiles. For example:
```
<head>
<link rel="me" href="nostr:nprofile1qyxhwumn8ghj7mn0wvhxcmmvqyd8wumn8ghj7un9d3shjtnhv4ehgetjde38gcewvdhk6qpq80cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwswpnfsn" />
</head>
```

32
25.md
View File

@@ -7,38 +7,38 @@ Reactions
`draft` `optional` `draft` `optional`
A reaction is a `kind 7` event that is used to indicate user reactions to other events. A A reaction is a `kind 7` event that is used to react to other events.
reaction's `content` field MUST include user-generated-content indicating the value of the
reaction (conventionally `+`, `-`, or an emoji).
A reaction with `content` set to `+` or an empty string MUST be interpreted as a "like" or "upvote". The generic reaction, represented by the `content` set to a `+` string, SHOULD
A reaction with `content` set to `-` MUST be interpreted as a "dislike" or "downvote". be interpreted as a "like" or "upvote".
A reaction with `content` set to an emoji or [NIP-30](30.md) custom emoji SHOULD NOT be interpreted A reaction with `content` set to `-` SHOULD be interpreted as a "dislike" or
as a "like" or "dislike". Clients MAY instead display this emoji reaction on the post. "downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a
downvote or dislike on a post. A client MAY also choose to tally likes against
dislikes in a reddit-like system of upvotes and downvotes, or display them as
separate tallies.
The `content` MAY be an emoji, or [NIP-30](30.md) custom emoji in this case it MAY be interpreted as a "like" or "dislike",
or the client MAY display this emoji reaction on the post. If the `content` is an empty string then the client should
consider it a "+".
Tags Tags
---- ----
There MUST be always an `e` tag set to the `id` of the event that is being reacted to. The `e` tag SHOULD include a relay hint pointing to a relay where the event being reacted to can be found. If a client decides to include other `e`, which not recommended, the target event `id` should be last of the `e` tags. There MUST be always an `e` tag set to the `id` of the event that is being reacted to. The `e` tag SHOULD include a relay hint pointing to a relay where the event being reacted to can be found. If a client decides to include other `e`, which not recommended, the target event `id` should be last of the `e` tags.
There SHOULD be a `p` tag set to the `pubkey` of the event being reacted to. If a client decides to include other `p` tags, which not recommended, the target event `pubkey` should be last the `p` tags. The SHOULD be a `p` tag set to the `pubkey` of the event being reacted to. If a client decides to include other `p` tags, which not recommended, the target event `pubkey` should be last the `p` tags.
If the event being reacted to is an addressable event, an `a` SHOULD be included together with the `e` tag, it must be set to the coordinates (`kind:pubkey:d-tag`) of the event being reacted to. If the event being reacted to is an addressable event, an `a` SHOULD be included together with the `e` tag, it must be set to the coordinates (`kind:pubkey:d-tag`) of the event being reacted to.
The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value. The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value.
The `e` and `a` tags SHOULD include relay and pubkey hints. The `p` tags SHOULD include relay hints.
The reaction event MAY include a `k` tag with the stringified kind number of the reacted event as its value.
**Example code** **Example code**
```swift ```swift
func make_like_event(pubkey: String, privkey: String, liked: NostrEvent, hint: String) -> NostrEvent { func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
var tags: [[String]] = [] tags.append(["e", liked.id, liked.source_relays.first ?? ""])
tags.append(["e", liked.id, hint, liked.pubkey]) tags.append(["p", liked.pubkey])
tags.append(["p", liked.pubkey, hint])
tags.append(["k", String(liked.kind)]) tags.append(["k", String(liked.kind)])
let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
ev.calculate_id() ev.calculate_id()

31
44.md
View File

@@ -84,10 +84,12 @@ NIP-44 version 2 has the following design characteristics:
- Slice 76-byte HKDF output into: `chacha_key` (bytes 0..32), `chacha_nonce` (bytes 32..44), `hmac_key` (bytes 44..76) - Slice 76-byte HKDF output into: `chacha_key` (bytes 0..32), `chacha_nonce` (bytes 32..44), `hmac_key` (bytes 44..76)
4. Add padding 4. Add padding
- Content must be encoded from UTF-8 into byte array - Content must be encoded from UTF-8 into byte array
- Validate plaintext length. Minimum is 1 byte, maximum is 65535 bytes - Validate plaintext length. Minimum is 1 byte, maximum is 4294967296 bytes
- Padding format is: `[plaintext_length: u16][plaintext][zero_bytes]` - Padding format is: `[plaintext_length: u16][plaintext][zero_bytes]`
- Padding algorithm is related to powers-of-two, with min padded msg size of 32 bytes - Padding algorithm is related to powers-of-two, with min padded msg size of 32 bytes
- Plaintext length is encoded in big-endian as first 2 bytes of the padded blob - Plaintext length is encoded in big-endian:
- if smaller than 65536, as a u16 in the first 2 bytes of the padded blob;
- if greater than 65536, the first 6 bytes of the padded blob, the first 2 being zero and the other 4 being the actual encoded length as u32
5. Encrypt padded content 5. Encrypt padded content
- Use ChaCha20, with key and nonce from step 3 - Use ChaCha20, with key and nonce from step 3
6. Calculate MAC (message authentication code) 6. Calculate MAC (message authentication code)
@@ -124,7 +126,9 @@ validation rules, refer to BIP-340.
6. Decrypt ciphertext 6. Decrypt ciphertext
- Use ChaCha20 with key and nonce from step 3 - Use ChaCha20 with key and nonce from step 3
7. Remove padding 7. Remove padding
- Read the first two BE bytes of plaintext that correspond to plaintext length - Read the first 2 bytes,
- if they're zero, read the next 4 bytes as the u32 big-endian plaintext length;
- otherwise interpret those 2 bytes as the u16 plaintext length
- Verify that the length of sliced plaintext matches the value of the two BE bytes - Verify that the length of sliced plaintext matches the value of the two BE bytes
- Verify that calculated padding from step 3 of the [encryption](#Encryption) process matches the actual padding - Verify that calculated padding from step 3 of the [encryption](#Encryption) process matches the actual padding
@@ -148,8 +152,6 @@ validation rules, refer to BIP-340.
- `x[i:j]`, where `x` is a byte array and `i, j <= 0` returns a `(j - i)`-byte array with a copy of the - `x[i:j]`, where `x` is a byte array and `i, j <= 0` returns a `(j - i)`-byte array with a copy of the
`i`-th byte (inclusive) to the `j`-th byte (exclusive) of `x`. `i`-th byte (inclusive) to the `j`-th byte (exclusive) of `x`.
- Constants `c`: - Constants `c`:
- `min_plaintext_size` is 1. 1 byte msg is padded to 32 bytes.
- `max_plaintext_size` is 65535 (64kB - 1). It is padded to 65536 bytes.
- Functions - Functions
- `base64_encode(string)` and `base64_decode(bytes)` are Base64 ([RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648), with padding) - `base64_encode(string)` and `base64_decode(bytes)` are Base64 ([RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648), with padding)
- `concat` refers to byte array concatenation - `concat` refers to byte array concatenation
@@ -182,16 +184,27 @@ def calc_padded_len(unpadded_len):
def pad(plaintext): def pad(plaintext):
unpadded = utf8_encode(plaintext) unpadded = utf8_encode(plaintext)
unpadded_len = len(plaintext) unpadded_len = len(plaintext)
if (unpadded_len < c.min_plaintext_size or if (unpadded_len < 1 or
unpadded_len > c.max_plaintext_size): raise Exception('invalid plaintext length') unpadded_len > 4294967295): raise Exception('invalid plaintext length')
prefix = write_u16_be(unpadded_len) if unpadded_len > 65536:
prefix = concat(
[0, 0],
write_u32_be(unpadded_len),
)
else:
prefix = write_u16_be(unpadded_len)
suffix = zeros(calc_padded_len(unpadded_len) - unpadded_len) suffix = zeros(calc_padded_len(unpadded_len) - unpadded_len)
return concat(prefix, unpadded, suffix) return concat(prefix, unpadded, suffix)
# Converts padded bytearray to unpadded plaintext # Converts padded bytearray to unpadded plaintext
def unpad(padded): def unpad(padded):
unpadded_len = read_uint16_be(padded[0:2]) unpadded_len = read_uint16_be(padded[0:2])
unpadded = padded[2:2+unpadded_len] if unpadded_len == 0:
unpadded_len = read_uint32_be(padded[2:6])
unpadded = padded[6:6+unpadded_len]
else:
unpadded = padded[2:2+unpadded_len]
if (unpadded_len == 0 or if (unpadded_len == 0 or
len(unpadded) != unpadded_len or len(unpadded) != unpadded_len or
len(padded) != 2 + calc_padded_len(unpadded_len)): raise Exception('invalid padding') len(padded) != 2 + calc_padded_len(unpadded_len)): raise Exception('invalid padding')

12
51.md
View File

@@ -22,7 +22,6 @@ For example, _mute list_ can contain the public keys of spammers and bad actors
| name | kind | description | expected tag items | | name | kind | description | expected tag items |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| Follow list | 3 | microblogging basic follow list, see [NIP-02](02.md) | `"p"` (pubkeys -- with optional relay hint and petname) |
| Mute list | 10000 | things the user doesn't want to see in their feeds | `"p"` (pubkeys), `"t"` (hashtags), `"word"` (lowercase string), `"e"` (threads) | | Mute list | 10000 | things the user doesn't want to see in their feeds | `"p"` (pubkeys), `"t"` (hashtags), `"word"` (lowercase string), `"e"` (threads) |
| Pinned notes | 10001 | events the user intends to showcase in their profile page | `"e"` (kind:1 notes) | | Pinned notes | 10001 | events the user intends to showcase in their profile page | `"e"` (kind:1 notes) |
| Read/write relays | 10002 | where a user publishes to and where they expect mentions | see [NIP-65](65.md) | | Read/write relays | 10002 | where a user publishes to and where they expect mentions | see [NIP-65](65.md) |
@@ -32,9 +31,7 @@ For example, _mute list_ can contain the public keys of spammers and bad actors
| Blocked relays | 10006 | relays clients should never connect to | `"relay"` (relay URLs) | | Blocked relays | 10006 | relays clients should never connect to | `"relay"` (relay URLs) |
| Search relays | 10007 | relays clients should use when performing search queries | `"relay"` (relay URLs) | | Search relays | 10007 | relays clients should use when performing search queries | `"relay"` (relay URLs) |
| Simple groups | 10009 | [NIP-29](29.md) groups the user is in | `"group"` ([NIP-29](29.md) group id + relay URL + optional group name), `"r"` for each relay in use | | Simple groups | 10009 | [NIP-29](29.md) groups the user is in | `"group"` ([NIP-29](29.md) group id + relay URL + optional group name), `"r"` for each relay in use |
| Favorite relays | 10012 | user favorite relays and pointers to relay sets | `"relay"` (relay URLs) and `"a"` (kind:30002 relay set) |
| Interests | 10015 | topics a user may be interested in and pointers | `"t"` (hashtags) and `"a"` (kind:30015 interest set) | | Interests | 10015 | topics a user may be interested in and pointers | `"t"` (hashtags) and `"a"` (kind:30015 interest set) |
| Media follows | 10020 | multimedia (photos, short video) follow list | `"p"` (pubkeys -- with optional relay hint and petname) |
| Emojis | 10030 | user preferred emojis and pointers to emoji sets | `"emoji"` (see [NIP-30](30.md)) and `"a"` (kind:30030 emoji set) | | Emojis | 10030 | user preferred emojis and pointers to emoji sets | `"emoji"` (see [NIP-30](30.md)) and `"a"` (kind:30030 emoji set) |
| DM relays | 10050 | Where to receive [NIP-17](17.md) direct messages | `"relay"` (see [NIP-17](17.md)) | | DM relays | 10050 | Where to receive [NIP-17](17.md) direct messages | `"relay"` (see [NIP-17](17.md)) |
| Good wiki authors | 10101 | [NIP-54](54.md) user recommended wiki authors | `"p"` (pubkeys) | | Good wiki authors | 10101 | [NIP-54](54.md) user recommended wiki authors | `"p"` (pubkeys) |
@@ -60,9 +57,6 @@ Aside from their main identifier, the `"d"` tag, sets can optionally have a `"ti
| Emoji sets | 30030 | categorized emoji groups | `"emoji"` (see [NIP-30](30.md)) | | Emoji sets | 30030 | categorized emoji groups | `"emoji"` (see [NIP-30](30.md)) |
| Release artifact sets | 30063 | group of artifacts of a software release | `"e"` (kind:1063 [file metadata](94.md) events), `"a"` (software application event) | | Release artifact sets | 30063 | group of artifacts of a software release | `"e"` (kind:1063 [file metadata](94.md) events), `"a"` (software application event) |
| App curation sets | 30267 | references to multiple software applications | `"a"` (software application event) | | App curation sets | 30267 | references to multiple software applications | `"a"` (software application event) |
| Calendar | 31924 | a set of events categorized in any way | `"a"` (calendar event event) |
| Starter packs | 39089 | a named set of profiles to be shared around with the goal of being followed together | `"p"` (pubkeys) |
| Media starter packs | 39092 | same as above, but specific to multimedia (photos, short video) clients | `"p"` (pubkeys) |
### Deprecated standard lists ### Deprecated standard lists
@@ -104,9 +98,9 @@ Some clients have used these lists in the past, but they should work on transiti
"kind": 30004, "kind": 30004,
"tags": [ "tags": [
["d", "jvdy9i4"], ["d", "jvdy9i4"],
["title", "Yaks"], ["name", "Yaks"],
["image", "https://cdn.britannica.com/40/188540-050-9AC748DE/Yak-Himalayas-Nepal.jpg"], ["picture", "https://cdn.britannica.com/40/188540-050-9AC748DE/Yak-Himalayas-Nepal.jpg"],
["description", "The domestic yak, also known as the Tartary ox, grunting ox, or hairy cattle, is a species of long-haired domesticated cattle found throughout the Himalayan region of the Indian subcontinent, the Tibetan Plateau, Gilgit-Baltistan, Tajikistan and as far north as Mongolia and Siberia."], ["about", "The domestic yak, also known as the Tartary ox, grunting ox, or hairy cattle, is a species of long-haired domesticated cattle found throughout the Himalayan region of the Indian subcontinent, the Tibetan Plateau, Gilgit-Baltistan, Tajikistan and as far north as Mongolia and Siberia."],
["a", "30023:26dc95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:95ODQzw3ajNoZ8SyMDOzQ"], ["a", "30023:26dc95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:95ODQzw3ajNoZ8SyMDOzQ"],
["a", "30023:54af95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:1-MYP8dAhramH9J5gJWKx"], ["a", "30023:54af95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:1-MYP8dAhramH9J5gJWKx"],
["a", "30023:f8fe95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:D2Tbd38bGrFvU0bIbvSMt"], ["a", "30023:f8fe95542e18b8b7aec2f14610f55c335abebec76f3db9e58c254661d0593a0c:D2Tbd38bGrFvU0bIbvSMt"],

129
52.md
View File

@@ -12,14 +12,23 @@ Unlike the term `calendar event` specific to this NIP, the term `event` is used
## Calendar Events ## Calendar Events
There are two types of calendar events represented by different kinds: _date-based_ and _time-based_ calendar events. There are two types of calendar events represented by different kinds: date-based and time-based calendar events. Calendar events are not required to be part of a [calendar](#calendar).
These tags are common to both types of calendar events: ### Date-Based Calendar Event
* `d` (required) a short unique string identifier. Generated by the client creating the calendar event. This kind of calendar event starts on a date and ends before a different date in the future. Its use is appropriate for all-day or multi-day events where time and time zone hold no significance. e.g., anniversary, public holidays, vacation days.
#### Format
The format uses an _addressable event_ of `kind:31922`.
The `.content` of these events should be a detailed description of the calendar event. It is required but can be an empty string.
The list of tags are as follows:
* `d` (required) universally unique identifier (UUID). Generated by the client creating the calendar event.
* `title` (required) title of the calendar event * `title` (required) title of the calendar event
* `summary` (optional) brief description of the calendar event * `start` (required) inclusive start date in ISO 8601 format (YYYY-MM-DD). Must be less than `end`, if it exists.
* `image` (optional) url of an image to use for the event * `end` (optional) exclusive end date in ISO 8601 format (YYYY-MM-DD). If omitted, the calendar event ends on the same date as `start`.
* `location` (optional, repeated) location of the calendar event. e.g. address, GPS coordinates, meeting room name, link to video call * `location` (optional, repeated) location of the calendar event. e.g. address, GPS coordinates, meeting room name, link to video call
* `g` (optional) [geohash](https://en.wikipedia.org/wiki/Geohash) to associate calendar event with a searchable physical location * `g` (optional) [geohash](https://en.wikipedia.org/wiki/Geohash) to associate calendar event with a searchable physical location
* `p` (optional, repeated) 32-bytes hex pubkey of a participant, optional recommended relay URL, and participant's role in the meeting * `p` (optional, repeated) 32-bytes hex pubkey of a participant, optional recommended relay URL, and participant's role in the meeting
@@ -27,49 +36,39 @@ These tags are common to both types of calendar events:
* `r` (optional, repeated) references / links to web pages, documents, video calls, recorded videos, etc. * `r` (optional, repeated) references / links to web pages, documents, video calls, recorded videos, etc.
The following tags are deprecated: The following tags are deprecated:
* `name` name of the calendar event. Use only if `title` is not available. * `name` name of the calendar event. Use only if `title` is not available.
Calendar events are _not_ required to be part of a [calendar](#calendar). ```jsonc
### Date-Based Calendar Event
This kind of calendar event starts on a date and ends before a different date in the future. Its use is appropriate for all-day or multi-day events where time and time zone hold no significance. e.g., anniversary, public holidays, vacation days.
It's an _addressable event_ of `kind:31922`.
The `.content` of these events SHOULD be a description of the calendar event.
Aside from the common tags, this also takes the following tags:
* `start` (required) inclusive start date in ISO 8601 format (YYYY-MM-DD). Must be less than `end`, if it exists.
* `end` (optional) exclusive end date in ISO 8601 format (YYYY-MM-DD). If omitted, the calendar event ends on the same date as `start`.
Example:
```yaml
{ {
"id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>, "id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the event creator>, "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
"created_at": <unix timestamp in seconds>, "created_at": <Unix timestamp in seconds>,
"kind": 31922, "kind": 31922,
"content": "<description of calendar event>", "content": "<description of calendar event>",
"tags": [ "tags": [
["d", "<random-identifier>"], ["d", "<UUID>"],
["title", "<title of calendar event>"], ["title", "<title of calendar event>"],
// dates // Dates
["start", "<YYYY-MM-DD>"], ["start", "<YYYY-MM-DD>"],
["end", "<YYYY-MM-DD>"], ["end", "<YYYY-MM-DD>"],
// location // Location
["location", "<location>"], ["location", "<location>"],
["g", "<geohash>"], ["g", "<geohash>"],
// participants // Participants
["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"], ["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"],
["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"], ["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"],
// Hashtags
["t", "<tag>"],
["t", "<tag>"],
// Reference links
["r", "<url>"],
["r", "<url>"]
] ]
} }
``` ```
@@ -78,68 +77,97 @@ Example:
This kind of calendar event spans between a start time and end time. This kind of calendar event spans between a start time and end time.
It's an _addressable event_ of `kind:31923`. #### Format
The `.content` of these events should be a description of the calendar event. It is required but can be an empty string. The format uses an _addressable event_ kind `31923`.
Aside from the common tags, this also takes the following tags: The `.content` of these events should be a detailed description of the calendar event. It is required but can be an empty string.
The list of tags are as follows:
* `d` (required) universally unique identifier (UUID). Generated by the client creating the calendar event.
* `title` (required) title of the calendar event
* `start` (required) inclusive start Unix timestamp in seconds. Must be less than `end`, if it exists. * `start` (required) inclusive start Unix timestamp in seconds. Must be less than `end`, if it exists.
* `end` (optional) exclusive end Unix timestamp in seconds. If omitted, the calendar event ends instantaneously. * `end` (optional) exclusive end Unix timestamp in seconds. If omitted, the calendar event ends instantaneously.
* `start_tzid` (optional) time zone of the start timestamp, as defined by the IANA Time Zone Database. e.g., `America/Costa_Rica` * `start_tzid` (optional) time zone of the start timestamp, as defined by the IANA Time Zone Database. e.g., `America/Costa_Rica`
* `end_tzid` (optional) time zone of the end timestamp, as defined by the IANA Time Zone Database. e.g., `America/Costa_Rica`. If omitted and `start_tzid` is provided, the time zone of the end timestamp is the same as the start timestamp. * `end_tzid` (optional) time zone of the end timestamp, as defined by the IANA Time Zone Database. e.g., `America/Costa_Rica`. If omitted and `start_tzid` is provided, the time zone of the end timestamp is the same as the start timestamp.
* `summary` (optional) brief description of the calendar event
* `image` (optional) url of an image to use for the event
* `location` (optional, repeated) location of the calendar event. e.g. address, GPS coordinates, meeting room name, link to video call
* `g` (optional) [geohash](https://en.wikipedia.org/wiki/Geohash) to associate calendar event with a searchable physical location
* `p` (optional, repeated) 32-bytes hex pubkey of a participant, optional recommended relay URL, and participant's role in the meeting
* `l` (optional, repeated) label to categorize calendar event. e.g. `audiospace` to denote a scheduled event from a live audio space implementation such as cornychat.com
* `t` (optional, repeated) hashtag to categorize calendar event
* `r` (optional, repeated) references / links to web pages, documents, video calls, recorded videos, etc.
```yaml The following tags are deprecated:
* `name` name of the calendar event. Use only if `title` is not available.
```jsonc
{ {
"id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>, "id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the event creator>, "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
"created_at": <unix timestamp in seconds>, "created_at": <Unix timestamp in seconds>,
"kind": 31923, "kind": 31923,
"content": "<description of calendar event>", "content": "<description of calendar event>",
"tags": [ "tags": [
["d", "<random-identifier>"], ["d", "<UUID>"],
["title", "<title of calendar event>"], ["title", "<title of calendar event>"],
["summary", "<brief description of the calendar event>"], ["summary", "<brief description of the calendar event>"],
["image", "<string with image URI>"], ["image", "<string with image URI>"],
// timestamps // Timestamps
["start", "<unix timestamp in seconds>"], ["start", "<Unix timestamp in seconds>"],
["end", "<unix timestamp in seconds>"], ["end", "<Unix timestamp in seconds>"],
["start_tzid", "<IANA Time Zone Database identifier>"], ["start_tzid", "<IANA Time Zone Database identifier>"],
["end_tzid", "<IANA Time Zone Database identifier>"], ["end_tzid", "<IANA Time Zone Database identifier>"],
// location // Location
["location", "<location>"], ["location", "<location>"],
["g", "<geohash>"], ["g", "<geohash>"],
// participants // Participants
["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"], ["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"],
["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"], ["p", "<32-bytes hex of a pubkey>", "<optional recommended relay URL>", "<role>"],
// Labels (example using com.cornychat namespace denoting the event as an audiospace)
["L", "com.cornychat"],
["l", "audiospace", "com.cornychat"],
// Hashtags
["t", "<tag>"],
["t", "<tag>"],
// Reference links
["r", "<url>"],
["r", "<url>"]
] ]
} }
``` ```
## Calendar ## Calendar
A calendar is a collection of calendar events, represented as a custom _addressable list_ event using kind `31924`. A user can have multiple calendars. One may create a calendar to segment calendar events for specific purposes. e.g., personal, work, travel, meetups, and conferences. A calendar is a collection of calendar events, represented as a custom replaceable list event using kind `31924`. A user can have multiple calendars. One may create a calendar to segment calendar events for specific purposes. e.g., personal, work, travel, meetups, and conferences.
### Format
The `.content` of these events should be a detailed description of the calendar. It is required but can be an empty string. The `.content` of these events should be a detailed description of the calendar. It is required but can be an empty string.
The format uses a custom replaceable list of kind `31924` with a list of tags as described below:
* `d` (required) universally unique identifier. Generated by the client creating the calendar. * `d` (required) universally unique identifier. Generated by the client creating the calendar.
* `title` (required) calendar title * `title` (required) calendar title
* `a` (repeated) reference tag to kind `31922` or `31923` calendar event being responded to * `a` (repeated) reference tag to kind `31922` or `31923` calendar event being responded to
```yaml ```json
{ {
"id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>, "id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the event creator>, "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
"created_at": <unix timestamp in seconds>, "created_at": <Unix timestamp in seconds>,
"kind": 31924, "kind": 31924,
"content": "<description of calendar>", "content": "<description of calendar>",
"tags": [ "tags": [
["d", "<random-identifier>"], ["d", "<UUID>"],
["title", "<calendar title>"], ["title", "<calendar title>"],
["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional relay url>"], ["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional relay url>"],
["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional relay url>"] ["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional relay url>"]
@@ -163,12 +191,13 @@ The RSVP MUST have an `a` tag of the event coordinates to the calendar event, an
The RSVP MAY tag the author of the calendar event it is in response to using a `p` tag so that clients can easily query all RSVPs that pertain to the author. The RSVP MAY tag the author of the calendar event it is in response to using a `p` tag so that clients can easily query all RSVPs that pertain to the author.
The RSVP is an _addressable event_ of `kind:31925`. ### Format
The format uses an _addressable event_ kind `31925`.
The `.content` of these events is optional and should be a free-form note that adds more context to this calendar event response. The `.content` of these events is optional and should be a free-form note that adds more context to this calendar event response.
The list of tags is as follows: The list of tags are as follows:
* `a` (required) coordinates to a kind `31922` or `31923` calendar event being responded to. * `a` (required) coordinates to a kind `31922` or `31923` calendar event being responded to.
* `e` (optional) event id of a kind `31922` or `31923` calendar event being responded to. * `e` (optional) event id of a kind `31922` or `31923` calendar event being responded to.
* `d` (required) universally unique identifier. Generated by the client creating the calendar event RSVP. * `d` (required) universally unique identifier. Generated by the client creating the calendar event RSVP.
@@ -176,17 +205,17 @@ The list of tags is as follows:
* `fb` (optional) `free` or `busy`. Determines if the user would be free or busy for the duration of the calendar event. This tag must be omitted or ignored if the `status` label is set to `declined`. * `fb` (optional) `free` or `busy`. Determines if the user would be free or busy for the duration of the calendar event. This tag must be omitted or ignored if the `status` label is set to `declined`.
* `p` (optional) pubkey of the author of the calendar event being responded to. * `p` (optional) pubkey of the author of the calendar event being responded to.
```yaml ```json
{ {
"id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>, "id": <32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the event creator>, "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
"created_at": <unix timestamp in seconds>, "created_at": <Unix timestamp in seconds>,
"kind": 31925, "kind": 31925,
"content": "<note>", "content": "<note>",
"tags": [ "tags": [
["e", "<kind 31922 or 31923 event id", "<optional recommended relay URL>"] ["e", "<kind 31922 or 31923 event id", "<optional recommended relay URL>"]
["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional recommended relay URL>"], ["a", "<31922 or 31923>:<calendar event author pubkey>:<d-identifier of calendar event>", "<optional recommended relay URL>"],
["d", "<random-identifier>"], ["d", "<UUID>"],
["status", "<accepted/declined/tentative>"], ["status", "<accepted/declined/tentative>"],
["fb", "<free/busy>"], ["fb", "<free/busy>"],
["p", "<hex pubkey of kind 31922 or 31923 event>", "<optional recommended relay URL>"] ["p", "<hex pubkey of kind 31922 or 31923 event>", "<optional recommended relay URL>"]

175
77.md
View File

@@ -1,175 +0,0 @@
NIP-77
======
Negentropy Syncing
------------------
`draft` `optional`
This document describes a protocol extension for syncing events. It works for both client-relay and relay-relay scenarios. If both sides of the sync have events in common, then this protocol will use less bandwidth than transferring the full set of events (or even just their IDs).
It is a Nostr-friendly wrapper around the [Negentropy](https://github.com/hoytech/negentropy) protocol, which uses a technique called [Range-Based Set Reconciliation](https://logperiodic.com/rbsr.html).
Since Negentropy is a binary protocol, this wrapper hex-encodes its messages. The specification for Negentropy Protocol V1 is attached as an appendix to this NIP below.
## High-Level Protocol Description
We're going to call the two sides engaged in the sync the client and the relay (even though the initiator could be another relay instead of a client).
* (1) Client (initiator) chooses a filter, and retrieves the set of events that it has locally that match this filter (or uses a cache), and constructs an initial message.
* (2) Client sends a `NEG-OPEN` message to the relay, which includes the filter and the initial message.
* (3) Relay selects the set of events that it has locally that match the filter (or uses a cache).
* (4) Relay constructs a response and returns it to the client in a `NEG-MSG` message.
* (5) Client parses the message to learn about IDs it has (and relay needs) and IDs it needs (and relay has).
* If client wishes to continue, then it constructs a new message and sends it to the relay in a `NEG-MSG` message. Goto step 4.
* If client wishes to stop, then it sends a `NEG-CLOSE` message or disconnects the websocket.
The above protocol only results in the client learning about IDs it has/needs, and does not actually transfer events. Given these IDs, the client can upload events it has with `EVENT`, and/or download events it needs with `REQ`. This can be performed over the same websocket connection in parallel with subsequent `NEG-MSG` messages. If a client is only interested in determining the number of unique events (ie, reaction counts), it may choose to not download/upload at all.
## Nostr Messages
### Initial message (client to relay):
```jsonc
[
"NEG-OPEN",
<subscription ID string>,
<filter>,
<initialMessage, hex-encoded>
]
```
* The subscription ID is used by each side to identify which query a message refers to. It only needs to be long enough to distinguish it from any other concurrent subscriptions on this websocket connection (an integer that increments once per `NEG-OPEN` is fine). Subscription IDs are in a separate namespace from `REQ` subscription IDs. If a `NEG-OPEN` is issued for a currently open subscription ID, the existing subscription is first closed.
* The filter is as described in [NIP-01](01.md).
* `initialMessage` is the initial Negentropy binary message, hex-encoded. See appendix.
### Error message (relay to client):
If a request cannot be serviced by the relay, an error is returned to the client:
```jsonc
[
"NEG-ERR",
<subscription ID string>,
<reason code string>
]
```
Error reasons are the same format as in NIP-01. They should begin with a machine-readable single-word prefix, followed by a `:` and then a human-readable message with more information.
The current suggested error reasons are
* `blocked`
* Relays can optionally reject queries that would require them to process too many records, or records that are too old
* The maximum number of records that can be processed can optionally be returned as the 4th element in the response
* Example: `blocked: this query is too big`
* `closed`
* Because the `NEG-OPEN` queries may be stateful, relays may choose to time-out inactive queries to recover memory resources
* Example: `closed: you took too long to respond!`
After a `NEG-ERR` is issued, the subscription is considered to be closed.
### Subsequent messages (bidirectional):
Relay and client alternate sending each other `NEG-MSG`s:
```jsonc
[
"NEG-MSG",
<subscription ID string>,
<message, hex-encoded>
]
```
* `message` is a Negentropy binary message, hex-encoded. Both message directions use the same format. See appendix.
### Close message (client to relay):
When finished, the client should tell the relay it can release its resources with a `NEG-CLOSE`:
```jsonc
[
"NEG-CLOSE",
<subscription ID string>
]
```
## Appendix: Negentropy Protocol V1
### Preparation
There are two protocol participants: Client and server. The client creates an initial message and transmits it to the server, which replies with its own message in response. The client continues querying the server until it is satisifed, and then terminates the protocol. Messages in either direction have the same format.
Each participant has a collection of records. A records consists of a 64-bit numeric timestamp and a 256-bit ID. Each participant starts by sorting their items according to timestamp, ascending. If two timestamps are equal then items are sorted lexically by ID, ascending by first differing byte. Items may not use the max uint64 value (`2**64 - 1`) as a timestamp since this is reserved as a special "infinity" value.
The goal of the protocol is for the client to learn the set of IDs that it has and the server does not, and the set of items that the server has and it does not.
### `Varint`
Varints (variable-sized unsigned integers) are represented as base-128 digits, most significant digit first, with as few digits as possible. Bit eight (the high bit) is set on each byte except the last.
Varint := <Digit+128>* <Digit>
### `Id`
IDs are represented as byte-strings of length `32`:
Id := Byte{32}
### `Message`
A reconciliation message is a protocol version byte followed by an ordered list of ranges:
Message := <protocolVersion (Byte)> <Range>*
The current protocol version is 1, represented by the byte `0x61`. Protocol version 2 will be `0x62`, and so forth. If a server receives a message with a protocol version that it cannot handle, it should reply with a single byte containing the highest protocol version it supports, allowing the client to downgrade and retry its message.
Each Range corresponds to a contiguous section of the timestamp/ID space. The first Range starts at timestamp 0 and an ID of 0 bytes. Ranges are always adjacent (no gaps). If the last Range doesn't end at the special infinity value, an implicit `Skip` to infinity Range is appended. This means that the list of Ranges always covers the full timestamp/ID space.
### `Range`
A Range consists of an upper bound, a mode, and a payload:
Range := <upperBound (Bound)> <mode (Varint)> <payload (Skip | Fingerprint | IdList)>
The contents of the payload is determined by mode:
* If `mode = 0`, then payload is `Skip`, meaning the sender does not wish to process this Range further. This payload is empty:
Skip :=
* If `mode = 1`, then payload is a `Fingerprint`, which is a [digest](#fingerprint-algorithm) of all the IDs the sender has within the Range:
Fingerprint := Byte{16}
* If `mode = 2`, the payload is `IdList`, a variable-length list of all IDs the sender has within the Range:
IdList := <length (Varint)> <ids (Id)>*
### `Bound`
Each Range is specified by an *inclusive* lower bound and an *exclusive* upper bound. As defined above, each Range only includes an upper bound: the lower bound of a Range is the upper bound of the previous Range, or 0 timestamp/0 ID for the first Range.
A Bound consists of an encoded timestamp and a variable-length disambiguating prefix of an ID (in case multiple items have the same timestamp):
Bound := <encodedTimestamp (Varint)> <length (Varint)> <idPrefix (Byte)>*
* The timestamp is encoded specially. The infinity timestamp is encoded as `0`. All other values are encoded as `1 + offset`, where offset is the difference between this timestamp and the previously encoded timestamp. The initial offset starts at `0` and resets at the beginning of each message.
Offsets are always non-negative since the upper bound's timestamp is greater than or equal to the lower bound's timestamp, ranges in a message are always encoded in ascending order, and ranges never overlap.
* The size of `idPrefix` is encoded in `length`, and can be between `0` and `32` bytes, inclusive. This allows implementations to use the shortest possible prefix to separate the first record of this Range from the last record of the previous Range. If these records' timestamps differ, then the length should be 0, otherwise it should be the byte-length of their common ID-prefix plus 1.
If the `idPrefix` length is less than `32` then the omitted trailing bytes are implicitly 0 bytes.
### Fingerprint Algorithm
The fingerprint of a Range is computed with the following algorithm:
* Compute the addition mod 2<sup>256</sup> of the element IDs (interpreted as 32-byte little-endian unsigned integers)
* Concatenate with the number of elements in the Range, encoded as a [Varint](#varint)
* Hash with SHA-256
* Take the first 16 bytes

2
84.md
View File

@@ -23,7 +23,7 @@ or obvious non-useful information from the query string.
### Attribution ### Attribution
Clients MAY include one or more `p` tags, tagging the original authors of the material being highlighted; this is particularly Clients MAY include one or more `p` tags, tagging the original authors of the material being highlighted; this is particularly
useful when highlighting non-nostr content for which the client might be able to get a nostr pubkey somehow useful when highlighting non-nostr content for which the client might be able to get a nostr pubkey somehow
(e.g. prompting the user or reading a `<link rel="me" href="nostr:nprofile1..." />` tag on the document). A role MAY be included as the (e.g. prompting the user or reading a `<meta name="nostr:nprofile1..." />` tag on the document). A role MAY be included as the
last value of the tag. last value of the tag.
```jsonc ```jsonc

View File

@@ -88,7 +88,6 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
- [NIP-72: Moderated Communities](72.md) - [NIP-72: Moderated Communities](72.md)
- [NIP-73: External Content IDs](73.md) - [NIP-73: External Content IDs](73.md)
- [NIP-75: Zap Goals](75.md) - [NIP-75: Zap Goals](75.md)
- [NIP-77: Negentropy Syncing](77.md)
- [NIP-78: Application-specific data](78.md) - [NIP-78: Application-specific data](78.md)
- [NIP-7D: Threads](7D.md) - [NIP-7D: Threads](7D.md)
- [NIP-84: Highlights](84.md) - [NIP-84: Highlights](84.md)
@@ -188,11 +187,9 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
| `10006` | Blocked relays list | [51](51.md) | | `10006` | Blocked relays list | [51](51.md) |
| `10007` | Search relays list | [51](51.md) | | `10007` | Search relays list | [51](51.md) |
| `10009` | User groups | [51](51.md), [29](29.md) | | `10009` | User groups | [51](51.md), [29](29.md) |
| `10012` | Favorite relays list | [51](51.md) |
| `10013` | Private event relay list | [37](37.md) | | `10013` | Private event relay list | [37](37.md) |
| `10015` | Interests list | [51](51.md) | | `10015` | Interests list | [51](51.md) |
| `10019` | Nutzap Mint Recommendation | [61](61.md) | | `10019` | Nutzap Mint Recommendation | [61](61.md) |
| `10020` | Media follows | [51](51.md) |
| `10030` | User emoji list | [51](51.md) | | `10030` | User emoji list | [51](51.md) |
| `10050` | Relay list to receive DMs | [51](51.md), [17](17.md) | | `10050` | Relay list to receive DMs | [51](51.md), [17](17.md) |
| `10063` | User server list | [Blossom][blossom] | | `10063` | User server list | [Blossom][blossom] |
@@ -252,8 +249,6 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
| `34550` | Community Definition | [72](72.md) | | `34550` | Community Definition | [72](72.md) |
| `38383` | Peer-to-peer Order events | [69](69.md) | | `38383` | Peer-to-peer Order events | [69](69.md) |
| `39000-9` | Group metadata events | [29](29.md) | | `39000-9` | Group metadata events | [29](29.md) |
| `39089` | Starter packs | [51](51.md) |
| `39092` | Media starter packs | [51](51.md) |
| `39701` | Web bookmarks | [B0](B0.md) | | `39701` | Web bookmarks | [B0](B0.md) |
[NUD: Custom Feeds]: https://wikifreedia.xyz/cip-01/ [NUD: Custom Feeds]: https://wikifreedia.xyz/cip-01/

72
xx.md
View File

@@ -1,72 +0,0 @@
NIP-XX
======
LLM Stuff
---------
`draft` `optional`
This NIP defines kinds related to LLM stuff.
# Prompt diffs
a way to publish LLM prompts that describe modifications to software projects. Where code diffs usually expire in a couple of releases and require constant upkeep,tThese "prompt diffs" enable way longer-lasting, shareable software modifications.
## Abstract
A prompt diff is a Nostr event that contains instructions for an LLM to modify a codebase. Prompt diffs describe the intent and let LLMs handle the implementation details.
## Event Structure
```json
{
"kind": 496,
"content": "<human-readable-description>",
"tags": [
["title", "<modification-title>"],
["description", "<prompt>"],
["r", "<git-repository-url>"],
["t", "<tag>"],
["model", "<suggested-llm-model>"],
]
}
Required Tags
title - Short title describing the modification
r - Git repository URL this applies to
prompt - The actual prompt containing modification instructions
## Optional Tags
t - Hashtags for categorization (#security, #performance, #feature-removal, etc.)
model - Suggested LLM model that successfully applies this modification
Example: Remove Edit Functionality from Amethyst
json{
"kind": 496,
"pubkey": "...",
"created_at": 1234567890,
"content": "Removes the ability to edit kind:1 text notes in Amethyst",
"tags": [
["title", "Remove Kind:1 Edit Functionality"],
["description", "Remove all edit functionality for kind:1 events from the Amethyst Android app. This includes:\n\n1. Find and remove the edit button/icon from the note options menu (three dots menu) for kind:1 events\n2. Remove any edit action handlers, click listeners, or menu item cases related to editing kind:1 notes\n3. Remove or disable any UI components like EditPostView or EditPostDialog that are used for editing existing posts\n4. Keep the edit functionality for other event kinds if they exist (like kind:30023 long-form content)\n5. Remove any edit-related permissions checks or business logic specific to kind:1 events\n6. Clean up any unused imports or resources that were only used for kind:1 editing\n7. Do not remove the ability to create new kind:1 posts, only the ability to edit existing ones\n8. Look for edit functionality in:\n - Note composition screens\n - Note option menus \n - ViewModels handling note actions\n - Any files with names containing 'Edit' and 'Note' or 'Post'\n\nMake sure the app still compiles and runs after these changes. The diff should be clean with no leftover dead code."],
["r", "https://github.com/vitorpamplona/amethyst"],
["t", "noedits"],
["t", "amethyst"],
["model", "claude-3.5-sonnet"],
],
"sig": "..."
}
# Implementation Guidelines
### For Prompt Authors
Write clear, specific prompts that describe intent rather than implementation
Include context about why changes should be made in certain locations
Specify what should NOT be changed to prevent over-modification
Add test commands to verify the modification works
Test prompts against the current main branch of the repository
# Security Considerations
* Always review LLM-generated changes before applying
* Prompt Injection Protection: Clients MUST sanitize repository file contents before passing to LLMs to prevent malicious code comments or documentation from hijacking the modification intent