Skip to content

Latest commit

 

History

History
185 lines (133 loc) · 6.13 KB

api.md

File metadata and controls

185 lines (133 loc) · 6.13 KB

Members

passphrase

Utilities for converting keys to passphrases using bip39 or niceware

Constants

DEFAULT_SEED_SIZE : number

Default seed size in bytes.

Functions

hmac(message, key)Uint8Array

Implementation of HMAC SHA512 from https://github.com/dchest/tweetnacl-auth-js

getHKDF(ikm, info, extractLength, [salt])Uint8Array

Returns HKDF output according to rfc5869 using sha512

getSeed([size])Uint8Array

Generates a random seed.

deriveSigningKeysFromSeed(seed, [salt])Object

Derives an Ed25519 keypair given a random seed and an optional HKDF salt. Returns a nacl.sign keypair object: https://github.com/dchest/tweetnacl-js#naclsignkeypair

uint8ToHex(arr)string

Converts Uint8Array or Buffer to a hex string.

hexToUint8([hex])Uint8Array

Converts hex string to a Uint8Array.

passphrase

Utilities for converting keys to passphrases using bip39 or niceware

Kind: global variable

passphrase.NICEWARE_32_BYTE_WORD_COUNT : number

Number of niceware words corresponding to 32 bytes

Kind: static constant of passphrase
Default: 16

passphrase.BIP39_32_BYTE_WORD_COUNT : number

Number of niceware words corresponding to 32 bytes

Kind: static constant of passphrase
Default: 24

passphrase.fromBytesOrHex(bytes, [useNiceware]) ⇒ string

Converts bytes to passphrase using bip39 (default) or niceware

Kind: static method of passphrase

Param Type Description
bytes Uint8Array | Buffer | string Uint8Array / Buffer / hex to convert
[useNiceware] boolean Whether to use Niceware; defaults to false

passphrase.toBytes32(passphrase) ⇒ Uint8Array

Converts a 32-byte passphrase to uint8array bytes. Infers whether the passphrase is bip39 or niceware based on length.

Kind: static method of passphrase

Param Type Description
passphrase string bip39/niceware phrase to convert

passphrase.toHex32(passphrase) ⇒ string

Converts a 32-byte passphrase to hex. Infers whether the passphrase is bip39 or niceware based on length.

Kind: static method of passphrase

Param Type Description
passphrase string bip39/niceware phrase to convert

DEFAULT_SEED_SIZE : number

Default seed size in bytes.

Kind: global constant
Default: 32

hmac(message, key) ⇒ Uint8Array

Implementation of HMAC SHA512 from https://github.com/dchest/tweetnacl-auth-js

Kind: global function

Param Type Description
message Uint8Array message to HMAC
key Uint8Array the HMAC key

getHKDF(ikm, info, extractLength, [salt]) ⇒ Uint8Array

Returns HKDF output according to rfc5869 using sha512

Kind: global function

Param Type Description
ikm Uint8Array input keying material
info Uint8Array context-specific info
extractLength number length of extracted output keying material in octets
[salt] Uint8Array optional salt

getSeed([size]) ⇒ Uint8Array

Generates a random seed.

Kind: global function

Param Type Description
[size] number seed size in bytes; defaults to 32

deriveSigningKeysFromSeed(seed, [salt]) ⇒ Object

Derives an Ed25519 keypair given a random seed and an optional HKDF salt. Returns a nacl.sign keypair object: https://github.com/dchest/tweetnacl-js#naclsignkeypair

Kind: global function

Param Type Description
seed Uint8Array random seed, recommended length 32
[salt] Uint8Array random salt, recommended length 64

uint8ToHex(arr) ⇒ string

Converts Uint8Array or Buffer to a hex string.

Kind: global function

Param Type Description
arr Uint8Array | Buffer Uint8Array / Buffer to convert

hexToUint8([hex]) ⇒ Uint8Array

Converts hex string to a Uint8Array.

Kind: global function

Param Type Description
[hex] string Hex string to convert; defaults to ''