upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Staab <shtaab@gmail.com>2023-08-11 13:09:17 -0700
committerJonathan Staab <shtaab@gmail.com>2023-08-11 13:14:52 -0700
commit30696049ccdc9f19b9f737b97290a78d0a64ba9c (patch)
tree8b2357b2f46b4103f69f06c5fc2bbbef5c30839d
parent00a8f9532eeee918c0417ae0f501c790cd5a3f56 (diff)
Deprecate NIP 04
-rw-r--r--04.md4
-rw-r--r--07.md6
-rw-r--r--44.md16
-rw-r--r--46.md10
-rw-r--r--README.md2
5 files changed, 23 insertions, 15 deletions
diff --git a/04.md b/04.md
index 6e45b74..2490c18 100644
--- a/04.md
+++ b/04.md
@@ -1,10 +1,12 @@
1> __Warning__ `unrecommended`: deprecated in favor of [NIP-44](44.md)
2
1NIP-04 3NIP-04
2====== 4======
3 5
4Encrypted Direct Message 6Encrypted Direct Message
5------------------------ 7------------------------
6 8
7`final` `optional` `author:arcbtc` 9`final` `unrecommended` `author:arcbtc`
8 10
9A special event with kind `4`, meaning "encrypted direct message". It is supposed to have the following attributes: 11A special event with kind `4`, meaning "encrypted direct message". It is supposed to have the following attributes:
10 12
diff --git a/07.md b/07.md
index ee4e372..661144e 100644
--- a/07.md
+++ b/07.md
@@ -18,8 +18,10 @@ async window.nostr.signEvent(event: Event): Event // takes an event object, adds
18Aside from these two basic above, the following functions can also be implemented optionally: 18Aside from these two basic above, the following functions can also be implemented optionally:
19``` 19```
20async window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} } // returns a basic map of relay urls to relay policies 20async window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} } // returns a basic map of relay urls to relay policies
21async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext and iv as specified in nip-04 21async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext and iv as specified in nip-04 (deprecated)
22async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 22async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 (deprecated)
23async window.nostr.nip44.encrypt(pubkey, plaintext): string // returns encrypted payload as specified in nip-44
24async window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes encrypted payload as specified in nip-44
23``` 25```
24 26
25### Implementation 27### Implementation
diff --git a/44.md b/44.md
index 9d43698..c6fb69a 100644
--- a/44.md
+++ b/44.md
@@ -8,7 +8,7 @@ Encrypted Payloads (Versioned)
8 8
9The NIP introduces a versioned encryption data model, allowing multiple algorithm choices to exist simultaneously. 9The NIP introduces a versioned encryption data model, allowing multiple algorithm choices to exist simultaneously.
10 10
11The algorithm described in NIP4 is potentially vulnerable to [padding oracle attacks](https://en.wikipedia.org/wiki/Padding_oracle_attack) and uses keys which are not indistinguishable from random. 11The algorithm described in NIP-04 is potentially vulnerable to [padding oracle attacks](https://en.wikipedia.org/wiki/Padding_oracle_attack) and uses keys which are not indistinguishable from random. For more information, see [here](https://github.com/nostr-protocol/nips/pull/715#issuecomment-1675301250-).
12 12
13An encrypted payload MUST be encoded as a JSON object. Different versions may have different parameters. Every format has a `v` field specifying its version. 13An encrypted payload MUST be encoded as a JSON object. Different versions may have different parameters. Every format has a `v` field specifying its version.
14 14
@@ -17,10 +17,6 @@ Currently defined encryption algorithms:
17- `0x00` - Reserved 17- `0x00` - Reserved
18- `0x01` - XChaCha with same key `sha256(ecdh)` per conversation 18- `0x01` - XChaCha with same key `sha256(ecdh)` per conversation
19 19
20# Version 0
21
22Version 0 is not defined, however implementations depending on this NIP MAY choose to support the payload described in NIP 04 in the same places a NIP 44 payload would otherwise be expected. This is intended to allow a smooth transition while clients and signing software adopt the new standard.
23
24# Version 1 20# Version 1
25 21
26Params: 22Params:
@@ -38,11 +34,13 @@ Example:
38} 34}
39``` 35```
40 36
41**Note**: By default in the [libsecp256k1](https://github.com/bitcoin-core/secp256k1) ECDH implementation, the secret is the SHA256 hash of the shared point (both X and Y coordinates). We are using this exact implementation. In NIP4, unhashed shared point was used. 37# Other Notes
38
39By default in the [libsecp256k1](https://github.com/bitcoin-core/secp256k1) ECDH implementation, the secret is the SHA256 hash of the shared point (both X and Y coordinates). We are using this exact implementation. In NIP-94, unhashed shared point was used.
42 40
43## Code Samples 41# Code Samples
44 42
45### Javascript 43## Javascript
46 44
47```javascript 45```javascript
48import {xchacha20} from "@noble/ciphers/chacha" 46import {xchacha20} from "@noble/ciphers/chacha"
@@ -99,7 +97,7 @@ export function decrypt(privkey: string, pubkey: string, payload: string) {
99} 97}
100``` 98```
101 99
102### Kotlin 100## Kotlin
103 101
104```kotlin 102```kotlin
105// implementation 'fr.acinq.secp256k1:secp256k1-kmp-jni-android:0.10.1' 103// implementation 'fr.acinq.secp256k1:secp256k1-kmp-jni-android:0.10.1'
diff --git a/46.md b/46.md
index 90fa1a0..06a2689 100644
--- a/46.md
+++ b/46.md
@@ -82,12 +82,18 @@ These are mandatory methods the remote signer app MUST implement:
82- **get_relays** 82- **get_relays**
83 - params [] 83 - params []
84 - result `{ [url: string]: {read: boolean, write: boolean} }` 84 - result `{ [url: string]: {read: boolean, write: boolean} }`
85- **nip04_encrypt** 85- **nip04_encrypt** (deprecated)
86 - params [`pubkey`, `plaintext`] 86 - params [`pubkey`, `plaintext`]
87 - result `nip4 ciphertext` 87 - result `nip4 ciphertext`
88- **nip04_decrypt** 88- **nip04_decrypt** (deprecated)
89 - params [`pubkey`, `nip4 ciphertext`] 89 - params [`pubkey`, `nip4 ciphertext`]
90 - result [`plaintext`] 90 - result [`plaintext`]
91- **nip44_encrypt**
92 - params [`pubkey`, `plaintext`]
93 - result `nip44 encrypted payload`
94- **nip44_decrypt**
95 - params [`pubkey`, `nip44 encrypted payload`]
96 - result [`plaintext`]
91 97
92 98
93NOTICE: `pubkey` and `signature` are hex-encoded strings. 99NOTICE: `pubkey` and `signature` are hex-encoded strings.
diff --git a/README.md b/README.md
index 3c35ef3..f50bf21 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
22- [NIP-01: Basic protocol flow description](01.md) 22- [NIP-01: Basic protocol flow description](01.md)
23- [NIP-02: Contact List and Petnames](02.md) 23- [NIP-02: Contact List and Petnames](02.md)
24- [NIP-03: OpenTimestamps Attestations for Events](03.md) 24- [NIP-03: OpenTimestamps Attestations for Events](03.md)
25- [NIP-04: Encrypted Direct Message](04.md) 25- [NIP-04: Encrypted Direct Message](04.md) --- **unrecommended**: deprecated in favor of [NIP-44](44.md)
26- [NIP-05: Mapping Nostr keys to DNS-based internet identifiers](05.md) 26- [NIP-05: Mapping Nostr keys to DNS-based internet identifiers](05.md)
27- [NIP-06: Basic key derivation from mnemonic seed phrase](06.md) 27- [NIP-06: Basic key derivation from mnemonic seed phrase](06.md)
28- [NIP-07: `window.nostr` capability for web browsers](07.md) 28- [NIP-07: `window.nostr` capability for web browsers](07.md)