fixed issues/typos with docs

This commit is contained in:
Juanra Dikal 2022-09-12 11:14:59 +02:00
parent fe7a8fe3fc
commit 6fda498df6
21 changed files with 184 additions and 241 deletions

55
dist/bundles/esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -82,7 +82,7 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
**`Throws`** **`Throws`**
This excepction is thrown if a or b are less than 0 RangeError if a or b are <= 0
#### Parameters #### Parameters
@ -99,7 +99,7 @@ A triple (g, x, y), such that ax + by = g = gcd(a, b).
#### Defined in #### Defined in
node_modules/bigint-mod-arith/types/egcd.d.ts:18 node_modules/bigint-mod-arith/types/egcd.d.ts:17
___ ___
@ -107,7 +107,7 @@ ___
**gcd**(`a`, `b`): `bigint` **gcd**(`a`, `b`): `bigint`
Greatest-common divisor of two integers based on the iterative binary algorithm. Greatest common divisor of two integers based on the iterative binary algorithm.
#### Parameters #### Parameters
@ -137,14 +137,14 @@ iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
**`Throws`** **`Throws`**
w MUST be >= 0 RangeError if w<0
#### Parameters #### Parameters
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ | | :------ | :------ | :------ | :------ |
| `w` | `number` \| `bigint` | `undefined` | A positive integer to be tested for primality | | `w` | `number` \| `bigint` | `undefined` | A positive integer to be tested for primality |
| `iterations` | `number` | `16` | The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 | | `iterations` | `number` | `16` | The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 of FIPS 186-4 |
| `disableWorkers` | `boolean` | `false` | Disable the use of workers for the primality test | | `disableWorkers` | `boolean` | `false` | Disable the use of workers for the primality test |
#### Returns #### Returns
@ -155,7 +155,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe
#### Defined in #### Defined in
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/isProbablyPrime.ts#L21) [src/ts/isProbablyPrime.ts:20](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/isProbablyPrime.ts#L20)
___ ___
@ -188,7 +188,7 @@ ___
**max**(`a`, `b`): `number` \| `bigint` **max**(`a`, `b`): `number` \| `bigint`
Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<=b Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<b
#### Parameters #### Parameters
@ -213,7 +213,7 @@ ___
**min**(`a`, `b`): `number` \| `bigint` **min**(`a`, `b`): `number` \| `bigint`
Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<=b Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<b
#### Parameters #### Parameters
@ -242,7 +242,7 @@ Modular inverse.
**`Throws`** **`Throws`**
Excpeption thorwn when a does not have inverse modulo n RangeError if a does not have inverse modulo n
#### Parameters #### Parameters
@ -259,7 +259,7 @@ The inverse modulo n
#### Defined in #### Defined in
node_modules/bigint-mod-arith/types/modInv.d.ts:12 node_modules/bigint-mod-arith/types/modInv.d.ts:11
___ ___
@ -271,7 +271,7 @@ Modular exponentiation b**e mod n. Currently using the right-to-left binary meth
**`Throws`** **`Throws`**
Excpeption thrown when n is not > 0 RangeError if n <= 0
#### Parameters #### Parameters
@ -289,7 +289,7 @@ b**e mod n
#### Defined in #### Defined in
node_modules/bigint-mod-arith/types/modPow.d.ts:13 node_modules/bigint-mod-arith/types/modPow.d.ts:12
___ ___
@ -305,7 +305,7 @@ and can be enabled at runtime executing node --experimental-worker with node >=1
**`Throws`** **`Throws`**
bitLength MUST be > 0 RangeError if bitLength < 1
#### Parameters #### Parameters
@ -322,7 +322,7 @@ A promise that resolves to a bigint probable prime of bitLength bits.
#### Defined in #### Defined in
[src/ts/prime.ts:29](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/prime.ts#L29) [src/ts/prime.ts:28](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/prime.ts#L28)
___ ___
@ -335,7 +335,7 @@ The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be
**`Throws`** **`Throws`**
bitLength MUST be > 0 RangeError if bitLength < 1
#### Parameters #### Parameters
@ -352,7 +352,7 @@ A bigint probable prime of bitLength bits.
#### Defined in #### Defined in
[src/ts/prime.ts:111](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/prime.ts#L111) [src/ts/prime.ts:109](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/prime.ts#L109)
___ ___
@ -364,7 +364,7 @@ Returns a cryptographically secure random integer between [min,max].
**`Throws`** **`Throws`**
Arguments MUST be: max > min RangeError if max <= min
#### Parameters #### Parameters
@ -381,7 +381,7 @@ A cryptographically secure random bigint between [min,max]
#### Defined in #### Defined in
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/randBetween.ts#L15) [src/ts/randBetween.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/randBetween.ts#L14)
___ ___
@ -393,14 +393,14 @@ Secure random bits for both node and browsers. Node version uses crypto.randomFi
**`Throws`** **`Throws`**
bitLength MUST be > 0 RangeError if bitLength < 1
#### Parameters #### Parameters
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ | | :------ | :------ | :------ | :------ |
| `bitLength` | `number` | `undefined` | The desired number of random bits | | `bitLength` | `number` | `undefined` | The desired number of random bits |
| `forceLength` | `boolean` | `false` | If we want to force the output to have a specific bit length. It basically forces the msb to be 1 | | `forceLength` | `boolean` | `false` | Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1 |
#### Returns #### Returns
@ -410,7 +410,7 @@ A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
#### Defined in #### Defined in
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/randBits.ts#L14) [src/ts/randBits.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/randBits.ts#L13)
___ ___
@ -422,14 +422,14 @@ Secure random bits for both node and browsers. Node version uses crypto.randomFi
**`Throws`** **`Throws`**
bitLength MUST be > 0 RangeError if bitLength < 1
#### Parameters #### Parameters
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ | | :------ | :------ | :------ | :------ |
| `bitLength` | `number` | `undefined` | The desired number of random bits | | `bitLength` | `number` | `undefined` | The desired number of random bits |
| `forceLength` | `boolean` | `false` | If we want to force the output to have a specific bit length. It basically forces the msb to be 1 | | `forceLength` | `boolean` | `false` | Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1 |
#### Returns #### Returns
@ -439,7 +439,7 @@ A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
#### Defined in #### Defined in
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/randBits.ts#L45) [src/ts/randBits.ts:43](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/randBits.ts#L43)
___ ___
@ -451,14 +451,14 @@ Secure random bytes for both node and browsers. Node version uses crypto.randomB
**`Throws`** **`Throws`**
byteLength MUST be > 0 RangeError if byteLength < 1
#### Parameters #### Parameters
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ | | :------ | :------ | :------ | :------ |
| `byteLength` | `number` | `undefined` | The desired number of random bytes | | `byteLength` | `number` | `undefined` | The desired number of random bytes |
| `forceLength` | `boolean` | `false` | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 | | `forceLength` | `boolean` | `false` | Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 |
#### Returns #### Returns
@ -468,7 +468,7 @@ A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
#### Defined in #### Defined in
[src/ts/randBytes.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/randBytes.ts#L14) [src/ts/randBytes.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/randBytes.ts#L13)
___ ___
@ -477,17 +477,18 @@ ___
**randBytesSync**(`byteLength`, `forceLength?`): `Uint8Array` \| `Buffer` **randBytesSync**(`byteLength`, `forceLength?`): `Uint8Array` \| `Buffer`
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()
This is the synchronous version, consider using the asynchronous one for improved efficiency.
**`Throws`** **`Throws`**
byteLength MUST be > 0 RangeError if byteLength < 1
#### Parameters #### Parameters
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ | | :------ | :------ | :------ | :------ |
| `byteLength` | `number` | `undefined` | The desired number of random bytes | | `byteLength` | `number` | `undefined` | The desired number of random bytes |
| `forceLength` | `boolean` | `false` | If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 | | `forceLength` | `boolean` | `false` | Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1 |
#### Returns #### Returns
@ -497,7 +498,7 @@ A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
#### Defined in #### Defined in
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/d4bc197/src/ts/randBytes.ts#L46) [src/ts/randBytes.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/fe7a8fe/src/ts/randBytes.ts#L45)
___ ___
@ -513,7 +514,7 @@ a and b must be the same type, either number or bigint
**`Throws`** **`Throws`**
Excpeption thrown when n is not > 0 RangeError if n <= 0
#### Parameters #### Parameters
@ -530,4 +531,4 @@ A bigint with the smallest positive representation of a modulo n
#### Defined in #### Defined in
node_modules/bigint-mod-arith/types/toZn.d.ts:15 node_modules/bigint-mod-arith/types/toZn.d.ts:14

60
package-lock.json generated
View File

@ -1019,9 +1019,9 @@
] ]
}, },
"node_modules/bigint-mod-arith": { "node_modules/bigint-mod-arith": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.0.tgz", "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.1.tgz",
"integrity": "sha512-vpiKCiv9B1nK8HhFOU7PMC4k9nrufQxeivgCj5yOH2ZMLD+UPwc/RfNgBCX+v8C6t0sF4q7mEZgZij6k53zpWA==", "integrity": "sha512-SzFqdncZKXq5uh3oLFZXmzaZEMDsA7ml9l53xKaVGO6/+y26xNwAaTQEg2R+D+d07YduLbKi0dni3YPsR51UDQ==",
"engines": { "engines": {
"node": ">=10.4.0" "node": ">=10.4.0"
} }
@ -1968,9 +1968,9 @@
} }
}, },
"node_modules/eslint-plugin-react": { "node_modules/eslint-plugin-react": {
"version": "7.31.7", "version": "7.31.8",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.31.7.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.31.8.tgz",
"integrity": "sha512-8NldBTeYp/kQoTV1uT0XF6HcmDqbgZ0lNPkN0wlRw8DJKXEnaWu+oh/6gt3xIhzvQ35wB2Y545fJhIbJSZ2NNw==", "integrity": "sha512-5lBTZmgQmARLLSYiwI71tiGVTLUuqXantZM6vlSY39OaDSV0M7+32K5DnLkmFrwTe+Ksz0ffuLUC91RUviVZfw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"array-includes": "^3.1.5", "array-includes": "^3.1.5",
@ -2319,9 +2319,9 @@
"dev": true "dev": true
}, },
"node_modules/fast-glob": { "node_modules/fast-glob": {
"version": "3.2.11", "version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.stat": "^2.0.2",
@ -2941,9 +2941,9 @@
} }
}, },
"node_modules/is-callable": { "node_modules/is-callable": {
"version": "1.2.4", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.5.tgz",
"integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", "integrity": "sha512-ZIWRujF6MvYGkEuHMYtFRkL2wAtFw89EHfKlXrkPkjQZZRWeh9L1q3SV13NIfHnqxugjLvAOkEHx9mb1zcMnEw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">= 0.4" "node": ">= 0.4"
@ -5442,9 +5442,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.8.2", "version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -6472,9 +6472,9 @@
"dev": true "dev": true
}, },
"bigint-mod-arith": { "bigint-mod-arith": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.0.tgz", "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.1.tgz",
"integrity": "sha512-vpiKCiv9B1nK8HhFOU7PMC4k9nrufQxeivgCj5yOH2ZMLD+UPwc/RfNgBCX+v8C6t0sF4q7mEZgZij6k53zpWA==" "integrity": "sha512-SzFqdncZKXq5uh3oLFZXmzaZEMDsA7ml9l53xKaVGO6/+y26xNwAaTQEg2R+D+d07YduLbKi0dni3YPsR51UDQ=="
}, },
"binary-extensions": { "binary-extensions": {
"version": "2.2.0", "version": "2.2.0",
@ -7260,9 +7260,9 @@
"requires": {} "requires": {}
}, },
"eslint-plugin-react": { "eslint-plugin-react": {
"version": "7.31.7", "version": "7.31.8",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.31.7.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.31.8.tgz",
"integrity": "sha512-8NldBTeYp/kQoTV1uT0XF6HcmDqbgZ0lNPkN0wlRw8DJKXEnaWu+oh/6gt3xIhzvQ35wB2Y545fJhIbJSZ2NNw==", "integrity": "sha512-5lBTZmgQmARLLSYiwI71tiGVTLUuqXantZM6vlSY39OaDSV0M7+32K5DnLkmFrwTe+Ksz0ffuLUC91RUviVZfw==",
"dev": true, "dev": true,
"requires": { "requires": {
"array-includes": "^3.1.5", "array-includes": "^3.1.5",
@ -7441,9 +7441,9 @@
"dev": true "dev": true
}, },
"fast-glob": { "fast-glob": {
"version": "3.2.11", "version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.stat": "^2.0.2",
@ -7887,9 +7887,9 @@
} }
}, },
"is-callable": { "is-callable": {
"version": "1.2.4", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.5.tgz",
"integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", "integrity": "sha512-ZIWRujF6MvYGkEuHMYtFRkL2wAtFw89EHfKlXrkPkjQZZRWeh9L1q3SV13NIfHnqxugjLvAOkEHx9mb1zcMnEw==",
"dev": true "dev": true
}, },
"is-core-module": { "is-core-module": {
@ -9744,9 +9744,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "4.8.2", "version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {

View File

@ -10,11 +10,10 @@ import { _useWorkers, _workerUrl, WorkerToMainMsg, MainToWorkerMsg } from './wor
* 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 w - A positive integer to be tested for primality * @param w - A positive integer to be tested for primality
* @param iterations - The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param iterations - The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 of FIPS 186-4
* @param disableWorkers - Disable the use of workers for the primality test * @param disableWorkers - Disable the use of workers for the primality test
* *
* @throws {RangeError} * @throws {@link RangeError} if w<0
* w MUST be >= 0
* *
* @returns A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @returns A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */

View File

@ -21,8 +21,7 @@ if (!IS_BROWSER) {
* @param bitLength - The required bit length for the generated prime * @param bitLength - The required bit length for the generated prime
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A promise that resolves to a bigint probable prime of bitLength bits. * @returns A promise that resolves to a bigint probable prime of bitLength bits.
*/ */
@ -103,8 +102,7 @@ export function prime (bitLength: number, iterations: number = 16): Promise<bigi
* @param bitLength - The required bit length for the generated prime * @param bitLength - The required bit length for the generated prime
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A bigint probable prime of bitLength bits. * @returns A bigint probable prime of bitLength bits.
*/ */

View File

@ -7,8 +7,7 @@ import { randBitsSync } from './randBits'
* @param max Returned value will be <= max * @param max Returned value will be <= max
* @param min Returned value will be >= min * @param min Returned value will be >= min
* *
* @throws {RangeError} * @throws {@link RangeError} if max <= min
* Arguments MUST be: max > min
* *
* @returns A cryptographically secure random bigint between [min,max] * @returns A cryptographically secure random bigint between [min,max]
*/ */

View File

@ -4,10 +4,9 @@ import { randBytes, randBytesSync } from './randBytes'
* 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 bitLength - The desired number of random bits * @param bitLength - The desired number of random bits
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param forceLength - Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits * @returns A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
*/ */
@ -35,10 +34,9 @@ export function randBits (bitLength: number, forceLength: boolean = false): Prom
/** /**
* 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 bitLength - The desired number of random bits * @param bitLength - The desired number of random bits
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param forceLength - Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits * @returns A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
*/ */

View File

@ -4,10 +4,9 @@ if (!IS_BROWSER) var crypto = await import('crypto') // eslint-disable-line no-v
* Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues()
* *
* @param byteLength - The desired number of random bytes * @param byteLength - The desired number of random bytes
* @param 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 forceLength - Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if byteLength < 1
* byteLength MUST be > 0
* *
* @returns A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes * @returns A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
*/ */
@ -34,12 +33,12 @@ export function randBytes (byteLength: number, forceLength = false): Promise<Uin
/** /**
* 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()
* This is the synchronous version, consider using the asynchronous one for improved efficiency.
* *
* @param byteLength - The desired number of random bytes * @param byteLength - The desired number of random bytes
* @param 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 forceLength - Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if byteLength < 1
* byteLength MUST be > 0
* *
* @returns A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes * @returns A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
*/ */

View File

@ -3,11 +3,10 @@
* 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 w - A positive integer to be tested for primality * @param w - A positive integer to be tested for primality
* @param iterations - The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 * @param iterations - The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3 of FIPS 186-4
* @param disableWorkers - Disable the use of workers for the primality test * @param disableWorkers - Disable the use of workers for the primality test
* *
* @throws {RangeError} * @throws {@link RangeError} if w<0
* w MUST be >= 0
* *
* @returns A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite) * @returns A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
*/ */

View File

@ -1 +1 @@
{"version":3,"file":"isProbablyPrime.d.ts","sourceRoot":"","sources":["../src/ts/isProbablyPrime.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,UAAU,GAAE,MAAW,EAAE,cAAc,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA2D7H;AAED,wBAAgB,gBAAgB,CAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CA0TxE;AAED,wBAAgB,yBAAyB,IAAK,MAAM,CA8BnD"} {"version":3,"file":"isProbablyPrime.d.ts","sourceRoot":"","sources":["../src/ts/isProbablyPrime.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,UAAU,GAAE,MAAW,EAAE,cAAc,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA2D7H;AAED,wBAAgB,gBAAgB,CAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CA0TxE;AAED,wBAAgB,yBAAyB,IAAK,MAAM,CA8BnD"}

6
types/prime.d.ts vendored
View File

@ -8,8 +8,7 @@
* @param bitLength - The required bit length for the generated prime * @param bitLength - The required bit length for the generated prime
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A promise that resolves to a bigint probable prime of bitLength bits. * @returns A promise that resolves to a bigint probable prime of bitLength bits.
*/ */
@ -21,8 +20,7 @@ export declare function prime(bitLength: number, iterations?: number): Promise<b
* @param bitLength - The required bit length for the generated prime * @param bitLength - The required bit length for the generated prime
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test * @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A bigint probable prime of bitLength bits. * @returns A bigint probable prime of bitLength bits.
*/ */

View File

@ -1 +1 @@
{"version":3,"file":"prime.d.ts","sourceRoot":"","sources":["../src/ts/prime.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAoElF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,MAAM,CAO7E"} {"version":3,"file":"prime.d.ts","sourceRoot":"","sources":["../src/ts/prime.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAoElF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,MAAM,CAO7E"}

View File

@ -3,8 +3,7 @@
* @param max Returned value will be <= max * @param max Returned value will be <= max
* @param min Returned value will be >= min * @param min Returned value will be >= min
* *
* @throws {RangeError} * @throws {@link RangeError} if max <= min
* Arguments MUST be: max > min
* *
* @returns A cryptographically secure random bigint between [min,max] * @returns A cryptographically secure random bigint between [min,max]
*/ */

View File

@ -1 +1 @@
{"version":3,"file":"randBetween.d.ts","sourceRoot":"","sources":["../src/ts/randBetween.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAW,GAAG,MAAM,CAUlE"} {"version":3,"file":"randBetween.d.ts","sourceRoot":"","sources":["../src/ts/randBetween.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAW,GAAG,MAAM,CAUlE"}

10
types/randBits.d.ts vendored
View File

@ -3,10 +3,9 @@
* 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 bitLength - The desired number of random bits * @param bitLength - The desired number of random bits
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param forceLength - Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits * @returns A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
*/ */
@ -14,10 +13,9 @@ export declare function randBits(bitLength: number, forceLength?: boolean): Prom
/** /**
* 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 bitLength - The desired number of random bits * @param bitLength - The desired number of random bits
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1 * @param forceLength - Set to true if you want to force the output to have a specific bit length. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if bitLength < 1
* bitLength MUST be > 0
* *
* @returns A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits * @returns A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
*/ */

View File

@ -1 +1 @@
{"version":3,"file":"randBits.d.ts","sourceRoot":"","sources":["../src/ts/randBits.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAmBrG;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAehG"} {"version":3,"file":"randBits.d.ts","sourceRoot":"","sources":["../src/ts/randBits.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAmBrG;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAehG"}

11
types/randBytes.d.ts vendored
View File

@ -3,22 +3,21 @@
* Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues() * Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues()
* *
* @param byteLength - The desired number of random bytes * @param byteLength - The desired number of random bytes
* @param 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 forceLength - Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if byteLength < 1
* byteLength MUST be > 0
* *
* @returns A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes * @returns A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
*/ */
export declare function randBytes(byteLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>; export declare function randBytes(byteLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>;
/** /**
* 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()
* This is the synchronous version, consider using the asynchronous one for improved efficiency.
* *
* @param byteLength - The desired number of random bytes * @param byteLength - The desired number of random bytes
* @param 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 forceLength - Set to true if you want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
* *
* @throws {RangeError} * @throws {@link RangeError} if byteLength < 1
* byteLength MUST be > 0
* *
* @returns A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes * @returns A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
*/ */

View File

@ -1 +1 @@
{"version":3,"file":"randBytes.d.ts","sourceRoot":"","sources":["../src/ts/randBytes.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAmB9F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAiBlG"} {"version":3,"file":"randBytes.d.ts","sourceRoot":"","sources":["../src/ts/randBytes.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAmB9F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAiBlG"}