upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/41.md
diff options
context:
space:
mode:
authorPablo Fernandez <p@f7z.io>2023-10-18 14:57:30 +0300
committerPablo Fernandez <p@f7z.io>2023-10-18 15:03:28 +0300
commitb3920f76b4f8adde785de785153b49e92be75f35 (patch)
tree9b0ce4e6dd020f95cb88517a2fa383ff4228e06b /41.md
parentcf672b764bdcb6c33361203c206d5d52270c22ec (diff)
Diffstat (limited to '41.md')
-rw-r--r--41.md88
1 files changed, 88 insertions, 0 deletions
diff --git a/41.md b/41.md
new file mode 100644
index 0000000..7ab54c7
--- /dev/null
+++ b/41.md
@@ -0,0 +1,88 @@
1# NIP-41
2## Identity rotation
3`draft` `optional` `author:pablof7z`
4
5This NIP introduces a simple way in which a pubkey can migrate to by whitelisting a new pubkey ahead of time.
6
7# Basic concepts
8* `kind:1776` whitelists a pubkey.
9* `kind:1777` migrates to a previously whitelisted pubkey.
10* `kind:1776` and `kind:1777` MUST be opentimestamped [NIP-03](https://github.com/nostr-protocol/nips/blob/master/03.md).
11* When a migration event is published, a 30-day period starts in which a user can publish a competing migration event pointing to an earlier `kind:1776` event. After this period, clients SHOULD automatically update the user's follow list to the new pubkey.
12* Relays SHOULD NOT delete `kind:1040` nor `kind:1776` events from their database upon receiving a `kind:5` event.
13
14# Flow
15## Whitelisting a pubkey
16The user's active pubkey (e.g. *pubkey A*) signs an event `kind:1776` whitelisting a pubkey that can be used to migrate an identity to.
17
18This should be done ahead of time, perhaps after a user has used Nostr enough for a few days. Clients can choose to prompt the user to "save a recovery kit" or different UXs when they see the user doesn't currently have a `kind:1776` published.
19
20The implementation can be done directly on regular clients or microapps to handle this type of thing could be implemented as well.
21
22```json
23{
24 "pubkey": "pubkey-A",
25 "kind": 1776,
26 "content": "",
27 "tags": [
28 [ "p", "pubkey-B" ],
29 [ "alt", "pubkey whitelisting event" ]
30 ]
31}
32```
33
34* `.content` SHOULD be ignored. Users might choose to use it to leave a base64 symmetrically-encrypted message of where they left the new key or anything else.
35* The event MUST have a single `p` tag listing the whitelisted pubkey.
36
37Multiple `kind:1776` events can exist. All `kind:1776` MUST be opentimestamped following [NIP-3](https://github.com/nostr-protocol/nips/blob/master/03.md).
38
39Relays SHOULD NOT delete `kind:1040` nor `kind:1776` events upon receiving a `kind:5` event.
40
41## Migrating to a pubkey
42When the user needs to change keys they sign an event `kind:1777` with the new key and creates a NIP-03 attestation.
43
44```json
45{
46 "pubkey": "pubkey-B",
47 "kind": 1777,
48 "content": "",
49 "tags": [
50 [ "p", "pubkey-A" ],
51 [ "e", "<kind:1776-event-id>" ],
52 [ "proof", "<kind:1040-event-id>" ],
53 [ "alt", "pubkey migration event" ],
54 [ "relays", "relay1", "relay2" ]
55 ]
56}
57```
58
59* `p` tag MUST list the previous pubkey
60* `e` tag MUST list the `kind:1776` event that whitelisted the new pubkey.
61* `proof` tag MUST list the `kind:1040` event that provides the Opentimestamp data of the `kind:1776` event.
62* `relays` tag SHOULD list relays where both `kind:1776` and `kind:1040` events can be found.
63* `.content` SHOULD be ignored; users can optionally write a message explaining the migration.
64
65## Following the new pubkey
66
67Upon seeing this event, the client MAY choose to display a warning to the user that the identity is migrating to a new key. The client should not take any automated action at this point since the migration could be an attack, but the user could communicate out of band with the user to confirm the migration.
68
69After 30 days the client of seeing the `kind:1777` event, the client SHOULD automatically update the user's follow list to the new pubkey after some verifications:
70When users who follow the old pubkey see a `kind:1777` event they SHOULD:
71
72* check `kind:1776` and `kind:1777` event signatures
73* check `kind:1777`'s `pubkey` matches `kind:1776`'s `p` tag
74* check `kind:1777` is more than 30 days old
75* check that no competing 1777 event exists pointing to an event with an older valid OTS proof
76
77After validating all these checks clients SHOULD replace the old pubkey in the user's follow list with the new one.
78
79### Notes
80
81#### Rational behind the 30 days delay
82This gives enough time for a user to notice a migration request published by an attacker and gives the user enough time to publish a competing migration request pointing to an earlier `kind:1776` whitelisting event.
83
84#### Preventing unpublished evil `kind:1777` attack
85Clients should keep track of when a `kind:1777` event should take into effect, counting at least 30 days from the time of seeing the event and not trusting the event timestamp. This is to prevent an attacker creating an evil `kind:1776`, its attestation, and a `kind:1777` event with its attestation and not publishing them until the 30 days of the attestation have elapsed.
86
87#### Preventing poorly-distributed evil `kind:1777` attack
88Additionally, clients SHOULD broadcast the `kind:1777` events to the relays it normally writes to. This is to prevent an attacker from creating a short-lived NIP-65 relay list where only a subset of users will see an evil `kind:1777` event but not widespread enough for the real owner to notice it.