Adds further descriptions to the event fields.

This commit is contained in:
Vitor Pamplona 2024-03-28 09:42:14 -04:00
parent 17e2bd715f
commit e3c1e88b4b

27
01.md
View File

@ -6,11 +6,20 @@ Nostr Protocol
`draft` `mandatory`
This NIP defines the mandatory part of the Nostr protocol. New NIPs may add new optional (or mandatory) fields, messages, and features to the structures and flows described here.
This NIP defines the mandatory part of the Nostr protocol. New NIPs may add new fields, message kinds, and features to the structures and flows described here.
# Events
# Signed Events
Event is the only object type available. It is a hashed and signed payload in the following format:
Events are the only data type transferred across the network. They consist in 4 main attributes:
- `pubkey` defines the signer of the event
- `kind` defines the type of event
- `tags` defines indexable and queryable properties of the event
- `created_at` defines the time it was created or signed
- `content` contains the contents of the event
These attributes are then hashed to create an event `id` and the `id` is then signed with the user's private key.
Events are formatted as follows:
```jsonc
{
@ -28,11 +37,7 @@ Event is the only object type available. It is a hashed and signed payload in th
}
```
Each user has a keypair and is identified by their public key (`.pubkey`).
## Signing
Signatures and encodings are done according to the [Schnorr signatures standard for the curve `secp256k1`](https://bips.xyz/340).
## Hashing Algorithm
To assemble the `.id`, hex encode the result of a `sha256` of the UTF-8 byte array of a JSON-serialized string in the following structure:
@ -58,7 +63,11 @@ The JSON serialization MUST follow these rules:
- backspace: `0x08` to `\b`
- form feed: `0x0C` to `\f`
Then proceed to sign the `.id` with the user's private key.
## Signing
Use an secp256k1 ECDSA library to sign the `.id` with the user's private key.
This is the same curve used by Bitcoin. Signatures and encodings follow the [Schnorr signatures standard for the curve `secp256k1`](https://bips.xyz/340) specification.
## Verifying