-
Notifications
You must be signed in to change notification settings - Fork 713
Key migration #2137
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
Open
staab
wants to merge
3
commits into
nostr-protocol:master
Choose a base branch
from
coracle-social:key-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−0
Open
Key migration #2137
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| NIP-D8 | ||
| ====== | ||
|
|
||
| Nostr Key Migration | ||
| ------------------- | ||
|
|
||
| `draft` `optional` | ||
|
|
||
| This NIP defines a simple mechanism which allows users to migrate to a new key and invalidate their current account. It combines signatures, social key recovery, Open Timestamp Attestations, and some trust assumptions to prevent hijacking by an attacker or loss of control through over-reliance on the social graph. | ||
|
|
||
| ## Creating a Migration Key | ||
|
|
||
| A user can create a `kind 360` `precommit` event which includes a single public key that is authorized in advanced as a `migration` key. This key MUST be stored securely. | ||
|
|
||
| ```typescript | ||
| { | ||
| "kind": 360, | ||
| "pubkey": "<identity pubkey>" | ||
| "tags": [ | ||
| ["p", "<migration pubkey>"] | ||
| ], | ||
| // Other fields | ||
| } | ||
| ``` | ||
|
|
||
| ## Migrating to a New Key | ||
|
|
||
| In order to migrate to a new key, a new `successor` key SHOULD be generated **at the time of migration**. Any `migration` key designated by a valid `kind 360` event may then be used to sign a `kind 361` `migration` event. | ||
|
|
||
| Migration keys MUST NOT be used for anything other than signing a single `kind 361` event. | ||
|
|
||
| ```typescript | ||
| { | ||
| "kind": 361, | ||
| "pubkey": "<migration pubkey>", | ||
| "tags": [ | ||
| ["p", "<successor pubkey>"], | ||
| ["e", "<id of the precommit event>", "<relay hint>"] | ||
| ], | ||
| } | ||
| ``` | ||
|
|
||
| Clients SHOULD NOT rely on `migration` events existing long-term, but should make an effort to help users move away from a user's old key as soon as possible. However, clients SHOULD NOT follow `successor` keys without explicit user consent. | ||
|
|
||
| When migrating to a new key, users MAY re-publish any content or metadata they want to be preserved on their account. Implementations SHOULD NOT attempt to establish a live link between the old and new identities. | ||
|
|
||
| ## Opting Out | ||
|
|
||
| Users SHOULD publish a `kind 360` event as soon as their account becomes valuable to them. If a key is leaked before a `migration` event is published, the attacker will be able to migrate to their own key, locking the original user permanently out of their account. This is the key trade-off of this NIP. | ||
|
|
||
| If a user prefers not to enable key migration on their account, they SHOULD publish a `kind 360` event with no designated `successor` keys, making it impossible to migrate. | ||
|
|
||
| ## Appendix A: Event Storage and Validation | ||
|
|
||
| This NIP is highly dependent on the existence of a complete and ordered record of `kind 360` and `kind 361` events. | ||
|
|
||
| `kind 360` MUST be readily available non-interactively (i.e., it can't be revealed at the same time a `kind 361` event is created), because an attacker with posession of the user's current key would otherwise be able to hijack the migration process by creating their own `kind 360` `precommit` and `kind 361` `migration` events. | ||
|
|
||
| Nostr relays offer no consistency guarantees, which means commodity relays cannot support this use case. Outbox relays can't be trusted because an attacker with access to a user's private key can update them. Trusted relays of any kind can become attack vectors, since they can selectively omit entries, facilitating a migration attack. | ||
|
|
||
| These risks can be mitigated (but not solved) in classically nostr fashion by spreading trust across a large number of `migration` relays. These relays MUST be independently run, and their owners MUST have an incentive to prevent account theft, which can only be assessed manually. All of these relays would have to collude in order to prevent a correct migration from occurring. | ||
|
|
||
| However these relays are chosen, the entire network MUST use the same set. Network partitioning is unacceptable in this case. Selection of actual relays is left to the nostr community. | ||
|
|
||
| All `kind 360` and `kind 361` events MUST be published to all `migration` relays along with an accompanying `kind 1040` [Open Timestamp Attestation](03.md) event. If multiple conflicting events exist, the first one published MUST be used. | ||
|
|
||
| In both cases, only the first event of each kind published by a given key is valid. `migration` relays MUST validate Open Timestamp attestations, and ensure that only `kind 361` events that match a valid `kind 360` event are stored. Clients SHOULD also perform this validation. `migration` relays MUST NOT delete `kind 360` or `kind 361` events for any reason. | ||
|
|
||
| ## Appendix B: In-Band Social Key Recovery | ||
|
|
||
| The recommended approach to `migration` key storage uses social key recovery in order to combine the strengths of cryptographic signatures with trusted counter parties. In this system, neither key compromise nor social engineering is a sufficient condition for an attacker to hijack the key migration process. This approach is not required, but SHOULD be considered the default. | ||
|
|
||
| For each `migration` key committed to in a `kind 360` event, use the [codex32 standard](https://secretcodex32.com/) for Shamir secret sharing to split the key into `n` shards. | ||
|
|
||
| For each shard, create a `kind 362` event with a `p` tag indicating the original user's pubkey, and a `shard` tag containing the shard. This event MUST NOT be signed, but MUST be wrapped following [NIP 59](59.md). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the symmetric encryption; shard-holders shouldn't be trusted to not collude with key material. This sounds harder than it is; all this means is that the payload should be encrypted symmetrically before sharding. |
||
|
|
||
| Each `kind 1059` wrapper event MUST be addressed to a user who the original user trusts not to leak the key material, and who will likely be available reconstitute the key. Holders of key shards SHOULD remain anonymous in order to prevent shard holder collusion, as well as additional attacks against shard holders. | ||
|
|
||
| In order to migrate a key, the original user SHOULD contact each shard holder out of band to recover the key material and use it to sign and publish a `kind 361` `migration` event. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary; all we need is that relays that signal support for this NIP:
36xevents