From 47ef4d716a8c7ff799b703d1fb1b0b6f3507540a Mon Sep 17 00:00:00 2001 From: 1l0 Date: Tue, 21 Jan 2025 15:08:46 +0900 Subject: [PATCH] NIP-A2: add draft --- A2.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 A2.md diff --git a/A2.md b/A2.md new file mode 100644 index 0000000000..827df1ec76 --- /dev/null +++ b/A2.md @@ -0,0 +1,85 @@ +NIP-A2 +====== + +Account delegation via kind-0 +------------------- + +`draft` `optional` + +Defines how to use kind-0 for account delegation. +The clients responsible for account management create and post the delegator kind-0 event. +A user can utilize the delegatee account listed in their own delegator event. If a user creates a delegatee kind-0 event and it is valid, it is considered to represent the same identity with a different key pair. + +## Delegator + +```js +{ + "kind": 0, + "tags": [ + ["p", , ...], + ], + "content": , + // ... +} +``` + +- The `p` tag contains the delegatee's pubkey. Optional approved kinds for override can be appended. If no approved kinds are specified, it is considered unrestricted. + - MAY have multiple `p` tags. + + +## Delegatee + +```js +{ + "kind": 0, + "tags": [ + ["P", ], + ["alt", "delegation account"], // optional + ], + "content": , + // ... +} +``` + +- The `P` tag contains the delegator's pubkey. + - MUST NOT have multiple `P` tags. +- The `content` can be empty or an override of the delegator's metadata if it is approved by the delegator. + +## Validation + +If a delegator's kind-0 has no `p` tags, and a delegatee's kind-0 contains the delegator's `P` tag, it is considered an invalid delegation, and vice versa. + +## Client + +Client SHOULD use the delegator's pubkey along with the delegatee's pubkey when adding to or removing from the contact list. +All delegatee stuff SHOULD be considered an override of the delegator's stuff if each kind is approved by the delegator. + +## Example of kind-0 events for delegation + +### Delegator + +```js +{ + "kind": 0, + "pubkey": "373ab6e211d2ef30fa72552a072f8cbc6c0cdb72902502d23f05818b6701eaf4", + "tags": [ + ["p", "1d58b9a772e6370e2193ac79055a67f4e2caabd8c9634e07e390ca1b1717946c", 0, 1, 3, 6, 7, 30023], + ], + "content": "{\"name\":\"User\",\"about\":\"I'm not a bitcoiner\"}", + // ... +} +``` + +### Delegatee + +```js +{ + "kind": 0, + "pubkey": "1d58b9a772e6370e2193ac79055a67f4e2caabd8c9634e07e390ca1b1717946c", + "tags": [ + ["P", "373ab6e211d2ef30fa72552a072f8cbc6c0cdb72902502d23f05818b6701eaf4"], + ], + "content": "{\"name\":\"User (delegatee)\"}", + // ... +} +``` \ No newline at end of file