Document crypto module
This commit is contained in:
parent
3389359ce5
commit
a9a21fe480
|
@ -146,15 +146,14 @@ var encrypted = exports.encrypted = {
|
||||||
* Encrypt message for given recepient's public key.
|
* Encrypt message for given recepient's public key.
|
||||||
* @param {Buffer} publicKeyTo - Recipient's public key (65 bytes)
|
* @param {Buffer} publicKeyTo - Recipient's public key (65 bytes)
|
||||||
* @param {Buffer} msg - The message being encrypted
|
* @param {Buffer} msg - The message being encrypted
|
||||||
* @param {?{?iv: Buffer, ?ephemPrivateKey: Buffer}} opts - You may also
|
* @param {Object=} opts - You may also specify initialization vector
|
||||||
* specify initialization vector (16 bytes) and ephemeral private key
|
* and ephemeral private key to get deterministic results
|
||||||
* (32 bytes) to get deterministic results.
|
* @param {Buffer} opts.iv - Initialization vector (16 bytes)
|
||||||
* @return {Promise.<Buffer>} - A promise that resolves with the buffer
|
* @param {Buffer} opts.ephemPrivateKey - Ephemeral private key (32
|
||||||
* in `encrypted` format successful encryption and rejects on failure.
|
* 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) {
|
exports.encrypt = function(publicKeyTo, msg, opts) {
|
||||||
return eccrypto.encrypt(publicKeyTo, msg, opts).then(function(encObj) {
|
return eccrypto.encrypt(publicKeyTo, msg, opts).then(function(encObj) {
|
||||||
return encrypted.encode(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
|
* @param {Buffer} privateKey - A 32-byte private key of recepient of
|
||||||
* the mesage
|
* the mesage
|
||||||
* @param {Buffer} buf - Encrypted data
|
* @param {Buffer} buf - Encrypted data
|
||||||
* @return {Promise.<Buffer>} - A promise that resolves with the
|
* @return {Promise.<Buffer>} A promise that resolves with the plaintext
|
||||||
* plaintext on successful decryption and rejects on failure.
|
* on successful decryption and rejects on failure.
|
||||||
*/
|
*/
|
||||||
exports.decrypt = function(privateKey, buf) {
|
exports.decrypt = function(privateKey, buf) {
|
||||||
return new PPromise(function(resolve) {
|
return new PPromise(function(resolve) {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
"homepage": "https://github.com/bitchan/bitmessage",
|
"homepage": "https://github.com/bitchan/bitmessage",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "*",
|
"chai": "*",
|
||||||
"jsdoc": "^3.3.0-beta1",
|
"jsdoc": "jsdoc3/jsdoc",
|
||||||
"jshint": "*",
|
"jshint": "*",
|
||||||
"karma": "^0.12.31",
|
"karma": "^0.12.31",
|
||||||
"karma-browserify": "^2.0.0",
|
"karma-browserify": "^2.0.0",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user