keys

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Unlicense Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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