mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-09 22:09:06 -05:00
Remove p tag, clarify that NIP 59 does not define a messaging protocol on its own
This commit is contained in:
parent
d7293a3924
commit
1a2b21b67e
16
59.md
16
59.md
|
@ -9,6 +9,8 @@ Gift Wrap
|
||||||
This NIP defines a protocol for encapsulating any nostr event. This makes it possible to obscure most metadata
|
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.
|
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.
|
This NIP relies on [NIP-44](./44.md)'s versioned encryption algorithms.
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
|
@ -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
|
## 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
|
A `gift wrap` event is a `kind:1059` event that wraps any other event. `tags` SHOULD include any information
|
||||||
containing the recipient's public key.
|
needed to route the event to its intended recipient, including the recipient's `p` tag or NIP-13 proof of work.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
@ -68,7 +67,7 @@ The only public information is the receiver's public key.
|
||||||
"content": "<encrypted kind 13>",
|
"content": "<encrypted kind 13>",
|
||||||
"kind": 1059,
|
"kind": 1059,
|
||||||
"created_at": 1686840217,
|
"created_at": 1686840217,
|
||||||
"tags": [["p", "<Receiver>"]],
|
"tags": [["p", "<recipient pubkey>"]],
|
||||||
"sig": "<random, one-time-use pubkey signature>"
|
"sig": "<random, one-time-use pubkey signature>"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -106,6 +105,9 @@ Let's send a wrapped `kind 1` message between two parties asking "Are you going
|
||||||
- Recipient private key: `e108399bd8424357a710b606ae0c13166d853d327e47a6e5e038197346bdbf45`
|
- Recipient private key: `e108399bd8424357a710b606ae0c13166d853d327e47a6e5e038197346bdbf45`
|
||||||
- Ephemeral wrapper key: `4f02eac59266002db5801adc5270700ca69d5b8f761d8732fab2fbf233c90cbd`
|
- 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
|
## 1. Create an event
|
||||||
|
|
||||||
Create a `kind 1` event with the message, the receivers, and any other tags you want, signed by the author.
|
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(
|
||||||
const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey)
|
const seal = createSeal(rumor, senderPrivateKey, recipientPublicKey)
|
||||||
const wrap = createWrap(seal, 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 unwrappedSeal = nip44Decrypt(wrap, recipientPrivateKey)
|
||||||
const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey)
|
const unsealedRumor = nip44Decrypt(unwrappedSeal, recipientPrivateKey)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user