fixed documentation

This commit is contained in:
juanelas 2019-12-20 17:07:32 +01:00
parent 5c51fa3ade
commit e0713c541e
8 changed files with 18 additions and 18 deletions

View File

@ -1,6 +1,6 @@
# bigint-crypto-utils # bigint-crypto-utils
Utils for working with cryptography using native JS (stage 3) implementation of BigInt. It includes some extra functions to work with modular arithmetics along with secure random numbers and a fast strong probable prime generator/tester (parallelised multi-threaded Miller-Rabin primality test). It can be used by any [Web Browser or webview supporting BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) and with Node.js (>=10.4.0). In the latter case, for multi-threaded primality tests, you should use Node.js 11 or enable at runtime with `node --experimental-worker` with Node.js >=10.5.0. Utils for working with cryptography using native JS (stage 3) implementation of BigInt. It includes some extra functions to work with modular arithmetics along with secure random numbers and a fast strong probable prime generator/tester (parallelised multi-threaded Miller-Rabin primality test). It can be used by any [Web Browser or webview supporting BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) and with Node.js (>=10.4.0). In the latter case, for multi-threaded primality tests, you should use Node.js v11 or newer or enable at runtime with `node --experimental-worker` with Node.js version >= 10.5.0 and < 11.
_The operations supported on BigInts are not constant time. BigInt can be therefore **[unsuitable for use in cryptography](https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html).** Many platforms provide native support for cryptography, such as [Web Cryptography API](https://w3c.github.io/webcrypto/) or [Node.js Crypto](https://nodejs.org/dist/latest/docs/api/crypto.html)._ _The operations supported on BigInts are not constant time. BigInt can be therefore **[unsuitable for use in cryptography](https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html).** Many platforms provide native support for cryptography, such as [Web Cryptography API](https://w3c.github.io/webcrypto/) or [Node.js Crypto](https://nodejs.org/dist/latest/docs/api/crypto.html)._

View File

@ -1,6 +1,6 @@
# bigint-crypto-utils # bigint-crypto-utils
Utils for working with cryptography using native JS (stage 3) implementation of BigInt. It includes some extra functions to work with modular arithmetics along with secure random numbers and a fast strong probable prime generator/tester (parallelised multi-threaded Miller-Rabin primality test). It can be used by any [Web Browser or webview supporting BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) and with Node.js (>=10.4.0). In the latter case, for multi-threaded primality tests, you should use Node.js 11 or enable at runtime with `node --experimental-worker` with Node.js >=10.5.0. Utils for working with cryptography using native JS (stage 3) implementation of BigInt. It includes some extra functions to work with modular arithmetics along with secure random numbers and a fast strong probable prime generator/tester (parallelised multi-threaded Miller-Rabin primality test). It can be used by any [Web Browser or webview supporting BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) and with Node.js (>=10.4.0). In the latter case, for multi-threaded primality tests, you should use Node.js v11 or newer or enable at runtime with `node --experimental-worker` with Node.js version >= 10.5.0 and < 11.
_The operations supported on BigInts are not constant time. BigInt can be therefore **[unsuitable for use in cryptography](https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html).** Many platforms provide native support for cryptography, such as [Web Cryptography API](https://w3c.github.io/webcrypto/) or [Node.js Crypto](https://nodejs.org/dist/latest/docs/api/crypto.html)._ _The operations supported on BigInts are not constant time. BigInt can be therefore **[unsuitable for use in cryptography](https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html).** Many platforms provide native support for cryptography, such as [Web Cryptography API](https://w3c.github.io/webcrypto/) or [Node.js Crypto](https://nodejs.org/dist/latest/docs/api/crypto.html)._
@ -97,7 +97,7 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
<dt><a href="#gcd">gcd(a, b)</a><code>bigint</code></dt> <dt><a href="#gcd">gcd(a, b)</a><code>bigint</code></dt>
<dd><p>Greatest-common divisor of two integers based on the iterative binary algorithm.</p> <dd><p>Greatest-common divisor of two integers based on the iterative binary algorithm.</p>
</dd> </dd>
<dt><a href="#isProbablyPrime">isProbablyPrime(w, iterations)</a><code>Promise</code></dt> <dt><a href="#isProbablyPrime">isProbablyPrime(w, [iterations])</a><code>Promise</code></dt>
<dd><p>The test first tries if any of the first 250 small primes are a factor of the input number and then passes several <dd><p>The test first tries if any of the first 250 small primes are a factor of the input number and then passes several
iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)</p> iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)</p>
</dd> </dd>
@ -205,17 +205,17 @@ Greatest-common divisor of two integers based on the iterative binary algorithm.
<a name="isProbablyPrime"></a> <a name="isProbablyPrime"></a>
## isProbablyPrime(w, iterations) ⇒ <code>Promise</code> ## isProbablyPrime(w, [iterations]) ⇒ <code>Promise</code>
The test first tries if any of the first 250 small primes are a factor of the input number and then passes several The test first tries if any of the first 250 small primes are a factor of the input number and then passes several
iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1) iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
**Kind**: global function **Kind**: global function
**Returns**: <code>Promise</code> - A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) **Returns**: <code>Promise</code> - A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
| Param | Type | Description | | Param | Type | Default | Description |
| --- | --- | --- | | --- | --- | --- | --- |
| w | <code>number</code> \| <code>bigint</code> | An integer to be tested for primality | | w | <code>number</code> \| <code>bigint</code> | | An integer to be tested for primality |
| iterations | <code>number</code> | The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 | | [iterations] | <code>number</code> | <code>16</code> | The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 |
<a name="lcm"></a> <a name="lcm"></a>

View File

@ -121,7 +121,7 @@ var bigintCryptoUtils = (function (exports) {
* iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1) * iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
* *
* @param {number|bigint} w An integer to be tested for primality * @param {number|bigint} w An integer to be tested for primality
* @param {number} iterations The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param {number} [iterations = 16] The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3
* *
* @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */

View File

@ -118,7 +118,7 @@ function gcd(a, b) {
* iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1) * iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
* *
* @param {number|bigint} w An integer to be tested for primality * @param {number|bigint} w An integer to be tested for primality
* @param {number} iterations The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param {number} [iterations = 16] The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3
* *
* @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */

View File

@ -122,7 +122,7 @@ function gcd(a, b) {
* iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1) * iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
* *
* @param {number|bigint} w An integer to be tested for primality * @param {number|bigint} w An integer to be tested for primality
* @param {number} iterations The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param {number} [iterations = 16] The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3
* *
* @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */

6
package-lock.json generated
View File

@ -2400,9 +2400,9 @@
} }
}, },
"rollup": { "rollup": {
"version": "1.27.9", "version": "1.27.13",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.9.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.13.tgz",
"integrity": "sha512-8AfW4cJTPZfG6EXWwT/ujL4owUsDI1Xl8J1t+hvK4wDX81F5I4IbwP9gvGbHzxnV19fnU4rRABZQwZSX9J402Q==", "integrity": "sha512-hDi7M07MpmNSDE8YVwGVFA8L7n8jTLJ4lG65nMAijAyqBe//rtu4JdxjUBE7JqXfdpqxqDTbCDys9WcqdpsQvw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/estree": "*", "@types/estree": "*",

View File

@ -36,15 +36,15 @@
"prepublishOnly": "npm run build && npm run build:docs" "prepublishOnly": "npm run build && npm run build:docs"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-replace": "^2.2.1",
"chai": ">=4.2.0", "chai": ">=4.2.0",
"eslint": "^6.5.1", "eslint": "^6.5.1",
"jsdoc-to-markdown": "^5.0.3", "jsdoc-to-markdown": "^5.0.3",
"mocha": "^6.2.1", "mocha": "^6.2.1",
"rollup": "^1.23.1", "rollup": "^1.27.13",
"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.1"
} }
} }

View File

@ -120,7 +120,7 @@ export function gcd(a, b) {
* iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1) * iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
* *
* @param {number|bigint} w An integer to be tested for primality * @param {number|bigint} w An integer to be tested for primality
* @param {number} iterations The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param {number} [iterations = 16] The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3
* *
* @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @return {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */