Documentation ¶
Index ¶
- func Hash(in []byte) (out []byte)
- type Ascending
- type C
- type Descending
- type T
- func (ev *T) CheckSignature() (valid bool, err error)
- func (ev *T) GetID() eventid.T
- func (ev *T) GetIDBytes() []byte
- func (ev *T) MarshalJSON() (bytes []byte, err error)
- func (ev *T) Serialize() []byte
- func (ev *T) Sign(skStr string, so ...schnorr.SignOption) (err error)
- func (ev *T) SignWithSecKey(sk *secp256k1.SecretKey, so ...schnorr.SignOption) (err error)
- func (ev *T) ToCanonical() (o array.T)
- func (ev *T) ToObject() (o object.T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ascending ¶
type Ascending []*T
Ascending is a slice of events that sorts in ascending chronological order
type Descending ¶
type Descending []*T
Descending sorts a slice of events in reverse chronological order (newest first)
func (Descending) Len ¶
func (e Descending) Len() int
func (Descending) Less ¶
func (e Descending) Less(i, j int) bool
func (Descending) Swap ¶
func (e Descending) Swap(i, j int)
type T ¶
type T struct { // ID is the SHA256 hash of the canonical encoding of the event ID eventid.T `json:"id"` // PubKey is the public key of the event creator in *hexadecimal* format PubKey string `json:"pubkey"` // CreatedAt is the UNIX timestamp of the event according to the event // creator (never trust a timestamp!) CreatedAt timestamp.T `json:"created_at"` // Kind is the nostr protocol code for the type of event. See kind.T Kind kind.T `json:"kind"` // Tags are a list of tags, which are a list of strings usually structured // as a 3 layer scheme indicating specific features of an event. Tags tags.T `json:"tags"` // Content is an arbitrary string that can contain anything, but usually // conforming to a specification relating to the Kind and the Tags. Content string `json:"content"` // Sig is the signature on the ID hash that validates as coming from the // Pubkey. Sig string `json:"sig"` }
T is the primary datatype of nostr. This is the form of the structure that defines its JSON string based format.
func (*T) CheckSignature ¶
CheckSignature checks if the signature is valid for the id (which is a hash of the serialized event content). returns an error if the signature itself is invalid.
func (*T) GetIDBytes ¶
GetIDBytes returns the raw SHA256 hash of the canonical form of an T.
func (*T) MarshalJSON ¶
func (*T) Sign ¶
func (ev *T) Sign(skStr string, so ...schnorr.SignOption) (err error)
Sign signs an event with a given Secret Key encoded in hexadecimal.
func (*T) SignWithSecKey ¶
SignWithSecKey signs an event with a given *secp256xk1.SecretKey.
func (*T) ToCanonical ¶
ToCanonical returns a structure that provides a byte stringer that generates the canonical form used to generate the ID hash that can be signed.