From c31a5043a369495e34151972c8476cbef943fc88 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 12 Feb 2024 11:42:10 -0500 Subject: [PATCH] Updating NIP-81 to add private and public statuses --- 81.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/81.md b/81.md index 4c8cfa9..bd629d1 100644 --- a/81.md +++ b/81.md @@ -1,18 +1,41 @@ NIP-81 ====== -Private Relationship Status ---------------------------- +Relationship Status +------------------- `draft` `optional` -A new `kind:30382` event documents a "Private Relationship Status" between two users of the network. +Event `kind:30382` documents a "Relationship Status" between two pubkeys and uses private and public tags to enhance the description of that relationship. -It is defined as a _parameterized replaceable event_ with a single `d` tag as a random UUID per pubkey. An optional `n` tag adds the target key to an unbound list. +Since statuses change over time, this event is defined as a _parameterized replaceable event_ with a single `d` tag as a random UUID per pubkey. -The other tags are stringified, NIP-44-encrypted and placed inside the `.content` of the event. +Optional `n` tags add the target key to an unbound list. -For example: +The private tags are stringified, NIP-44-encrypted and placed inside the `.content` of the event. + +Examples: + +Public Status + +```js +{ + "kind": 30382, + "tags": [ + ["d", ""], + ["n", "Clients"], + ["n", "Developers"], + ["p", "", "relay"], + ["trust_level", "1"], + ["nickname", ""], + ["summary", ""] + ], + "content": "", + // ...other fields +} +``` + +Private Status ```js { @@ -21,12 +44,12 @@ For example: ["d", ""], ["n", "Clients"] ], - "content": "", "relay"] ["nickname", ""] ["summary", ""], ["nip82secret", ""] - )", + ])), ...other fields } ``` @@ -36,3 +59,29 @@ For example: Profile screens MAY display the summary of the relationship and allow the user to change the tags of this event. Clients MAY filter by `kind:30382`, with or without `n` tags, to determine how to assemble feeds, group messages, and when to display content. + +### Private `n`-tags + +Clients MAY hide human readable `n`-tags behind a code and list their code maps in `kind:10007` using the `n_name` tag. + +```js +{ + "kind": 10007, + "content": nip44Encrypt(JSON.stringify([ + ["n_name", "", ""], + ["n_name", "Clients", "Clients"] // public list of my Clients + ["n_name", "6064460175057025", "Idiot"] // private list of idiots + ])), + // ...other fields +} +``` + +### Deterministic `d`-Tag. + +For private use cases that must contain deterministic d-Tags, the recommendation is to use NIP-44's `hkdf` function and use a hash between the user's private key and the pubkey of the `p` tag. + +``` +nip81_key = hkdf(private_key, salt: 'nip81') +bobs_tag = sha256(nip81_key || bobs_pub) +kates_tag = sha256(nip81_key || kates_pub) +``` \ No newline at end of file