diff --git a/lib/address.js b/lib/address.js index 64fd531..9e6cfbd 100644 --- a/lib/address.js +++ b/lib/address.js @@ -69,7 +69,7 @@ function getchecksum(data) { }); } -// Get RIPEMD160(SHA512(SIGN_PUBLIC_KEY || ENC_PUBLIC_KEY)) +// Get RIPEMD160(SHA512(SIGN_PUBLIC_KEY || ENC_PUBLIC_KEY)). // Arguments could be either private or public keys. Private keys are // **always** 32 bytes in length. function keys2ripe(signKey, encKey) { @@ -122,7 +122,7 @@ function assertstream(stream) { assert(stream, "No stream"); } -// Get truncated ripe hash length. +// Get truncated Ripe hash length. function getripelen(ripe) { var zeroes = 0; for (var i = 0; i < 20, ripe[i] === 0; i++) { @@ -131,7 +131,7 @@ function getripelen(ripe) { return 20 - zeroes; } -// Do neccessary checkings of the truncated ripe hash length depending +// Do neccessary checkings of the truncated Ripe hash length depending // on the address version. function assertripelen(ripelen, version) { switch (version) { @@ -152,7 +152,7 @@ function assertripelen(ripelen, version) { } } -// The same as `assertripelen` but return true/false instead of throw an +// The same as `assertripelen` but return boolean instead of thrown an // Error. function checkripelen(ripelen, version) { try { @@ -210,8 +210,8 @@ exports.encode = function(addr) { */ exports.getRandom = function(opts) { var version, stream, ripelen, signPrivateKey; + opts = opts || {}; try { - opts = opts || {}; version = opts.version || 4; assertversion(version); stream = opts.stream || 1; @@ -224,12 +224,12 @@ exports.getRandom = function(opts) { } catch(e) { return Promise.reject(e); } - var nextTick = typeof setImmediate === "undefined" ? - process.nextTick : - setImmediate; // Should the generated Ripe length be strictly equal to the specified // (less-or-equal by default); var strictripelen = !!opts.strictripelen; + var nextTick = typeof setImmediate === "undefined" ? + process.nextTick : + setImmediate; var signPublicKey = bmcrypto.getPublic(signPrivateKey); // FIXME(Kagami): This function is rather slow in browsers so diff --git a/lib/crypto-platform.browser.js b/lib/crypto-platform.browser.js index a43d41c..aeec1ab 100644 --- a/lib/crypto-platform.browser.js +++ b/lib/crypto-platform.browser.js @@ -29,8 +29,8 @@ exports.sha256 = function(buf) { }; exports.ripemd160 = function(buf) { - // XXX(Kagami): No support in browsers via Web Crypto API currently, - // so use module. + // XXX(Kagami): RIPEMD is not defined in WebCryptoAPI so we provide it + // using pure JS third-party implementation. return Promise.resolve(ripemd160(buf)); }; diff --git a/lib/crypto.js b/lib/crypto.js index 6d52c76..d5d7724 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -1,6 +1,6 @@ /** - * Isomorphic Bitmessage crypto module. Reexport platform-specific - * functions and also export some common routines. + * Isomorphic Bitmessage crypto module. Reexports platform-specific + * functions and also some common routines. * @module bitmessage/crypto */ diff --git a/lib/index.js b/lib/index.js index db3c624..ac1e3f4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ /** - * Main Bitmessage module. Just reexports all public submodules. + * Main Bitmessage module. Just reexports all main submodules. * @module bitmessage */