Documentation ¶
Index ¶
- Constants
- Variables
- func BinToNpub(b B) (s B, err error)
- func BinToNsec(sk B) (nsec B, err error)
- func ConvertForBech32(b8 B) (b5 B, err error)
- func ConvertFromBech32(b5 B) (b8 B, err error)
- func Decode(bech32string B) (prefix B, value any, err E)
- func DecodeToString(bech32String B) (prefix, value B, err E)
- func EncodeEntity(pk B, k *kind.T, id B, relays []B) (s B, err E)
- func EncodeEvent(eventIDHex *eventid.T, relays []B, author B) (s B, err E)
- func EncodeNote(eventIDHex B) (s B, err E)
- func EncodeProfile(publicKeyHex B, relays []B) (s B, err E)
- func HexToNpub(publicKeyHex B) (s B, err error)
- func HexToNsec(sk B) (nsec B, err error)
- func HexToPublicKey(pk string) (p *btcec.PublicKey, err error)
- func HexToSecretKey(sk B) (s *btcec.SecretKey, err error)
- func NpubToPublicKey(encoded B) (pk *secp256k1.PublicKey, err error)
- func NsecToHex(nsec B) (hexSec B, err error)
- func NsecToSecretKey(encoded B) (sk *secp256k1.SecretKey, err error)
- func PublicKeyToNpub(pk *secp256k1.PublicKey) (encoded B, err error)
- func SecretKeyToHex(sk *btcec.SecretKey) (hexSec B)
- func SecretKeyToNsec(sk *secp256k1.SecretKey) (encoded B, err error)
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 = B("nsec") PubHRP = B("npub") )
var ( NoteHRP = B("note") NsecHRP = B("nsec") NpubHRP = B("npub") NprofileHRP = B("nprofile") NeventHRP = B("nevent") NentityHRP = B("naddr") )
Functions ¶
func BinToNsec ¶
func BinToNsec(sk B) (nsec B, err error)
BinToNsec converts a binary secret key to a bech32 encoded nsec.
func ConvertForBech32 ¶
func ConvertForBech32(b8 B) (b5 B, err error)
ConvertForBech32 performs the bit expansion required for encoding into Bech32.
func ConvertFromBech32 ¶
func ConvertFromBech32(b5 B) (b8 B, err error)
ConvertFromBech32 collapses together the bit expanded 5 bit numbers encoded in bech32.
func DecodeToString ¶
func DecodeToString(bech32String B) (prefix, value B, err E)
func EncodeEntity ¶
func EncodeEvent ¶
func EncodeNote ¶
func EncodeNote(eventIDHex B) (s B, err E)
func EncodeProfile ¶
func EncodeProfile(publicKeyHex B, relays []B) (s B, err E)
func HexToNsec ¶
func HexToNsec(sk B) (nsec B, err error)
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.