nips/81.md

73 lines
2.1 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, with the `d` tag receiving the public key each target key.
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
}
```
2024-03-19 20:16:00 +00:00
`petname` SHOULD be used instead of the person's display name in all interfaces.
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
2024-03-19 20:01:55 +00:00
Optional `n` tags `["n", "<list code>"]` add the target key to unbound lists. This allows clients to query by `n` and download all members of a list.
2024-03-19 20:01:55 +00:00
List `codes` can be human readable or not. A new event kind named "Unbound List Names" (`kind:10008`) uses `map` tags to display the list name. Clients SHOULD display the `name` instead of the `code` if the `code` is present in this list.
```js
{
2024-02-12 16:57:50 +00:00
"kind": 10008,
"content": nip44Encrypt(JSON.stringify([
2024-03-19 20:01:55 +00:00
["map", "<code>", "<name>"],
["map", "bitcoiner", "bitcoiner"],
["map", "6064460175057025", "debtor"]
])),
// ...other fields
}
```
2024-03-19 20:01:55 +00:00
### Private Relationship Status
2024-03-19 20:16:00 +00:00
For relationships that MUST remain private, 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"],
["n", "clients-list"],
2024-03-19 20:01:55 +00:00
["petname", "<My buddy>"],
["summary", "<Summary of the relationship>"],
])),
// ...other fields
}
```