Documentation ¶
Index ¶
- Constants
- Variables
- func BinToNpub(b by) (s by, err er)
- func BinToNsec(sk by) (nsec by, err er)
- func ConvertForBech32(b8 by) (b5 by, err er)
- func ConvertFromBech32(b5 by) (b8 by, err er)
- func Decode(bech32string by) (prefix by, value any, err er)
- func DecodeToString(bech32String by) (prefix, value by, err er)
- func EncodeEntity(pk by, k *kind.T, id by, relays []by) (s by, err er)
- func EncodeEvent(eventIDHex *eventid.T, relays []by, author by) (s by, err er)
- func EncodeNote(eventIDHex by) (s by, err er)
- func EncodeProfile(publicKeyHex by, relays []by) (s by, err er)
- func HexToNpub(publicKeyHex by) (s by, err er)
- func HexToNsec(sk by) (nsec by, err er)
- func HexToPublicKey(pk st) (p *btcec.PublicKey, err er)
- func HexToSecretKey(sk by) (s *btcec.SecretKey, err er)
- func NpubToPublicKey(encoded by) (pk *secp256k1.PublicKey, err er)
- func NsecToHex(nsec by) (hexSec by, err er)
- func NsecToSecretKey(encoded by) (sk *secp256k1.SecretKey, err er)
- func PublicKeyToNpub(pk *secp256k1.PublicKey) (encoded by, err er)
- func SecretKeyToHex(sk *btcec.SecretKey) (hexSec by)
- func SecretKeyToNsec(sk *secp256k1.SecretKey) (encoded by, err er)
Constants ¶
const ( // MinKeyStringLen is 56 because Bech32 needs 52 characters plus 4 for the HRP, // any string shorter than this cannot be a nostr key. MinKeyStringLen = 56 HexKeyLen = 64 Bech32HRPLen = 4 )
const ( TLVDefault byte = iota TLVRelay TLVAuthor TLVKind )
Variables ¶
var ( SecHRP = by("nsec") PubHRP = by("npub") )
var ( NoteHRP = by("note") NsecHRP = by("nsec") NpubHRP = by("npub") NprofileHRP = by("nprofile") NeventHRP = by("nevent") NentityHRP = by("naddr") )
Functions ¶
func BinToNsec ¶
func BinToNsec(sk by) (nsec by, err er)
BinToNsec converts a binary secret key to a bech32 encoded nsec.
func ConvertForBech32 ¶
func ConvertForBech32(b8 by) (b5 by, err er)
ConvertForBech32 performs the bit expansion required for encoding into Bech32.
func ConvertFromBech32 ¶
func ConvertFromBech32(b5 by) (b8 by, err er)
ConvertFromBech32 collapses together the bit expanded 5 bit numbers encoded in bech32.
func DecodeToString ¶
func DecodeToString(bech32String by) (prefix, value by, err er)
func EncodeEntity ¶
func EncodeEvent ¶
func EncodeNote ¶
func EncodeNote(eventIDHex by) (s by, err er)
func EncodeProfile ¶
func EncodeProfile(publicKeyHex by, relays []by) (s by, err er)
func HexToNsec ¶
func HexToNsec(sk by) (nsec by, err er)
HexToNsec converts a hex encoded secret key to a bech32 encoded nsec.
func HexToPublicKey ¶
HexToPublicKey decodes a string that should be a 64 character long hex encoded public key into a btcec.PublicKey that can be used to verify a signature or encode to Bech32.
func HexToSecretKey ¶
HexToSecretKey decodes a string that should be a 64 character long hex encoded public key into a btcec.PublicKey that can be used to verify a signature or encode to Bech32.
func NpubToPublicKey ¶
NpubToPublicKey decodes an nostr public key (npub) and returns an secp256k1 public key.
func NsecToSecretKey ¶
NsecToSecretKey decodes a nostr secret key (nsec) and returns the secp256k1 secret key.
func PublicKeyToNpub ¶
PublicKeyToNpub encodes a public key as a bech32 string (npub).
func SecretKeyToHex ¶
SecretKeyToHex converts a secret key to the hex encoding.
func SecretKeyToNsec ¶
SecretKeyToNsec encodes an secp256k1 secret key as a Bech32 string (nsec).
Types ¶
This section is empty.