From e74b163b9eed1d26e81757c9fe9730223f31e929 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 16 May 2016 03:41:50 -0700 Subject: [PATCH] utils.nonce. --- lib/bcoin/utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/bcoin/utils.js b/lib/bcoin/utils.js index cd122794..fff7ffce 100644 --- a/lib/bcoin/utils.js +++ b/lib/bcoin/utils.js @@ -1285,14 +1285,15 @@ utils.U32 = new bn(0xffffffff); utils.U64 = new bn('ffffffffffffffff', 'hex'); /** - * Create a 64 bit nonce. + * Create an 8 byte nonce. * @returns {BN} */ -utils.nonce = function nonce() { - var nonce = utils.U64.clone(); - nonce.imuln(Math.random()); - return nonce; +utils.nonce = function _nonce() { + var nonce = new Buffer(8); + utils.writeU32(nonce, Math.random() * 0x100000000 | 0, 0); + utils.writeU32(nonce, Math.random() * 0x100000000 | 0, 4); + return new bn(nonce); }; //