Module: crypto

Members

(static) AEAD

AEAD

Source:
See:

(static) ChaCha20

ChaCha20

Source:
See:

(static) chachapoly

chachapoly module

Source:
See:

(static) ec

ec module

Source:
See:

(static) ecdsa

ECDSA

Source:
See:

(static) pk

pk module

Source:
See:

(static) Poly1305

Poly1305

Source:
See:

(static) rsa

RSA

Source:
See:

(static) schnorr

schnorr module

Source:
See:

(static) siphash

siphash module

Source:
See:

(static) siphash256

siphash256

Source:
See:

Methods

(static) ccmp(a, b) → {Boolean}

memcmp in constant time (can only return true or false). This protects us against timing attacks when comparing an input against a secret string.

Parameters:
Name Type Description
a Buffer
b Buffer
Source:
See:
Returns:
Type
Boolean

(static) cleanse(data)

A maybe-secure memzero.

Parameters:
Name Type Description
data Buffer
Source:

(static) createMerkleBranch(index, leaves) → {Array:.<Buffer:>}

Collect a merkle branch at vector index.

Parameters:
Name Type Description
index Number
leaves Array:.<Buffer:>
Source:
Returns:

branch

Type
Array:.<Buffer:>

(static) createMerkleRoot(leaves) → {MerkleRoot}

Calculate merkle root from leaves.

Parameters:
Name Type Description
leaves Array:.<Buffer:>
Source:
Returns:
Type
MerkleRoot

(static) createMerkleTree(leaves) → {MerkleTree}

Build a merkle tree from leaves. Note that this will mutate the leaves array!

Parameters:
Name Type Description
leaves Array:.<Buffer:>
Source:
Returns:
Type
MerkleTree

(static) decipher(data, key, iv) → {Buffer}

Decrypt with aes-256-cbc.

Parameters:
Name Type Description
data Buffer
key Buffer

256 bit key.

iv Buffer

128 bit initialization vector.

Source:
Returns:
Type
Buffer

(static) encipher(data, key, iv) → {Buffer}

Encrypt with aes-256-cbc.

Parameters:
Name Type Description
data Buffer
key Buffer

256 bit key.

iv Buffer

128 bit initialization vector.

Source:
Returns:
Type
Buffer

(static) hash(alg, data) → {Buffer}

Hash with chosen algorithm.

Parameters:
Name Type Description
alg String
data Buffer
Source:
Returns:
Type
Buffer

(static) hash160(data) → {Buffer}

Hash with sha256 and ripemd160 (OP_HASH160).

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Buffer

(static) hash256(data) → {Buffer}

Hash with sha256 twice (OP_HASH256).

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Buffer

(static) hkdfExpand(prk, info, len, alg) → {Buffer}

Perform hkdf expansion.

Parameters:
Name Type Description
prk Buffer
info Buffer
len Number
alg String
Source:
Returns:
Type
Buffer

(static) hkdfExtract(ikm, key, alg) → {Buffer}

Perform hkdf extraction.

Parameters:
Name Type Description
ikm Buffer
key Buffer
alg String
Source:
Returns:
Type
Buffer

(static) hmac(alg, data, key) → {Buffer}

Create an HMAC.

Parameters:
Name Type Description
alg String
data Buffer
key Buffer
Source:
Returns:

HMAC

Type
Buffer

(static) pbkdf2(key, salt, iter, len, alg) → {Buffer}

Perform key derivation using PBKDF2.

Parameters:
Name Type Description
key Buffer
salt Buffer
iter Number
len Number
alg String
Source:
Returns:
Type
Buffer

(static) pbkdf2Async(key, salt, iter, len, alg) → {Promise}

Execute pbkdf2 asynchronously.

Parameters:
Name Type Description
key Buffer
salt Buffer
iter Number
len Number
alg String
Source:
Returns:
Type
Promise

(static) randomBytes(size) → {Buffer}

Generate some random bytes.

Parameters:
Name Type Description
size Number
Source:
Returns:
Type
Buffer

(static) randomInt() → {Number}

Generate a random uint32. Probably more cryptographically sound than Math.random().

Source:
Returns:
Type
Number

(static) randomRange(min, max) → {Number}

Generate a random number within a range. Probably more cryptographically sound than Math.random().

Parameters:
Name Type Description
min Number

Inclusive.

max Number

Exclusive.

Source:
Returns:
Type
Number

(static) ripemd160(data) → {Buffer}

Hash with ripemd160.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Buffer

(static) scrypt(passwd, salt, N, r, p, len) → {Buffer}

Perform key derivation using scrypt.

Parameters:
Name Type Description
passwd Buffer
salt Buffer
N Number
r Number
p Number
len Number
Source:
Returns:
Type
Buffer

(static) scryptAsync(passwd, salt, N, r, p, len) → {Promise}

Execute scrypt asynchronously.

Parameters:
Name Type Description
passwd Buffer
salt Buffer
N Number
r Number
p Number
len Number
Source:
Returns:
Type
Promise

(static) sha1(data) → {Buffer}

Hash with sha1.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Buffer

(static) sha256(data) → {Buffer}

Hash with sha256.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Buffer

(static) verifyMerkleBranch(hash, branch, index) → {Buffer}

Check a merkle branch at vector index.

Parameters:
Name Type Description
hash Buffer
branch Array:.<Buffer:>
index Number
Source:
Returns:

Hash.

Type
Buffer