tools

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeNote added in v0.5.0

func DecodeNote(note string) (string, error)

DecodeNote decodes a note (event ID) from bech32

func DecodeNpub

func DecodeNpub(npub string) (string, error)

DecodeNpub decodes a Bech32 encoded npub to its corresponding pubkey

func DecodeNsec added in v0.4.12

func DecodeNsec(nsec string) (string, error)

DecodeNsec decodes a Bech32 encoded nsec to its corresponding hex private key

func DerivePublicKey

func DerivePublicKey(privateKeyHex string) (string, error)

DerivePublicKey derives a public key from a private key

func EncodePrivateKey

func EncodePrivateKey(hexPrivateKey string) (string, error)

EncodePrivateKey encodes a hex private key into a Bech32 nsec

func EncodePubkey

func EncodePubkey(hexPubKey string) (string, error)

EncodePubkey encodes a hex public key into a Bech32 npub

Types

type KeyPair

type KeyPair struct {
	PrivateKey string `json:"private_key"` // hex format
	PublicKey  string `json:"public_key"`  // hex format
	Nsec       string `json:"nsec"`        // bech32 format
	Npub       string `json:"npub"`        // bech32 format
}

KeyPair represents a Nostr key pair

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair generates a new random Nostr key pair

type Nip19Entity added in v0.5.0

type Nip19Entity struct {
	Type   string   `json:"type"`   // npub, note, nprofile, nevent, naddr
	Data   string   `json:"data"`   // hex pubkey or event id
	Relays []string `json:"relays"` // optional relay hints
	Author string   `json:"author"` // optional author pubkey (for naddr/nevent)
	Kind   *int     `json:"kind"`   // optional event kind
	DTag   string   `json:"d_tag"`  // optional d tag (for naddr)
}

Nip19Entity represents a decoded NIP-19 entity with TLV data

func DecodeNip19Entity added in v0.5.0

func DecodeNip19Entity(encoded string) (*Nip19Entity, error)

DecodeNip19Entity decodes any NIP-19 bech32 encoded entity

Jump to

Keyboard shortcuts

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