diff options
| -rw-r--r-- | 59.md | 16 |
1 files changed, 9 insertions, 7 deletions
| @@ -9,6 +9,8 @@ Gift Wrap | |||
| 9 | This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata | 9 | This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata |
| 10 | for a given event, perform collaborative signing, and more. | 10 | for a given event, perform collaborative signing, and more. |
| 11 | 11 | ||
| 12 | This NIP *does not* define any messaging protocol. Applications of this NIP should be defined separately. | ||
| 13 | |||
| 12 | This NIP relies on [NIP-44](./44.md)'s versioned encryption algorithms. | 14 | This NIP relies on [NIP-44](./44.md)'s versioned encryption algorithms. |
| 13 | 15 | ||
| 14 | # Overview | 16 | # Overview |
| @@ -55,11 +57,8 @@ Tags MUST must always be empty in a `kind:13`. The inner event MUST always be un | |||
| 55 | 57 | ||
| 56 | ## 3. Gift Wrap Event Kind | 58 | ## 3. Gift Wrap Event Kind |
| 57 | 59 | ||
| 58 | A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` MUST include a single `p` tag | 60 | A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` SHOULD include any information |
| 59 | containing the recipient's public key. | 61 | needed to route the event to its intended recipient, including the recipient's `p` tag or NIP-13 proof of work. |
| 60 | |||
| 61 | The goal is to hide the sender's information, the metadata, and the content of the original event from the public. | ||
| 62 | The only public information is the receiver's public key. | ||
| 63 | 62 | ||
| 64 | ```js | 63 | ```js |
| 65 | { | 64 | { |
| @@ -68,7 +67,7 @@ The only public information is the receiver's public key. | |||
| 68 | "content": "<encrypted kind 13>", | 67 | "content": "<encrypted kind 13>", |
| 69 | "kind": 1059, | 68 | "kind": 1059, |
| 70 | "created_at": 1686840217, | 69 | "created_at": 1686840217, |
| 71 | "tags": [["p", "<Receiver>"]], | 70 | "tags": [["p", "<recipient pubkey>"]], |
| 72 | "sig": "<random, one-time-use pubkey signature>" | 71 | "sig": "<random, one-time-use pubkey signature>" |
| 73 | } | 72 | } |
| 74 | ``` | 73 | ``` |
| @@ -106,6 +105,9 @@ Let's send a wrapped `kind 1` message between two parties asking "Are you going | |||
| 106 | - Recipient private key: `e108399bd8424357a710b606ae0c13166d853d327e47a6e5e038197346bdbf45` | 105 | - Recipient private key: `e108399bd8424357a710b606ae0c13166d853d327e47a6e5e038197346bdbf45` |
| 107 | - Ephemeral wrapper key: `4f02eac59266002db5801adc5270700ca69d5b8f761d8732fab2fbf233c90cbd` | 106 | - Ephemeral wrapper key: `4f02eac59266002db5801adc5270700ca69d5b8f761d8732fab2fbf233c90cbd` |
| 108 | 107 | ||
| 108 | Note that this messaging protocol should not be used in practice, this is just an example. Refer to other | ||
| 109 | NIPs for concrete messaging protocols that depend on gift wraps. | ||
| 110 | |||
| 109 | ## 1. Create an event | 111 | ## 1. Create an event |
| 110 | 112 | ||
| 111 | Create a `kind 1` event with the message, the receivers, and any other tags you want, signed by the author. | 113 | Create a `kind 1` event with the message, the receivers, and any other tags you want, signed by the author. |
| @@ -243,7 +245,7 @@ const rumor = createRumor( | |||
| 243 | const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey) | 245 | const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey) |
| 244 | const wrap = createWrap(seal, recipientPublicKey) | 246 | const wrap = createWrap(seal, recipientPublicKey) |
| 245 | 247 | ||
| 246 | // Receiver unwraps with his/her private key. | 248 | // Recipient unwraps with his/her private key. |
| 247 | 249 | ||
| 248 | const unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey) | 250 | const unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey) |
| 249 | const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey) | 251 | const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey) |