nips/81.md

75 lines
2.2 KiB
Markdown
Raw Normal View History

2023-09-04 15:35:30 +00:00
NIP-81
======
Relationship Status
-------------------
2023-09-04 15:35:30 +00:00
`draft` `optional`
2023-09-04 15:35:30 +00:00
2024-03-19 20:16:00 +00:00
This NIP defines two new event kinds (`30382` and `30383`) to document the relationship between two keys.
2023-09-04 15:35:30 +00:00
2024-03-19 20:16:00 +00:00
Both kinds offer public and private tags to describe that relationship. Private tags are JSON Stringified, [NIP-44](44.md)-encrypted to the signer's keys and placed inside the `.content` of the event.
2024-02-07 22:59:27 +00:00
2024-03-19 20:16:00 +00:00
### Public Relationship Status
Event kind `30382` is used when the relationship itself is public. The `d` tag contains the target public key in hex.
2023-09-04 15:35:30 +00:00
```js
{
"kind": 30382,
"tags": [
2024-03-19 20:01:55 +00:00
["d", "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411"],
["n", "follow"],
["n", "bitcoiner"],
2024-03-19 20:01:55 +00:00
["n", "6064460175057025"]
2023-09-04 15:35:30 +00:00
],
"content": nip44Encrypt(JSON.stringify([
2024-03-19 20:01:55 +00:00
["petname", "NVK (Coldcard)"],
["summary", "Owes me a beer"]
])),
2024-02-12 16:51:45 +00:00
// ...other fields
2023-09-04 15:35:30 +00:00
}
```
`petname` SHOULD be rendered instead of the person's display name in all interfaces when the signer of this event is logged in.
2024-02-12 17:17:06 +00:00
2024-03-19 20:01:55 +00:00
### Relationship Categories
2024-02-12 17:17:06 +00:00
Optional `n` tags `["n", "<identifier>"]` add the target key to event sets. This allows clients to query by `n` and download all members of a set.
Set `identifier` can be human readable and public or not.
For private cases, a new event kind named "Event Set Names" (`kind:10008`) uses `map` tags to store the set name. Clients SHOULD display the `name` instead of the `identifier` if the `identifier` is present in this event.
```js
{
2024-02-12 16:57:50 +00:00
"kind": 10008,
"content": nip44Encrypt(JSON.stringify([
["map", "<identifier>", "<name>"],
["map", "bitcoiner", "bitcoiner"],
["map", "6064460175057025", "debtor"]
])),
// ...other fields
}
```
2024-03-19 20:01:55 +00:00
### Private Relationship Status
For relationships that must remain private (e.g private follows, client lists, etc), the event kind `30383` uses a similar structure but with a hashed `d` tag using [NIP-44](44.md)'s `hkdf` function.
2024-03-19 20:01:55 +00:00
```js
{
2024-03-19 20:16:00 +00:00
"kind": 30383,
2024-03-19 20:01:55 +00:00
"tags": [
["d", sha256(hkdf(private_key, salt: 'nip81') || "<pubkey>")],
2024-03-19 20:16:00 +00:00
["n", "6064460175057025"],
2024-03-19 20:01:55 +00:00
],
"content": nip44Encrypt(JSON.stringify([
["p", "<pubkey>", "<relay url>"],
["n", "client-list"],
2024-03-19 20:01:55 +00:00
["petname", "<My buddy>"],
["summary", "<Summary of the relationship>"],
])),
// ...other fields
}
```