docs
This commit is contained in:
parent
9cc05a488a
commit
bb0149e603
@ -230,230 +230,155 @@ utils.isBase58 = function isBase58(obj) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Hash with chosen algorithm.
|
||||
* @function
|
||||
* @param {String} alg
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.hash
|
||||
*/
|
||||
|
||||
utils.hash = crypto.hash;
|
||||
|
||||
/**
|
||||
* Hash with ripemd160.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.ripemd160
|
||||
*/
|
||||
|
||||
utils.ripemd160 = crypto.ripemd160;
|
||||
|
||||
/**
|
||||
* Hash with sha1.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.ripemd160
|
||||
*/
|
||||
|
||||
utils.sha1 = crypto.sha1;
|
||||
|
||||
/**
|
||||
* Hash with sha256.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.sha256
|
||||
*/
|
||||
|
||||
utils.sha256 = crypto.sha256;
|
||||
|
||||
/**
|
||||
* Hash with sha256 and ripemd160 (OP_HASH160).
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.hash160
|
||||
*/
|
||||
|
||||
utils.hash160 = crypto.hash160;
|
||||
|
||||
/**
|
||||
* Hash with sha256 twice (OP_HASH256).
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.hash256
|
||||
*/
|
||||
|
||||
utils.hash256 = crypto.hash256;
|
||||
|
||||
/**
|
||||
* Create a sha256 checksum (common in bitcoin).
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @returns {Buffer}
|
||||
* @see crypto.checksum
|
||||
*/
|
||||
|
||||
utils.checksum = crypto.checksum;
|
||||
|
||||
/**
|
||||
* Create an HMAC.
|
||||
* @function
|
||||
* @param {String} alg
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer} salt
|
||||
* @returns {Buffer} HMAC
|
||||
* @see crypto.hmac
|
||||
*/
|
||||
|
||||
utils.hmac = crypto.hmac;
|
||||
|
||||
/**
|
||||
* Perform key stretching using PBKDF2.
|
||||
* @function
|
||||
* @param {Buffer} key
|
||||
* @param {Buffer} salt
|
||||
* @param {Number} iter
|
||||
* @param {Number} len
|
||||
* @param {String} alg
|
||||
* @returns {Buffer}
|
||||
* @see crypto.pbkdf2Sync
|
||||
*/
|
||||
|
||||
utils.pbkdf2Sync = crypto.pbkdf2Sync;
|
||||
|
||||
/**
|
||||
* Execute pbkdf2 asynchronously.
|
||||
* @function
|
||||
* @param {Buffer} key
|
||||
* @param {Buffer} salt
|
||||
* @param {Number} iter
|
||||
* @param {Number} len
|
||||
* @param {String} alg
|
||||
* @param {Function} callback
|
||||
* @see crypto.pbkdf2
|
||||
*/
|
||||
|
||||
utils.pbkdf2 = crypto.pbkdf2;
|
||||
|
||||
/**
|
||||
* Derive a key using pbkdf2 with 50,000 iterations.
|
||||
* @function
|
||||
* @param {Buffer|String} passphrase
|
||||
* @param {Function} callback
|
||||
* @see crypto.derive
|
||||
*/
|
||||
|
||||
utils.derive = crypto.derive;
|
||||
|
||||
/**
|
||||
* Encrypt with aes-256-cbc. Derives key with {@link utils.derive}.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer|String} passphrase
|
||||
* @param {Buffer} iv - 128 bit initialization vector.
|
||||
* @param {Function} callback
|
||||
* @see crypto.encrypt
|
||||
*/
|
||||
|
||||
utils.encrypt = crypto.encrypt;
|
||||
|
||||
/**
|
||||
* Encrypt with aes-256-cbc.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer} key - 256 bit key.
|
||||
* @param {Buffer} iv - 128 bit initialization vector.
|
||||
* @returns {Buffer}
|
||||
* @see crypto.encipher
|
||||
*/
|
||||
|
||||
utils.encipher = crypto.encipher;
|
||||
|
||||
/**
|
||||
* Decrypt with aes-256-cbc. Derives key with {@link utils.derive}.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer|String} passphrase
|
||||
* @param {Buffer} iv - 128 bit initialization vector.
|
||||
* @param {Function} callback
|
||||
* @see crypto.decrypt
|
||||
*/
|
||||
|
||||
utils.decrypt = crypto.decrypt;
|
||||
|
||||
/**
|
||||
* Decrypt with aes-256-cbc.
|
||||
* @function
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer} key - 256 bit key.
|
||||
* @param {Buffer} iv - 128 bit initialization vector.
|
||||
* @returns {Buffer}
|
||||
* @see crypto.decipher
|
||||
*/
|
||||
|
||||
utils.decipher = crypto.decipher;
|
||||
|
||||
/**
|
||||
* Perform hkdf extraction.
|
||||
* @function
|
||||
* @param {Buffer} ikm
|
||||
* @param {Buffer} salt
|
||||
* @param {String} alg
|
||||
* @returns {Buffer}
|
||||
* @see crypto.hkdfExtract
|
||||
*/
|
||||
|
||||
utils.hkdfExtract = crypto.hkdfExtract;
|
||||
|
||||
/**
|
||||
* Perform hkdf expansion.
|
||||
* @function
|
||||
* @param {Buffer} prk
|
||||
* @param {Buffer} info
|
||||
* @param {Number} len
|
||||
* @param {String} alg
|
||||
* @returns {Buffer}
|
||||
* @see crypto.hkdfExpand
|
||||
*/
|
||||
|
||||
utils.hkdfExpand = crypto.hkdfExpand;
|
||||
|
||||
/**
|
||||
* memcmp in constant time (can only return true or false).
|
||||
* This protects us against timing attacks when
|
||||
* comparing an input against a secret string.
|
||||
* @see https://cryptocoding.net/index.php/Coding_rules
|
||||
* @see `$ man 3 memcmp` (NetBSD's consttime_memequal)
|
||||
* @param {Buffer} a
|
||||
* @param {Buffer} b
|
||||
* @returns {Boolean}
|
||||
* @function
|
||||
* @see crypto.ccmp
|
||||
*/
|
||||
|
||||
utils.ccmp = crypto.ccmp;
|
||||
|
||||
/**
|
||||
* Build a merkle tree from leaves.
|
||||
* @function
|
||||
* @param {Buffer[]} leaves
|
||||
* @returns {Buffer[]} Tree (in rare cases this may return null).
|
||||
* @see crypto.buildMerkleTree
|
||||
*/
|
||||
|
||||
utils.buildMerkleTree = crypto.buildMerkleTree;
|
||||
|
||||
/**
|
||||
* Calculate merkle root from leaves.
|
||||
* @function
|
||||
* @param {Buffer[]} leaves
|
||||
* @returns {Buffer?} Merkle root.
|
||||
* @see crypto.getMerkleRoot
|
||||
*/
|
||||
|
||||
utils.getMerkleRoot = crypto.getMerkleRoot;
|
||||
|
||||
/**
|
||||
* Collect a merkle branch at vector index.
|
||||
* @function
|
||||
* @param {Number} index
|
||||
* @param {Buffer[]} leaves
|
||||
* @returns {Buffer[]} branch
|
||||
* @see crypto.getMerkleBranch
|
||||
*/
|
||||
|
||||
utils.getMerkleBranch = crypto.getMerkleBranch;
|
||||
|
||||
/**
|
||||
* Check a merkle branch at vector index.
|
||||
* @function
|
||||
* @param {Buffer} hash
|
||||
* @param {Buffer[]} branch
|
||||
* @param {Number} index
|
||||
* @returns {Buffer} Hash.
|
||||
* @see crypto.checkMerkleBranch
|
||||
*/
|
||||
|
||||
utils.checkMerkleBranch = crypto.checkMerkleBranch;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user