Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertForBech32(b8 []byte) (b5 []byte, err error)
- func ConvertFromBech32(b5 []byte) (b8 []byte, err error)
- func Decode(bech32string string) (prefix string, value any, err error)
- func DecodeToString(bech32String string) (prefix, value string, err error)
- func EncodeEntity(publicKey string, kind kind.T, identifier string, relays []string) (s string, err error)
- func EncodeEvent(eventIDHex eventid.T, relays []string, author string) (s string, err error)
- func EncodeNote(eventIDHex string) (s string, err error)
- func EncodeProfile(publicKeyHex string, relays []string) (s string, err error)
- func EncodePublicKey(publicKeyHex string) (s string, err error)
- func EncodeSecretKey(privateKeyHex string) (nsec string, err error)
- func HexToNsec(sk string) (nsec string, err error)
- func HexToPublicKey(pk string) (p *ec.PublicKey, err error)
- func HexToSecretKey(sk string) (s *ec.SecretKey, err error)
- func NpubToPublicKey(encoded string) (pk *secp256k1.PublicKey, err error)
- func NsecToHex(nsec string) (hexSec string, err error)
- func NsecToSecretKey(encoded string) (sk *secp256k1.SecretKey, err error)
- func PublicKeyToNpub(pk *secp256k1.PublicKey) (encoded string, err error)
- func SecretKeyToHex(sk *ec.SecretKey) (hexSec string)
- func SecretKeyToNsec(sk *secp256k1.SecretKey) (encoded string, 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 SecHRP = "nsec" PubHRP = "npub" )
const ( NoteHRP = "note" NsecHRP = "nsec" NpubHRP = "npub" NprofileHRP = "nprofile" NeventHRP = "nevent" NentityHRP = "naddr" )
const ( TLVDefault byte = iota TLVRelay TLVAuthor TLVKind )
Variables ¶
var EncodePrivateKey = EncodeSecretKey
Functions ¶
func ConvertForBech32 ¶
ConvertForBech32 performs the bit expansion required for encoding into Bech32.
func ConvertFromBech32 ¶
ConvertFromBech32 collapses together the bit expanded 5 bit numbers encoded in bech32.
func DecodeToString ¶
func EncodeEntity ¶
func EncodeEvent ¶
func EncodeNote ¶
func EncodePublicKey ¶ added in v1.0.11
func EncodeSecretKey ¶ added in v1.0.11
func HexToPublicKey ¶
HexToPublicKey decodes a string that should be a 64 character long hex encoded public key into a ec.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 ec.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.
Types ¶
This section is empty.