Documentation ¶
Index ¶
- Constants
- func ConvertForBech32(b8 []byte) (b5 []byte, e error)
- func ConvertFromBech32(b5 []byte) (b8 []byte, e error)
- func Decode(bech32string string) (prefix string, value any, e error)
- func DecodeSignature(encoded string) (sig *schnorr.Signature, e error)
- func DecodeToString(bech32String string) (prefix, value string, e error)
- func EncodeEntity(publicKey string, kind kind.T, identifier string, relays []string) (s string, e error)
- func EncodeEvent(eventIDHex string, relays []string, author string) (s string, e error)
- func EncodeNote(eventIDHex string) (s string, e error)
- func EncodePrivateKey(privateKeyHex string) (string, error)
- func EncodeProfile(publicKeyHex string, relays []string) (s string, e error)
- func EncodePublicKey(publicKeyHex string) (s string, e error)
- func EncodeSignature(sig *schnorr.Signature) (str string, e error)
- func GetPublicKey(sk string) (s string, e error)
- func HexToPublicKey(pk string) (p *btcec.PublicKey, e error)
- func HexToSecretKey(sk string) (s *btcec.SecretKey, e error)
- func NpubToPublicKey(encoded string) (pk *secp.PublicKey, e error)
- func NsecToSecretKey(encoded string) (sk *secp.SecretKey, e error)
- func PublicKeyToNpub(pk *secp.PublicKey) (encoded string, e error)
- func SecretKeyToNsec(sk *secp.SecretKey) (encoded string, e 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" SigHRP = "nsig" )
const ( NoteHRP = "note" NsecHRP = "nsec" NpubHRP = "npub" NprofileHRP = "nprofile" NeventHRP = "nevent" NentityHRP = "naddr" )
const ( TLVDefault uint8 = 0 TLVRelay uint8 = 1 TLVAuthor uint8 = 2 TLVKind uint8 = 3 )
Variables ¶
This section is empty.
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 DecodeSignature ¶
DecodeSignature decodes a Bech32 encoded nsig nostr (schnorr) signature into its runtime binary form.
func DecodeToString ¶ added in v1.0.10
func EncodeEntity ¶
func EncodeEvent ¶
func EncodeNote ¶
func EncodePrivateKey ¶
func EncodePublicKey ¶
func EncodeSignature ¶
EncodeSignature encodes a schnorr signature as Bech32 with the HRP "nsig" to be consistent with the key encodings 4 characters starting with 'n'.
func GetPublicKey ¶
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 kxey as a bech32 string (npub).
Types ¶
This section is empty.