keys

package
v0.2.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: Unlicense Imports: 5 Imported by: 0

Documentation

Overview

Package keys is a set of helpers for generating and converting public/secret keys to hex and back to binary.

Index

Constants

This section is empty.

Variables

View Source
var GeneratePrivateKey = func() string { return GenerateSecretKeyHex() }

GeneratePrivateKey - deprecated, use GenerateSecretKeyHex

Functions

func GenerateSecretKey

func GenerateSecretKey() (skb []byte, err error)

GenerateSecretKey creates a new secret key and returns the bytes of the secret.

func GenerateSecretKeyHex

func GenerateSecretKeyHex() (sks string)

GenerateSecretKeyHex generates a secret key and encodes the bytes as hex.

func GetPublicKeyHex

func GetPublicKeyHex(sk string) (pk string, err error)

GetPublicKeyHex generates a public key from a hex encoded secret key.

func HexPubkeyToBytes

func HexPubkeyToBytes[V []byte | string](hpk V) (pkb []byte, err error)

HexPubkeyToBytes decodes a pubkey from hex encoded string/bytes.

func IsValid32ByteHex

func IsValid32ByteHex[V []byte | string](pk V) bool

IsValid32ByteHex checks that a hex string is a valid 32 bytes lower case hex encoded value as per nostr NIP-01 spec.

func IsValidPublicKey

func IsValidPublicKey[V []byte | string](pk V) bool

IsValidPublicKey checks that a hex encoded public key is a valid BIP-340 public key.

func SecretBytesToPubKeyHex

func SecretBytesToPubKeyHex(skb []byte) (pk string, err error)

SecretBytesToPubKeyHex generates a public key from secret key bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL