upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--59.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/59.md b/59.md
index cd841cf..c990236 100644
--- a/59.md
+++ b/59.md
@@ -9,6 +9,8 @@ Gift Wrap
9This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata 9This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata
10for a given event, perform collaborative signing, and more. 10for a given event, perform collaborative signing, and more.
11 11
12This NIP *does not* define any messaging protocol. Applications of this NIP should be defined separately.
13
12This NIP relies on [NIP-44](./44.md)'s versioned encryption algorithms. 14This 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
58A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` MUST include a single `p` tag 60A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` SHOULD include any information
59containing the recipient's public key. 61needed to route the event to its intended recipient, including the recipient's `p` tag or NIP-13 proof of work.
60
61The goal is to hide the sender's information, the metadata, and the content of the original event from the public.
62The 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
108Note that this messaging protocol should not be used in practice, this is just an example. Refer to other
109NIPs for concrete messaging protocols that depend on gift wraps.
110
109## 1. Create an event 111## 1. Create an event
110 112
111Create a `kind 1` event with the message, the receivers, and any other tags you want, signed by the author. 113Create 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(
243const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey) 245const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey)
244const wrap = createWrap(seal, recipientPublicKey) 246const wrap = createWrap(seal, recipientPublicKey)
245 247
246// Receiver unwraps with his/her private key. 248// Recipient unwraps with his/her private key.
247 249
248const unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey) 250const unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey)
249const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey) 251const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey)