Documentation ¶
Index ¶
- Constants
- Variables
- 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 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 NsecToSecretKey(encoded B) (sk *secp256k1.SecretKey, err error)
- type B
- 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 HexToNpub(publicKeyHex B) (s B, err error)
- func HexToNsec(sk B) (nsec B, err error)
- func NsecToHex(nsec B) (hexSec B, 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)
- type E
- type N
- type S
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") )
Functions ¶
func DecodeToString ¶
func EncodeNote ¶
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.
Types ¶
type B ¶
type B = []byte
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 PublicKeyToNpub ¶
PublicKeyToNpub encodes a public key as a bech32 string (npub).
func SecretKeyToHex ¶
SecretKeyToHex converts a secret key to the hex encoding.