event

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyEvent

func VerifyEvent(e Event) error

func VerifyEventID

func VerifyEventID(e Event) error

func VerifySignature

func VerifySignature(e Event) error

Types

type Event

type Event struct {
	ID        ID        `json:"id" bson:"id"`
	PubKey    PubKey    `json:"pubkey" bson:"pubkey"`
	CreatedAt Timestamp `json:"created_at" bson:"created_at"`
	Kind      Kind      `json:"kind" bson:"kind"`
	Tags      []Tag     `json:"tags" bson:"tags"`
	Content   string    `json:"content" bson:"content"`
	Sig       Signature `json:"sig" bson:"sig"`
}

func UnStructure

func UnStructure(e StructuredEvent) Event

type ID

type ID string // <32-bytes lowercase hex-encoded sha256 of the the serialized event data>

func E

func E(t Tag) (ID, bool)

func NewEventID

func NewEventID(pub PubKey, createdAt Timestamp, kind Kind, tags []Tag, content string) (ID, error)

func (ID) Bytes

func (id ID) Bytes() ([]byte, error)

type Kind

type Kind int64

type PubKey

type PubKey string //  <32-bytes lowercase hex-encoded public key of the event creator>

func P

func P(t Tag) (PubKey, bool)

func (PubKey) BIP340Secp256k1

func (pk PubKey) BIP340Secp256k1() (btcec.PublicKey, error)

type Signature

type Signature string // <64-bytes hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field>

func (Signature) BIP340Secp256k1

func (sig Signature) BIP340Secp256k1() (schnorr.Signature, error)

func (Signature) Bytes

func (sig Signature) Bytes() ([]byte, error)

func (Signature) Hex

func (sig Signature) Hex() string

type StructuredEvent

type StructuredEvent struct {
	Event Event    `bson:"event"`
	E     []ID     `bson:"#e"`
	P     []PubKey `bson:"#p"`
}

func Structure

func Structure(e Event) StructuredEvent

func (StructuredEvent) UniqueMatch added in v0.1.6

func (e StructuredEvent) UniqueMatch() primitive.M

type Tag

type Tag []string

["e", <32-bytes hex of the id of another event>, <recommended relay URL>], ["p", <32-bytes hex of the key>, <recommended relay URL>],

type Timestamp

type Timestamp int64 // <unix timestamp in seconds>,

type URL

type URL string

Jump to

Keyboard shortcuts

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