diff --git a/README.md b/README.md index fe726b6..0489676 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The appropriate version for browser or node is automatically exported. > 1. If you experience issues using webpack/babel to create your production bundles, you may edit the supported browsers list and leave only [supported browsers and versions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility). The browsers list is usually located in your project's `package.json` or the `.browserslistrc` file. > 2. In order to use `bigint-crypto-utils` with TypeScript you need to set `target`, and `lib` and `module` if in use, to `ES2020` in your project's `tsconfig.json`. -You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundles/iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundles/esm.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundles/umd.js) and manually add it to your project, or, if you have already installed `bigint-crypto-utils` in your project, just get the bundles from `node_modules/bigint-crypto-utils/dist/bundles/`. +You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundle.iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundle.esm.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-crypto-utils/main/dist/bundle.umd.js) and manually add it to your project, or, if you have already installed `bigint-crypto-utils` in your project, just get the bundles from `node_modules/bigint-crypto-utils/dist/bundles/`. An example of usage could be (complete examples can be found in the [examples](https://github.com/juanelas/bigint-crypto-utils/tree/master/examples) directory): diff --git a/build/bin/mocha-ts.cjs b/build/bin/mocha-ts.cjs index 14349a7..c8dbe49 100644 --- a/build/bin/mocha-ts.cjs +++ b/build/bin/mocha-ts.cjs @@ -2,7 +2,7 @@ const fs = require('fs') const path = require('path') const glob = require('glob') -const minimatch = require('minimatch') +const minimatch = require('minimatch').minimatch const rimraf = require('rimraf') const runScript = require('../run-script.cjs') diff --git a/build/rollup-plugin-dts.js b/build/rollup-plugin-dts.js index 547c668..b5151a3 100644 --- a/build/rollup-plugin-dts.js +++ b/build/rollup-plugin-dts.js @@ -1,4 +1,4 @@ -import { mkdirSync, readFileSync, writeFileSync } from 'fs' +import { mkdirSync, writeFileSync } from 'fs' import ts from 'typescript' import { join, dirname, extname } from 'path' import { sync } from 'rimraf' @@ -8,9 +8,7 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) const { readJsonConfigFile, sys, parseJsonSourceFileConfigFileContent, createCompilerHost, createProgram } = ts const rootDir = join(__dirname, '..') -const pkgJson = JSON.parse(readFileSync(join(rootDir, 'package.json'))) const srcFile = join(rootDir, 'src/ts/index.ts') -const outDir = dirname(join(rootDir, pkgJson.types)) const tsConfigPath = join(rootDir, 'tsconfig.json') @@ -20,31 +18,31 @@ const configFile = readJsonConfigFile(tsConfigPath, (file) => { const tsConfig = parseJsonSourceFileConfigFileContent(configFile, sys, dirname(tsConfigPath)) -const compilerOptions = { - ...tsConfig.options, - declaration: true, - declarationMap: true, - emitDeclarationOnly: true, - outDir -} - -const host = createCompilerHost(compilerOptions) - -host.writeFile = (fileName, contents) => { - mkdirSync(dirname(fileName), { recursive: true }) - writeFileSync(fileName, contents) - - // we also write the .d.cts types - let fileName2 = '' - if (extname(fileName) === '.ts') { - fileName2 = fileName.slice(0, -2) + 'cts' - } else { // ext is .d.ts.map - fileName2 = fileName.slice(0, -6) + 'cts.map' +export const compile = (outDir) => { + const compilerOptions = { + ...tsConfig.options, + declaration: true, + declarationMap: true, + emitDeclarationOnly: true, + outDir + } + + const host = createCompilerHost(compilerOptions) + + host.writeFile = (fileName, contents) => { + mkdirSync(dirname(fileName), { recursive: true }) + writeFileSync(fileName, contents) + + // we also write the .d.cts types + let fileName2 = '' + if (extname(fileName) === '.ts') { + fileName2 = fileName.slice(0, -2) + 'cts' + } else { // ext is .d.ts.map + fileName2 = fileName.slice(0, -6) + 'cts.map' + } + writeFileSync(fileName2, contents) } - writeFileSync(fileName2, contents) -} -export const compile = () => { // Clear the types dir sync(outDir) // Prepare and emit the d.ts files diff --git a/build/rollup.config.js b/build/rollup.config.js index 8b6b4bb..88e9345 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,17 +1,16 @@ 'use strict' +import commonjs from '@rollup/plugin-commonjs' import inject from '@rollup/plugin-inject' +import json from '@rollup/plugin-json' import { nodeResolve as resolve } from '@rollup/plugin-node-resolve' import replace from '@rollup/plugin-replace' import terser from '@rollup/plugin-terser' -import typescriptPlugin from '@rollup/plugin-typescript' -import commonjs from '@rollup/plugin-commonjs' -import json from '@rollup/plugin-json' - -import { dirname, join } from 'path' +import rollupPluginTs from '@rollup/plugin-typescript' import { existsSync, readFileSync } from 'fs' - -// import { browser, name as _name, exports } from '../package.json' assert { type: 'json' } +import { builtinModules } from 'module' +import { join } from 'path' +import dts from 'rollup-plugin-dts' import { compile } from './rollup-plugin-dts.js' import * as url from 'url' @@ -19,9 +18,11 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) const rootDir = join(__dirname, '..') const pkgJson = JSON.parse(readFileSync(join(rootDir, 'package.json'))) -// const dstDir = join(rootDir, directories.dist) +const pkgJsonLock = JSON.parse(readFileSync(join(rootDir, 'package-lock.json'))) const srcDir = join(rootDir, 'src', 'ts') +const tsConfigPath = join(rootDir, 'tsconfig.json') + function camelise (str) { return str.replace(/-([a-z])/g, function (m, w) { @@ -29,6 +30,11 @@ function camelise (str) { }) } +function isDevDependency (moduleName) { + const packageEntry = pkgJsonLock.packages['node_modules/' + moduleName] + return (packageEntry ?? {}).dev === true +} + const regex = /^(?:(?@.*?)\/)?(?.*)/ // We are going to take only the package name part if there is a scope, e.g. @my-org/package-name const { name } = pkgJson.name.match(regex).groups const pkgCamelisedName = camelise(name) @@ -36,9 +42,9 @@ const pkgCamelisedName = camelise(name) const input = join(srcDir, 'index.ts') if (existsSync(input) !== true) throw new Error('The entry point should be index.ts') -const tsBundleOptions = { - tsconfig: join(rootDir, 'tsconfig.json'), - outDir: undefined, // ignore outDir in tsconfig.json +const tsPluginOptions = { + tsconfig: tsConfigPath, + outDir: undefined, include: ['src/ts/**/*', 'build/typings/is-browser.d.ts'], exclude: ['src/**/*.spec.ts'] } @@ -48,23 +54,47 @@ const sourcemapOutputOptions = { sourcemapExcludeSources: true } -function compileDts () { +function compileDts (outDir) { return { name: 'compile-dts', closeBundle () { - compile() + compile(outDir) } } } +function resolveOnly (module) { // if a dev dependency is imported we will resolve it so that the dist modules always work + const moduleNameMatch = module.match(/^(?:@[a-z0-9_-]+\/)?(?:node:)?[a-z0-9_-]+/) + if (moduleNameMatch === null || moduleNameMatch.length !== 1) { + return false + } + const moduleName = moduleNameMatch[0].replace(/^node:/, '') + // don't resolve if it is a native module + if (builtinModules.includes(moduleName)) { + return false + } + + if (isDevDependency(moduleName)) { + console.warn(`\x1b[33m⚠ WARM: dev dependency \x1b[0m${module}\x1b[33m being bundled. Should it be a dependency instead?\x1b[0m`) + return true + } + + return false +} + +const tmpDeclarationsDir = join(rootDir, '.types') + export default [ - { // Browser ESM bundle + { // Browser ESM input, output: [ { - file: join(rootDir, pkgJson.browser), + file: join(rootDir, pkgJson.exports['.'].default.default), ...sourcemapOutputOptions, - format: 'es' + format: 'es', + plugins: [ + terser() + ] } ], plugins: [ @@ -73,14 +103,15 @@ export default [ _MODULE_TYPE: "'ESM'", preventAssignment: true }), - typescriptPlugin(tsBundleOptions), + rollupPluginTs(tsPluginOptions), + commonjs({ extensions: ['.js', '.cjs', '.jsx', '.cjsx'] }), + json(), resolve({ browser: true, exportConditions: ['browser', 'default'], - mainFields: ['browser', 'module', 'main'] - }), - commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required - json() + mainFields: ['browser', 'module', 'main'], + resolveOnly + }) ] }, { // Browser bundles @@ -114,17 +145,13 @@ export default [ _MODULE_TYPE: "'BUNDLE'", preventAssignment: true }), - typescriptPlugin({ - ...tsBundleOptions, + rollupPluginTs({ + ...tsPluginOptions, sourceMap: false }), - resolve({ - browser: true, - exportConditions: ['browser', 'default'], - mainFields: ['browser', 'module', 'main'] - }), - commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required - json() + commonjs({ extensions: ['.js', '.cjs', '.jsx', '.cjsx'] }), + json(), + resolve({ browser: true }) ] }, { // Node CJS @@ -151,16 +178,16 @@ export default [ _MODULE_TYPE: "'CJS'", preventAssignment: true }), + rollupPluginTs(tsPluginOptions), inject({ crypto: ['crypto', 'webcrypto'] }), - typescriptPlugin(tsBundleOptions), + commonjs({ extensions: ['.js', '.cjs', '.jsx', '.cjsx'] }), + json(), resolve({ - browser: false, - exportConditions: ['require', 'node', 'module'] - }), - commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required - json() + exportConditions: ['node'], + resolveOnly + }) ] }, { // Node ESM and type declarations @@ -179,21 +206,37 @@ export default [ replace({ IS_BROWSER: false, _MODULE_TYPE: "'ESM'", - __filename: `'${pkgJson.exports['.'].node.import.default}'`, - __dirname: `'${dirname(pkgJson.exports['.'].node.import.default)}'`, + __filename: 'fileURLToPath(import.meta.url)', + __dirname: 'fileURLToPath(new URL(\'.\', import.meta.url))', preventAssignment: true }), + rollupPluginTs(tsPluginOptions), + compileDts(tmpDeclarationsDir), inject({ - crypto: ['crypto', 'webcrypto'] + crypto: ['crypto', 'webcrypto'], + fileURLToPath: ['url', 'fileURLToPath'] }), - typescriptPlugin(tsBundleOptions), + commonjs({ extensions: ['.js', '.cjs', '.jsx', '.cjsx'] }), + json(), resolve({ - browser: false, - exportConditions: ['node', 'import'] - }), - compileDts(), - commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required - json() + exportConditions: ['node'], + resolveOnly + }) ] + }, + { + input: join(tmpDeclarationsDir, 'index.d.ts'), + output: [{ file: 'dist/index.d.ts', format: 'es' }], + plugins: [ + dts({ + respectExternal: true + }) + ], + external: (module) => { + if (/^[./]/.test(module)) { + return false + } + return !resolveOnly(module) + } } ] diff --git a/build/testing/browser/index.cjs b/build/testing/browser/index.cjs index f455aa8..32ab5f4 100644 --- a/build/testing/browser/index.cjs +++ b/build/testing/browser/index.cjs @@ -1,7 +1,7 @@ const path = require('path') const puppeteer = require('puppeteer') -const minimatch = require('minimatch') +const minimatch = require('minimatch').minimatch const glob = require('glob') const rootDir = path.join(__dirname, '../../..') const pkgJson = require(path.join(rootDir, 'package.json')) diff --git a/build/testing/browser/server.cjs b/build/testing/browser/server.cjs index b9b8917..ea1ebb6 100644 --- a/build/testing/browser/server.cjs +++ b/build/testing/browser/server.cjs @@ -60,24 +60,20 @@ async function buildTests (testFiles) { input: testFiles, plugins: [ multi(), - replace({ - '#pkg': `/${name}.esm.js`, - delimiters: ['', ''], - preventAssignment: true - }), replace({ IS_BROWSER: true, _MODULE_TYPE: "'ESM'", preventAssignment: true }), typescriptPlugin(tsBundleOptions), - resolve({ - browser: true, - exportConditions: ['browser', 'default'], - mainFields: ['browser', 'module', 'main'] - }), - commonjs(), - json() + commonjs({ extensions: ['.js', '.cjs', '.jsx', '.cjsx'] }), + json(), + resolve({ browser: true }), + replace({ + '#pkg': `/${name}.esm.js`, + delimiters: ['', ''], + preventAssignment: true + }) ], external: [`/${name}.esm.js`] } diff --git a/dist/bundles/esm.js b/dist/bundle.esm.js similarity index 77% rename from dist/bundles/esm.js rename to dist/bundle.esm.js index 3d0b055..1f23e5d 100644 --- a/dist/bundles/esm.js +++ b/dist/bundle.esm.js @@ -1,147 +1,4 @@ -function abs(a) { - return (a >= 0) ? a : -a; -} - -function bitLength(a) { - if (typeof a === 'number') - a = BigInt(a); - if (a === 1n) { - return 1; - } - let bits = 1; - do { - bits++; - } while ((a >>= 1n) > 1n); - return bits; -} - -function eGcd(a, b) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof b === 'number') - b = BigInt(b); - if (a <= 0n || b <= 0n) - throw new RangeError('a and b MUST be > 0'); - let x = 0n; - let y = 1n; - let u = 1n; - let v = 0n; - while (a !== 0n) { - const q = b / a; - const r = b % a; - const m = x - (u * q); - const n = y - (v * q); - b = a; - a = r; - x = u; - y = v; - u = m; - v = n; - } - return { - g: b, - x, - y - }; -} - -function gcd(a, b) { - let aAbs = (typeof a === 'number') ? BigInt(abs(a)) : abs(a); - let bAbs = (typeof b === 'number') ? BigInt(abs(b)) : abs(b); - if (aAbs === 0n) { - return bAbs; - } - else if (bAbs === 0n) { - return aAbs; - } - let shift = 0n; - while (((aAbs | bAbs) & 1n) === 0n) { - aAbs >>= 1n; - bAbs >>= 1n; - shift++; - } - while ((aAbs & 1n) === 0n) - aAbs >>= 1n; - do { - while ((bAbs & 1n) === 0n) - bAbs >>= 1n; - if (aAbs > bAbs) { - const x = aAbs; - aAbs = bAbs; - bAbs = x; - } - bAbs -= aAbs; - } while (bAbs !== 0n); - return aAbs << shift; -} - -function lcm(a, b) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof b === 'number') - b = BigInt(b); - if (a === 0n && b === 0n) - return BigInt(0); - return abs((a / gcd(a, b)) * b); -} - -function max(a, b) { - return (a >= b) ? a : b; -} - -function min(a, b) { - return (a >= b) ? b : a; -} - -function toZn(a, n) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof n === 'number') - n = BigInt(n); - if (n <= 0n) { - throw new RangeError('n must be > 0'); - } - const aZn = a % n; - return (aZn < 0n) ? aZn + n : aZn; -} - -function modInv(a, n) { - const egcd = eGcd(toZn(a, n), n); - if (egcd.g !== 1n) { - throw new RangeError(`${a.toString()} does not have inverse modulo ${n.toString()}`); - } - else { - return toZn(egcd.x, n); - } -} - -function modPow(b, e, n) { - if (typeof b === 'number') - b = BigInt(b); - if (typeof e === 'number') - e = BigInt(e); - if (typeof n === 'number') - n = BigInt(n); - if (n <= 0n) { - throw new RangeError('n must be > 0'); - } - else if (n === 1n) { - return 0n; - } - b = toZn(b, n); - if (e < 0n) { - return modInv(modPow(b, abs(e), n), n); - } - let r = 1n; - while (e > 0) { - if ((e % 2n) === 1n) { - r = r * b % n; - } - e = e / 2n; - b = b ** 2n % n; - } - return r; -} +function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++;}while((n>>=1n)>1n);return t}function r(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,e=1n,o=1n,u=0n;for(;0n!==n;){const i=t/n,f=t%n,g=r-o*i,b=e-u*i;t=n,n=f,r=o,e=u,o=g,u=b;}return {g:t,x:r,y:e}}function e(t,r){let e="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof r?BigInt(n(r)):n(r);if(0n===e)return o;if(0n===o)return e;let u=0n;for(;0n===(1n&(e|o));)e>>=1n,o>>=1n,u++;for(;0n===(1n&e);)e>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(e>o){const n=e;e=o,o=n;}o-=e;}while(0n!==o);return e<=t?n:t}function i(n,t){return n>=t?t:n}function f(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const r=n%t;return r<0n?r+t:r}function g(n,t){const e=r(f(n,t),t);if(1n!==e.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return f(e.x,t)}function b(t,r,e){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),"number"==typeof e&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");if(1n===e)return 0n;if(t=f(t,e),r<0n)return g(b(t,n(r),e),e);let o=1n;for(;r>0;)r%2n===1n&&(o=o*t%e),r/=2n,t=t**2n%e;return o} function fromBuffer(buf) { let ret = 0n; @@ -233,7 +90,7 @@ function randBetween(max, min = 1n) { if (max <= min) throw new RangeError('Arguments MUST be: max > min'); const interval = max - min; - const bitLen = bitLength(interval); + const bitLen = t(interval); let rnd; do { const buf = randBitsSync(bitLen); @@ -555,13 +412,13 @@ function _isProbablyPrime(w, iterations) { } const m = d / (2n ** a); do { - const b = randBetween(d, 2n); - let z = modPow(b, m, w); + const b$1 = randBetween(d, 2n); + let z = b(b$1, m, w); if (z === 1n || z === d) continue; let j = 1; while (j < a) { - z = modPow(z, 2n, w); + z = b(z, 2n, w); if (z === d) break; if (z === 1n) @@ -576,15 +433,15 @@ function _isProbablyPrime(w, iterations) { function _isProbablyPrimeWorkerUrl() { let workerCode = ` 'use strict'; - const ${eGcd.name} = ${eGcd.toString()}; - const ${modInv.name} = ${modInv.toString()}; - const ${modPow.name} = ${modPow.toString()}; - const ${toZn.name} = ${toZn.toString()}; + const ${r.name} = ${r.toString()}; + const ${g.name} = ${g.toString()}; + const ${b.name} = ${b.toString()}; + const ${f.name} = ${f.toString()}; const ${randBitsSync.name} = ${randBitsSync.toString()}; const ${randBytesSync.name} = ${randBytesSync.toString()}; const ${randBetween.name} = ${randBetween.toString()}; const ${isProbablyPrime.name} = ${_isProbablyPrime.toString()}; - ${bitLength.toString()}; + ${t.toString()}; ${fromBuffer.toString()};`; workerCode += ` onmessage = async function(msg) { @@ -673,4 +530,4 @@ function primeSync(bitLength, iterations = 16) { return rnd; } -export { abs, bitLength, eGcd, gcd, isProbablyPrime, lcm, max, min, modInv, modPow, prime, primeSync, randBetween, randBits, randBitsSync, randBytes, randBytesSync, toZn }; +export { n as abs, t as bitLength, r as eGcd, e as gcd, isProbablyPrime, o as lcm, u as max, i as min, g as modInv, b as modPow, prime, primeSync, randBetween, randBits, randBitsSync, randBytes, randBytesSync, f as toZn }; diff --git a/dist/bundles/esm.min.js b/dist/bundle.esm.min.js similarity index 82% rename from dist/bundles/esm.min.js rename to dist/bundle.esm.min.js index 62ebd66..f5bd4c5 100644 --- a/dist/bundles/esm.min.js +++ b/dist/bundle.esm.min.js @@ -1 +1 @@ -function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function e(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const u=t/n,s=t%n,a=e-o*u,c=r-i*u;t=n,n=s,e=o,r=i,o=a,i=c}return{g:t,x:e,y:r}}function r(t,e){let r="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof e?BigInt(n(e)):n(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<=t?n:t}function u(n,t){return n>=t?t:n}function s(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const e=n%t;return e<0n?e+t:e}function a(n,t){const r=e(s(n,t),t);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return s(r.x,t)}function c(t,e,r){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(t=s(t,r),e<0n)return a(c(t,n(e),r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*t%r),e/=2n,t=t**2n%r;return o}function f(n){let t=0n;for(const e of n.values()){t=(t<<8n)+BigInt(e)}return t}function g(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(e,r){{const r=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(r);else for(let t=0;t 0");{const e=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(e);else for(let t=0;t 0");const e=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{g(e,!1).then((function(e){if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}n(e)}))}))}function l(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=m(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}return e}function b(n,e=1n){if(n<=e)throw new RangeError("Arguments MUST be: max > min");const r=n-e,o=t(r);let i;do{i=f(l(o))}while(i>r);return i+e}let w=!1;function h(n,t=16,e=!1){if("number"==typeof n&&(n=BigInt(n)),n<0n)throw RangeError("w MUST be >= 0");return new Promise(((e,r)=>{const o=new Worker(p());o.onmessage=n=>{void 0!==n?.data?._bcu?.isPrime&&(o.terminate(),e(n.data._bcu.isPrime))},o.onmessageerror=n=>{r(n)};const i={_bcu:{rnd:n,iterations:t,id:0}};o.postMessage(i)}))}function y(n,t){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const e=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let t=0;t {${n}})()`;const t=new Blob([n],{type:"text/javascript"});return window.URL.createObjectURL(t)}(n)}function $(n,t=16){if(n<1)throw new RangeError("bitLength MUST be > 0");if(!w){let e=0n;do{e=f(l(n,!0))}while(!y(e,t));return new Promise((n=>{n(e)}))}return new Promise(((e,r)=>{const o=[],i=(r,i)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();e(r._bcu.value)}else{const e=f(l(n,!0));try{const n={_bcu:{rnd:e,iterations:t,id:r._bcu.id}};i.postMessage(n)}catch(n){}}};{const n=p();for(let t=0;ti(n.data,t),o.push(t)}}for(let e=0;e 0");let e=0n;do{e=f(l(n,!0))}while(!y(e,t));return e}void 0!==self.Worker&&(w=!0);export{n as abs,t as bitLength,e as eGcd,r as gcd,h as isProbablyPrime,o as lcm,i as max,u as min,a as modInv,c as modPow,$ as prime,S as primeSync,b as randBetween,d as randBits,l as randBitsSync,g as randBytes,m as randBytesSync,s as toZn}; +function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function e(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const s=t/n,u=t%n,a=e-o*s,c=r-i*s;t=n,n=u,e=o,r=i,o=a,i=c}return{g:t,x:e,y:r}}function r(t,e){let r="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof e?BigInt(n(e)):n(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<=t?n:t}function s(n,t){return n>=t?t:n}function u(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const e=n%t;return e<0n?e+t:e}function a(n,t){const r=e(u(n,t),t);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return u(r.x,t)}function c(t,e,r){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(t=u(t,r),e<0n)return a(c(t,n(e),r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*t%r),e/=2n,t=t**2n%r;return o}function f(n){let t=0n;for(const e of n.values()){t=(t<<8n)+BigInt(e)}return t}function g(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(e,r){{const r=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(r);else for(let t=0;t 0");{const e=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(e);else for(let t=0;t 0");const e=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{g(e,!1).then((function(e){if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}n(e)}))}))}function b(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=m(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}return e}function l(n,e=1n){if(n<=e)throw new RangeError("Arguments MUST be: max > min");const r=n-e,o=t(r);let i;do{i=f(b(o))}while(i>r);return i+e}let w=!1;function h(n,t=16,e=!1){if("number"==typeof n&&(n=BigInt(n)),n<0n)throw RangeError("w MUST be >= 0");return new Promise(((e,r)=>{const o=new Worker(p());o.onmessage=n=>{void 0!==n?.data?._bcu?.isPrime&&(o.terminate(),e(n.data._bcu.isPrime))},o.onmessageerror=n=>{r(n)};const i={_bcu:{rnd:n,iterations:t,id:0}};o.postMessage(i)}))}function y(n,t){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const e=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let t=0;t {${n}})()`;const t=new Blob([n],{type:"text/javascript"});return window.URL.createObjectURL(t)}(n)}function $(n,t=16){if(n<1)throw new RangeError("bitLength MUST be > 0");if(!w){let e=0n;do{e=f(b(n,!0))}while(!y(e,t));return new Promise((n=>{n(e)}))}return new Promise(((e,r)=>{const o=[],i=(r,i)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();e(r._bcu.value)}else{const e=f(b(n,!0));try{const n={_bcu:{rnd:e,iterations:t,id:r._bcu.id}};i.postMessage(n)}catch(n){}}};{const n=p();for(let t=0;ti(n.data,t),o.push(t)}}for(let e=0;e 0");let e=0n;do{e=f(b(n,!0))}while(!y(e,t));return e}void 0!==self.Worker&&(w=!0);export{n as abs,t as bitLength,e as eGcd,r as gcd,h as isProbablyPrime,o as lcm,i as max,s as min,a as modInv,c as modPow,$ as prime,S as primeSync,l as randBetween,d as randBits,b as randBitsSync,g as randBytes,m as randBytesSync,u as toZn}; diff --git a/dist/bundles/iife.js b/dist/bundle.iife.js similarity index 100% rename from dist/bundles/iife.js rename to dist/bundle.iife.js diff --git a/dist/bundles/umd.js b/dist/bundle.umd.js similarity index 100% rename from dist/bundles/umd.js rename to dist/bundle.umd.js diff --git a/dist/cjs/index.node.cjs b/dist/cjs/index.node.cjs deleted file mode 100644 index c30cf21..0000000 --- a/dist/cjs/index.node.cjs +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";function n(n){return n>=0?n:-n}function e(n,e){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),n<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let t=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const s=e/n,u=e%n,c=t-o*s,f=r-i*s;e=n,n=u,t=o,r=i,o=c,i=f}return{g:e,x:t,y:r}}function t(e,t){let r="number"==typeof e?BigInt(n(e)):n(e),o="number"==typeof t?BigInt(n(t)):n(t);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r< 0");const t=n%e;return t<0n?t+e:t}function o(n,t){const o=e(r(n,t),t);if(1n!==o.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return r(o.x,t)}function i(n){let e=0n;for(const t of n.values()){e=(e<<8n)+BigInt(t)}return e}exports.toZn=void 0,exports.modPow=void 0,exports.modInv=void 0,exports.min=void 0,exports.max=void 0,exports.lcm=void 0,exports.gcd=void 0,exports.eGcd=void 0,exports.bitLength=void 0,exports.abs=void 0,exports.abs=n,exports.bitLength=function(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let e=1;do{e++}while((n>>=1n)>1n);return e},exports.eGcd=e,exports.gcd=t,exports.lcm=function(e,r){return"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),0n===e&&0n===r?BigInt(0):n(e/t(e,r)*r)},exports.max=function(n,e){return n>=e?n:e},exports.min=function(n,e){return n>=e?e:n},exports.modInv=o,exports.modPow=function e(t,i,s){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof i&&(i=BigInt(i)),"number"==typeof s&&(s=BigInt(s)),s<=0n)throw new RangeError("n must be > 0");if(1n===s)return 0n;if(t=r(t,s),i<0n)return o(e(t,n(i),s),s);let u=1n;for(;i>0;)i%2n===1n&&(u=u*t%s),i/=2n,t=t**2n%s;return u},exports.toZn=r;var s=require("crypto");function u(n,e=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(t,r){s.randomBytes(n,(function(n,o){null!==n&&r(n),e&&(o[0]=128|o[0]),t(o)}))}))}function c(n,e=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");{const t=s.randomBytes(n);return e&&(t[0]=128|t[0]),t}}function f(n,e=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const t=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{u(t,!1).then((function(t){if(0!==r&&(t[0]=t[0]&2**r-1),e){const n=0!==r?2**(r-1):128;t[0]=t[0]|n}n(t)}))}))}function a(n,e=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const t=c(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(t[0]=t[0]&2**r-1),e){const n=0!==r?2**(r-1):128;t[0]=t[0]|n}return t}function d(n,e=1n){if(n<=e)throw new RangeError("Arguments MUST be: max > min");const t=n-e,r=exports.bitLength(t);let o;do{o=i(a(r))}while(o>t);return o+e}let p=!1;try{require("worker_threads"),p=!0}catch(r){console.log("[bigint-crypto-utils] WARNING:\nThis node version doesn't support worker_threads. You should enable them in order to greatly speedup the generation of big prime numbers.\n · With Node >=11 it is enabled by default (consider upgrading).\n · With Node 10, starting with 10.5.0, you can enable worker_threads at runtime executing node --experimental-worker ")}function g(n,e){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const t=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let e=0;e= 0");return new Promise(!t&&p?(t,r)=>{const o=new b.Worker(__filename);o.on("message",(n=>{void 0!==n?._bcu?.isPrime&&(o.terminate().catch(r),t(n._bcu.isPrime))})),o.on("error",r);const i={_bcu:{rnd:n,iterations:e,id:0}};o.postMessage(i)}:t=>{t(g(n,e))})},exports.prime=function(n,e=16){if(n<1)throw new RangeError("bitLength MUST be > 0");if(!p){let t=0n;do{t=i(a(n,!0))}while(!g(t,e));return new Promise((n=>{n(t)}))}return new Promise(((t,r)=>{const o=[],s=(r,s)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();t(r._bcu.value)}else{const t=i(a(n,!0));try{const n={_bcu:{rnd:t,iterations:e,id:r._bcu.id}};s.postMessage(n)}catch(n){}}};for(let n=0;ns(e,n))),o.push(n)}for(let t=0;t 0");let t=0n;do{t=i(a(n,!0))}while(!g(t,e));return t},exports.randBetween=d,exports.randBits=f,exports.randBitsSync=a,exports.randBytes=u,exports.randBytesSync=c; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgubm9kZS5janMiLCJzb3VyY2VzIjpbIi4uLy4uL25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VCLEdBQ3ZDLE1BQU1tQyxFQUFNcEMsRUFBV0MsR0FDdkJzRSxFQUFXL0UsR0FBR3NFLFlBQVksQ0FDeEJMLEtBQU0sQ0FDSnJCLE1BQ0FNLGFBQ0FtQixHQUFJckUsSUFHVixJQUFHOEUsTUFBTWpELEVBQ1YsR0FFTCw2QkFhMkJoQixFQUFtQnFDLEVBQXFCLElBQ2pFLEdBQUlyQyxFQUFZLEVBQUcsTUFBTSxJQUFJakIsV0FBVyx5QkFDeEMsSUFBSWdELEVBQU0sR0FDVixHQUNFQSxFQUFNcEMsRUFBV2dDLEVBQWEzQixHQUFXLFdBQ2pDbUMsRUFBaUJKLEVBQUtNLElBQ2hDLE9BQU9OLENBQ1QiLCJ4X2dvb2dsZV9pZ25vcmVMaXN0IjpbMF19 diff --git a/dist/esm/index.browser.js b/dist/esm/index.browser.js deleted file mode 100644 index 75e4e9b..0000000 --- a/dist/esm/index.browser.js +++ /dev/null @@ -1,677 +0,0 @@ -function abs(a) { - return (a >= 0) ? a : -a; -} - -function bitLength(a) { - if (typeof a === 'number') - a = BigInt(a); - if (a === 1n) { - return 1; - } - let bits = 1; - do { - bits++; - } while ((a >>= 1n) > 1n); - return bits; -} - -function eGcd(a, b) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof b === 'number') - b = BigInt(b); - if (a <= 0n || b <= 0n) - throw new RangeError('a and b MUST be > 0'); - let x = 0n; - let y = 1n; - let u = 1n; - let v = 0n; - while (a !== 0n) { - const q = b / a; - const r = b % a; - const m = x - (u * q); - const n = y - (v * q); - b = a; - a = r; - x = u; - y = v; - u = m; - v = n; - } - return { - g: b, - x, - y - }; -} - -function gcd(a, b) { - let aAbs = (typeof a === 'number') ? BigInt(abs(a)) : abs(a); - let bAbs = (typeof b === 'number') ? BigInt(abs(b)) : abs(b); - if (aAbs === 0n) { - return bAbs; - } - else if (bAbs === 0n) { - return aAbs; - } - let shift = 0n; - while (((aAbs | bAbs) & 1n) === 0n) { - aAbs >>= 1n; - bAbs >>= 1n; - shift++; - } - while ((aAbs & 1n) === 0n) - aAbs >>= 1n; - do { - while ((bAbs & 1n) === 0n) - bAbs >>= 1n; - if (aAbs > bAbs) { - const x = aAbs; - aAbs = bAbs; - bAbs = x; - } - bAbs -= aAbs; - } while (bAbs !== 0n); - return aAbs << shift; -} - -function lcm(a, b) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof b === 'number') - b = BigInt(b); - if (a === 0n && b === 0n) - return BigInt(0); - return abs((a / gcd(a, b)) * b); -} - -function max(a, b) { - return (a >= b) ? a : b; -} - -function min(a, b) { - return (a >= b) ? b : a; -} - -function toZn(a, n) { - if (typeof a === 'number') - a = BigInt(a); - if (typeof n === 'number') - n = BigInt(n); - if (n <= 0n) { - throw new RangeError('n must be > 0'); - } - const aZn = a % n; - return (aZn < 0n) ? aZn + n : aZn; -} - -function modInv(a, n) { - const egcd = eGcd(toZn(a, n), n); - if (egcd.g !== 1n) { - throw new RangeError(`${a.toString()} does not have inverse modulo ${n.toString()}`); - } - else { - return toZn(egcd.x, n); - } -} - -function modPow(b, e, n) { - if (typeof b === 'number') - b = BigInt(b); - if (typeof e === 'number') - e = BigInt(e); - if (typeof n === 'number') - n = BigInt(n); - if (n <= 0n) { - throw new RangeError('n must be > 0'); - } - else if (n === 1n) { - return 0n; - } - b = toZn(b, n); - if (e < 0n) { - return modInv(modPow(b, abs(e), n), n); - } - let r = 1n; - while (e > 0) { - if ((e % 2n) === 1n) { - r = r * b % n; - } - e = e / 2n; - b = b ** 2n % n; - } - return r; -} - -function fromBuffer(buf) { - let ret = 0n; - for (const i of buf.values()) { - const bi = BigInt(i); - ret = (ret << 8n) + bi; - } - return ret; -} - -function randBytes(byteLength, forceLength = false) { - if (byteLength < 1) - throw new RangeError('byteLength MUST be > 0'); - return new Promise(function (resolve, reject) { - { - const buf = new Uint8Array(byteLength); - if (byteLength <= 65536) { - self.crypto.getRandomValues(buf); - } - else { - for (let i = 0; i < Math.ceil(byteLength / 65536); i++) { - const begin = i * 65536; - const end = ((begin + 65535) < byteLength) ? begin + 65535 : byteLength - 1; - self.crypto.getRandomValues(buf.subarray(begin, end)); - } - } - if (forceLength) - buf[0] = buf[0] | 128; - resolve(buf); - } - }); -} -function randBytesSync(byteLength, forceLength = false) { - if (byteLength < 1) - throw new RangeError('byteLength MUST be > 0'); - { - const buf = new Uint8Array(byteLength); - if (byteLength <= 65536) { - self.crypto.getRandomValues(buf); - } - else { - for (let i = 0; i < Math.ceil(byteLength / 65536); i++) { - const begin = i * 65536; - const end = ((begin + 65535) < byteLength) ? begin + 65535 : byteLength - 1; - self.crypto.getRandomValues(buf.subarray(begin, end)); - } - } - if (forceLength) - buf[0] = buf[0] | 128; - return buf; - } -} - -function randBits(bitLength, forceLength = false) { - if (bitLength < 1) - throw new RangeError('bitLength MUST be > 0'); - const byteLength = Math.ceil(bitLength / 8); - const bitLengthMod8 = bitLength % 8; - return new Promise((resolve, reject) => { - randBytes(byteLength, false).then(function (rndBytes) { - if (bitLengthMod8 !== 0) { - rndBytes[0] = rndBytes[0] & (2 ** bitLengthMod8 - 1); - } - if (forceLength) { - const mask = (bitLengthMod8 !== 0) ? 2 ** (bitLengthMod8 - 1) : 128; - rndBytes[0] = rndBytes[0] | mask; - } - resolve(rndBytes); - }); - }); -} -function randBitsSync(bitLength, forceLength = false) { - if (bitLength < 1) - throw new RangeError('bitLength MUST be > 0'); - const byteLength = Math.ceil(bitLength / 8); - const rndBytes = randBytesSync(byteLength, false); - const bitLengthMod8 = bitLength % 8; - if (bitLengthMod8 !== 0) { - rndBytes[0] = rndBytes[0] & (2 ** bitLengthMod8 - 1); - } - if (forceLength) { - const mask = (bitLengthMod8 !== 0) ? 2 ** (bitLengthMod8 - 1) : 128; - rndBytes[0] = rndBytes[0] | mask; - } - return rndBytes; -} - -function randBetween(max, min = 1n) { - if (max <= min) - throw new RangeError('Arguments MUST be: max > min'); - const interval = max - min; - const bitLen = bitLength(interval); - let rnd; - do { - const buf = randBitsSync(bitLen); - rnd = fromBuffer(buf); - } while (rnd > interval); - return rnd + min; -} - -function _workerUrl(workerCode) { - workerCode = `(() => {${workerCode}})()`; - const _blob = new Blob([workerCode], { type: 'text/javascript' }); - return window.URL.createObjectURL(_blob); -} -let _useWorkers = false; -{ - if (self.Worker !== undefined) - _useWorkers = true; -} - -function isProbablyPrime(w, iterations = 16, disableWorkers = false) { - if (typeof w === 'number') { - w = BigInt(w); - } - if (w < 0n) - throw RangeError('w MUST be >= 0'); - { - return new Promise((resolve, reject) => { - const worker = new Worker(_isProbablyPrimeWorkerUrl()); - worker.onmessage = (event) => { - if (event?.data?._bcu?.isPrime !== undefined) { - worker.terminate(); - resolve(event.data._bcu.isPrime); - } - }; - worker.onmessageerror = (event) => { - reject(event); - }; - const msg = { - _bcu: { - rnd: w, - iterations, - id: 0 - } - }; - worker.postMessage(msg); - }); - } -} -function _isProbablyPrime(w, iterations) { - if (w === 2n) - return true; - else if ((w & 1n) === 0n || w === 1n) - return false; - const firstPrimes = [ - 3n, - 5n, - 7n, - 11n, - 13n, - 17n, - 19n, - 23n, - 29n, - 31n, - 37n, - 41n, - 43n, - 47n, - 53n, - 59n, - 61n, - 67n, - 71n, - 73n, - 79n, - 83n, - 89n, - 97n, - 101n, - 103n, - 107n, - 109n, - 113n, - 127n, - 131n, - 137n, - 139n, - 149n, - 151n, - 157n, - 163n, - 167n, - 173n, - 179n, - 181n, - 191n, - 193n, - 197n, - 199n, - 211n, - 223n, - 227n, - 229n, - 233n, - 239n, - 241n, - 251n, - 257n, - 263n, - 269n, - 271n, - 277n, - 281n, - 283n, - 293n, - 307n, - 311n, - 313n, - 317n, - 331n, - 337n, - 347n, - 349n, - 353n, - 359n, - 367n, - 373n, - 379n, - 383n, - 389n, - 397n, - 401n, - 409n, - 419n, - 421n, - 431n, - 433n, - 439n, - 443n, - 449n, - 457n, - 461n, - 463n, - 467n, - 479n, - 487n, - 491n, - 499n, - 503n, - 509n, - 521n, - 523n, - 541n, - 547n, - 557n, - 563n, - 569n, - 571n, - 577n, - 587n, - 593n, - 599n, - 601n, - 607n, - 613n, - 617n, - 619n, - 631n, - 641n, - 643n, - 647n, - 653n, - 659n, - 661n, - 673n, - 677n, - 683n, - 691n, - 701n, - 709n, - 719n, - 727n, - 733n, - 739n, - 743n, - 751n, - 757n, - 761n, - 769n, - 773n, - 787n, - 797n, - 809n, - 811n, - 821n, - 823n, - 827n, - 829n, - 839n, - 853n, - 857n, - 859n, - 863n, - 877n, - 881n, - 883n, - 887n, - 907n, - 911n, - 919n, - 929n, - 937n, - 941n, - 947n, - 953n, - 967n, - 971n, - 977n, - 983n, - 991n, - 997n, - 1009n, - 1013n, - 1019n, - 1021n, - 1031n, - 1033n, - 1039n, - 1049n, - 1051n, - 1061n, - 1063n, - 1069n, - 1087n, - 1091n, - 1093n, - 1097n, - 1103n, - 1109n, - 1117n, - 1123n, - 1129n, - 1151n, - 1153n, - 1163n, - 1171n, - 1181n, - 1187n, - 1193n, - 1201n, - 1213n, - 1217n, - 1223n, - 1229n, - 1231n, - 1237n, - 1249n, - 1259n, - 1277n, - 1279n, - 1283n, - 1289n, - 1291n, - 1297n, - 1301n, - 1303n, - 1307n, - 1319n, - 1321n, - 1327n, - 1361n, - 1367n, - 1373n, - 1381n, - 1399n, - 1409n, - 1423n, - 1427n, - 1429n, - 1433n, - 1439n, - 1447n, - 1451n, - 1453n, - 1459n, - 1471n, - 1481n, - 1483n, - 1487n, - 1489n, - 1493n, - 1499n, - 1511n, - 1523n, - 1531n, - 1543n, - 1549n, - 1553n, - 1559n, - 1567n, - 1571n, - 1579n, - 1583n, - 1597n - ]; - for (let i = 0; i < firstPrimes.length && (firstPrimes[i] <= w); i++) { - const p = firstPrimes[i]; - if (w === p) - return true; - else if (w % p === 0n) - return false; - } - let a = 0n; - const d = w - 1n; - let aux = d; - while (aux % 2n === 0n) { - aux /= 2n; - ++a; - } - const m = d / (2n ** a); - do { - const b = randBetween(d, 2n); - let z = modPow(b, m, w); - if (z === 1n || z === d) - continue; - let j = 1; - while (j < a) { - z = modPow(z, 2n, w); - if (z === d) - break; - if (z === 1n) - return false; - j++; - } - if (z !== d) - return false; - } while (--iterations !== 0); - return true; -} -function _isProbablyPrimeWorkerUrl() { - let workerCode = ` - 'use strict'; - const ${eGcd.name} = ${eGcd.toString()}; - const ${modInv.name} = ${modInv.toString()}; - const ${modPow.name} = ${modPow.toString()}; - const ${toZn.name} = ${toZn.toString()}; - const ${randBitsSync.name} = ${randBitsSync.toString()}; - const ${randBytesSync.name} = ${randBytesSync.toString()}; - const ${randBetween.name} = ${randBetween.toString()}; - const ${isProbablyPrime.name} = ${_isProbablyPrime.toString()}; - ${bitLength.toString()}; - ${fromBuffer.toString()};`; - workerCode += ` - onmessage = async function(msg) { - if (msg !== undefined && msg.data !== undefined && msg.data._bcu !== undefined && msg.data._bcu.id !== undefined && msg.data._bcu.iterations !== undefined && msg.data._bcu.rnd !== undefined) { - const msgToParent = { - _bcu: { - isPrime: await ${isProbablyPrime.name}(msg.data._bcu.rnd, msg.data._bcu.iterations), - value: msg.data._bcu.rnd, - id: msg.data._bcu.id - } - }; - postMessage(msgToParent); - } - }`; - return _workerUrl(workerCode); -} - -function prime(bitLength, iterations = 16) { - if (bitLength < 1) - throw new RangeError('bitLength MUST be > 0'); - if (!_useWorkers) { - let rnd = 0n; - do { - rnd = fromBuffer(randBitsSync(bitLength, true)); - } while (!_isProbablyPrime(rnd, iterations)); - return new Promise((resolve) => { resolve(rnd); }); - } - return new Promise((resolve, reject) => { - const workerList = []; - const _onmessage = (msg, newWorker) => { - if (msg._bcu.isPrime) { - for (let j = 0; j < workerList.length; j++) { - workerList[j].terminate(); - } - while (workerList.length > 0) { - workerList.pop(); - } - resolve(msg._bcu.value); - } - else { - const buf = randBitsSync(bitLength, true); - const rnd = fromBuffer(buf); - try { - const msgToWorker = { - _bcu: { - rnd, - iterations, - id: msg._bcu.id - } - }; - newWorker.postMessage(msgToWorker); - } - catch (error) { - } - } - }; - { - const workerURL = _isProbablyPrimeWorkerUrl(); - for (let i = 0; i < self.navigator.hardwareConcurrency - 1; i++) { - const newWorker = new Worker(workerURL); - newWorker.onmessage = (event) => _onmessage(event.data, newWorker); - workerList.push(newWorker); - } - } - for (let i = 0; i < workerList.length; i++) { - randBits(bitLength, true).then(function (buf) { - const rnd = fromBuffer(buf); - workerList[i].postMessage({ - _bcu: { - rnd, - iterations, - id: i - } - }); - }).catch(reject); - } - }); -} -function primeSync(bitLength, iterations = 16) { - if (bitLength < 1) - throw new RangeError('bitLength MUST be > 0'); - let rnd = 0n; - do { - rnd = fromBuffer(randBitsSync(bitLength, true)); - } while (!_isProbablyPrime(rnd, iterations)); - return rnd; -} - -export { abs, bitLength, eGcd, gcd, isProbablyPrime, lcm, max, min, modInv, modPow, prime, primeSync, randBetween, randBits, randBitsSync, randBytes, randBytesSync, toZn }; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguYnJvd3Nlci5qcyIsInNvdXJjZXMiOlsiLi4vLi4vbm9kZV9tb2R1bGVzL2JpZ2ludC1tb2QtYXJpdGgvZGlzdC9lc20vaW5kZXguYnJvd3Nlci5qcyIsIi4uLy4uL3NyYy90cy9mcm9tQnVmZmVyLnRzIiwiLi4vLi4vc3JjL3RzL3JhbmRCeXRlcy50cyIsIi4uLy4uL3NyYy90cy9yYW5kQml0cy50cyIsIi4uLy4uL3NyYy90cy9yYW5kQmV0d2Vlbi50cyIsIi4uLy4uL3NyYy90cy93b3JrZXJVdGlscy50cyIsIi4uLy4uL3NyYy90cy9pc1Byb2JhYmx5UHJpbWUudHMiLCIuLi8uLi9zcmMvdHMvcHJpbWUudHMiXSwic291cmNlc0NvbnRlbnQiOm51bGwsIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFNBQVMsR0FBRyxDQUFDLENBQUMsRUFBRTtBQUNoQixJQUFJLE9BQU8sQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsR0FBRyxDQU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GdCQUFBLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUM7QUFDeEIsb0JBQUEsSUFBSSxFQUFFO3dCQUNKLEdBQUc7d0JBQ0gsVUFBVTtBQUNWLHdCQUFBLEVBQUUsRUFBRSxDQUFDO0FBQ04scUJBQUE7QUFDRixpQkFBQSxDQUFDLENBQUE7QUFDSixhQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUE7QUFDakIsU0FBQTtBQUNILEtBQUMsQ0FBQyxDQUFBO0FBQ0osQ0FBQztTQWFlLFNBQVMsQ0FBRSxTQUFpQixFQUFFLGFBQXFCLEVBQUUsRUFBQTtJQUNuRSxJQUFJLFNBQVMsR0FBRyxDQUFDO0FBQUUsUUFBQSxNQUFNLElBQUksVUFBVSxDQUFDLHVCQUF1QixDQUFDLENBQUE7SUFDaEUsSUFBSSxHQUFHLEdBQUcsRUFBRSxDQUFBO0lBQ1osR0FBRztRQUNELEdBQUcsR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFDLFNBQVMsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFBO0FBQ2hELEtBQUEsUUFBUSxDQUFDLGdCQUFnQixDQUFDLEdBQUcsRUFBRSxVQUFVLENBQUMsRUFBQztBQUM1QyxJQUFBLE9BQU8sR0FBRyxDQUFBO0FBQ1o7Ozs7IiwieF9nb29nbGVfaWdub3JlTGlzdCI6WzBdfQ== diff --git a/dist/esm/index.node.js b/dist/esm/index.node.js deleted file mode 100644 index bf9aea6..0000000 --- a/dist/esm/index.node.js +++ /dev/null @@ -1,2 +0,0 @@ -function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function e(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const u=t/n,s=t%n,a=e-o*u,c=r-i*u;t=n,n=s,e=o,r=i,o=a,i=c}return{g:t,x:e,y:r}}function r(t,e){let r="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof e?BigInt(n(e)):n(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<=t?n:t}function u(n,t){return n>=t?t:n}function s(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const e=n%t;return e<0n?e+t:e}function a(n,t){const r=e(s(n,t),t);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return s(r.x,t)}function c(t,e,r){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(t=s(t,r),e<0n)return a(c(t,n(e),r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*t%r),e/=2n,t=t**2n%r;return o}function f(n){let t=0n;for(const e of n.values()){t=(t<<8n)+BigInt(e)}return t}var g=await import("crypto");function b(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(e,r){g.randomBytes(n,(function(n,o){null!==n&&r(n),t&&(o[0]=128|o[0]),e(o)}))}))}function h(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");{const e=g.randomBytes(n);return t&&(e[0]=128|e[0]),e}}function d(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{b(e,!1).then((function(e){if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}n(e)}))}))}function m(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=h(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}return e}function l(n,e=1n){if(n<=e)throw new RangeError("Arguments MUST be: max > min");const r=n-e,o=t(r);let i;do{i=f(m(o))}while(i>r);return i+e}let w=!1;try{await import("worker_threads"),w=!0}catch(r){console.log("[bigint-crypto-utils] WARNING:\nThis node version doesn't support worker_threads. You should enable them in order to greatly speedup the generation of big prime numbers.\n · With Node >=11 it is enabled by default (consider upgrading).\n · With Node 10, starting with 10.5.0, you can enable worker_threads at runtime executing node --experimental-worker ")}function p(n,t=16,e=!1){if("number"==typeof n&&(n=BigInt(n)),n<0n)throw RangeError("w MUST be >= 0");return new Promise(!e&&w?(e,r)=>{const o=new _.Worker("./dist/esm/index.node.js");o.on("message",(n=>{void 0!==n?._bcu?.isPrime&&(o.terminate().catch(r),e(n._bcu.isPrime))})),o.on("error",r);const i={_bcu:{rnd:n,iterations:t,id:0}};o.postMessage(i)}:e=>{e(y(n,t))})}function y(n,t){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const e=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let t=0;t 0");if(!w){let e=0n;do{e=f(m(n,!0))}while(!y(e,t));return new Promise((n=>{n(e)}))}return new Promise(((e,r)=>{const o=[],i=(r,i)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();e(r._bcu.value)}else{const e=f(m(n,!0));try{const n={_bcu:{rnd:e,iterations:t,id:r._bcu.id}};i.postMessage(n)}catch(n){}}};for(let n=0;ni(t,n))),o.push(n)}for(let e=0;e 0");let e=0n;do{e=f(m(n,!0))}while(!y(e,t));return e}export{n as abs,t as bitLength,e as eGcd,r as gcd,p as isProbablyPrime,o as lcm,i as max,u as min,a as modInv,c as modPow,M as prime,v as primeSync,l as randBetween,d as randBits,m as randBitsSync,b as randBytes,h as randBytesSync,s as toZn}; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgubm9kZS5qcyIsInNvdXJjZXMiOlsiLi4vLi4vbm9kZV9tb2R1bGVzL2JpZ2ludC1tb2QtYXJpdGgvZGlzdC9lc20vaW5kZXgubm9kZS5qcyIsIi4uLy4uL3NyYy90cy9mcm9tQnVmZmVyLnRzIiwiLi4vLi4vc3JjL3RzL3Jhb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dvb2dsZV9pZ25vcmVMaXN0IjpbMF19 diff --git a/dist/index.browser.esm.js b/dist/index.browser.esm.js new file mode 100644 index 0000000..2a06841 --- /dev/null +++ b/dist/index.browser.esm.js @@ -0,0 +1,2 @@ +function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function e(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const s=t/n,u=t%n,a=e-o*s,c=r-i*s;t=n,n=u,e=o,r=i,o=a,i=c}return{g:t,x:e,y:r}}function r(t,e){let r="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof e?BigInt(n(e)):n(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<=t?n:t}function s(n,t){return n>=t?t:n}function u(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const e=n%t;return e<0n?e+t:e}function a(n,t){const r=e(u(n,t),t);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return u(r.x,t)}function c(t,e,r){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(t=u(t,r),e<0n)return a(c(t,n(e),r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*t%r),e/=2n,t=t**2n%r;return o}function f(n){let t=0n;for(const e of n.values()){t=(t<<8n)+BigInt(e)}return t}function g(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(e,r){{const r=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(r);else for(let t=0;t 0");{const e=new Uint8Array(n);if(n<=65536)self.crypto.getRandomValues(e);else for(let t=0;t 0");const e=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{g(e,!1).then((function(e){if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}n(e)}))}))}function b(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=m(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}return e}function l(n,e=1n){if(n<=e)throw new RangeError("Arguments MUST be: max > min");const r=n-e,o=t(r);let i;do{i=f(b(o))}while(i>r);return i+e}let w=!1;function h(n,t=16,e=!1){if("number"==typeof n&&(n=BigInt(n)),n<0n)throw RangeError("w MUST be >= 0");return new Promise(((e,r)=>{const o=new Worker(p());o.onmessage=n=>{void 0!==n?.data?._bcu?.isPrime&&(o.terminate(),e(n.data._bcu.isPrime))},o.onmessageerror=n=>{r(n)};const i={_bcu:{rnd:n,iterations:t,id:0}};o.postMessage(i)}))}function y(n,t){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const e=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let t=0;t {${n}})()`;const t=new Blob([n],{type:"text/javascript"});return window.URL.createObjectURL(t)}(n)}function $(n,t=16){if(n<1)throw new RangeError("bitLength MUST be > 0");if(!w){let e=0n;do{e=f(b(n,!0))}while(!y(e,t));return new Promise((n=>{n(e)}))}return new Promise(((e,r)=>{const o=[],i=(r,i)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();e(r._bcu.value)}else{const e=f(b(n,!0));try{const n={_bcu:{rnd:e,iterations:t,id:r._bcu.id}};i.postMessage(n)}catch(n){}}};{const n=p();for(let t=0;ti(n.data,t),o.push(t)}}for(let e=0;e 0");let e=0n;do{e=f(b(n,!0))}while(!y(e,t));return e}void 0!==self.Worker&&(w=!0);export{n as abs,t as bitLength,e as eGcd,r as gcd,h as isProbablyPrime,o as lcm,i as max,s as min,a as modInv,c as modPow,$ as prime,S as primeSync,l as randBetween,d as randBits,b as randBitsSync,g as randBytes,m as randBytesSync,u as toZn}; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5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ThCLEVBQ3ZCLENBQUMsTUFBT0MsR0FFUixDQUNGLEdBRWEsQ0FDZCxNQUFNQyxFQUFZM0MsSUFDbEIsSUFBSyxJQUFJL0MsRUFBSSxFQUFHQSxFQUFJa0IsS0FBS3lFLFVBQVVDLG9CQUFzQixFQUFHNUYsSUFBSyxDQUMvRCxNQUFNcUYsRUFBWSxJQUFJdkMsT0FBTzRDLEdBQzdCTCxFQUFVckMsVUFBYUMsR0FBVW1DLEVBQVduQyxFQUFNRSxLQUFNa0MsR0FDeERGLEVBQVdVLEtBQUtSLEVBQ2pCLENBT0YsQ0FDRCxJQUFLLElBQUlyRixFQUFJLEVBQUdBLEVBQUltRixFQUFXdEIsT0FBUTdELElBQ3JDMkIsRUFBU0MsR0FBVyxHQUFNRSxNQUFLLFNBQVV0QixHQUN2QyxNQUFNK0IsRUFBTWhDLEVBQVdDLEdBQ3ZCMkUsRUFBV25GLEdBQUcwRCxZQUFZLENBQ3hCTixLQUFNLENBQ0piLE1BQ0FJLGFBQ0FjLEdBQUl6RCxJQUdWLElBQUc4RixNQUFNOUUsRUFDVixHQUVMLFVBYWdCK0UsRUFBV25FLEVBQW1CZSxFQUFxQixJQUNqRSxHQUFJZixFQUFZLEVBQUcsTUFBTSxJQUFJaEMsV0FBVyx5QkFDeEMsSUFBSTJDLEVBQU0sR0FDVixHQUNFQSxFQUFNaEMsRUFBVzBCLEVBQWFMLEdBQVcsV0FDakMrQixFQUFpQnBCLEVBQUtJLElBQ2hDLE9BQU9KLENBQ1QsTUYvRnNCVyxJQUFoQmhDLEtBQUs0QixTQUFzQk4sR0FBYyIsInhfZ29vZ2xlX2lnbm9yZUxpc3QiOlswXX0= diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..48ea84f --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,40 @@ +/// +declare function abs(a: number | bigint): number | bigint; + +declare function bitLength(a: number | bigint): number; + +interface Egcd { + g: bigint; + x: bigint; + y: bigint; +} +declare function eGcd(a: number | bigint, b: number | bigint): Egcd; + +declare function gcd(a: number | bigint, b: number | bigint): bigint; + +declare function lcm(a: number | bigint, b: number | bigint): bigint; + +declare function max(a: number | bigint, b: number | bigint): number | bigint; + +declare function min(a: number | bigint, b: number | bigint): number | bigint; + +declare function modInv(a: number | bigint, n: number | bigint): bigint; + +declare function modPow(b: number | bigint, e: number | bigint, n: number | bigint): bigint; + +declare function toZn(a: number | bigint, n: number | bigint): bigint; + +declare function isProbablyPrime(w: number | bigint, iterations?: number, disableWorkers?: boolean): Promise; + +declare function prime(bitLength: number, iterations?: number): Promise; +declare function primeSync(bitLength: number, iterations?: number): bigint; + +declare function randBetween(max: bigint, min?: bigint): bigint; + +declare function randBits(bitLength: number, forceLength?: boolean): Promise; +declare function randBitsSync(bitLength: number, forceLength?: boolean): Uint8Array | Buffer; + +declare function randBytes(byteLength: number, forceLength?: boolean): Promise; +declare function randBytesSync(byteLength: number, forceLength?: boolean): Uint8Array | Buffer; + +export { abs, bitLength, eGcd, gcd, isProbablyPrime, lcm, max, min, modInv, modPow, prime, primeSync, randBetween, randBits, randBitsSync, randBytes, randBytesSync, toZn }; diff --git a/dist/index.node.cjs b/dist/index.node.cjs new file mode 100644 index 0000000..90423f0 --- /dev/null +++ b/dist/index.node.cjs @@ -0,0 +1,2 @@ +"use strict";function n(n){return n>=0?n:-n}function e(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let e=1;do{e++}while((n>>=1n)>1n);return e}function t(n,e){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),n<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let t=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const u=e/n,s=e%n,c=t-o*u,f=r-i*u;e=n,n=s,t=o,r=i,o=c,i=f}return{g:e,x:t,y:r}}function r(e,t){let r="number"==typeof e?BigInt(n(e)):n(e),o="number"==typeof t?BigInt(n(t)):n(t);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r< 0");const t=n%e;return t<0n?t+e:t}function i(n,e){const r=t(o(n,e),e);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${e.toString()}`);return o(r.x,e)}function u(e,t,r){if("number"==typeof e&&(e=BigInt(e)),"number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(e=o(e,r),t<0n)return i(u(e,n(t),r),r);let s=1n;for(;t>0;)t%2n===1n&&(s=s*e%r),t/=2n,e=e**2n%r;return s}function s(n){let e=0n;for(const t of n.values()){e=(e<<8n)+BigInt(t)}return e}var c=require("crypto");function f(n,e=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(t,r){c.randomBytes(n,(function(n,o){null!==n&&r(n),e&&(o[0]=128|o[0]),t(o)}))}))}function a(n,e=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");{const t=c.randomBytes(n);return e&&(t[0]=128|t[0]),t}}function g(n,e=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const t=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{f(t,!1).then((function(t){if(0!==r&&(t[0]=t[0]&2**r-1),e){const n=0!==r?2**(r-1):128;t[0]=t[0]|n}n(t)}))}))}function b(n,e=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const t=a(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(t[0]=t[0]&2**r-1),e){const n=0!==r?2**(r-1):128;t[0]=t[0]|n}return t}function h(n,t=1n){if(n<=t)throw new RangeError("Arguments MUST be: max > min");const r=n-t,o=e(r);let i;do{i=s(b(o))}while(i>r);return i+t}let l=!1;try{require("worker_threads"),l=!0}catch(r){console.log("[bigint-crypto-utils] WARNING:\nThis node version doesn't support worker_threads. You should enable them in order to greatly speedup the generation of big prime numbers.\n · With Node >=11 it is enabled by default (consider upgrading).\n · With Node 10, starting with 10.5.0, you can enable worker_threads at runtime executing node --experimental-worker ")}function d(n,e){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const t=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let e=0;e= 0");return new Promise(!t&&l?(t,r)=>{const o=new p.Worker(__filename);o.on("message",(n=>{void 0!==n?._bcu?.isPrime&&(o.terminate().catch(r),t(n._bcu.isPrime))})),o.on("error",r);const i={_bcu:{rnd:n,iterations:e,id:0}};o.postMessage(i)}:t=>{t(d(n,e))})},exports.lcm=function(e,t){return"number"==typeof e&&(e=BigInt(e)),"number"==typeof t&&(t=BigInt(t)),0n===e&&0n===t?BigInt(0):n(e/r(e,t)*t)},exports.max=function(n,e){return n>=e?n:e},exports.min=function(n,e){return n>=e?e:n},exports.modInv=i,exports.modPow=u,exports.prime=function(n,e=16){if(n<1)throw new RangeError("bitLength MUST be > 0");if(!l){let t=0n;do{t=s(b(n,!0))}while(!d(t,e));return new Promise((n=>{n(t)}))}return new Promise(((t,r)=>{const o=[],i=(r,i)=>{if(r._bcu.isPrime){for(let n=0;n0;)o.pop();t(r._bcu.value)}else{const t=s(b(n,!0));try{const n={_bcu:{rnd:t,iterations:e,id:r._bcu.id}};i.postMessage(n)}catch(n){}}};for(let n=0;ni(e,n))),o.push(n)}for(let t=0;t 0");let t=0n;do{t=s(b(n,!0))}while(!d(t,e));return t},exports.randBetween=h,exports.randBits=g,exports.randBitsSync=b,exports.randBytes=f,exports.randBytesSync=a,exports.toZn=o; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgubm9kZS5janMiLCJzb3VyY2VzIjpbIi4uL25vZGVfbW9kdWxlcy9iaWdpbnQtbW9kLWFyaXRoL2Rpc3QvaW5kZXgubm9kZS5lc20uanMiLCIuLi9zcmMvdHMvZnJvbUJ1ZmZlci50cyIsIi4uL3NyYy90cy9yYW5kQnl0ZXMudHMiLCIuLi9zcmMvdHMvcmFuZEJpdHMudHMiLCIuLi9zcmMvdHMvcmFuZEJldHdlZW4udHMiLCIuLi9zcmMvdHMvd29ya2VyVXRpbHMudHMiLCIuLi9zcmMvdHMvaXNQcm9iYWJseVByaW1lLnRzIiwiLi4vc3JjL3RzL3ByaW1lLnRzIl0sInNvdXJjZXNDb250ZW50Ijp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ixDQUFDLE1BQU9aLEdBRVIsQ0FDRixHQVVELElBQUssSUFBSWhFLEVBQUksRUFBR0EsRUFBSWlFLEVBQUdZLE9BQU9qQyxPQUFTLEVBQUc1QyxJQUFLLENBQzdDLE1BQU0wRSxFQUFZLElBQUlyQixFQUFjZSxPQUFPQyxZQUMzQ0ssRUFBVW5CLEdBQUcsV0FBWUksR0FBeUJjLEVBQVdkLEVBQUtlLEtBQ2xFRixFQUFXTSxLQUFLSixFQUNqQixDQUVILElBQUssSUFBSTFFLEVBQUksRUFBR0EsRUFBSXdFLEVBQVc1QixPQUFRNUMsSUFDckNzQixFQUFTQyxHQUFXLEdBQU1JLE1BQUssU0FBVW5CLEdBQ3ZDLE1BQU00QixFQUFNN0IsRUFBV0MsR0FDdkJnRSxFQUFXeEUsR0FBRytELFlBQVksQ0FDeEJMLEtBQU0sQ0FDSnRCLE1BQ0FNLGFBQ0FvQixHQUFJOUQsSUFHVixJQUFHdUUsTUFBTXJELEVBQ1YsR0FFTCw2QkFhMkJLLEVBQW1CbUIsRUFBcUIsSUFDakUsR0FBSW5CLEVBQVksRUFBRyxNQUFNLElBQUkzQixXQUFXLHlCQUN4QyxJQUFJd0MsRUFBTSxHQUNWLEdBQ0VBLEVBQU03QixFQUFXdUIsRUFBYVAsR0FBVyxXQUNqQ2lCLEVBQWlCSixFQUFLTSxJQUNoQyxPQUFPTixDQUNUIiwieF9nb29nbGVfaWdub3JlTGlzdCI6WzBdfQ== diff --git a/dist/index.node.esm.js b/dist/index.node.esm.js new file mode 100644 index 0000000..15aaa51 --- /dev/null +++ b/dist/index.node.esm.js @@ -0,0 +1,2 @@ +import{fileURLToPath as n}from"url";function t(n){return n>=0?n:-n}function e(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function r(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const u=t/n,s=t%n,a=e-o*u,c=r-i*u;t=n,n=s,e=o,r=i,o=a,i=c}return{g:t,x:e,y:r}}function o(n,e){let r="number"==typeof n?BigInt(t(n)):t(n),o="number"==typeof e?BigInt(t(e)):t(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<=t?n:t}function s(n,t){return n>=t?t:n}function a(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const e=n%t;return e<0n?e+t:e}function c(n,t){const e=r(a(n,t),t);if(1n!==e.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return a(e.x,t)}function f(n,e,r){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(1n===r)return 0n;if(n=a(n,r),e<0n)return c(f(n,t(e),r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*n%r),e/=2n,n=n**2n%r;return o}function g(n){let t=0n;for(const e of n.values()){t=(t<<8n)+BigInt(e)}return t}var m=await import("crypto");function b(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");return new Promise((function(e,r){m.randomBytes(n,(function(n,o){null!==n&&r(n),t&&(o[0]=128|o[0]),e(o)}))}))}function h(n,t=!1){if(n<1)throw new RangeError("byteLength MUST be > 0");{const e=m.randomBytes(n);return t&&(e[0]=128|e[0]),e}}function l(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=Math.ceil(n/8),r=n%8;return new Promise(((n,o)=>{b(e,!1).then((function(e){if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}n(e)}))}))}function w(n,t=!1){if(n<1)throw new RangeError("bitLength MUST be > 0");const e=h(Math.ceil(n/8),!1),r=n%8;if(0!==r&&(e[0]=e[0]&2**r-1),t){const n=0!==r?2**(r-1):128;e[0]=e[0]|n}return e}function d(n,t=1n){if(n<=t)throw new RangeError("Arguments MUST be: max > min");const r=n-t,o=e(r);let i;do{i=g(w(o))}while(i>r);return i+t}let p=!1;try{await import("worker_threads"),p=!0}catch(o){console.log("[bigint-crypto-utils] WARNING:\nThis node version doesn't support worker_threads. You should enable them in order to greatly speedup the generation of big prime numbers.\n · With Node >=11 it is enabled by default (consider upgrading).\n · With Node 10, starting with 10.5.0, you can enable worker_threads at runtime executing node --experimental-worker ")}function y(t,e=16,r=!1){if("number"==typeof t&&(t=BigInt(t)),t<0n)throw RangeError("w MUST be >= 0");return new Promise(!r&&p?(r,o)=>{const i=new B.Worker(n(import.meta.url));i.on("message",(n=>{void 0!==n?._bcu?.isPrime&&(i.terminate().catch(o),r(n._bcu.isPrime))})),i.on("error",o);const u={_bcu:{rnd:t,iterations:e,id:0}};i.postMessage(u)}:n=>{n(_(t,e))})}function _(n,t){if(2n===n)return!0;if(0n===(1n&n)||1n===n)return!1;const e=[3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n,1009n,1013n,1019n,1021n,1031n,1033n,1039n,1049n,1051n,1061n,1063n,1069n,1087n,1091n,1093n,1097n,1103n,1109n,1117n,1123n,1129n,1151n,1153n,1163n,1171n,1181n,1187n,1193n,1201n,1213n,1217n,1223n,1229n,1231n,1237n,1249n,1259n,1277n,1279n,1283n,1289n,1291n,1297n,1301n,1303n,1307n,1319n,1321n,1327n,1361n,1367n,1373n,1381n,1399n,1409n,1423n,1427n,1429n,1433n,1439n,1447n,1451n,1453n,1459n,1471n,1481n,1483n,1487n,1489n,1493n,1499n,1511n,1523n,1531n,1543n,1549n,1553n,1559n,1567n,1571n,1579n,1583n,1597n];for(let t=0;t 0");if(!p){let n=0n;do{n=g(w(t,!0))}while(!_(n,e));return new Promise((t=>{t(n)}))}return new Promise(((r,o)=>{const i=[],u=(n,o)=>{if(n._bcu.isPrime){for(let n=0;n0;)i.pop();r(n._bcu.value)}else{const r=g(w(t,!0));try{const t={_bcu:{rnd:r,iterations:e,id:n._bcu.id}};o.postMessage(t)}catch(n){}}};for(let t=0;tu(n,t))),i.push(t)}for(let n=0;n 0");let e=0n;do{e=g(w(n,!0))}while(!_(e,t));return e}export{t as abs,e as bitLength,r as eGcd,o as gcd,y as isProbablyPrime,i as lcm,u as max,s as min,c as modInv,f as modPow,v as prime,R as primeSync,d as randBetween,l as randBits,w as randBitsSync,b as randBytes,h as randBytesSync,a as toZn}; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgubm9kZS5lc20uanMiLCJzb3VyY2VzIjpbIi4uL25vZGVfbW9kdWxlcy9iaWdpbnQtbW9kLWFyaXRoL2Rpc3QvaW5kZXgubm9kZS5lc20uanMiLCIuLi9zcmMvdHMvZnJvbUJ1ZmZlci50cyIsIi4uL3NyYy90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b0MsRUFBaUJ2QixFQUFLTSxJQUNoQyxPQUFPTixDQUNUIiwieF9nb29nbGVfaWdub3JlTGlzdCI6WzBdfQ== diff --git a/docs/API.md b/docs/API.md index c19e172..c8780d3 100644 --- a/docs/API.md +++ b/docs/API.md @@ -41,7 +41,7 @@ #### Defined in -node_modules/bigint-mod-arith/types/abs.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:1 ___ @@ -61,7 +61,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/bitLength.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:3 ___ @@ -82,7 +82,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/egcd.d.ts:6 +node_modules/bigint-mod-arith/dist/index.d.ts:10 ___ @@ -103,7 +103,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/gcd.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:12 ___ @@ -134,7 +134,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe #### Defined in -[src/ts/isProbablyPrime.ts:20](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/isProbablyPrime.ts#L20) +[src/ts/isProbablyPrime.ts:20](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/isProbablyPrime.ts#L20) ___ @@ -155,7 +155,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/lcm.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:14 ___ @@ -176,7 +176,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/max.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:16 ___ @@ -197,7 +197,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/min.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:18 ___ @@ -218,7 +218,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/modInv.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:20 ___ @@ -240,7 +240,7 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/modPow.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:22 ___ @@ -273,7 +273,7 @@ A promise that resolves to a bigint probable prime of bitLength bits. #### Defined in -[src/ts/prime.ts:28](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/prime.ts#L28) +[src/ts/prime.ts:28](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/prime.ts#L28) ___ @@ -303,7 +303,7 @@ A bigint probable prime of bitLength bits. #### Defined in -[src/ts/prime.ts:109](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/prime.ts#L109) +[src/ts/prime.ts:109](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/prime.ts#L109) ___ @@ -332,7 +332,7 @@ A cryptographically secure random bigint between [min,max] #### Defined in -[src/ts/randBetween.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/randBetween.ts#L14) +[src/ts/randBetween.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/randBetween.ts#L14) ___ @@ -361,7 +361,7 @@ A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry #### Defined in -[src/ts/randBits.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/randBits.ts#L13) +[src/ts/randBits.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/randBits.ts#L13) ___ @@ -390,7 +390,7 @@ A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando #### Defined in -[src/ts/randBits.ts:43](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/randBits.ts#L43) +[src/ts/randBits.ts:43](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/randBits.ts#L43) ___ @@ -419,7 +419,7 @@ A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry #### Defined in -[src/ts/randBytes.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/randBytes.ts#L13) +[src/ts/randBytes.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/randBytes.ts#L13) ___ @@ -449,7 +449,7 @@ A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando #### Defined in -[src/ts/randBytes.ts:54](https://github.com/juanelas/bigint-crypto-utils/blob/8f2c2a5/src/ts/randBytes.ts#L54) +[src/ts/randBytes.ts:54](https://github.com/juanelas/bigint-crypto-utils/blob/9ebe60d/src/ts/randBytes.ts#L54) ___ @@ -470,4 +470,4 @@ ___ #### Defined in -node_modules/bigint-mod-arith/types/toZn.d.ts:1 +node_modules/bigint-mod-arith/dist/index.d.ts:24 diff --git a/examples/node.esm.js b/examples/node.esm.js index 2eb751d..39a4e60 100644 --- a/examples/node.esm.js +++ b/examples/node.esm.js @@ -1,4 +1,4 @@ -const bigintCryptoUtils = await import('../dist/esm/index.node.js') +import * as bigintCryptoUtils from '#pkg' // const bigintCryptoUtils = require('bigint-crypto-utils') /* A BigInt with value 666 can be declared calling the bigint constructor as diff --git a/package-lock.json b/package-lock.json index f9888ad..8216938 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,6 @@ "name": "bigint-crypto-utils", "version": "3.2.1", "license": "MIT", - "dependencies": { - "bigint-mod-arith": "^3.2.0" - }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-inject": "^5.0.3", @@ -22,18 +19,20 @@ "@rollup/plugin-typescript": "^11.1.0", "@types/chai": "^4.2.22", "@types/mocha": "^10.0.0", + "bigint-mod-arith": "^3.2.1", "c8": "^7.12.0", "chai": "^4.3.3", "dotenv": "^16.0.3", - "glob": "^9.3.4", + "glob": "^10.0.0", "json5": "^2.2.0", - "minimatch": "^8.0.3", + "minimatch": "^9.0.0", "mocha": "^10.0.0", "npm-run-all": "^4.1.5", "pirates": "^4.0.1", "puppeteer": "^19.1.2", - "rimraf": "^4.4.1", + "rimraf": "^5.0.0", "rollup": "^3.20.2", + "rollup-plugin-dts": "^5.3.0", "ts-standard": "^12.0.2", "tslib": "^2.3.1", "typedoc": "~0.23.0", @@ -398,9 +397,9 @@ } }, "node_modules/@puppeteer/browsers": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-0.4.0.tgz", - "integrity": "sha512-3iB5pWn9Sr55PKKwqFWSWjLsTKCOEhKNI+uV3BZesgXuA3IhsX8I3hW0HI+3ksMIPkh2mVYzKSpvgq3oicjG2Q==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-0.4.1.tgz", + "integrity": "sha512-4IICvy1McAkT/HyNZHIs7sp8ngBX1dmO0TPQ+FWq9ATQMqI8p+Ulm5A3kS2wYDh5HDHHkYrrETOu6rlj64VuTw==", "dev": true, "dependencies": { "debug": "4.3.4", @@ -469,9 +468,9 @@ } }, "node_modules/@rollup/plugin-commonjs": { - "version": "24.0.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-24.0.1.tgz", - "integrity": "sha512-15LsiWRZk4eOGqvrJyu3z3DaBu5BhXIMeWnijSRvd8irrrg9SHpQ1pH+BUK4H6Z9wL9yOxZJMTLU+Au86XHxow==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-24.1.0.tgz", + "integrity": "sha512-eSL45hjhCWI0jCCXcNtLVqM5N1JlBGvlFfY0m6oOYnLCJ6N0qEXoZql4sY2MOUArzhH4SA/qBpTxvvZp2Sc+DQ==", "dev": true, "dependencies": { "@rollup/pluginutils": "^5.0.1", @@ -1299,9 +1298,10 @@ ] }, "node_modules/bigint-mod-arith": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.2.0.tgz", - "integrity": "sha512-Khb+sLGLqbe/2NOLVMOpCSgsC3lz8r3VIRZGc41hccudLPnvks7RYZNOnGukQZV8scn5+bA6MABga3Ueq6z3+w==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.2.1.tgz", + "integrity": "sha512-roLlzeQ0okNjT8Ph9zL9Nvw85ucHSQkNndLRfAR2CVaYOEAMtbpIK3f6oJb3Jv/hg9mkrYaw/DknysTuvc8QhA==", + "dev": true, "engines": { "node": ">=10.4.0" } @@ -2977,15 +2977,15 @@ } }, "node_modules/glob": { - "version": "9.3.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", - "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.0.0.tgz", + "integrity": "sha512-zmp9ZDC6NpDNLujV2W2n+3lH+BafIVZ4/ct+Yj3BMZTH/+bgm/eVjHzeFLwxJrrIGgjjS2eiQLlpurHsNlEAtQ==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", - "minimatch": "^8.0.2", - "minipass": "^4.2.4", - "path-scurry": "^1.6.1" + "minimatch": "^9.0.0", + "minipass": "^5.0.0", + "path-scurry": "^1.6.4" }, "engines": { "node": ">=16 || 14 >=14.17" @@ -3988,9 +3988,9 @@ } }, "node_modules/minimatch": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz", - "integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.0.tgz", + "integrity": "sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -4012,9 +4012,9 @@ } }, "node_modules/minipass": { - "version": "4.2.7", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.7.tgz", - "integrity": "sha512-ScVIgqHcXRMyfflqHmEW0bm8z8rb5McHyOY3ewX9JBgZaR77G7nxq9L/mtV96/QbAAwtbCAHVVLzD1kkyfFQEw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "engines": { "node": ">=8" @@ -4686,15 +4686,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/path-scurry/node_modules/minipass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -4926,27 +4917,27 @@ } }, "node_modules/puppeteer": { - "version": "19.8.5", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.8.5.tgz", - "integrity": "sha512-WSjouU7eux6cwBMEz4A7mDRVZWTQQTDXrb1R6AhKDdeEgpiBBkAzcAusPhILxiJOKj60rULZpWuCZ7HZIO6GTA==", + "version": "19.9.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.9.0.tgz", + "integrity": "sha512-JDx8WwGlkdQYTaa3OMYDF+uFWimiwNnacg5FGEC5J6+VxDsLK30wHKU/Db2LqEhtAoIu4RwS+BRH4zRPlCsFpA==", "dev": true, "hasInstallScript": true, "dependencies": { - "@puppeteer/browsers": "0.4.0", + "@puppeteer/browsers": "0.4.1", "cosmiconfig": "8.1.3", "https-proxy-agent": "5.0.1", "progress": "2.0.3", "proxy-from-env": "1.1.0", - "puppeteer-core": "19.8.5" + "puppeteer-core": "19.9.0" } }, "node_modules/puppeteer-core": { - "version": "19.8.5", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.8.5.tgz", - "integrity": "sha512-zoGhim/oBQbkND6h4Xz4X7l5DkWVH9wH7z0mVty5qa/c0P1Yad47t/npVtt2xS10BiQwzztWKx7Pa2nJ5yykdw==", + "version": "19.9.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.9.0.tgz", + "integrity": "sha512-IJYfCE0oFpi5dTvNFqOwo8Dey6zzx7hANy7z6K2bjpCux9oPOSOIubq40awNhaHlfi8soYtgU4qabnzMXB7xBQ==", "dev": true, "dependencies": { - "@puppeteer/browsers": "0.4.0", + "@puppeteer/browsers": "0.4.1", "chromium-bidi": "0.4.6", "cross-fetch": "3.1.5", "debug": "4.3.4", @@ -5132,12 +5123,12 @@ } }, "node_modules/rimraf": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-4.4.1.tgz", - "integrity": "sha512-Gk8NlF062+T9CqNGn6h4tls3k6T1+/nXdOcSZVikNVtlRdYpA7wRJJMoXmuvOnLW844rPjdQ7JgXCYM6PPC/og==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.0.tgz", + "integrity": "sha512-Jf9llaP+RvaEVS5nPShYFhtXIrb3LRKP281ib3So0KkeZKo2wIKyq0Re7TOSwanasA423PSr6CCIL4bP6T040g==", "dev": true, "dependencies": { - "glob": "^9.2.0" + "glob": "^10.0.0" }, "bin": { "rimraf": "dist/cjs/src/bin.js" @@ -5165,6 +5156,40 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-dts": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz", + "integrity": "sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==", + "dev": true, + "dependencies": { + "magic-string": "^0.30.0" + }, + "engines": { + "node": ">=v14" + }, + "funding": { + "url": "https://github.com/sponsors/Swatinem" + }, + "optionalDependencies": { + "@babel/code-frame": "^7.18.6" + }, + "peerDependencies": { + "rollup": "^3.0.0", + "typescript": "^4.1 || ^5.0" + } + }, + "node_modules/rollup-plugin-dts/node_modules/magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index a031259..047ac11 100644 --- a/package.json +++ b/package.json @@ -25,46 +25,50 @@ "node": ">=14.0.0" }, "type": "module", - "main": "./dist/cjs/index.node.cjs", - "types": "./types/index.d.cts", - "browser": "./dist/esm/index.browser.js", - "module": "./dist/esm/index.node.js", + "main": "./dist/index.node.cjs", + "browser": "./dist/index.browser.esm.js", + "types": "./dist/index.d.ts", "exports": { ".": { "node": { - "require": { - "default": "./dist/cjs/index.node.cjs", - "types": "./types/index.d.cts" + "module": { + "types": "./dist/index.d.ts", + "default": "./dist/index.node.esm.js" }, "import": { - "default": "./dist/esm/index.node.js", - "types": "./types/index.d.ts" + "types": "./dist/index.d.ts", + "default": "./dist/index.node.esm.js" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.node.cjs" } }, + "script": "./dist/bundle.iife.js", "default": { - "default": "./dist/esm/index.browser.js", - "types": "./types/index.d.ts" + "types": "./dist/index.d.ts", + "default": "./dist/index.browser.esm.js" } }, - "./esm-browser-bundle": "./dist/bundles/esm.min.js", - "./esm-browser-bundle-nomin": "./dist/bundles/esm.js", - "./iife-browser-bundle": "./dist/bundles/iife.js", - "./umd-browser-bundle": "./dist/bundles/umd.js", - "./types": "./types/index.d.cts" + "./esm-browser-bundle": "./dist/bundle.esm.min.js", + "./esm-browser-bundle-nomin": "./dist/bundle.esm.js", + "./iife-browser-bundle": "./dist/bundle.iife.js", + "./umd-browser-bundle": "./dist/bundle.umd.js", + "./types": "./dist/index.d.ts" }, "imports": { "#pkg": { "require": { - "default": "./dist/cjs/index.node.cjs", - "types": "./types/index.d.cts" + "types": "./dist/index.d.ts", + "default": "./dist/index.node.cjs" }, "import": { - "default": "./dist/esm/index.node.js", - "types": "./types/index.d.ts" + "types": "./dist/index.d.ts", + "default": "./dist/index.node.esm.js" }, "default": { - "default": "./dist/esm/index.browser.js", - "types": "./types/index.d.ts" + "types": "./dist/esm/index.d.ts", + "default": "./dist/index.browser.esm.js" } } }, @@ -80,7 +84,8 @@ "scripts": { "build": "run-s lint:src build:js lint:test docs", "build:js": "rollup -c build/rollup.config.js", - "clean": "rimraf .mocha-ts coverage dist types docs", + "postbuild:js": "rimraf .types", + "clean": "rimraf .mocha-ts coverage dist .types docs", "coverage": "c8 --clean --check-coverage --exclude \"{src/ts/**/*.spec.ts,test,test-vectors,build}\" --exclude-after-remap --reporter=text --reporter=lcov node ./build/bin/mocha-ts.cjs --commonjs ", "docs": "node build/build.docs.cjs", "git:add": "git add -A", @@ -141,25 +146,24 @@ "@rollup/plugin-typescript": "^11.1.0", "@types/chai": "^4.2.22", "@types/mocha": "^10.0.0", + "bigint-mod-arith": "^3.2.1", "c8": "^7.12.0", "chai": "^4.3.3", "dotenv": "^16.0.3", - "glob": "^9.3.4", + "glob": "^10.0.0", "json5": "^2.2.0", - "minimatch": "^8.0.3", + "minimatch": "^9.0.0", "mocha": "^10.0.0", "npm-run-all": "^4.1.5", "pirates": "^4.0.1", "puppeteer": "^19.1.2", - "rimraf": "^4.4.1", + "rimraf": "^5.0.0", "rollup": "^3.20.2", + "rollup-plugin-dts": "^5.3.0", "ts-standard": "^12.0.2", "tslib": "^2.3.1", "typedoc": "~0.23.0", "typedoc-plugin-markdown": "~3.14.0", "typescript": "^5.0.3" - }, - "dependencies": { - "bigint-mod-arith": "^3.2.0" } }