Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP-A2: Account delegation via kind-0 #1709

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions A2.md
Original file line number Diff line number Diff line change
@@ -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", <delegatee pubkey>, <approved kind for override>...],
],
"content": <metadata>,
// ...
}
```

- 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", <delegator pubkey>],
["alt", "delegation account"], // optional
],
"content": <empty or metadata override>,
// ...
}
```

- 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)\"}",
// ...
}
```