nips/81.md

75 lines
2.2 KiB
Markdown
Raw Normal View History

2023-09-04 11:35:30 -04:00
NIP-81
======
Relationship Status
-------------------
2023-09-04 11:35:30 -04:00
`draft` `optional`
2023-09-04 11:35:30 -04:00
2024-06-20 14:35:45 -04:00
This NIP defines two new event kinds (`30382` and `31382`) to document the relationship between two keys.
2023-09-04 11:35:30 -04:00
2024-03-19 16:16:00 -04: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 17:59:27 -05:00
2024-03-19 16:16:00 -04: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 11:35:30 -04:00
```js
{
"kind": 30382,
"tags": [
2024-03-19 16:01:55 -04:00
["d", "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411"],
["n", "follow"],
["n", "bitcoiner"],
2024-03-19 16:01:55 -04:00
["n", "6064460175057025"]
2023-09-04 11:35:30 -04:00
],
"content": nip44Encrypt(JSON.stringify([
2024-03-19 16:01:55 -04:00
["petname", "NVK (Coldcard)"],
["summary", "Owes me a beer"]
])),
2024-02-12 11:51:45 -05:00
// ...other fields
2023-09-04 11:35:30 -04: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 12:17:06 -05:00
2024-03-19 16:01:55 -04:00
### Relationship Categories
2024-02-12 12:17:06 -05: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 11:57:50 -05:00
"kind": 10008,
"content": nip44Encrypt(JSON.stringify([
["map", "<identifier>", "<name>"],
["map", "bitcoiner", "bitcoiner"],
["map", "6064460175057025", "debtor"]
])),
// ...other fields
}
```
2024-03-19 16:01:55 -04:00
### Private Relationship Status
2024-06-20 14:35:45 -04:00
For relationships that must remain private (e.g private follows, client lists, etc), the event kind `31382` uses a similar structure but with a hashed `d` tag using [NIP-44](44.md)'s `hkdf` function.
2024-03-19 16:01:55 -04:00
```js
{
2024-06-20 14:35:45 -04:00
"kind": 31382,
2024-03-19 16:01:55 -04:00
"tags": [
["d", sha256(hkdf(private_key, salt: 'nip81') || "<pubkey>")],
2024-03-19 16:16:00 -04:00
["n", "6064460175057025"],
2024-03-19 16:01:55 -04:00
],
"content": nip44Encrypt(JSON.stringify([
["p", "<pubkey>", "<relay url>"],
["n", "client-list"],
2024-03-19 16:01:55 -04:00
["petname", "<My buddy>"],
["summary", "<Summary of the relationship>"],
])),
// ...other fields
}
```