Global

Methods

bufferToHex(buffer) → {string}

Description:
  • Converts a given buffer to a hexadecimal string.
Source:
Parameters:
Name Type Description
buffer Buffer The buffer to convert.
Returns:
The hexadecimal string.
Type
string

decodeBytes(bech32EncodedString) → {string}

Description:
  • Decode bech32 encoded bytes
Source:
Parameters:
Name Type Description
bech32EncodedString string
Throws:
if input is not a valid bech32 encoded string
Type
Error
Returns:
hex
Type
string

decodePEM(txt) → {Object}

Description:
  • This function decodes a PEM (Privacy Enhanced Mail) string and returns an object containing the public and private key.
Source:
Parameters:
Name Type Description
txt string The PEM string to decode.
Returns:
An object containing the public and private key, or null if the string could not be decoded.
Type
Object

encodeBytes(prefix, hex) → {string}

Description:
  • Encode bytes into bech32 format
Source:
Parameters:
Name Type Description
prefix string
hex string
Returns:
bech32 encoded string
Type
string

encodePEM(keys) → {String}

Description:
  • This function encodes a given set of keys in PEM format.
Source:
Parameters:
Name Type Description
keys Object An object containing the public and private keys.
Returns:
A string representing the encoded PEM format.
Type
String

generate_public_key(privKey) → {string}

Description:
  • Generates a public key from a given private key
Source:
Parameters:
Name Type Description
privKey string The private key used to generate the public key
Returns:
The generated public key in hexadecimal format
Type
string

getAllKeys(privateKey) → {Object}

Description:
  • Generates various keys and related information from a given private key using different algorithms.
Source:
Properties:
Name Type Description
privkey string The original private key.
nsec string The nsec value for the private key.
pubkey string The public key generated from the private key.
pubkeycompressed string The compressed public key generated from the private key.
npub string The npub value for the public key.
nrepo string The nrepo value for the public key.
taproot string The taproot address generated from the public key.
taproottestnet string The taproot testnet address generated from the public key.
liquidtaproot string The liquid taproot address generated from the public key.
ed25519pubkey string The ed25519 public key generated from the private key.
openSSHed25519pubkey string The OpenSSH ed25519 public key generated from the private key.
openSSHed25519privkey string The OpenSSH ed25519 private key generated from the private key.
Parameters:
Name Type Description
privateKey string The private key to generate keys from.
Returns:
An object containing the generated keys and related information.
Type
Object

getPublicKey(privateKey) → {String}

Description:
  • getPublicKey Gets a public key from a given private key
Source:
Parameters:
Name Type Description
privateKey Buffer | Uint8Array The private key to use to generate the public key
Returns:
Hex encoded public key
Type
String

hexToBase64(str) → {string}

Description:
  • Converts a hexadecimal string to a base64 encoded string
Source:
Parameters:
Name Type Description
str string A string of hexadecimal characters
Returns:
A base64 encoded string
Type
string

nip19(data, prefix) → {string}

Description:
  • Function to convert a hexadecimal data to a bech32 encoded string
Source:
Parameters:
Name Type Description
data string Hexadecimal data to be encoded
prefix string Prefix of the bech32 encoded string
Returns:
bech32 encoded string
Type
string

secp256k1Add(keyA, keyB) → {string}

Description:
  • This function adds two secp256k1 keys together using the XOR operator.
Source:
Parameters:
Name Type Description
keyA string The first secp256k1 key to be added.
keyB string The second secp256k1 key to be added.
Returns:
The result of the addition of the two keys in hexadecimal format.
Type
string

splitLongStrings(str) → {string}

Description:
  • Splits a long string into multiple lines of a specified character limit
Source:
Parameters:
Name Type Description
str string The string to be split
Returns:
The splitted string
Type
string