NIP-46: add an optional "encrypted" tag with the encryption method used

This commit is contained in:
Alex Gleason 2024-05-26 11:57:36 -05:00
parent a1d348cfea
commit d3b47d1982
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

41
46.md
View File

@ -56,7 +56,7 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
{
"kind": 24133,
"pubkey": "eff37350d839ce3707332348af4549a96051bd695d3223af4aabce4993531d86",
"content": nip04({
"content": encrypt({
"id": <random_string>,
"method": "sign_event",
"params": [json_stringified(<{
@ -66,7 +66,10 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
created_at: 1714078911
}>)]
}),
"tags": [["p", "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52"]], // p-tags the remote user pubkey
"tags": [
["p", "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52"], // p-tags the remote user pubkey
["encrypted", "nip04"] // specifies the encryption used
],
}
```
@ -76,14 +79,33 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
{
"kind": 24133,
"pubkey": "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52",
"content": nip04({
"content": encrypt({
"id": <random_string>,
"result": json_stringified(<signed-event>)
}),
"tags": [["p", "eff37350d839ce3707332348af4549a96051bd695d3223af4aabce4993531d86"]], // p-tags the local keypair pubkey
"tags": [
["p", "eff37350d839ce3707332348af4549a96051bd695d3223af4aabce4993531d86"], // p-tags the local keypair pubkey
["encrypted", "nip04"], // specifies the encryption used
]
}
```
#### Encryption
An `encrypted` tag MAY be included in kind 24133 events to specify the encryption method used.
The tag is in the form:
```
["encrypted", "<encryption>"]
```
Where encryption is one of:
- `nip04` - NIP-04 encryption
- `nip44` - NIP-44 encryption
If the tag is not included, the encryption method is assumed to be NIP-04 for backwards-compatibility.
#### Diagram
![signing-example](https://i.nostr.build/P3gW.png)
@ -95,8 +117,11 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
"id": <id>,
"kind": 24133,
"pubkey": <local_keypair_pubkey>,
"content": <nip04(<request>)>,
"tags": [["p", <remote_user_pubkey>]], // NB: in the `create_account` event, the remote signer pubkey should be `p` tagged.
"content": <encrypt(<request>)>,
"tags": [
["p", <remote_user_pubkey>], // NB: in the `create_account` event, the remote signer pubkey should be `p` tagged.
["encrypted", "nip04"]
],
"created_at": <unix timestamp in seconds>
}
```
@ -142,8 +167,8 @@ The `connect` method may be provided with `optional_requested_permissions` for u
"id": <id>,
"kind": 24133,
"pubkey": <remote_signer_pubkey>,
"content": <nip04(<response>)>,
"tags": [["p", <local_keypair_pubkey>]],
"content": <encrypt(<response>)>,
"tags": [["p", <local_keypair_pubkey>], ["encrypted", "nip04"]],
"created_at": <unix timestamp in seconds>
}
```