mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-02-22 13:19:00 +00:00
2.5 KiB
2.5 KiB
NIP-4B
nsec Transfer
draft
optional
This NIP defines how to accomplish nsec transfer from client to client including browser extensions or signers.
Terminology
- Source client: A client that holds the user's nsec.
- Destination client: A client that doesn't have the user's nsec and wants it.
- Ephemeral pubkey: A pubkey of a key pair generated for one-time use only.
Flow
1. The destination client creates a transfer request URL.
- The client generates an ephemeral pubkey.
- The client creates a transfer request URL, which includes the ephemeral pubkey and relay URLs.
- The client shows the user the URL. The client MAY show the user a QR code.
- The client subscribes to the relays and waits for the kind-1059 response, which includes the
["p", "<destination client's ephemeral pubkey>"]
tag.
Transfer request URL
transfer://<destination client's ephemeral pubkey>?relay=<relay URL>&relay=<relay URL>
2. The source client responds with gift-wrapped ncryptsec.
- The user enters the transfer request URL.
- The client parses the URL.
- The client generates an ncryptsec (NIP-49) from the user's nsec and a random 6-digit PIN.
- The client creates an ncryptsec rumor (NIP-59) event.
- The client seals and gift-wraps the rumor event.
- The client publishes the gift-wrapped event to the destination's relays.
- The client shows the user the PIN.
ncryptsec rumor event
kind: 24144
This event MUST NOT be signed.
{
"kind": 24144,
"pubkey": "<source client's ephemeral pubkey A>",
"content": "<ncryptsec>",
// ...
}
Sealed event
{
"pubkey": "<source client's ephemeral pubkey A>",
"content": "<NIP-44 encrypted ncryptsec rumor event>",
"kind": 13,
"sig": "<source client's ephemeral pubkey A signature>"
// ...
}
Gift-wrapped event
source client's ephemeral pubkey B
MUST NOT be the same as A
described above.
{
"pubkey": "<source client's ephemeral pubkey B>",
"content": "<NIP-44 encrypted sealed event>",
"kind": 1059,
"tags": [["p", "<destination client's ephemeral pubkey>"]],
"sig": "<source client's ephemeral pubkey B signature>"
// ...
}
3. The destination client fetches the response.
- The client fetches and validates the gift-wrapped event.
- The client prompts the user to enter the PIN.
- If the PIN is valid, the client retrieves the user's nsec from the ncryptsec.