diff --git a/README.md b/README.md
index 8729c28..bf831c0 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,7 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
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)
@@ -126,7 +126,7 @@ iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
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
main process, and it can be much faster (if several cores or cpu are available).
@@ -143,7 +143,7 @@ The sync version is NOT RECOMMENDED since it won't use workers and thus it
@@ -215,12 +215,12 @@ Greatest-common divisor of two integers based on the iterative binary algorithm.
-## isProbablyPrime(w, [iterations]) ⇒ Promise
+## isProbablyPrime(w, [iterations]) ⇒ Promise.<boolean>
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)
**Kind**: global function
-**Returns**: Promise - A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
+**Returns**: Promise.<boolean> - A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
@@ -295,7 +295,7 @@ Modular exponentiation b**e mod n. Currently using the right-to-left binary meth
-## prime(bitLength, [iterations]) ⇒ Promise
+## prime(bitLength, [iterations]) ⇒ Promise.<bigint>
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
main process, and it can be much faster (if several cores or cpu are available).
@@ -303,7 +303,7 @@ The node version can also use worker_threads if they are available (enabled by d
and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
**Kind**: global function
-**Returns**: Promise - A promise that resolves to a bigint probable prime of bitLength bits.
+**Returns**: Promise.<bigint> - A promise that resolves to a bigint probable prime of bitLength bits.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
@@ -352,11 +352,11 @@ Secure random bits for both node and browsers. Node version uses crypto.randomFi
-## randBytes(byteLength, [forceLength]) ⇒ Promise
+## randBytes(byteLength, [forceLength]) ⇒ Promise.<(Buffer\|Uint8Array)>
Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
**Kind**: global function
-**Returns**: Promise - A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
+**Returns**: Promise.<(Buffer\|Uint8Array)> - A promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bytes
| Param | Type | Default | Description |
| --- | --- | --- | --- |
diff --git a/dist/bigint-crypto-utils-latest.browser.js b/dist/bigint-crypto-utils-latest.browser.js
index d522e6e..486d4b8 100644
--- a/dist/bigint-crypto-utils-latest.browser.js
+++ b/dist/bigint-crypto-utils-latest.browser.js
@@ -8,7 +8,7 @@ var bigintCryptoUtils = (function (exports) {
/**
* Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
*
- * @param {number|bigint} a
+ * @param {number | bigint} a
*
* @returns {bigint} the absolute value of a
*/
@@ -123,7 +123,7 @@ var bigintCryptoUtils = (function (exports) {
* @param {number|bigint} w An integer to be tested for primality
* @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)
+ * @returns {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/
async function isProbablyPrime(w, iterations = 16) {
if (typeof w === 'number') {
@@ -258,7 +258,7 @@ var bigintCryptoUtils = (function (exports) {
* @param {number} bitLength The required bit length for the generated prime
* @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
*
- * @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.
*/
function prime(bitLength, iterations = 16) {
if (bitLength < 1)
@@ -379,7 +379,7 @@ var bigintCryptoUtils = (function (exports) {
* @param {number} byteLength The desired number of random bytes
* @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
*/
function randBytes(byteLength, forceLength = false) {
if (byteLength < 1)
diff --git a/dist/bigint-crypto-utils-latest.browser.mod.js b/dist/bigint-crypto-utils-latest.browser.mod.js
index 54d6194..1ed848e 100644
--- a/dist/bigint-crypto-utils-latest.browser.mod.js
+++ b/dist/bigint-crypto-utils-latest.browser.mod.js
@@ -5,7 +5,7 @@ const _TWO = BigInt(2);
/**
* Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
*
- * @param {number|bigint} a
+ * @param {number | bigint} a
*
* @returns {bigint} the absolute value of a
*/
@@ -120,7 +120,7 @@ function gcd(a, b) {
* @param {number|bigint} w An integer to be tested for primality
* @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)
+ * @returns {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/
async function isProbablyPrime(w, iterations = 16) {
if (typeof w === 'number') {
@@ -255,7 +255,7 @@ function modPow(b, e, n) {
* @param {number} bitLength The required bit length for the generated prime
* @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
*
- * @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.
*/
function prime(bitLength, iterations = 16) {
if (bitLength < 1)
@@ -376,7 +376,7 @@ function randBits(bitLength, forceLength = false) {
* @param {number} byteLength The desired number of random bytes
* @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
*/
function randBytes(byteLength, forceLength = false) {
if (byteLength < 1)
diff --git a/dist/bigint-crypto-utils-latest.node.js b/dist/bigint-crypto-utils-latest.node.js
index 74e5847..cdb8622 100644
--- a/dist/bigint-crypto-utils-latest.node.js
+++ b/dist/bigint-crypto-utils-latest.node.js
@@ -9,7 +9,7 @@ const _TWO = BigInt(2);
/**
* Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
*
- * @param {number|bigint} a
+ * @param {number | bigint} a
*
* @returns {bigint} the absolute value of a
*/
@@ -124,7 +124,7 @@ function gcd(a, b) {
* @param {number|bigint} w An integer to be tested for primality
* @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)
+ * @returns {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/
async function isProbablyPrime(w, iterations = 16) {
if (typeof w === 'number') {
@@ -265,7 +265,7 @@ function modPow(b, e, n) {
* @param {number} bitLength The required bit length for the generated prime
* @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
*
- * @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.
*/
function prime(bitLength, iterations = 16) {
if (bitLength < 1)
@@ -395,7 +395,7 @@ function randBits(bitLength, forceLength = false) {
* @param {number} byteLength The desired number of random bytes
* @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
*/
function randBytes(byteLength, forceLength = false) {
if (byteLength < 1)
diff --git a/package-lock.json b/package-lock.json
index 3a03dc0..bf3a456 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -97,10 +97,9 @@
"dev": true
},
"@types/node": {
- "version": "13.9.1",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.1.tgz",
- "integrity": "sha512-E6M6N0blf/jiZx8Q3nb0vNaswQeEyn0XlupO+xN6DtJ6r6IT4nXrTry7zhIfYvFCl3/8Cu6WIysmUBKiqV0bqQ==",
- "dev": true
+ "version": "13.9.3",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.3.tgz",
+ "integrity": "sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA=="
},
"@types/resolve": {
"version": "0.0.8",
@@ -1799,9 +1798,9 @@
"dev": true
},
"mocha": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.0.tgz",
- "integrity": "sha512-MymHK8UkU0K15Q/zX7uflZgVoRWiTjy0fXE/QjKts6mowUvGxOdPhZ2qj3b0iZdUrNZlW9LAIMFHB4IW+2b3EQ==",
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.1.tgz",
+ "integrity": "sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA==",
"dev": true,
"requires": {
"ansi-colors": "3.2.3",
@@ -1817,7 +1816,7 @@
"js-yaml": "3.13.1",
"log-symbols": "3.0.0",
"minimatch": "3.0.4",
- "mkdirp": "0.5.1",
+ "mkdirp": "0.5.3",
"ms": "2.1.1",
"node-environment-flags": "1.0.6",
"object.assign": "4.1.0",
@@ -1825,8 +1824,8 @@
"supports-color": "6.0.0",
"which": "1.3.1",
"wide-align": "1.1.3",
- "yargs": "13.3.0",
- "yargs-parser": "13.1.1",
+ "yargs": "13.3.2",
+ "yargs-parser": "13.1.2",
"yargs-unparser": "1.6.0"
},
"dependencies": {
@@ -1853,6 +1852,21 @@
"path-is-absolute": "^1.0.0"
}
},
+ "minimist": {
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
+ "integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
+ "dev": true,
+ "requires": {
+ "minimist": "^1.2.5"
+ }
+ },
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
@@ -2150,9 +2164,9 @@
"dev": true
},
"picomatch": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz",
- "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==",
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
"dev": true
},
"pidtree": {
@@ -2349,9 +2363,9 @@
}
},
"rollup": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.0.6.tgz",
- "integrity": "sha512-P42IlI6a/bxh52ed8hEXXe44LcHfep2f26OZybMJPN1TTQftibvQEl3CWeOmJrzqGbFxOA000QXDWO9WJaOQpA==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.2.0.tgz",
+ "integrity": "sha512-iAu/j9/WJ0i+zT0sAMuQnsEbmOKzdQ4Yxu5rbPs9aUCyqveI1Kw3H4Fi9NWfCOpb8luEySD2lDyFWL9CrLE8iw==",
"dev": true,
"requires": {
"fsevents": "~2.1.2"
@@ -3044,9 +3058,9 @@
"dev": true
},
"yargs": {
- "version": "13.3.0",
- "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz",
- "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==",
+ "version": "13.3.2",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
+ "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
"dev": true,
"requires": {
"cliui": "^5.0.0",
@@ -3058,7 +3072,7 @@
"string-width": "^3.0.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
- "yargs-parser": "^13.1.1"
+ "yargs-parser": "^13.1.2"
},
"dependencies": {
"emoji-regex": {
@@ -3087,9 +3101,9 @@
}
},
"yargs-parser": {
- "version": "13.1.1",
- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz",
- "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==",
+ "version": "13.1.2",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+ "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
"dev": true,
"requires": {
"camelcase": "^5.0.0",
diff --git a/package.json b/package.json
index 0b8990c..85d65a6 100644
--- a/package.json
+++ b/package.json
@@ -15,19 +15,19 @@
"license": "MIT",
"author": {
"name": "Juan Hernández Serrano",
- "email": "jserrano@entel.upc.edu",
+ "email": "j.hernandez@upc.edu",
"url": "https://github.com/juanelas"
},
"repository": "github:juanelas/bigint-crypto-utils",
"main": "./dist/bigint-crypto-utils-latest.node.js",
- "browser": "./dist/bigint-crypto-utils-latest.browser.mod.min.js",
+ "browser": "./dist/bigint-crypto-utils-latest.browser.mod.js",
"types": "./types/bigint-crypto-utils.d.ts",
"directories": {
"build": "./build",
"dist": "./dist",
"src": "./src",
"test": "./test",
- "types": "/types"
+ "types": "./types"
},
"scripts": {
"test": "mocha --timeout 600000",
@@ -46,10 +46,13 @@
"chai": ">=4.2.0",
"eslint": "^6.8.0",
"jsdoc-to-markdown": "^5.0.3",
- "mocha": "^7.1.0",
+ "mocha": "^7.1.1",
"npm-run-all": "^4.1.5",
- "rollup": "^2.0.6",
+ "rollup": "^2.2.0",
"rollup-plugin-terser": "^5.3.0",
"typescript": "^3.8.3"
+ },
+ "dependencies": {
+ "@types/node": "^13.9.3"
}
}
diff --git a/src/main.js b/src/main.js
index f3c8656..345d736 100644
--- a/src/main.js
+++ b/src/main.js
@@ -7,7 +7,7 @@ const _TWO = BigInt(2);
/**
* Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
*
- * @param {number|bigint} a
+ * @param {number | bigint} a
*
* @returns {bigint} the absolute value of a
*/
@@ -122,7 +122,7 @@ export function gcd(a, b) {
* @param {number|bigint} w An integer to be tested for primality
* @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)
+ * @returns {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/
export async function isProbablyPrime(w, iterations = 16) {
if (typeof w === 'number') {
@@ -282,7 +282,7 @@ export function modPow(b, e, n) {
* @param {number} bitLength The required bit length for the generated prime
* @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
*
- * @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.
*/
export function prime(bitLength, iterations = 16) {
if (bitLength < 1)
@@ -419,7 +419,7 @@ export function randBits(bitLength, forceLength = false) {
* @param {number} byteLength The desired number of random bytes
* @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
*/
export function randBytes(byteLength, forceLength = false) {
if (byteLength < 1)
diff --git a/test/browser/index.html b/test/browser/index.html
index fa25c43..729fce8 100644
--- a/test/browser/index.html
+++ b/test/browser/index.html
@@ -2,11 +2,11 @@
bigint-crypto-utils - Mocha Tests
-
+
-
+
diff --git a/types/bigint-crypto-utils.d.ts b/types/bigint-crypto-utils.d.ts
index 9c1f2e3..0868e8e 100644
--- a/types/bigint-crypto-utils.d.ts
+++ b/types/bigint-crypto-utils.d.ts
@@ -1,21 +1,169 @@
-export function abs(a: any): any;
-export function bitLength(a: any): number;
-export function eGcd(a: any, b: any): number | {
- b: any;
+/**
+ * A triple (g, x, y), such that ax + by = g = gcd(a, b).
+ */
+export type egcdReturn = {
+ g: bigint;
x: bigint;
y: bigint;
};
-export function gcd(a: any, b: any): any;
-export function isProbablyPrime(w: any, iterations?: number): Promise;
-export function lcm(a: any, b: any): number | bigint;
-export function max(a: any, b: any): any;
-export function min(a: any, b: any): any;
-export function modInv(a: any, n: any): any;
-export function modPow(b: any, e: any, n: any): any;
-export function prime(bitLength: any, iterations?: number): Promise;
-export function primeSync(bitLength: any, iterations?: number): bigint;
-export function randBetween(max: any, min?: bigint): bigint;
-export function randBits(bitLength: any, forceLength?: boolean): Uint8Array;
-export function randBytes(byteLength: any, forceLength?: boolean): Promise;
-export function randBytesSync(byteLength: any, forceLength?: boolean): Uint8Array;
-export function toZn(a: any, n: any): any;
+/**
+ * Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
+ *
+ * @param {number | bigint} a
+ *
+ * @returns {bigint} the absolute value of a
+ */
+export function abs(a: number | bigint): bigint;
+/**
+ * Returns the bitlength of a number
+ *
+ * @param {number|bigint} a
+ * @returns {number} - the bit length
+ */
+export function bitLength(a: number | bigint): number;
+/**
+ * @typedef {Object} egcdReturn A triple (g, x, y), such that ax + by = g = gcd(a, b).
+ * @property {bigint} g
+ * @property {bigint} x
+ * @property {bigint} y
+ */
+/**
+ * An iterative implementation of the extended euclidean algorithm or extended greatest common divisor algorithm.
+ * Take positive integers a, b as input, and return a triple (g, x, y), such that ax + by = g = gcd(a, b).
+ *
+ * @param {number|bigint} a
+ * @param {number|bigint} b
+ *
+ * @returns {egcdReturn} A triple (g, x, y), such that ax + by = g = gcd(a, b).
+ */
+export function eGcd(a: number | bigint, b: number | bigint): egcdReturn;
+/**
+ * Greatest-common divisor of two integers based on the iterative binary algorithm.
+ *
+ * @param {number|bigint} a
+ * @param {number|bigint} b
+ *
+ * @returns {bigint} The greatest common divisor of a and b
+ */
+export function gcd(a: number | bigint, b: number | bigint): bigint;
+/**
+ * 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)
+ *
+ * @param {number|bigint} w An integer to be tested for primality
+ * @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
+ *
+ * @returns {Promise} A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
+ */
+export function isProbablyPrime(w: number | bigint, iterations?: number): Promise;
+/**
+ * The least common multiple computed as abs(a*b)/gcd(a,b)
+ * @param {number|bigint} a
+ * @param {number|bigint} b
+ *
+ * @returns {bigint} The least common multiple of a and b
+ */
+export function lcm(a: number | bigint, b: number | bigint): bigint;
+/**
+ * Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<=b
+ *
+ * @param {number|bigint} a
+ * @param {number|bigint} b
+ *
+ * @returns {bigint} maximum of numbers a and b
+ */
+export function max(a: number | bigint, b: number | bigint): bigint;
+/**
+ * Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<=b
+ *
+ * @param {number|bigint} a
+ * @param {number|bigint} b
+ *
+ * @returns {bigint} minimum of numbers a and b
+ */
+export function min(a: number | bigint, b: number | bigint): bigint;
+/**
+ * Modular inverse.
+ *
+ * @param {number|bigint} a The number to find an inverse for
+ * @param {number|bigint} n The modulo
+ *
+ * @returns {bigint} the inverse modulo n or NaN if it does not exist
+ */
+export function modInv(a: number | bigint, n: number | bigint): bigint;
+/**
+ * Modular exponentiation b**e mod n. Currently using the right-to-left binary method
+ *
+ * @param {number|bigint} b base
+ * @param {number|bigint} e exponent
+ * @param {number|bigint} n modulo
+ *
+ * @returns {bigint} b**e mod n
+ */
+export function modPow(b: number | bigint, e: number | bigint, n: number | bigint): bigint;
+/**
+ * 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
+ * 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
+ * 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} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
+ *
+ * @returns {Promise} A promise that resolves to a bigint probable prime of bitLength bits.
+ */
+export function prime(bitLength: number, iterations?: number): Promise;
+/**
+ * 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.
+ *
+ * @param {number} bitLength The required bit length for the generated prime
+ * @param {number} [iterations = 16] The number of iterations for the Miller-Rabin Probabilistic Primality Test
+ *
+ * @returns {bigint} A bigint probable prime of bitLength bits.
+ */
+export function primeSync(bitLength: number, iterations?: number): bigint;
+/**
+ * Returns a cryptographically secure random integer between [min,max]
+ * @param {bigint} max Returned value will be <= max
+ * @param {bigint} [min = BigInt(1)] Returned value will be >= min
+ *
+ * @returns {bigint} A cryptographically secure random bigint between [min,max]
+ */
+export function randBetween(max: bigint, min?: bigint): bigint;
+/**
+ * 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 {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
+ */
+export function randBits(bitLength: number, forceLength?: boolean): Uint8Array | Buffer;
+/**
+ * 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 {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
+ */
+export function randBytes(byteLength: number, forceLength?: boolean): Promise;
+/**
+ * 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 {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
+ */
+export function randBytesSync(byteLength: number, forceLength?: boolean): Uint8Array | Buffer;
+/**
+ * Finds the smallest positive element that is congruent to a in modulo n
+ * @param {number|bigint} a An integer
+ * @param {number|bigint} n The modulo
+ *
+ * @returns {bigint} The smallest positive representation of a in modulo n
+ */
+export function toZn(a: number | bigint, n: number | bigint): bigint;