event

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2024 License: CC0-1.0, MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(in []byte) (out []byte)

Types

type T

type T struct {

	// ID is the SHA256 hash of the canonical encoding of the event
	ID eventid.EventID `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

func (ev *T) CheckSignature() (valid bool, e error)

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) GetID

func (ev *T) GetID() eventid.EventID

GetID serializes and returns the event ID as a hexadecimal string.

func (*T) GetIDBytes

func (ev *T) GetIDBytes() []byte

GetIDBytes returns the raw SHA256 hash of the canonical form of an T.

func (*T) MarshalJSON

func (ev *T) MarshalJSON() (bytes []byte, e error)

func (*T) Serialize

func (ev *T) Serialize() []byte

func (*T) Sign

func (ev *T) Sign(skStr string, so ...schnorr.SignOption) (e error)

Sign signs an event with a given Secret Key encoded in hexadecimal.

func (*T) SignWithSecKey

func (ev *T) SignWithSecKey(sk *secp256k1.SecretKey,
	so ...schnorr.SignOption) (e error)

SignWithSecKey signs an event with a given *secp256xk1.SecretKey.

func (*T) ToCanonical

func (ev *T) ToCanonical() (o array.T)

ToCanonical returns a structure that provides a byte stringer that generates the canonical form used to generate the ID hash that can be signed.

func (*T) ToObject

func (ev *T) ToObject() (o object.T)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL