Document crypto module

This commit is contained in:
Kagami Hiiragi 2015-02-10 21:22:13 +03:00
parent 3389359ce5
commit a9a21fe480
2 changed files with 10 additions and 11 deletions

View File

@ -146,15 +146,14 @@ var encrypted = exports.encrypted = {
* Encrypt message for given recepient's public key.
* @param {Buffer} publicKeyTo - Recipient's public key (65 bytes)
* @param {Buffer} msg - The message being encrypted
* @param {?{?iv: Buffer, ?ephemPrivateKey: Buffer}} opts - You may also
* specify initialization vector (16 bytes) and ephemeral private key
* (32 bytes) to get deterministic results.
* @return {Promise.<Buffer>} - A promise that resolves with the buffer
* in `encrypted` format successful encryption and rejects on failure.
* @param {Object=} opts - You may also specify initialization vector
* and ephemeral private key to get deterministic results
* @param {Buffer} opts.iv - Initialization vector (16 bytes)
* @param {Buffer} opts.ephemPrivateKey - Ephemeral private key (32
* bytes)
* @return {Promise.<Buffer>} A promise that resolves with the buffer in
* `encrypted` format successful encryption and rejects on failure.
*/
// TODO(Kagami): Properly document `opts`. Documenting multiple
// function arguments with options object at the end for now gives
// strange results (probably a bug in jsdoc).
exports.encrypt = function(publicKeyTo, msg, opts) {
return eccrypto.encrypt(publicKeyTo, msg, opts).then(function(encObj) {
return encrypted.encode(encObj);
@ -166,8 +165,8 @@ exports.encrypt = function(publicKeyTo, msg, opts) {
* @param {Buffer} privateKey - A 32-byte private key of recepient of
* the mesage
* @param {Buffer} buf - Encrypted data
* @return {Promise.<Buffer>} - A promise that resolves with the
* plaintext on successful decryption and rejects on failure.
* @return {Promise.<Buffer>} A promise that resolves with the plaintext
* on successful decryption and rejects on failure.
*/
exports.decrypt = function(privateKey, buf) {
return new PPromise(function(resolve) {

View File

@ -41,7 +41,7 @@
"homepage": "https://github.com/bitchan/bitmessage",
"devDependencies": {
"chai": "*",
"jsdoc": "^3.3.0-beta1",
"jsdoc": "jsdoc3/jsdoc",
"jshint": "*",
"karma": "^0.12.31",
"karma-browserify": "^2.0.0",