updated deps
This commit is contained in:
parent
1a8342c4f7
commit
4640e8d34f
288
docs/API.md
288
docs/API.md
|
@ -27,47 +27,55 @@
|
|||
|
||||
### abs
|
||||
|
||||
▸ **abs**(`a`: *number* \| *bigint*): *number* \| *bigint*
|
||||
▸ **abs**(`a`): `number` \| `bigint`
|
||||
|
||||
Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
The absolute value of a
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/abs.d.ts:8
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/abs.d.ts:8
|
||||
|
||||
___
|
||||
|
||||
### bitLength
|
||||
|
||||
▸ **bitLength**(`a`: *number* \| *bigint*): *number*
|
||||
▸ **bitLength**(`a`): `number`
|
||||
|
||||
Returns the bitlength of a number
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number*
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
The bit length
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/bitLength.d.ts:7
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/bitLength.d.ts:7
|
||||
|
||||
___
|
||||
|
||||
### eGcd
|
||||
|
||||
▸ **eGcd**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): Egcd
|
||||
▸ **eGcd**(`a`, `b`): `Egcd`
|
||||
|
||||
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).
|
||||
|
@ -75,45 +83,53 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
|
|||
**`throws`** {RangeError}
|
||||
This excepction is thrown if a or b are less than 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `b` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** Egcd
|
||||
#### Returns
|
||||
|
||||
`Egcd`
|
||||
|
||||
A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/egcd.d.ts:18
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/egcd.d.ts:18
|
||||
|
||||
___
|
||||
|
||||
### gcd
|
||||
|
||||
▸ **gcd**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint*
|
||||
▸ **gcd**(`a`, `b`): `bigint`
|
||||
|
||||
Greatest-common divisor of two integers based on the iterative binary algorithm.
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `b` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
The greatest common divisor of a and b
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/gcd.d.ts:9
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/gcd.d.ts:9
|
||||
|
||||
___
|
||||
|
||||
### isProbablyPrime
|
||||
|
||||
▸ **isProbablyPrime**(`w`: *number* \| *bigint*, `iterations?`: *number*, `disableWorkers?`: *boolean*): *Promise*<boolean\>
|
||||
▸ **isProbablyPrime**(`w`, `iterations?`, `disableWorkers?`): `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)
|
||||
|
@ -121,137 +137,161 @@ iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
|
|||
**`throws`** {RangeError}
|
||||
w MUST be >= 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `w` | *number* \| *bigint* | - | 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 |
|
||||
| `disableWorkers` | *boolean* | false | Disable the use of workers for the primality test |
|
||||
| `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 |
|
||||
| `disableWorkers` | `boolean` | `false` | Disable the use of workers for the primality test |
|
||||
|
||||
**Returns:** *Promise*<boolean\>
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
|
||||
|
||||
Defined in: [src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/isProbablyPrime.ts#L21)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/isProbablyPrime.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### lcm
|
||||
|
||||
▸ **lcm**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint*
|
||||
▸ **lcm**(`a`, `b`): `bigint`
|
||||
|
||||
The least common multiple computed as abs(a*b)/gcd(a,b)
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `b` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
The least common multiple of a and b
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/lcm.d.ts:8
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/lcm.d.ts:8
|
||||
|
||||
___
|
||||
|
||||
### max
|
||||
|
||||
▸ **max**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *number* \| *bigint*
|
||||
▸ **max**(`a`, `b`): `number` \| `bigint`
|
||||
|
||||
Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<=b
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `b` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
Maximum of numbers a and b
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/max.d.ts:9
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/max.d.ts:9
|
||||
|
||||
___
|
||||
|
||||
### min
|
||||
|
||||
▸ **min**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *number* \| *bigint*
|
||||
▸ **min**(`a`, `b`): `number` \| `bigint`
|
||||
|
||||
Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<=b
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | *number* \| *bigint* |
|
||||
| `b` | *number* \| *bigint* |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
Minimum of numbers a and b
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/min.d.ts:9
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/min.d.ts:9
|
||||
|
||||
___
|
||||
|
||||
### modInv
|
||||
|
||||
▸ **modInv**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint*
|
||||
▸ **modInv**(`a`, `n`): `bigint`
|
||||
|
||||
Modular inverse.
|
||||
|
||||
**`throws`** {RangeError}
|
||||
Excpeption thorwn when a does not have inverse modulo n
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `a` | *number* \| *bigint* | The number to find an inverse for |
|
||||
| `n` | *number* \| *bigint* | The modulo |
|
||||
| `a` | `number` \| `bigint` | The number to find an inverse for |
|
||||
| `n` | `number` \| `bigint` | The modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
The inverse modulo n
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/modInv.d.ts:12
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/modInv.d.ts:12
|
||||
|
||||
___
|
||||
|
||||
### modPow
|
||||
|
||||
▸ **modPow**(`b`: *number* \| *bigint*, `e`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint*
|
||||
▸ **modPow**(`b`, `e`, `n`): `bigint`
|
||||
|
||||
Modular exponentiation b**e mod n. Currently using the right-to-left binary method
|
||||
|
||||
**`throws`** {RangeError}
|
||||
Excpeption thrown when n is not > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `b` | *number* \| *bigint* | base |
|
||||
| `e` | *number* \| *bigint* | exponent |
|
||||
| `n` | *number* \| *bigint* | modulo |
|
||||
| `b` | `number` \| `bigint` | base |
|
||||
| `e` | `number` \| `bigint` | exponent |
|
||||
| `n` | `number` \| `bigint` | modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
b**e mod n
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/modPow.d.ts:13
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/modPow.d.ts:13
|
||||
|
||||
___
|
||||
|
||||
### prime
|
||||
|
||||
▸ **prime**(`bitLength`: *number*, `iterations?`: *number*): *Promise*<bigint\>
|
||||
▸ **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
|
||||
|
@ -262,24 +302,28 @@ and can be enabled at runtime executing node --experimental-worker with node >=1
|
|||
**`throws`** {RangeError}
|
||||
bitLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `bitLength` | *number* | - | The required bit length for the generated prime |
|
||||
| `iterations` | *number* | 16 | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
|
||||
| `bitLength` | `number` | `undefined` | The required bit length for the generated prime |
|
||||
| `iterations` | `number` | `16` | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
|
||||
|
||||
**Returns:** *Promise*<bigint\>
|
||||
#### Returns
|
||||
|
||||
`Promise`<`bigint`\>
|
||||
|
||||
A promise that resolves to a bigint probable prime of bitLength bits.
|
||||
|
||||
Defined in: [src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/prime.ts#L21)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/prime.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### primeSync
|
||||
|
||||
▸ **primeSync**(`bitLength`: *number*, `iterations?`: *number*): *bigint*
|
||||
▸ **primeSync**(`bitLength`, `iterations?`): `bigint`
|
||||
|
||||
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.
|
||||
|
@ -287,144 +331,168 @@ The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be
|
|||
**`throws`** {RangeError}
|
||||
bitLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `bitLength` | *number* | - | The required bit length for the generated prime |
|
||||
| `iterations` | *number* | 16 | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
|
||||
| `bitLength` | `number` | `undefined` | The required bit length for the generated prime |
|
||||
| `iterations` | `number` | `16` | The number of iterations for the Miller-Rabin Probabilistic Primality Test |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
A bigint probable prime of bitLength bits.
|
||||
|
||||
Defined in: [src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/prime.ts#L100)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/prime.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### randBetween
|
||||
|
||||
▸ **randBetween**(`max`: *bigint*, `min?`: *bigint*): *bigint*
|
||||
▸ **randBetween**(`max`, `min?`): `bigint`
|
||||
|
||||
Returns a cryptographically secure random integer between [min,max]. Both numbers must be >=0
|
||||
|
||||
**`throws`** {RangeError}
|
||||
Arguments MUST be: max > 0 && min >=0 && max > min
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `max` | *bigint* | Returned value will be <= max |
|
||||
| `min` | *bigint* | Returned value will be >= min |
|
||||
| `max` | `bigint` | Returned value will be <= max |
|
||||
| `min` | `bigint` | Returned value will be >= min |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
A cryptographically secure random bigint between [min,max]
|
||||
|
||||
Defined in: [src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/randBetween.ts#L15)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/randBetween.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### randBits
|
||||
|
||||
▸ **randBits**(`bitLength`: *number*, `forceLength?`: *boolean*): *Promise*<Uint8Array \| Buffer\>
|
||||
▸ **randBits**(`bitLength`, `forceLength?`): `Promise`<`Uint8Array` \| `Buffer`\>
|
||||
|
||||
Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||
|
||||
**`throws`** {RangeError}
|
||||
bitLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `bitLength` | *number* | - | 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 |
|
||||
| `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 |
|
||||
|
||||
**Returns:** *Promise*<Uint8Array \| Buffer\>
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Uint8Array` \| `Buffer`\>
|
||||
|
||||
A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
|
||||
|
||||
Defined in: [src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/randBits.ts#L14)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/randBits.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### randBitsSync
|
||||
|
||||
▸ **randBitsSync**(`bitLength`: *number*, `forceLength?`: *boolean*): Uint8Array \| Buffer
|
||||
▸ **randBitsSync**(`bitLength`, `forceLength?`): `Uint8Array` \| `Buffer`
|
||||
|
||||
Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||
|
||||
**`throws`** {RangeError}
|
||||
bitLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `bitLength` | *number* | - | 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 |
|
||||
| `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 |
|
||||
|
||||
**Returns:** Uint8Array \| Buffer
|
||||
#### Returns
|
||||
|
||||
`Uint8Array` \| `Buffer`
|
||||
|
||||
A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
|
||||
|
||||
Defined in: [src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/randBits.ts#L45)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/randBits.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### randBytes
|
||||
|
||||
▸ **randBytes**(`byteLength`: *number*, `forceLength?`: *boolean*): *Promise*<Uint8Array \| Buffer\>
|
||||
▸ **randBytes**(`byteLength`, `forceLength?`): `Promise`<`Uint8Array` \| `Buffer`\>
|
||||
|
||||
Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues()
|
||||
|
||||
**`throws`** {RangeError}
|
||||
byteLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `byteLength` | *number* | - | 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 |
|
||||
| `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 |
|
||||
|
||||
**Returns:** *Promise*<Uint8Array \| Buffer\>
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Uint8Array` \| `Buffer`\>
|
||||
|
||||
A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
|
||||
|
||||
Defined in: [src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/randBytes.ts#L12)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/randBytes.ts#L12)
|
||||
|
||||
___
|
||||
|
||||
### randBytesSync
|
||||
|
||||
▸ **randBytesSync**(`byteLength`: *number*, `forceLength?`: *boolean*): 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()
|
||||
|
||||
**`throws`** {RangeError}
|
||||
byteLength MUST be > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `byteLength` | *number* | - | 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 |
|
||||
| `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 |
|
||||
|
||||
**Returns:** Uint8Array \| Buffer
|
||||
#### Returns
|
||||
|
||||
`Uint8Array` \| `Buffer`
|
||||
|
||||
A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
|
||||
|
||||
Defined in: [src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/2ff1ec3/src/ts/randBytes.ts#L46)
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/1a8342c/src/ts/randBytes.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### toZn
|
||||
|
||||
▸ **toZn**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint*
|
||||
▸ **toZn**(`a`, `n`): `bigint`
|
||||
|
||||
Finds the smallest positive element that is congruent to a in modulo n
|
||||
|
||||
|
@ -434,15 +502,19 @@ a and b must be the same type, either number or bigint
|
|||
**`throws`** {RangeError}
|
||||
Excpeption thrown when n is not > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `a` | *number* \| *bigint* | An integer |
|
||||
| `n` | *number* \| *bigint* | The modulo |
|
||||
| `a` | `number` \| `bigint` | An integer |
|
||||
| `n` | `number` \| `bigint` | The modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
A bigint with the smallest positive representation of a modulo n
|
||||
|
||||
Defined in: node_modules/bigint-mod-arith/dist/esm/types/ts/toZn.d.ts:15
|
||||
#### Defined in
|
||||
|
||||
node_modules/bigint-mod-arith/dist/esm/types/ts/toZn.d.ts:15
|
||||
|
|
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
|
@ -88,30 +88,30 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-multi-entry": "^4.0.0",
|
||||
"@rollup/plugin-multi-entry": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.0",
|
||||
"@rollup/plugin-replace": "^2.4.1",
|
||||
"@rollup/plugin-typescript": "^8.2.0",
|
||||
"@types/chai": "^4.2.14",
|
||||
"@types/mocha": "^8.2.1",
|
||||
"@types/node": ">=10.4",
|
||||
"@rollup/plugin-typescript": "^8.2.5",
|
||||
"@types/chai": "^4.2.21",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.4.11",
|
||||
"chai": "^4.3.3",
|
||||
"glob": "^7.1.6",
|
||||
"glob": "^7.1.7",
|
||||
"json5": "^2.2.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"mocha": "^8.3.0",
|
||||
"mocha": "^8.4.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.1.0",
|
||||
"pirates": "^4.0.1",
|
||||
"puppeteer": "^8.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.40.0",
|
||||
"rollup": "^2.55.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"ts-standard": "^10.0.0",
|
||||
"tslib": "^2.1.0",
|
||||
"typedoc": "^0.20.29",
|
||||
"typedoc-plugin-markdown": "^3.6.0",
|
||||
"typescript": "^4.2.2"
|
||||
"tslib": "^2.3.0",
|
||||
"typedoc": "^0.21.5",
|
||||
"typedoc-plugin-markdown": "^3.10.4",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">10.4"
|
||||
|
|
Loading…
Reference in New Issue