Updated dependencies and fixed issue with default values in README

This commit is contained in:
juanelas 2019-12-09 13:14:47 +01:00
parent ef5d73a0e4
commit 743b483072
9 changed files with 913 additions and 1868 deletions

View File

@ -116,27 +116,27 @@ iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)</p>
<dt><a href="#modPow">modPow(b, e, n)</a><code>bigint</code></dt> <dt><a href="#modPow">modPow(b, e, n)</a><code>bigint</code></dt>
<dd><p>Modular exponentiation b**e mod n. Currently using the right-to-left binary method</p> <dd><p>Modular exponentiation b**e mod n. Currently using the right-to-left binary method</p>
</dd> </dd>
<dt><a href="#prime">prime(bitLength, iterations, sync)</a><code>Promise</code></dt> <dt><a href="#prime">prime(bitLength, [iterations], sync)</a><code>Promise</code></dt>
<dd><p>A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator. <dd><p>A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
The browser version uses web workers to parallelise prime look up. Therefore, it does not lock the UI The browser version uses web workers to parallelise prime look up. Therefore, it does not lock the UI
main process, and it can be much faster (if several cores or cpu are available). main process, and it can be much faster (if several cores or cpu are available).
The node version can also use worker_threads if they are available (enabled by default with Node 11 and The node version can also use worker_threads if they are available (enabled by default with Node 11 and
and can be enabled at runtime executing node --experimental-worker with node &gt;=10.5.0).</p> and can be enabled at runtime executing node --experimental-worker with node &gt;=10.5.0).</p>
</dd> </dd>
<dt><a href="#primeSync">primeSync(bitLength, iterations)</a><code>bigint</code></dt> <dt><a href="#primeSync">primeSync(bitLength, [iterations])</a><code>bigint</code></dt>
<dd><p>A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator. <dd><p>A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
The sync version is NOT RECOMMENDED since it won&#39;t use workers and thus it&#39;ll be slower and may freeze thw window in browser&#39;s javascript. Please consider using prime() instead.</p> The sync version is NOT RECOMMENDED since it won&#39;t use workers and thus it&#39;ll be slower and may freeze thw window in browser&#39;s javascript. Please consider using prime() instead.</p>
</dd> </dd>
<dt><a href="#randBetween">randBetween(max, min)</a><code>bigint</code></dt> <dt><a href="#randBetween">randBetween(max, [min])</a><code>bigint</code></dt>
<dd><p>Returns a cryptographically secure random integer between [min,max]</p> <dd><p>Returns a cryptographically secure random integer between [min,max]</p>
</dd> </dd>
<dt><a href="#randBits">randBits(bitLength, forceLength)</a><code>Buffer</code> | <code>Uint8Array</code></dt> <dt><a href="#randBits">randBits(bitLength, [forceLength])</a><code>Buffer</code> | <code>Uint8Array</code></dt>
<dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p> <dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
</dd> </dd>
<dt><a href="#randBytes">randBytes(byteLength, forceLength)</a><code>Promise</code></dt> <dt><a href="#randBytes">randBytes(byteLength, [forceLength])</a><code>Promise</code></dt>
<dd><p>Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p> <dd><p>Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
</dd> </dd>
<dt><a href="#randBytesSync">randBytesSync(byteLength, forceLength)</a><code>Buffer</code> | <code>Uint8Array</code></dt> <dt><a href="#randBytesSync">randBytesSync(byteLength, [forceLength])</a><code>Buffer</code> | <code>Uint8Array</code></dt>
<dd><p>Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p> <dd><p>Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
</dd> </dd>
<dt><a href="#toZn">toZn(a, n)</a><code>bigint</code></dt> <dt><a href="#toZn">toZn(a, n)</a><code>bigint</code></dt>
@ -285,7 +285,7 @@ Modular exponentiation b**e mod n. Currently using the right-to-left binary meth
<a name="prime"></a> <a name="prime"></a>
## prime(bitLength, iterations, sync) ⇒ <code>Promise</code> ## prime(bitLength, [iterations], sync) ⇒ <code>Promise</code>
A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator. A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
The browser version uses web workers to parallelise prime look up. Therefore, it does not lock the UI The browser version uses web workers to parallelise prime look up. Therefore, it does not lock the UI
main process, and it can be much faster (if several cores or cpu are available). main process, and it can be much faster (if several cores or cpu are available).
@ -295,77 +295,77 @@ and can be enabled at runtime executing node --experimental-worker with node >=1
**Kind**: global function **Kind**: global function
**Returns**: <code>Promise</code> - A promise that resolves to a bigint probable prime of bitLength bits. **Returns**: <code>Promise</code> - A promise that resolves to a bigint probable prime of bitLength bits.
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| bitLength | <code>number</code> | The required bit length for the generated prime | | bitLength | <code>number</code> | | The required bit length for the generated prime |
| iterations | <code>number</code> | The number of iterations for the Miller-Rabin Probabilistic Primality Test | | [iterations] | <code>number</code> | <code>16</code> | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
| sync | <code>boolean</code> | NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. | | sync | <code>boolean</code> | | NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. |
<a name="primeSync"></a> <a name="primeSync"></a>
## primeSync(bitLength, iterations) ⇒ <code>bigint</code> ## primeSync(bitLength, [iterations]) ⇒ <code>bigint</code>
A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator. A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead. The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
**Kind**: global function **Kind**: global function
**Returns**: <code>bigint</code> - A bigint probable prime of bitLength bits. **Returns**: <code>bigint</code> - A bigint probable prime of bitLength bits.
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| bitLength | <code>number</code> | The required bit length for the generated prime | | bitLength | <code>number</code> | | The required bit length for the generated prime |
| iterations | <code>number</code> | The number of iterations for the Miller-Rabin Probabilistic Primality Test | | [iterations] | <code>number</code> | <code>16</code> | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
<a name="randBetween"></a> <a name="randBetween"></a>
## randBetween(max, min) ⇒ <code>bigint</code> ## randBetween(max, [min]) ⇒ <code>bigint</code>
Returns a cryptographically secure random integer between [min,max] Returns a cryptographically secure random integer between [min,max]
**Kind**: global function **Kind**: global function
**Returns**: <code>bigint</code> - A cryptographically secure random bigint between [min,max] **Returns**: <code>bigint</code> - A cryptographically secure random bigint between [min,max]
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| max | <code>bigint</code> | Returned value will be <= max | | max | <code>bigint</code> | | Returned value will be <= max |
| min | <code>bigint</code> | Returned value will be >= min | | [min] | <code>bigint</code> | <code>BigInt(1)</code> | Returned value will be >= min |
<a name="randBits"></a> <a name="randBits"></a>
## randBits(bitLength, forceLength) ⇒ <code>Buffer</code> \| <code>Uint8Array</code> ## randBits(bitLength, [forceLength]) ⇒ <code>Buffer</code> \| <code>Uint8Array</code>
Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
**Kind**: global function **Kind**: global function
**Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits **Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| bitLength | <code>number</code> | The desired number of random bits | | bitLength | <code>number</code> | | The desired number of random bits |
| forceLength | <code>boolean</code> | If we want to force the output to have a specific bit length. It basically forces the msb to be 1 | | [forceLength] | <code>boolean</code> | <code>false</code> | If we want to force the output to have a specific bit length. It basically forces the msb to be 1 |
<a name="randBytes"></a> <a name="randBytes"></a>
## randBytes(byteLength, forceLength) ⇒ <code>Promise</code> ## randBytes(byteLength, [forceLength]) ⇒ <code>Promise</code>
Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
**Kind**: global function **Kind**: global function
**Returns**: <code>Promise</code> - A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes **Returns**: <code>Promise</code> - A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| byteLength | <code>number</code> | The desired number of random bytes | | byteLength | <code>number</code> | | The desired number of random bytes |
| forceLength | <code>boolean</code> | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 | | [forceLength] | <code>boolean</code> | <code>false</code> | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 |
<a name="randBytesSync"></a> <a name="randBytesSync"></a>
## randBytesSync(byteLength, forceLength) ⇒ <code>Buffer</code> \| <code>Uint8Array</code> ## randBytesSync(byteLength, [forceLength]) ⇒ <code>Buffer</code> \| <code>Uint8Array</code>
Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
**Kind**: global function **Kind**: global function
**Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes **Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| byteLength | <code>number</code> | The desired number of random bytes | | byteLength | <code>number</code> | | The desired number of random bytes |
| forceLength | <code>boolean</code> | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 | | [forceLength] | <code>boolean</code> | <code>false</code> | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 |
<a name="toZn"></a> <a name="toZn"></a>

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const rollup = require('rollup'); const rollup = require('rollup');
const replace = require('rollup-plugin-replace'); const replace = require('@rollup/plugin-replace');
const resolve = require('rollup-plugin-node-resolve'); const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs'); const commonjs = require('rollup-plugin-commonjs');
const multiEntry = require('rollup-plugin-multi-entry'); const multiEntry = require('rollup-plugin-multi-entry');

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const rollup = require('rollup'); const rollup = require('rollup');
const replace = require('rollup-plugin-replace'); const replace = require('@rollup/plugin-replace');
const minify = require('rollup-plugin-babel-minify'); const minify = require('rollup-plugin-babel-minify');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');

View File

@ -256,7 +256,7 @@ var bigintCryptoUtils = (function (exports) {
* and can be enabled at runtime executing node --experimental-worker with node >=10.5.0). * and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. * @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript.
* *
* @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits. * @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits.
@ -315,7 +315,7 @@ var bigintCryptoUtils = (function (exports) {
* The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead. * The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @returns {bigint} A bigint probable prime of bitLength bits. * @returns {bigint} A bigint probable prime of bitLength bits.
*/ */
@ -332,7 +332,7 @@ var bigintCryptoUtils = (function (exports) {
/** /**
* Returns a cryptographically secure random integer between [min,max] * Returns a cryptographically secure random integer between [min,max]
* @param {bigint} max Returned value will be <= max * @param {bigint} max Returned value will be <= max
* @param {bigint} min Returned value will be >= min * @param {bigint} [min = BigInt(1)] Returned value will be >= min
* *
* @returns {bigint} A cryptographically secure random bigint between [min,max] * @returns {bigint} A cryptographically secure random bigint between [min,max]
*/ */
@ -352,7 +352,7 @@ var bigintCryptoUtils = (function (exports) {
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} bitLength The desired number of random bits * @param {number} bitLength The desired number of random bits
* @param {boolean} forceLength If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
*/ */
@ -375,7 +375,7 @@ var bigintCryptoUtils = (function (exports) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */
@ -400,7 +400,7 @@ var bigintCryptoUtils = (function (exports) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */

View File

@ -253,7 +253,7 @@ function modPow(b, e, n) {
* and can be enabled at runtime executing node --experimental-worker with node >=10.5.0). * and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. * @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript.
* *
* @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits. * @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits.
@ -312,7 +312,7 @@ function prime(bitLength, iterations = 16) {
* The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead. * The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @returns {bigint} A bigint probable prime of bitLength bits. * @returns {bigint} A bigint probable prime of bitLength bits.
*/ */
@ -329,7 +329,7 @@ function primeSync(bitLength, iterations = 16) {
/** /**
* Returns a cryptographically secure random integer between [min,max] * Returns a cryptographically secure random integer between [min,max]
* @param {bigint} max Returned value will be <= max * @param {bigint} max Returned value will be <= max
* @param {bigint} min Returned value will be >= min * @param {bigint} [min = BigInt(1)] Returned value will be >= min
* *
* @returns {bigint} A cryptographically secure random bigint between [min,max] * @returns {bigint} A cryptographically secure random bigint between [min,max]
*/ */
@ -349,7 +349,7 @@ function randBetween(max, min = _ONE) {
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} bitLength The desired number of random bits * @param {number} bitLength The desired number of random bits
* @param {boolean} forceLength If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
*/ */
@ -372,7 +372,7 @@ function randBits(bitLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */
@ -397,7 +397,7 @@ function randBytes(byteLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */

View File

@ -263,7 +263,7 @@ function modPow(b, e, n) {
* and can be enabled at runtime executing node --experimental-worker with node >=10.5.0). * and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. * @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript.
* *
* @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits. * @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits.
@ -331,7 +331,7 @@ function prime(bitLength, iterations = 16) {
* The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead. * The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @returns {bigint} A bigint probable prime of bitLength bits. * @returns {bigint} A bigint probable prime of bitLength bits.
*/ */
@ -348,7 +348,7 @@ function primeSync(bitLength, iterations = 16) {
/** /**
* Returns a cryptographically secure random integer between [min,max] * Returns a cryptographically secure random integer between [min,max]
* @param {bigint} max Returned value will be <= max * @param {bigint} max Returned value will be <= max
* @param {bigint} min Returned value will be >= min * @param {bigint} [min = BigInt(1)] Returned value will be >= min
* *
* @returns {bigint} A cryptographically secure random bigint between [min,max] * @returns {bigint} A cryptographically secure random bigint between [min,max]
*/ */
@ -368,7 +368,7 @@ function randBetween(max, min = _ONE) {
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} bitLength The desired number of random bits * @param {number} bitLength The desired number of random bits
* @param {boolean} forceLength If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
*/ */
@ -391,7 +391,7 @@ function randBits(bitLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */
@ -416,7 +416,7 @@ function randBytes(byteLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */

2657
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -38,13 +38,13 @@
"devDependencies": { "devDependencies": {
"chai": ">=4.2.0", "chai": ">=4.2.0",
"eslint": "^6.5.1", "eslint": "^6.5.1",
"jsdoc-to-markdown": "^5.0.1", "jsdoc-to-markdown": "^5.0.3",
"mocha": "^6.2.1", "mocha": "^6.2.1",
"rollup": "^1.23.1", "rollup": "^1.23.1",
"rollup-plugin-babel-minify": "^9.1.0", "rollup-plugin-babel-minify": "^9.1.0",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-multi-entry": ">=2.1.0", "rollup-plugin-multi-entry": ">=2.1.0",
"rollup-plugin-node-resolve": ">=5.2.0", "rollup-plugin-node-resolve": ">=5.2.0",
"rollup-plugin-replace": ">=2.2.0" "@rollup/plugin-replace": "^2.2.1"
} }
} }

View File

@ -280,7 +280,7 @@ export function modPow(b, e, n) {
* and can be enabled at runtime executing node --experimental-worker with node >=10.5.0). * and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript. * @param {boolean} sync NOT RECOMMENDED. Invoke the function synchronously. It won't use workers so it'll be slower and may freeze thw window in browser's javascript.
* *
* @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits. * @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits.
@ -355,7 +355,7 @@ export function prime(bitLength, iterations = 16) {
* The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead. * The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
* *
* @param {number} bitLength The required bit length for the generated prime * @param {number} bitLength The required bit length for the generated prime
* @param {number} iterations The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @returns {bigint} A bigint probable prime of bitLength bits. * @returns {bigint} A bigint probable prime of bitLength bits.
*/ */
@ -372,7 +372,7 @@ export function primeSync(bitLength, iterations = 16) {
/** /**
* Returns a cryptographically secure random integer between [min,max] * Returns a cryptographically secure random integer between [min,max]
* @param {bigint} max Returned value will be <= max * @param {bigint} max Returned value will be <= max
* @param {bigint} min Returned value will be >= min * @param {bigint} [min = BigInt(1)] Returned value will be >= min
* *
* @returns {bigint} A cryptographically secure random bigint between [min,max] * @returns {bigint} A cryptographically secure random bigint between [min,max]
*/ */
@ -392,7 +392,7 @@ export function randBetween(max, min = _ONE) {
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} bitLength The desired number of random bits * @param {number} bitLength The desired number of random bits
* @param {boolean} forceLength If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
*/ */
@ -415,7 +415,7 @@ export function randBits(bitLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Promise} A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */
@ -449,7 +449,7 @@ export function randBytes(byteLength, forceLength = false) {
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
* *
* @param {number} byteLength The desired number of random bytes * @param {number} byteLength The desired number of random bytes
* @param {boolean} forceLength If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 * @param {boolean} [forceLength = false] If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes * @returns {Buffer|Uint8Array} A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
*/ */