Documentation ¶
Index ¶
- func Hash(in by) (out by)
- func Marshal(ev *T, dst by) (b by)
- func NewCanonical() (a *json.Array)
- func Unmarshal(ev *T, b by) (r by, err er)
- type Ascending
- type C
- type Descending
- type T
- func (ev *T) CheckSignature() (valid bo, err er)deprecated
- func (ev *T) ContentString() (s st)
- func (ev *T) EventID() (eid *eventid.T)
- func (ev *T) FromCanonical(b by) (rem by, err er)
- func (ev *T) GetIDBytes() by
- func (ev *T) IDString() (s st)
- func (ev *T) Marshal(dst by) (b by)
- func (ev *T) MarshalCompact(dst by) (b by)
- func (ev *T) PubKeyString() (s st)
- func (ev *T) Serialize() (b by)
- func (ev *T) SigString() (s st)
- func (ev *T) Sign(keys signer.I) (err er)
- func (ev *T) SignWithSecKey(sk *k1.SecretKey, so ...sch.SignOption) (err er)deprecated
- func (ev *T) TagStrings() (s [][]st)
- func (ev *T) ToCanonical(dst by) (b by)
- func (ev *T) Unmarshal(b by) (r by, err er)
- func (ev *T) UnmarshalCompact(b by) (rem by, err er)
- func (ev *T) Verify() (valid bo, err er)
- type Ts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCanonical ¶ added in v1.2.41
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() no
func (Descending) Less ¶
func (e Descending) Less(i, j no) bo
func (Descending) Swap ¶
func (e Descending) Swap(i, j no)
type T ¶
type T struct { // ID is the SHA256 hash of the canonical encoding of the event in binary format ID by // PubKey is the public key of the event creator in binary format PubKey by // CreatedAt is the UNIX timestamp of the event according to the event // creator (never trust a timestamp!) CreatedAt *timestamp.T // Kind is the nostr protocol code for the type of event. See kind.T Kind *kind.T // 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 // Content is an arbitrary string that can contain anything, but usually // conforming to a specification relating to the Kind and the Tags. Content by // Sig is the signature on the ID hash that validates as coming from the // Pubkey in binary format. Sig by }
T is the primary datatype of nostr. This is the form of the structure that defines its JSON string based format.
func (*T) CheckSignature
deprecated
func (ev *T) CheckSignature() (valid bo, err er)
CheckSignature returns whether an event signature is authentic and matches the event ID and Pubkey.
Deprecated: use Verify
func (*T) ContentString ¶
func (ev *T) ContentString() (s st)
func (*T) FromCanonical ¶ added in v1.3.0
func (ev *T) FromCanonical(b by) (rem by, err er)
FromCanonical reverses the process of creating the canonical encoding, note that the signature is missing in this form. Allocate an event.T before calling this.
func (*T) GetIDBytes ¶
func (ev *T) GetIDBytes() by
GetIDBytes returns the raw SHA256 hash of the canonical form of an T.
func (*T) MarshalCompact ¶ added in v1.3.0
func (ev *T) MarshalCompact(dst by) (b by)
MarshalCompact encodes an event as the canonical form folowed by the raw binary signature (64 bytes) which hashes to form the ID, thus a compact form for the database that is smaller and fast to decode.
func (*T) PubKeyString ¶
func (ev *T) PubKeyString() (s st)
func (*T) Sign ¶
Sign the event using the signer.I. Uses github.com/bitcoin-core/secp256k1 if available for much faster signatures.
func (*T) SignWithSecKey
deprecated
func (ev *T) SignWithSecKey(sk *k1.SecretKey, so ...sch.SignOption) (err er)
SignWithSecKey signs an event with a given *secp256xk1.SecretKey.
Deprecated: use Sign and nostr.I and p256k.Signer / p256k.BTCECSigner implementations.
func (*T) TagStrings ¶
func (ev *T) TagStrings() (s [][]st)
func (*T) ToCanonical ¶
func (ev *T) ToCanonical(dst by) (b by)
ToCanonical converts the event to the canonical encoding used to derive the event ID.
func (*T) UnmarshalCompact ¶ added in v1.3.0
func (ev *T) UnmarshalCompact(b by) (rem by, err er)