diff --git a/crypto_box.js b/crypto_box.js index b189045..1f2af82 100644 --- a/crypto_box.js +++ b/crypto_box.js @@ -4,7 +4,6 @@ const { randombytes } = require('./randombytes') const { crypto_generichash_batch } = require('./crypto_generichash') const { crypto_secretbox_open_easy, crypto_secretbox_easy } = require('./crypto_secretbox') const xsalsa20 = require('xsalsa20') -const { memzero } = require('./') var crypto_box_PUBLICKEYBYTES = 32, crypto_box_SECRETKEYBYTES = 32, @@ -47,7 +46,7 @@ function crypto_box_seed_keypair(pk, sk, seed) { const hash = Buffer.alloc(64) crypto_hash_sha512(hash, seed, 32) hash.copy(sk, 0, 0, 32) - memzero(hash) + hash.fill(0) return crypto_scalarmult_base(pk, sk) } diff --git a/index.js b/index.js index 11fc7ee..df09fcb 100644 --- a/index.js +++ b/index.js @@ -13,8 +13,8 @@ var sodium = module.exports // also forwarded at the bottom but randombytes is non-enumerable var randombytes = require('./randombytes').randombytes -sodium.sodium_memzero = function (len, offset) { - for (var i = offset; i < len; i++) arr[i] = 0; +sodium.sodium_memzero = function (arr) { + arr.fill(0) } sodium.sodium_malloc = function (n) {