A mirror for NIPS
Go to file
cmd 325adae009
Add method for deriving HMAC keys from the private key.
I ran into an issue where I want to derive child-keys from the parent private key, but there is currently no way to do this with the current spec.

I propose adding a `window.nostr.getDerivedKey(key: string): string` method to the spec, which is a simple HMAC method using the private key and a user supplied key. HMAC has wide-spread support in the WebCrypto spec, and is easy to implement. 

https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto

Here is some reference code for performing a simple HMAC operation using WebCrypto API:
```ts
async function hmac (
  // Perform an HMAC signing operation.
  key   : Uint8Array,
  data : Uint8Array,
  fmt   : string = 'SHA-256'
) : Promise<Uint8Array> {
  const cryptoKey = await importKey(key, fmt)
  return crypto.subtle
    .sign('HMAC', cryptoKey, data)
    .then((buffer) => new Uint8Array(buffer))
}
async function importKey (
  // Create a CryptoKey from the 
  // supplied key and format string.
  key : Uint8Array,
  fmt : string = 'SHA-256'
) : Promise<CryptoKey> {
  const config = { name: 'HMAC', hash: fmt }
  return crypto.subtle.importKey(
    'raw', key, config, false, ['sign', 'verify']
  )
}
```
2023-02-03 15:50:58 -06:00
01.md Update NIP-01 to clarify since and until filters 2023-01-25 14:21:52 -03:00
02.md fix minor typo 2023-01-15 17:53:34 -03:00
03.md Several NIP examples (3, 11) weren't quoting the field keys (JSON keys must be quoted) 2023-01-18 09:42:32 -03:00
04.md finalize some NIPs we will not going to change anymore. 2022-11-22 14:52:34 -03:00
05.md fix: typo 2023-02-03 10:40:57 -03:00
06.md migrate nips from main nostr repo. 2022-05-01 07:48:57 -03:00
07.md Add method for deriving HMAC keys from the private key. 2023-02-03 15:50:58 -06:00
08.md finalize some NIPs we will not going to change anymore. 2022-11-22 14:52:34 -03:00
09.md fix erroneous reference to pubkey 2023-01-15 17:53:34 -03:00
10.md clarify top level reply behavior 2023-01-15 09:18:15 -03:00
11.md Several NIP examples (3, 11) weren't quoting the field keys (JSON keys must be quoted) 2023-01-18 09:42:32 -03:00
12.md change NIP-12 so only single-letter tags are indexed. 2022-07-10 15:33:07 -03:00
13.md Minor grammar fixes 2022-12-17 22:28:49 -03:00
14.md Nip-14 for subject tag 2022-05-24 07:33:11 -05:00
15.md finalize some NIPs we will not going to change anymore. 2022-11-22 14:52:34 -03:00
16.md Clarify use of kind 1 and kind 1000-10000 2022-12-08 14:33:43 -03:00
19.md Bech32 encoded relay entities (#196) 2023-01-27 14:49:43 -03:00
20.md Minor grammar fixes 2022-12-17 22:34:29 -03:00
21.md add NIP-21, nostr: url scheme. 2023-01-25 13:08:20 -03:00
22.md NIP-22: use nip-20; minor updates 2023-01-07 17:53:24 -03:00
25.md NIP25: allow for emojis to be considered dislikes 2023-01-11 17:47:26 -03:00
26.md NIP-26: Advice on using after operators in conditions query string (#199) 2023-02-01 09:05:25 -03:00
28.md NIP-28 Add missing comma's in tags 2023-01-22 09:51:36 -05:00
33.md NIP-33: d tag requirements 2023-01-24 15:54:57 -03:00
36.md NIP-36 - sensitive content / content-warning (#82) 2022-12-01 20:41:15 -03:00
40.md Update 40.md 2022-12-16 12:03:07 +01:00
42.md Update 42.md 2023-01-11 00:05:15 -03:00
50.md Fix NIP-50 typo 2023-02-01 07:06:25 -03:00
README.md add NIP-50 to README. 2023-01-27 07:47:12 -03:00

NIPs

NIPs stand for Nostr Implementation Possibilities. They exist to document what MUST, what SHOULD and what MAY be implemented by Nostr-compatible relay and client software.

Event Kinds

kind description NIP
0 Metadata 1, 5
1 Text 1
2 Recommend Relay 1
3 Contacts 2
4 Encrypted Direct Messages 4
5 Event Deletion 9
7 Reaction 25
40 Channel Creation 28
41 Channel Metadata 28
42 Channel Message 28
43 Channel Hide Message 28
44 Channel Mute User 28
45-49 Public Chat Reserved 28
22242 Client Authentication 42
10000-19999 Replaceable Events Reserved 16
20000-29999 Ephemeral Events Reserved 16
30000-39999 Param. Repl. Events Reserved 33

Message types

Client to Relay

type description NIP
EVENT used to publish events 1
REQ used to request events and subscribe to new updates 1
CLOSE used to stop previous subscriptions 1
AUTH used to send authentication events 42

Relay to Client

type description NIP
EVENT used to send events requested to clients 1
NOTICE used to send human-readable messages to clients 1
EOSE used to notify clients all stored events have been sent 15
OK used to notify clients if an EVENT was successuful 20
AUTH used to send authentication challenges 42

Please update these lists when proposing NIPs introducing new event kinds.

When experimenting with kinds, keep in mind the classification introduced by NIP-16.

Standardized Tags

name value other parameters NIP
e event id (hex) relay URL, marker 1, 10
p pubkey (hex) relay URL 1
r a reference (URL, etc) 12
t hashtag 12
g geohash 12
nonce random 13
subject subject 14
d identifier 33
expiration unix timestamp (string) 40

Criteria for acceptance of NIPs

  1. They should be implemented in at least two clients and one relay -- when applicable.
  2. They should make sense.
  3. They should be optional and backwards-compatible: care must be taken such that clients and relays that choose to not implement them do not stop working when interacting with the ones that choose to.
  4. There should be no more than one way of doing the same thing.
  5. Other rules will be made up when necessary.

License

All NIPs are public domain.