nips/81.md
2024-03-19 16:01:55 -04:00

73 lines
2.2 KiB
Markdown

NIP-81
======
Relationship Status
-------------------
`draft` `optional`
Event `kind:30382` documents a "Relationship Status" between two keys and uses private and public tags to describe that relationship.
Since statuses change over time, this event is defined as a _parameterized replaceable event_ with a single `d` tag that identifies the target key.
When the relationship is public, the `d` tag is the same as the `p`-tag.
```js
{
"kind": 30382,
"tags": [
["d", "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411"],
["n", "Follow"],
["n", "Bitcoiners"],
["n", "6064460175057025"]
["p", "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411", "<relay>"],
],
"content": nip44Encrypt(JSON.stringify([
["petname", "NVK (Coldcard)"],
["summary", "Owes me a beer"]
])),
// ...other fields
}
```
The private tags are JSON Stringified, [NIP-44](44.md)-encrypted to the signer's keys and placed inside the `.content` of the event.
`petname` SHOULD be used instead of the person's display name in all interfaces
### Relationship Categories
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.
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
{
"kind": 10008,
"content": nip44Encrypt(JSON.stringify([
["map", "<code>", "<name>"],
["map", "Bitcoiners", "Bitcoiners"],
["map", "6064460175057025", "Debtors"]
])),
// ...other fields
}
```
### Private Relationship Status
For relationships that MUST remain private, a deterministic `d`-Tag is calculated using [NIP-44](44.md)'s `hkdf` function and a `sha256` hash between the signer's private key and the pubkey of the `p` tag.
```js
{
"kind": 30382,
"tags": [
["d", sha256(hkdf(private_key, salt: 'nip81') || "<pubkey>")],
],
"content": nip44Encrypt(JSON.stringify([
["p", "<pubkey>", "relay"],
["n", "Clients List"],
["petname", "<My buddy>"],
["summary", "<Summary of the relationship>"],
])),
// ...other fields
}
```