mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-09-30 08:50:55 +00:00
NIP-46: add an optional "encrypted" tag with the encryption method used
This commit is contained in:
parent
a1d348cfea
commit
d3b47d1982
41
46.md
41
46.md
@ -56,7 +56,7 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
|
|||||||
{
|
{
|
||||||
"kind": 24133,
|
"kind": 24133,
|
||||||
"pubkey": "eff37350d839ce3707332348af4549a96051bd695d3223af4aabce4993531d86",
|
"pubkey": "eff37350d839ce3707332348af4549a96051bd695d3223af4aabce4993531d86",
|
||||||
"content": nip04({
|
"content": encrypt({
|
||||||
"id": <random_string>,
|
"id": <random_string>,
|
||||||
"method": "sign_event",
|
"method": "sign_event",
|
||||||
"params": [json_stringified(<{
|
"params": [json_stringified(<{
|
||||||
@ -66,7 +66,10 @@ nostrconnect://<local-keypair-pubkey>?relay=<wss://relay-to-connect-on>&metadata
|
|||||||
created_at: 1714078911
|
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,
|
"kind": 24133,
|
||||||
"pubkey": "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52",
|
"pubkey": "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52",
|
||||||
"content": nip04({
|
"content": encrypt({
|
||||||
"id": <random_string>,
|
"id": <random_string>,
|
||||||
"result": json_stringified(<signed-event>)
|
"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
|
#### Diagram
|
||||||
|
|
||||||
![signing-example](https://i.nostr.build/P3gW.png)
|
![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>,
|
"id": <id>,
|
||||||
"kind": 24133,
|
"kind": 24133,
|
||||||
"pubkey": <local_keypair_pubkey>,
|
"pubkey": <local_keypair_pubkey>,
|
||||||
"content": <nip04(<request>)>,
|
"content": <encrypt(<request>)>,
|
||||||
"tags": [["p", <remote_user_pubkey>]], // NB: in the `create_account` event, the remote signer pubkey should be `p` tagged.
|
"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>
|
"created_at": <unix timestamp in seconds>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -142,8 +167,8 @@ The `connect` method may be provided with `optional_requested_permissions` for u
|
|||||||
"id": <id>,
|
"id": <id>,
|
||||||
"kind": 24133,
|
"kind": 24133,
|
||||||
"pubkey": <remote_signer_pubkey>,
|
"pubkey": <remote_signer_pubkey>,
|
||||||
"content": <nip04(<response>)>,
|
"content": <encrypt(<response>)>,
|
||||||
"tags": [["p", <local_keypair_pubkey>]],
|
"tags": [["p", <local_keypair_pubkey>], ["encrypted", "nip04"]],
|
||||||
"created_at": <unix timestamp in seconds>
|
"created_at": <unix timestamp in seconds>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user