utils.nonce.

This commit is contained in:
Christopher Jeffrey 2016-05-16 03:41:50 -07:00
parent 56445cf562
commit e74b163b9e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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);
};
//