diff options
| author | fiatjaf <fiatjaf@gmail.com> | 2022-12-16 11:56:12 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-16 11:56:12 -0300 |
| commit | 9e13889deee1b33565652e1204ad0667a0805cd4 (patch) | |
| tree | 5e832b0848c52c29bdf94a04e817dd86755854ae | |
| parent | 0c7b732867ea55527a6ec7562e92c091bb329476 (diff) | |
add NIP-19: bech32-encoding of stuff. (#57)
* add NIP-19: bech32-encoding of stuff.
* add note prefix for kind-01 notes.
* specify endianness.
* 1 byte for T and L.
* incorporate suggestions after feedback and discussions.
* fix typos.
| -rw-r--r-- | 19.md | 43 |
1 files changed, 43 insertions, 0 deletions
| @@ -0,0 +1,43 @@ | |||
| 1 | NIP-19 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | bech32-encoded entities | ||
| 5 | ----------------------- | ||
| 6 | |||
| 7 | `draft` `optional` `author:jb55` `author:fiatjaf` `author:Semisol` | ||
| 8 | |||
| 9 | This NIP specifies all bech32-encoded entities. | ||
| 10 | |||
| 11 | ## Bare keys and ids | ||
| 12 | |||
| 13 | To prevent confusion and mixing between private keys, public keys and event ids, which are all 32 byte strings. bech32-(not-m) encoding with different prefixes can be used for each of these entities. | ||
| 14 | |||
| 15 | These are the possible bech32 prefixes: | ||
| 16 | |||
| 17 | - `npub`: public keys | ||
| 18 | - `nsec`: private keys | ||
| 19 | - `note`: note ids | ||
| 20 | |||
| 21 | Example: the hex public key `3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d` translates to `npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6`. | ||
| 22 | |||
| 23 | The bech32 encodings of keys and ids are not meant to be used inside the standard NIP-01 event formats or inside the filters, they're meant for human-friendlier display and input only. Clients should still accept keys in both hex and npubformat for now, and convert internally. | ||
| 24 | |||
| 25 | ## Shareable identifiers with extra metadata | ||
| 26 | |||
| 27 | When sharing a profile or an event, an app may decide to include relay information and other metadata such that other apps can locate and display these entities more easily. | ||
| 28 | |||
| 29 | For these events, the contents are a binary-encoded list of `TLV` (type-length-value), with `T` and `L` being 1 byte each (`uint8`, i.e. a number in the range of 0-255), and `V` being a sequence of bytes of the size indicated by `L`. | ||
| 30 | |||
| 31 | These are the possible bech32 prefixes with `TLV`: | ||
| 32 | |||
| 33 | - `nprofile`: a nostr profile | ||
| 34 | - `nevent`: a nostr event | ||
| 35 | |||
| 36 | These possible standardized `TLV` types are indicated here: | ||
| 37 | |||
| 38 | - `0`: `special` | ||
| 39 | - depends on the bech32 prefix: | ||
| 40 | - for `nprofile` it will be the 32 bytes of the profile public key | ||
| 41 | - for `nevent` it will be the 32 bytes of the event id | ||
| 42 | - `1`: `relay` | ||
| 43 | - A relay in which the entity (profile or event) is more likely to be found, encoded as UTF-8. This may be included multiple times. | ||