Skip to content

Commit

Permalink
Remove p tag, clarify that NIP 59 does not define a messaging protoco…
Browse files Browse the repository at this point in the history
…l on its own
  • Loading branch information
Jon Staab committed Jan 16, 2024
1 parent d7293a3 commit 1a2b21b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions 59.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Gift Wrap
This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata
for a given event, perform collaborative signing, and more.

This NIP *does not* define any messaging protocol. Applications of this NIP should be defined separately.

This NIP relies on [NIP-44](./44.md)'s versioned encryption algorithms.

# Overview
Expand Down Expand Up @@ -55,11 +57,8 @@ Tags MUST must always be empty in a `kind:13`. The inner event MUST always be un

## 3. Gift Wrap Event Kind

A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` MUST include a single `p` tag
containing the recipient's public key.

The goal is to hide the sender's information, the metadata, and the content of the original event from the public.
The only public information is the receiver's public key.
A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` SHOULD include any information
needed to route the event to its intended recipient, including the recipient's `p` tag or NIP-13 proof of work.

```js
{
Expand All @@ -68,7 +67,7 @@ The only public information is the receiver's public key.
"content": "<encrypted kind 13>",
"kind": 1059,
"created_at": 1686840217,
"tags": [["p", "<Receiver>"]],
"tags": [["p", "<recipient pubkey>"]],
"sig": "<random, one-time-use pubkey signature>"
}
```
Expand Down Expand Up @@ -106,6 +105,9 @@ Let's send a wrapped `kind 1` message between two parties asking "Are you going
- Recipient private key: `e108399bd8424357a710b606ae0c13166d853d327e47a6e5e038197346bdbf45`
- Ephemeral wrapper key: `4f02eac59266002db5801adc5270700ca69d5b8f761d8732fab2fbf233c90cbd`

Note that this messaging protocol should not be used in practice, this is just an example. Refer to other
NIPs for concrete messaging protocols that depend on gift wraps.

## 1. Create an event

Create a `kind 1` event with the message, the receivers, and any other tags you want, signed by the author.
Expand Down Expand Up @@ -243,7 +245,7 @@ const rumor = createRumor(
const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey)
const wrap = createWrap(seal, recipientPublicKey)

// Receiver unwraps with his/her private key.
// Recipient unwraps with his/her private key.

const unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey)
const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey)
Expand Down

0 comments on commit 1a2b21b

Please sign in to comment.