diff --git a/index.js b/index.js index 1a9f228..717ce28 100644 --- a/index.js +++ b/index.js @@ -2,24 +2,13 @@ // Based on https://github.com/dchest/tweetnacl-js/blob/6dcbcaf5f5cbfd313f2dcfe763db35c828c8ff5b/nacl-fast.js. -var sodium = module.exports - // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. // Public domain. // // Implementation derived from TweetNaCl version 20140427. // See for details: http://tweetnacl.cr.yp.to/ -// also forwarded at the bottom but randombytes is non-enumerable - -sodium.sodium_memzero = function (arr) { - arr.fill(0) -} - -sodium.sodium_malloc = function (n) { - return new Uint8Array(n) -} - +forward(require('./memory')) forward(require('./crypto_box')) forward(require('./crypto_generichash')) forward(require('./crypto_hash')) diff --git a/memory.js b/memory.js new file mode 100644 index 0000000..e641d6b --- /dev/null +++ b/memory.js @@ -0,0 +1,14 @@ +/* eslint-disable camelcase */ + +function sodium_malloc (n) { + return new Uint8Array(n) +} + +function sodium_memzero (arr) { + arr.fill(0) +} + +module.exports = { + sodium_malloc, + sodium_memzero +}