diff --git a/Makefile b/Makefile index 940928f7..c11e3d9b 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ setup: --region us-east-1 awslocal ssm put-parameter \ --name /rss-nostr-lambda/last-run-time \ - --value "2023-11-24T00:00:00Z" \ + --value "2023-11-23T14:46:56Z" \ --overwrite rm handler.zip @@ -25,7 +25,15 @@ invoke: --region us-east-1 \ --function-name rss-nostr-lambda \ --cli-binary-format raw-in-base64-out \ - --payload '{"dryRun":true,"feedUrl":"https://nitter.1d4.us/culturaltutor/rss","nostrNsec":"nsec1wp68lflspznnmelmjh5ktflyv6c4ljf8xrlkey0w8yqr4305awcs8wyakj","lastRunTimeParam":"/rss-nostr-lambda/last-run-time"}' \ + --payload '{"feedUrl":"https://nitter.1d4.us/culturaltutor/rss","nostrNsec":"nsec1eg458xl7d3eywld94rpfx8daa6h2hqfqxylmk43dz6ep8q388e2sfe4thg","lastRunTimeParam":"/rss-nostr-lambda/last-run-time"}' \ + response.json + +invoke-dryrun: + awslocal lambda invoke \ + --region us-east-1 \ + --function-name rss-nostr-lambda \ + --cli-binary-format raw-in-base64-out \ + --payload '{"dryRun":true,"feedUrl":"https://nitter.1d4.us/culturaltutor/rss","nostrNsec":"nsec1eg458xl7d3eywld94rpfx8daa6h2hqfqxylmk43dz6ep8q388e2sfe4thg","lastRunTimeParam":"/rss-nostr-lambda/last-run-time"}' \ response.json recreate: diff --git a/index.mjs b/index.mjs index 96456dc6..c099c3bf 100644 --- a/index.mjs +++ b/index.mjs @@ -13,8 +13,17 @@ const toHexString = nsec => { return s + hex; }, ''); } - +const htmlToAscii = html => { + let ascii = html + ascii = ascii.replaceAll("

", "") + ascii = ascii.replaceAll("

", "") + ascii = ascii.replaceAll("
", "") + ascii = ascii.replaceAll("", "") + return ascii +} + export const handler = async (event) => { const region = process.env.AWS_REGION || "us-east-1" const feed = event.feedUrl @@ -39,87 +48,88 @@ export const handler = async (event) => { const ssmGetCommand = new GetParameterCommand(params); let since = new Date() - ssmClient.send(ssmGetCommand) + await ssmClient.send(ssmGetCommand) .then(data => { - console.log("Using since date:", data.Parameter.Value) since = data.Parameter.Value }).catch(err => { - console.error(err) + console.dir(err) response.errors.push(err) return response }) if (feed === "") { - console.error("feedUrl was not set.") + console.dir("feedUrl was not set.") return { statusCode: 400, body: "feedUrl must be provided in payload." } } - + const ndk = new NDK({ - signer: new NDKPrivateKeySigner(privkey), explicitRelayUrls: [ "wss://nostr.mom", "wss://nostr.snort.social", "wss://nostr.lol" ] }) - const user = await ndk.signer.user() - - for (let url of user.relayUrls) { - ndk.pool.relays.push(url) - } await ndk.connect(6000).catch(err => { - console.error(err) - response.errors.push ("failed to connect to relay", err) + console.dir(err) + response.errors.push("failed to connect to relay", err) }) - let rss = await extract(feed) + const signer = new NDKPrivateKeySigner(privkey) + ndk.signer = signer + + let rss = await extract(feed, { descriptionMaxLen: 0, normalization: false }) .catch(err => { - console.error(err.error); + console.dir(err); return response }) - let filtered = rss.entries.filter(item => moment(item.published).isAfter(since)) + let filtered = rss.item.filter(item => moment(item.published).isAfter(since)) response.totalItems = filtered.length for (let item of filtered) { let ndkEvent = new NDKEvent(ndk, { kind: 1, - pubkey: user.hexpubkey, - content: `${item.description}\n${item.link}`, + pubkey: ndk.signer.user().hexpubkey, + content: htmlToAscii(item.description), created_at: Math.floor(Date.now() / 1000), }) if (dryrun) { + console.dir(ndkEvent) response.successes++ continue } - await ndkEvent.publish() - .then(() => { + try { + await ndkEvent.sign(ndk.signer) + const published = await ndkEvent.publish() + if (published) { response.successes++ - }).catch(err => { - console.error(err) - response.errors.push(err) - }) - } + + params.Name = lastRunTimeParam + params.Value = new Date().toISOString() + params.Type = "String" + params.Overwrite = true - params.Name = lastRunTimeParam - params.Value = new Date().toISOString() - params.Type = "String" - params.Overwrite = true - - const ssmPutCommand = new PutParameterCommand(params) - ssmClient.send(ssmPutCommand) - .catch(err => { - console.error(err) - response.errors.push(err) + const ssmPutCommand = new PutParameterCommand(params) + await ssmClient.send(ssmPutCommand) + .catch(err => { + console.dir(err) + response.errors.push(err) + return response + }) + } + } catch(e) { + console.dir(e) + response.errors.push(e) return response - }) + } + } return response } diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index e8817075..db147405 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -624,6 +624,28 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@noble/curves": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", + "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", + "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/hashes": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", @@ -647,40 +669,23 @@ ] }, "node_modules/@nostr-dev-kit/ndk": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nostr-dev-kit/ndk/-/ndk-2.0.5.tgz", - "integrity": "sha512-EvVr43y+4N9lMSZIIe5V8jFWYlKTVkMyyJfbgRaDGCGiBZAm9iy0wcO2Yi+W57awOAlvr3mjT5fAwG9RDb6HSA==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@nostr-dev-kit/ndk/-/ndk-2.1.1.tgz", + "integrity": "sha512-sMD4re3QVpSVMzoyvJAFiftPxJBXkhjRInrK5DcjhSkkPTlJhI+oiVXCpcvCJ3PHT5PilhDgKkg3LyOvv135UQ==", "dependencies": { "@noble/hashes": "^1.3.1", "@noble/secp256k1": "^2.0.0", "@scure/base": "^1.1.1", "debug": "^4.3.4", - "eventemitter3": "^5.0.1", "light-bolt11-decoder": "^3.0.0", "node-fetch": "^3.3.1", "nostr-tools": "^1.15.0", + "tseep": "^1.1.1", "typescript-lru-cache": "^2.0.0", "utf8-buffer": "^1.0.0", "websocket-polyfill": "^0.0.3" } }, - "node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "node_modules/@scure/base": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", @@ -702,28 +707,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/@scure/bip32/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@scure/bip39": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", @@ -1291,6 +1274,25 @@ "node-fetch": "^2.6.12" } }, + "node_modules/cross-fetch/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -1357,11 +1359,6 @@ "ext": "^1.1.2" } }, - "node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" - }, "node_modules/ext": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", @@ -1505,22 +1502,20 @@ } }, "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/node-gyp-build": { @@ -1554,17 +1549,6 @@ } } }, - "node_modules/nostr-tools/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/nostr-tools/node_modules/@noble/hashes": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", @@ -1597,6 +1581,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/tseep": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tseep/-/tseep-1.1.3.tgz", + "integrity": "sha512-deBIcIlXUMlr3xaN0UEochqjU/zXGaZGPqHPd1rxo4w6DklBdRM6WQQtsk7bekIF+qY6QTeen3nE6OA7BxL9rg==" + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/LICENSE b/node_modules/@noble/curves/LICENSE similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/LICENSE rename to node_modules/@noble/curves/LICENSE diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/README.md b/node_modules/@noble/curves/README.md similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/README.md rename to node_modules/@noble/curves/README.md diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.d.ts b/node_modules/@noble/curves/_shortw_utils.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.d.ts rename to node_modules/@noble/curves/_shortw_utils.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.d.ts.map b/node_modules/@noble/curves/_shortw_utils.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.d.ts.map rename to node_modules/@noble/curves/_shortw_utils.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.js b/node_modules/@noble/curves/_shortw_utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.js rename to node_modules/@noble/curves/_shortw_utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.js.map b/node_modules/@noble/curves/_shortw_utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.js.map rename to node_modules/@noble/curves/_shortw_utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.d.ts b/node_modules/@noble/curves/abstract/bls.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.d.ts rename to node_modules/@noble/curves/abstract/bls.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.d.ts.map b/node_modules/@noble/curves/abstract/bls.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.d.ts.map rename to node_modules/@noble/curves/abstract/bls.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.js b/node_modules/@noble/curves/abstract/bls.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.js rename to node_modules/@noble/curves/abstract/bls.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.js.map b/node_modules/@noble/curves/abstract/bls.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/bls.js.map rename to node_modules/@noble/curves/abstract/bls.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.d.ts b/node_modules/@noble/curves/abstract/curve.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.d.ts rename to node_modules/@noble/curves/abstract/curve.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.d.ts.map b/node_modules/@noble/curves/abstract/curve.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.d.ts.map rename to node_modules/@noble/curves/abstract/curve.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.js b/node_modules/@noble/curves/abstract/curve.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.js rename to node_modules/@noble/curves/abstract/curve.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.js.map b/node_modules/@noble/curves/abstract/curve.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.js.map rename to node_modules/@noble/curves/abstract/curve.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.d.ts b/node_modules/@noble/curves/abstract/edwards.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.d.ts rename to node_modules/@noble/curves/abstract/edwards.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.d.ts.map b/node_modules/@noble/curves/abstract/edwards.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.d.ts.map rename to node_modules/@noble/curves/abstract/edwards.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.js b/node_modules/@noble/curves/abstract/edwards.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.js rename to node_modules/@noble/curves/abstract/edwards.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.js.map b/node_modules/@noble/curves/abstract/edwards.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/edwards.js.map rename to node_modules/@noble/curves/abstract/edwards.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.d.ts b/node_modules/@noble/curves/abstract/hash-to-curve.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.d.ts rename to node_modules/@noble/curves/abstract/hash-to-curve.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map b/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map rename to node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.js b/node_modules/@noble/curves/abstract/hash-to-curve.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.js rename to node_modules/@noble/curves/abstract/hash-to-curve.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.js.map b/node_modules/@noble/curves/abstract/hash-to-curve.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.js.map rename to node_modules/@noble/curves/abstract/hash-to-curve.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.d.ts b/node_modules/@noble/curves/abstract/modular.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.d.ts rename to node_modules/@noble/curves/abstract/modular.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.d.ts.map b/node_modules/@noble/curves/abstract/modular.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.d.ts.map rename to node_modules/@noble/curves/abstract/modular.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.js b/node_modules/@noble/curves/abstract/modular.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.js rename to node_modules/@noble/curves/abstract/modular.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.js.map b/node_modules/@noble/curves/abstract/modular.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.js.map rename to node_modules/@noble/curves/abstract/modular.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.d.ts b/node_modules/@noble/curves/abstract/montgomery.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.d.ts rename to node_modules/@noble/curves/abstract/montgomery.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.d.ts.map b/node_modules/@noble/curves/abstract/montgomery.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.d.ts.map rename to node_modules/@noble/curves/abstract/montgomery.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.js b/node_modules/@noble/curves/abstract/montgomery.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.js rename to node_modules/@noble/curves/abstract/montgomery.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.js.map b/node_modules/@noble/curves/abstract/montgomery.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/montgomery.js.map rename to node_modules/@noble/curves/abstract/montgomery.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.d.ts b/node_modules/@noble/curves/abstract/poseidon.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.d.ts rename to node_modules/@noble/curves/abstract/poseidon.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.d.ts.map b/node_modules/@noble/curves/abstract/poseidon.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.d.ts.map rename to node_modules/@noble/curves/abstract/poseidon.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.js b/node_modules/@noble/curves/abstract/poseidon.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.js rename to node_modules/@noble/curves/abstract/poseidon.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.js.map b/node_modules/@noble/curves/abstract/poseidon.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/poseidon.js.map rename to node_modules/@noble/curves/abstract/poseidon.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.d.ts b/node_modules/@noble/curves/abstract/utils.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.d.ts rename to node_modules/@noble/curves/abstract/utils.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.d.ts.map b/node_modules/@noble/curves/abstract/utils.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.d.ts.map rename to node_modules/@noble/curves/abstract/utils.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.js b/node_modules/@noble/curves/abstract/utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.js rename to node_modules/@noble/curves/abstract/utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.js.map b/node_modules/@noble/curves/abstract/utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.js.map rename to node_modules/@noble/curves/abstract/utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.d.ts b/node_modules/@noble/curves/abstract/weierstrass.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.d.ts rename to node_modules/@noble/curves/abstract/weierstrass.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.d.ts.map b/node_modules/@noble/curves/abstract/weierstrass.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.d.ts.map rename to node_modules/@noble/curves/abstract/weierstrass.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.js b/node_modules/@noble/curves/abstract/weierstrass.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.js rename to node_modules/@noble/curves/abstract/weierstrass.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.js.map b/node_modules/@noble/curves/abstract/weierstrass.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/abstract/weierstrass.js.map rename to node_modules/@noble/curves/abstract/weierstrass.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.d.ts b/node_modules/@noble/curves/bls12-381.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.d.ts rename to node_modules/@noble/curves/bls12-381.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.d.ts.map b/node_modules/@noble/curves/bls12-381.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.d.ts.map rename to node_modules/@noble/curves/bls12-381.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.js b/node_modules/@noble/curves/bls12-381.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.js rename to node_modules/@noble/curves/bls12-381.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.js.map b/node_modules/@noble/curves/bls12-381.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bls12-381.js.map rename to node_modules/@noble/curves/bls12-381.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bn254.d.ts b/node_modules/@noble/curves/bn254.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bn254.d.ts rename to node_modules/@noble/curves/bn254.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bn254.d.ts.map b/node_modules/@noble/curves/bn254.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bn254.d.ts.map rename to node_modules/@noble/curves/bn254.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bn254.js b/node_modules/@noble/curves/bn254.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bn254.js rename to node_modules/@noble/curves/bn254.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/bn254.js.map b/node_modules/@noble/curves/bn254.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/bn254.js.map rename to node_modules/@noble/curves/bn254.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.d.ts b/node_modules/@noble/curves/ed25519.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.d.ts rename to node_modules/@noble/curves/ed25519.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.d.ts.map b/node_modules/@noble/curves/ed25519.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.d.ts.map rename to node_modules/@noble/curves/ed25519.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.js b/node_modules/@noble/curves/ed25519.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.js rename to node_modules/@noble/curves/ed25519.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.js.map b/node_modules/@noble/curves/ed25519.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed25519.js.map rename to node_modules/@noble/curves/ed25519.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed448.d.ts b/node_modules/@noble/curves/ed448.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed448.d.ts rename to node_modules/@noble/curves/ed448.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed448.d.ts.map b/node_modules/@noble/curves/ed448.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed448.d.ts.map rename to node_modules/@noble/curves/ed448.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed448.js b/node_modules/@noble/curves/ed448.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed448.js rename to node_modules/@noble/curves/ed448.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/ed448.js.map b/node_modules/@noble/curves/ed448.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/ed448.js.map rename to node_modules/@noble/curves/ed448.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/_shortw_utils.js b/node_modules/@noble/curves/esm/_shortw_utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/_shortw_utils.js rename to node_modules/@noble/curves/esm/_shortw_utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/_shortw_utils.js.map b/node_modules/@noble/curves/esm/_shortw_utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/_shortw_utils.js.map rename to node_modules/@noble/curves/esm/_shortw_utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/bls.js b/node_modules/@noble/curves/esm/abstract/bls.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/bls.js rename to node_modules/@noble/curves/esm/abstract/bls.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/bls.js.map b/node_modules/@noble/curves/esm/abstract/bls.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/bls.js.map rename to node_modules/@noble/curves/esm/abstract/bls.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/curve.js b/node_modules/@noble/curves/esm/abstract/curve.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/curve.js rename to node_modules/@noble/curves/esm/abstract/curve.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/curve.js.map b/node_modules/@noble/curves/esm/abstract/curve.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/curve.js.map rename to node_modules/@noble/curves/esm/abstract/curve.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/edwards.js b/node_modules/@noble/curves/esm/abstract/edwards.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/edwards.js rename to node_modules/@noble/curves/esm/abstract/edwards.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/edwards.js.map b/node_modules/@noble/curves/esm/abstract/edwards.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/edwards.js.map rename to node_modules/@noble/curves/esm/abstract/edwards.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/hash-to-curve.js b/node_modules/@noble/curves/esm/abstract/hash-to-curve.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/hash-to-curve.js rename to node_modules/@noble/curves/esm/abstract/hash-to-curve.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map b/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map rename to node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/modular.js b/node_modules/@noble/curves/esm/abstract/modular.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/modular.js rename to node_modules/@noble/curves/esm/abstract/modular.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/modular.js.map b/node_modules/@noble/curves/esm/abstract/modular.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/modular.js.map rename to node_modules/@noble/curves/esm/abstract/modular.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/montgomery.js b/node_modules/@noble/curves/esm/abstract/montgomery.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/montgomery.js rename to node_modules/@noble/curves/esm/abstract/montgomery.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/montgomery.js.map b/node_modules/@noble/curves/esm/abstract/montgomery.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/montgomery.js.map rename to node_modules/@noble/curves/esm/abstract/montgomery.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/poseidon.js b/node_modules/@noble/curves/esm/abstract/poseidon.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/poseidon.js rename to node_modules/@noble/curves/esm/abstract/poseidon.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/poseidon.js.map b/node_modules/@noble/curves/esm/abstract/poseidon.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/poseidon.js.map rename to node_modules/@noble/curves/esm/abstract/poseidon.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/utils.js b/node_modules/@noble/curves/esm/abstract/utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/utils.js rename to node_modules/@noble/curves/esm/abstract/utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/utils.js.map b/node_modules/@noble/curves/esm/abstract/utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/utils.js.map rename to node_modules/@noble/curves/esm/abstract/utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/weierstrass.js b/node_modules/@noble/curves/esm/abstract/weierstrass.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/weierstrass.js rename to node_modules/@noble/curves/esm/abstract/weierstrass.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/weierstrass.js.map b/node_modules/@noble/curves/esm/abstract/weierstrass.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/abstract/weierstrass.js.map rename to node_modules/@noble/curves/esm/abstract/weierstrass.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/bls12-381.js b/node_modules/@noble/curves/esm/bls12-381.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/bls12-381.js rename to node_modules/@noble/curves/esm/bls12-381.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/bls12-381.js.map b/node_modules/@noble/curves/esm/bls12-381.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/bls12-381.js.map rename to node_modules/@noble/curves/esm/bls12-381.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/bn254.js b/node_modules/@noble/curves/esm/bn254.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/bn254.js rename to node_modules/@noble/curves/esm/bn254.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/bn254.js.map b/node_modules/@noble/curves/esm/bn254.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/bn254.js.map rename to node_modules/@noble/curves/esm/bn254.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed25519.js b/node_modules/@noble/curves/esm/ed25519.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed25519.js rename to node_modules/@noble/curves/esm/ed25519.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed25519.js.map b/node_modules/@noble/curves/esm/ed25519.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed25519.js.map rename to node_modules/@noble/curves/esm/ed25519.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed448.js b/node_modules/@noble/curves/esm/ed448.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed448.js rename to node_modules/@noble/curves/esm/ed448.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed448.js.map b/node_modules/@noble/curves/esm/ed448.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/ed448.js.map rename to node_modules/@noble/curves/esm/ed448.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/index.js b/node_modules/@noble/curves/esm/index.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/index.js rename to node_modules/@noble/curves/esm/index.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/index.js.map b/node_modules/@noble/curves/esm/index.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/index.js.map rename to node_modules/@noble/curves/esm/index.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/jubjub.js b/node_modules/@noble/curves/esm/jubjub.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/jubjub.js rename to node_modules/@noble/curves/esm/jubjub.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/jubjub.js.map b/node_modules/@noble/curves/esm/jubjub.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/jubjub.js.map rename to node_modules/@noble/curves/esm/jubjub.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p256.js b/node_modules/@noble/curves/esm/p256.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p256.js rename to node_modules/@noble/curves/esm/p256.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p256.js.map b/node_modules/@noble/curves/esm/p256.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p256.js.map rename to node_modules/@noble/curves/esm/p256.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p384.js b/node_modules/@noble/curves/esm/p384.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p384.js rename to node_modules/@noble/curves/esm/p384.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p384.js.map b/node_modules/@noble/curves/esm/p384.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p384.js.map rename to node_modules/@noble/curves/esm/p384.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p521.js b/node_modules/@noble/curves/esm/p521.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p521.js rename to node_modules/@noble/curves/esm/p521.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/p521.js.map b/node_modules/@noble/curves/esm/p521.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/p521.js.map rename to node_modules/@noble/curves/esm/p521.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/package.json b/node_modules/@noble/curves/esm/package.json similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/package.json rename to node_modules/@noble/curves/esm/package.json diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/pasta.js b/node_modules/@noble/curves/esm/pasta.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/pasta.js rename to node_modules/@noble/curves/esm/pasta.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/pasta.js.map b/node_modules/@noble/curves/esm/pasta.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/pasta.js.map rename to node_modules/@noble/curves/esm/pasta.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/secp256k1.js b/node_modules/@noble/curves/esm/secp256k1.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/secp256k1.js rename to node_modules/@noble/curves/esm/secp256k1.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/esm/secp256k1.js.map b/node_modules/@noble/curves/esm/secp256k1.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/esm/secp256k1.js.map rename to node_modules/@noble/curves/esm/secp256k1.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/index.d.ts b/node_modules/@noble/curves/index.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/index.d.ts rename to node_modules/@noble/curves/index.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/index.d.ts.map b/node_modules/@noble/curves/index.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/index.d.ts.map rename to node_modules/@noble/curves/index.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/index.js b/node_modules/@noble/curves/index.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/index.js rename to node_modules/@noble/curves/index.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/index.js.map b/node_modules/@noble/curves/index.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/index.js.map rename to node_modules/@noble/curves/index.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.d.ts b/node_modules/@noble/curves/jubjub.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.d.ts rename to node_modules/@noble/curves/jubjub.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.d.ts.map b/node_modules/@noble/curves/jubjub.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.d.ts.map rename to node_modules/@noble/curves/jubjub.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.js b/node_modules/@noble/curves/jubjub.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.js rename to node_modules/@noble/curves/jubjub.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.js.map b/node_modules/@noble/curves/jubjub.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/jubjub.js.map rename to node_modules/@noble/curves/jubjub.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/LICENSE b/node_modules/@noble/curves/node_modules/@noble/hashes/LICENSE similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/LICENSE rename to node_modules/@noble/curves/node_modules/@noble/hashes/LICENSE diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/README.md b/node_modules/@noble/curves/node_modules/@noble/hashes/README.md similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/README.md rename to node_modules/@noble/curves/node_modules/@noble/hashes/README.md diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/_assert.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/_assert.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.js b/node_modules/@noble/curves/node_modules/@noble/hashes/_assert.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/_assert.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/_assert.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_assert.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/_assert.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_blake2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/_blake2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_sha2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/_u64.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/_u64.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.js b/node_modules/@noble/curves/node_modules/@noble/hashes/_u64.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/_u64.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/_u64.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/_u64.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/_u64.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/argon2.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/argon2.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/argon2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/argon2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/argon2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/argon2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/argon2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.js b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2b.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2b.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.js b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake2s.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake2s.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/blake3.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake3.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.js b/node_modules/@noble/curves/node_modules/@noble/hashes/blake3.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake3.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/blake3.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/blake3.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/blake3.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/crypto.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/crypto.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.js b/node_modules/@noble/curves/node_modules/@noble/hashes/crypto.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/crypto.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/crypto.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/crypto.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/crypto.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.js b/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/cryptoNode.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.js b/node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/eskdf.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/eskdf.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_assert.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_assert.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_assert.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_assert.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_blake2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_blake2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_blake2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_blake2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_blake2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_blake2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_blake2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_blake2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_sha2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_sha2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_sha2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_sha2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_u64.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_u64.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_u64.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/_u64.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/argon2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/argon2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/argon2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/argon2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/argon2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/argon2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/argon2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/argon2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2b.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2b.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2b.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2b.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2b.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2b.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2b.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2b.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2s.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2s.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2s.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2s.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2s.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2s.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake2s.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake2s.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake3.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake3.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake3.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake3.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake3.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake3.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/blake3.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/blake3.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/crypto.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/crypto.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/crypto.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/crypto.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/cryptoNode.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/cryptoNode.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/cryptoNode.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/cryptoNode.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/eskdf.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/eskdf.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/eskdf.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/eskdf.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/eskdf.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/eskdf.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/eskdf.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/eskdf.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hkdf.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hkdf.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hkdf.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/hkdf.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hkdf.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hkdf.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hkdf.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/hkdf.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hmac.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hmac.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hmac.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/hmac.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/index.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/index.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/index.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/index.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/index.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/index.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/index.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/index.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/package.json b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/package.json similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/package.json rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/package.json diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/pbkdf2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/pbkdf2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/pbkdf2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/pbkdf2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/pbkdf2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/pbkdf2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/pbkdf2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/pbkdf2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/ripemd160.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/ripemd160.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/ripemd160.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/ripemd160.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/ripemd160.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/ripemd160.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/ripemd160.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/ripemd160.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/scrypt.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/scrypt.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/scrypt.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/scrypt.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/scrypt.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/scrypt.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/scrypt.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/scrypt.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha1.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha1.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha1.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha1.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha1.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha1.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha1.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha1.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha256.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha256.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha256.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha256.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3-addons.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3-addons.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3-addons.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3-addons.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3-addons.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3-addons.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3-addons.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3-addons.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha3.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha512.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha512.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha512.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha512.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha512.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha512.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/sha512.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha512.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/utils.js b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/utils.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/esm/utils.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/esm/utils.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.js b/node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hkdf.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/hkdf.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/hmac.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/hmac.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.js b/node_modules/@noble/curves/node_modules/@noble/hashes/hmac.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/hmac.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/hmac.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/hmac.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/hmac.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/index.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/index.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/index.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/index.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/index.js b/node_modules/@noble/curves/node_modules/@noble/hashes/index.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/index.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/index.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/index.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/index.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/index.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/index.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/package.json b/node_modules/@noble/curves/node_modules/@noble/hashes/package.json similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/package.json rename to node_modules/@noble/curves/node_modules/@noble/hashes/package.json diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.js b/node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/pbkdf2.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/pbkdf2.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.js b/node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/ripemd160.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/ripemd160.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.js b/node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/scrypt.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/scrypt.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/sha1.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha1.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.js b/node_modules/@noble/curves/node_modules/@noble/hashes/sha1.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha1.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/sha1.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha1.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha1.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/sha256.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha256.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.js b/node_modules/@noble/curves/node_modules/@noble/hashes/sha256.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha256.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/sha256.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha256.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha256.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.js b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3-addons.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3-addons.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.js b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/sha3.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha3.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha3.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/sha512.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha512.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.js b/node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/sha512.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/_assert.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/_assert.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/_assert.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/_assert.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/_blake2.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/_blake2.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/_blake2.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/_blake2.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/_sha2.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/_sha2.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/_sha2.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/_sha2.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/_u64.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/_u64.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/_u64.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/_u64.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/argon2.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/argon2.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/argon2.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/argon2.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake2b.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/blake2b.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake2b.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/blake2b.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake2s.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/blake2s.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake2s.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/blake2s.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake3.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/blake3.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/blake3.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/blake3.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/crypto.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/crypto.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/crypto.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/crypto.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/cryptoNode.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/cryptoNode.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/cryptoNode.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/cryptoNode.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/eskdf.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/eskdf.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/eskdf.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/eskdf.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/hkdf.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/hkdf.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/hkdf.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/hkdf.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/hmac.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/hmac.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/hmac.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/hmac.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/index.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/index.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/index.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/index.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/pbkdf2.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/pbkdf2.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/pbkdf2.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/pbkdf2.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/ripemd160.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/ripemd160.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/ripemd160.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/ripemd160.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/scrypt.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/scrypt.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/scrypt.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/scrypt.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha1.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/sha1.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha1.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/sha1.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha256.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/sha256.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha256.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/sha256.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha3-addons.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/sha3-addons.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha3-addons.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/sha3-addons.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha3.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/sha3.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha3.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/sha3.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha512.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/sha512.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/sha512.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/sha512.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/src/utils.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/src/utils.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/src/utils.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/src/utils.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/utils.d.ts b/node_modules/@noble/curves/node_modules/@noble/hashes/utils.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/utils.d.ts rename to node_modules/@noble/curves/node_modules/@noble/hashes/utils.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/utils.js b/node_modules/@noble/curves/node_modules/@noble/hashes/utils.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/utils.js rename to node_modules/@noble/curves/node_modules/@noble/hashes/utils.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/hashes/utils.js.map b/node_modules/@noble/curves/node_modules/@noble/hashes/utils.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/hashes/utils.js.map rename to node_modules/@noble/curves/node_modules/@noble/hashes/utils.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p256.d.ts b/node_modules/@noble/curves/p256.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p256.d.ts rename to node_modules/@noble/curves/p256.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p256.d.ts.map b/node_modules/@noble/curves/p256.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p256.d.ts.map rename to node_modules/@noble/curves/p256.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p256.js b/node_modules/@noble/curves/p256.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p256.js rename to node_modules/@noble/curves/p256.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p256.js.map b/node_modules/@noble/curves/p256.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p256.js.map rename to node_modules/@noble/curves/p256.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p384.d.ts b/node_modules/@noble/curves/p384.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p384.d.ts rename to node_modules/@noble/curves/p384.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p384.d.ts.map b/node_modules/@noble/curves/p384.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p384.d.ts.map rename to node_modules/@noble/curves/p384.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p384.js b/node_modules/@noble/curves/p384.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p384.js rename to node_modules/@noble/curves/p384.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p384.js.map b/node_modules/@noble/curves/p384.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p384.js.map rename to node_modules/@noble/curves/p384.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p521.d.ts b/node_modules/@noble/curves/p521.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p521.d.ts rename to node_modules/@noble/curves/p521.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p521.d.ts.map b/node_modules/@noble/curves/p521.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p521.d.ts.map rename to node_modules/@noble/curves/p521.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p521.js b/node_modules/@noble/curves/p521.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p521.js rename to node_modules/@noble/curves/p521.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/p521.js.map b/node_modules/@noble/curves/p521.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/p521.js.map rename to node_modules/@noble/curves/p521.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/package.json b/node_modules/@noble/curves/package.json similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/package.json rename to node_modules/@noble/curves/package.json diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/pasta.d.ts b/node_modules/@noble/curves/pasta.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/pasta.d.ts rename to node_modules/@noble/curves/pasta.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/pasta.d.ts.map b/node_modules/@noble/curves/pasta.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/pasta.d.ts.map rename to node_modules/@noble/curves/pasta.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/pasta.js b/node_modules/@noble/curves/pasta.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/pasta.js rename to node_modules/@noble/curves/pasta.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/pasta.js.map b/node_modules/@noble/curves/pasta.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/pasta.js.map rename to node_modules/@noble/curves/pasta.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.d.ts b/node_modules/@noble/curves/secp256k1.d.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.d.ts rename to node_modules/@noble/curves/secp256k1.d.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.d.ts.map b/node_modules/@noble/curves/secp256k1.d.ts.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.d.ts.map rename to node_modules/@noble/curves/secp256k1.d.ts.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.js b/node_modules/@noble/curves/secp256k1.js similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.js rename to node_modules/@noble/curves/secp256k1.js diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.js.map b/node_modules/@noble/curves/secp256k1.js.map similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/secp256k1.js.map rename to node_modules/@noble/curves/secp256k1.js.map diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/_shortw_utils.ts b/node_modules/@noble/curves/src/_shortw_utils.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/_shortw_utils.ts rename to node_modules/@noble/curves/src/_shortw_utils.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/bls.ts b/node_modules/@noble/curves/src/abstract/bls.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/bls.ts rename to node_modules/@noble/curves/src/abstract/bls.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/curve.ts b/node_modules/@noble/curves/src/abstract/curve.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/curve.ts rename to node_modules/@noble/curves/src/abstract/curve.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/edwards.ts b/node_modules/@noble/curves/src/abstract/edwards.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/edwards.ts rename to node_modules/@noble/curves/src/abstract/edwards.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/hash-to-curve.ts b/node_modules/@noble/curves/src/abstract/hash-to-curve.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/hash-to-curve.ts rename to node_modules/@noble/curves/src/abstract/hash-to-curve.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/modular.ts b/node_modules/@noble/curves/src/abstract/modular.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/modular.ts rename to node_modules/@noble/curves/src/abstract/modular.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/montgomery.ts b/node_modules/@noble/curves/src/abstract/montgomery.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/montgomery.ts rename to node_modules/@noble/curves/src/abstract/montgomery.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/poseidon.ts b/node_modules/@noble/curves/src/abstract/poseidon.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/poseidon.ts rename to node_modules/@noble/curves/src/abstract/poseidon.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/utils.ts b/node_modules/@noble/curves/src/abstract/utils.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/utils.ts rename to node_modules/@noble/curves/src/abstract/utils.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/weierstrass.ts b/node_modules/@noble/curves/src/abstract/weierstrass.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/abstract/weierstrass.ts rename to node_modules/@noble/curves/src/abstract/weierstrass.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/bls12-381.ts b/node_modules/@noble/curves/src/bls12-381.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/bls12-381.ts rename to node_modules/@noble/curves/src/bls12-381.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/bn254.ts b/node_modules/@noble/curves/src/bn254.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/bn254.ts rename to node_modules/@noble/curves/src/bn254.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/ed25519.ts b/node_modules/@noble/curves/src/ed25519.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/ed25519.ts rename to node_modules/@noble/curves/src/ed25519.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/ed448.ts b/node_modules/@noble/curves/src/ed448.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/ed448.ts rename to node_modules/@noble/curves/src/ed448.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/index.ts b/node_modules/@noble/curves/src/index.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/index.ts rename to node_modules/@noble/curves/src/index.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/jubjub.ts b/node_modules/@noble/curves/src/jubjub.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/jubjub.ts rename to node_modules/@noble/curves/src/jubjub.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/p256.ts b/node_modules/@noble/curves/src/p256.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/p256.ts rename to node_modules/@noble/curves/src/p256.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/p384.ts b/node_modules/@noble/curves/src/p384.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/p384.ts rename to node_modules/@noble/curves/src/p384.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/p521.ts b/node_modules/@noble/curves/src/p521.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/p521.ts rename to node_modules/@noble/curves/src/p521.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/pasta.ts b/node_modules/@noble/curves/src/pasta.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/pasta.ts rename to node_modules/@noble/curves/src/pasta.ts diff --git a/node_modules/@scure/bip32/node_modules/@noble/curves/src/secp256k1.ts b/node_modules/@noble/curves/src/secp256k1.ts similarity index 100% rename from node_modules/@scure/bip32/node_modules/@noble/curves/src/secp256k1.ts rename to node_modules/@noble/curves/src/secp256k1.ts diff --git a/node_modules/@nostr-dev-kit/ndk/README.md b/node_modules/@nostr-dev-kit/ndk/README.md index fc8db169..3950c741 100644 --- a/node_modules/@nostr-dev-kit/ndk/README.md +++ b/node_modules/@nostr-dev-kit/ndk/README.md @@ -93,12 +93,23 @@ You can pass an object with several options to a newly created instance of NDK. // Import the package import NDK from "@nostr-dev-kit/ndk"; -/ Create a new NDK instance with explicit relays +// Create a new NDK instance with explicit relays const ndk = new NDK({ explicitRelayUrls: ["wss://a.relay", "wss://another.relay"], }); ``` +If the signer implements the `getRelays()` method, NDK will use the relays returned by that method as the explicit relays. + +```ts +// Import the package +import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk"; + +// Create a new NDK instance with just a signer (provided the signer implements the getRelays() method) +const nip07signer = new NDKNip07Signer(); +const ndk = new NDK({ signer: nip07signer }); +``` + Note: In normal client use, it's best practice to instantiate NDK as a singleton class. [See more below](#architecture-decisions--suggestions). ## Connecting diff --git a/node_modules/@nostr-dev-kit/ndk/dist/index.d.ts b/node_modules/@nostr-dev-kit/ndk/dist/index.d.ts index e06e636d..60bba120 100644 --- a/node_modules/@nostr-dev-kit/ndk/dist/index.d.ts +++ b/node_modules/@nostr-dev-kit/ndk/dist/index.d.ts @@ -1,7 +1,8 @@ -import EventEmitter from 'eventemitter3'; +import { EventEmitter } from 'tseep'; import debug$1 from 'debug'; import { LRUCache } from 'typescript-lru-cache'; import { Relay } from 'nostr-tools'; +import EventEmitter$1 from 'eventemitter3'; declare enum NDKKind { Metadata = 0, @@ -13,6 +14,8 @@ declare enum NDKKind { Repost = 6, Reaction = 7, BadgeAward = 8, + GroupNote = 9, + GroupChat = 11, GenericRepost = 16, ChannelCreation = 40, ChannelMetadata = 41, @@ -28,29 +31,44 @@ declare enum NDKKind { DVMReqImageGeneration = 5100, DVMReqDiscoveryNostrContent = 5300, DVMReqDiscoveryNostrPeople = 5301, + DVMReqTimestamping = 5900, DVMJobFeedback = 7000, - ZapRequest = 9734, - Zap = 9735, - Highlight = 9802, MuteList = 10000, PinList = 10001, RelayList = 10002, - ClientAuth = 22242, - NostrConnect = 24133, + BookmarkList = 10003, + CommunityList = 10004, + PublicChatList = 10005, + BlockRelayList = 10006, + SearchRelayList = 10007, + InterestList = 10015, + EmojiList = 10030, + FollowSet = 30000, CategorizedPeopleList = 30000, CategorizedBookmarkList = 30001, + RelaySet = 30002, + CategorizedRelayList = 30002, + BookmarkSet = 30003, + CurationSet = 30004, + InterestSet = 30015, + InterestsList = 30015, + EmojiSet = 30030, + HighlightSet = 39802, + CategorizedHighlightList = 39802, + ZapRequest = 9734, + Zap = 9735, + Highlight = 9802, + ClientAuth = 22242, + NostrConnect = 24133, ProfileBadge = 30008, BadgeDefinition = 30009, - InterestsList = 30015, MarketStall = 30017, MarketProduct = 30018, - CategorizedRelayList = 30022, Article = 30023, AppSpecificData = 30078, Classified = 30402, AppRecommendation = 31989, - AppHandler = 31990, - CategorizedHighlightList = 39802 + AppHandler = 31990 } declare const NDKListKinds: NDKKind[]; @@ -351,6 +369,11 @@ interface NDKSigner { * @returns A promise that resolves to the signature of the signed event. */ sign(event: NostrEvent): Promise; + /** + * Getter for the preferred relays. + * @returns A promise containing a simple map of preferred relays and their read/write policies. + */ + relays?(): Promise; /** * Encrypts the given Nostr event for the given recipient. * @param value - The value to be encrypted. @@ -366,6 +389,16 @@ interface NDKSigner { type Hexpubkey = string; type Npub = string; +type ProfilePointer = { + pubkey: string; + relays?: string[]; +}; +type EventPointer = { + id: string; + relays?: string[]; + author?: string; + kind?: number; +}; interface NDKUserParams { npub?: Npub; hexpubkey?: Hexpubkey; @@ -424,6 +457,10 @@ declare class NDKUser { * Returns a set of users that this user follows. */ follows: (opts?: NDKSubscriptionOptions | undefined, outbox?: boolean | undefined) => Promise>; + /** + * Pins a user or an event + */ + pin: (event: NDKEvent, pinEvent?: NDKEvent | undefined, publish?: boolean | undefined) => Promise; /** * Returns a set of relay list events for a user. * @returns {Promise>} A set of NDKEvents returned for the given user. @@ -440,7 +477,7 @@ declare class NDKUser { * Get the tags that can be used to reference this user in an event * @returns {NDKTag[]} an array of NDKTag */ - referenceTags(): NDKTag[]; + referenceTags(marker?: string): NDKTag[]; /** * Publishes the current profile. */ @@ -457,8 +494,8 @@ declare class NDKUser { * Validate a user's NIP-05 identifier (usually fetched from their kind:0 profile data) * * @param nip05Id The NIP-05 string to validate - * @returns {Promise} True if the NIP-05 is found and matches this user's hexpubkey, - * False if the NIP-05 is found but doesn't match this user's hexpubkey, + * @returns {Promise} True if the NIP-05 is found and matches this user's pubkey, + * False if the NIP-05 is found but doesn't match this user's pubkey, * null if the NIP-05 isn't found on the domain or we're unable to verify (because of network issues, etc.) */ validateNip05(nip05Id: string): Promise; @@ -687,6 +724,10 @@ interface NDKConstructorParams { * Muted pubkeys and eventIds */ mutedIds?: Map; + /** + * Client ID to add to events' tag + */ + client?: string; } interface GetUserParams extends NDKUserParams { npub?: string; @@ -707,6 +748,7 @@ declare class NDK extends EventEmitter { devWriteRelaySet?: NDKRelaySet; outboxTracker?: OutboxTracker; mutedIds: Map; + readonly client?: string; private autoConnectUserRelays; private autoFetchUserMutelist; constructor(opts?: NDKConstructorParams); @@ -850,7 +892,7 @@ declare class NDKEvent extends EventEmitter { * * @returns {string} - Encoded naddr, note or nevent. */ - encode: () => `nevent1${string}` | `naddr1${string}` | `note1${string}`; + encode: () => `naddr1${string}` | `nevent1${string}` | `note1${string}`; encrypt: (recipient?: NDKUser | undefined, signer?: NDKSigner | undefined) => Promise; decrypt: (sender?: NDKUser | undefined, signer?: NDKSigner | undefined) => Promise; /** @@ -918,9 +960,11 @@ declare class NDKEvent extends EventEmitter { * @returns {string} The id */ tagAddress(): string; - /** @deprecated Use referenceTags instead. */ /** - * Get the tag that can be used to reference this event from another event + * Get the tag that can be used to reference this event from another event. + * + * Consider using referenceTags() instead (unless you have a good reason to use this) + * * @example * event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] }); * event.tagReference(); // ["a", "30000:pubkey:d-code"] @@ -929,7 +973,7 @@ declare class NDKEvent extends EventEmitter { * event.tagReference(); // ["e", "eventid"] * @returns {NDKTag} The NDKTag object referencing this event */ - tagReference(): NDKTag; + tagReference(marker?: string): NDKTag; /** * Get the tags that can be used to reference this event from another event * @param marker The marker to use in the tag @@ -941,7 +985,7 @@ declare class NDKEvent extends EventEmitter { * event.referenceTags(); // [["e", "parent-id"]] * @returns {NDKTag} The NDKTag object referencing this event */ - referenceTags(marker?: string): NDKTag[]; + referenceTags(marker?: string, skipAuthorTag?: boolean): NDKTag[]; /** * Provides the filter that will return matching events for this event. * @@ -1339,6 +1383,12 @@ type Nip04QueueItem = { resolve: (value: string) => void; reject: (reason?: Error) => void; }; +type Nip07RelayMap = { + [key: string]: { + read: boolean; + write: boolean; + }; +}; /** * NDKNip07Signer implements the NDKSigner interface for signing Nostr events * with a NIP-07 browser extension (e.g., getalby, nos2x). @@ -1366,6 +1416,7 @@ declare class NDKNip07Signer implements NDKSigner { * @throws Error if the NIP-07 is not available on the window object. */ sign(event: NostrEvent): Promise; + relays(): Promise; encrypt(recipient: NDKUser, value: string): Promise; decrypt(sender: NDKUser, value: string): Promise; private queueNip04; @@ -1379,7 +1430,8 @@ declare global { signEvent(event: NostrEvent): Promise<{ sig: string; }>; - nip04: { + getRelays?: () => Promise; + nip04?: { encrypt(recipientHexPubKey: string, value: string): Promise; decrypt(senderHexPubKey: string, value: string): Promise; }; @@ -1399,62 +1451,6 @@ declare class NDKPrivateKeySigner implements NDKSigner { decrypt(sender: NDKUser, value: string): Promise; } -type Nip46PermitCallback = (pubkey: string, method: string, params?: any) => Promise; -type Nip46ApplyTokenCallback = (pubkey: string, token: string) => Promise; -interface IEventHandlingStrategy { - handle(backend: NDKNip46Backend, remotePubkey: string, params: string[]): Promise; -} -/** - * This class implements a NIP-46 backend, meaning that it will hold a private key - * of the npub that wants to be published as. - * - * This backend is meant to be used by an NDKNip46Signer, which is the class that - * should run client-side, where the user wants to sign events from. - */ -declare class NDKNip46Backend { - readonly ndk: NDK; - readonly signer: NDKPrivateKeySigner; - localUser?: NDKUser; - readonly debug: debug.Debugger; - private rpc; - private permitCallback; - /** - * @param ndk The NDK instance to use - * @param privateKey The private key of the npub that wants to be published as - */ - constructor(ndk: NDK, privateKey: string, permitCallback: Nip46PermitCallback); - /** - * This method starts the backend, which will start listening for incoming - * requests. - */ - start(): Promise; - handlers: { - [method: string]: IEventHandlingStrategy; - }; - /** - * Enables the user to set a custom strategy for handling incoming events. - * @param method - The method to set the strategy for - * @param strategy - The strategy to set - */ - setStrategy(method: string, strategy: IEventHandlingStrategy): void; - /** - * Overload this method to apply tokens, which can - * wrap permission sets to be applied to a pubkey. - * @param pubkey public key to apply token to - * @param token token to apply - */ - applyToken(pubkey: string, token: string): Promise; - protected handleIncomingEvent(event: NDKEvent): Promise; - decrypt(remotePubkey: string, senderUser: NDKUser, payload: string): Promise; - encrypt(remotePubkey: string, recipientUser: NDKUser, payload: string): Promise; - signEvent(remotePubkey: string, params: string[]): Promise; - /** - * This method should be overriden by the user to allow or reject incoming - * connections. - */ - pubkeyAllowed(pubkey: string, method: string, params?: any): Promise; -} - interface NDKRpcRequest { id: string; pubkey: string; @@ -1490,16 +1486,84 @@ declare class NDKNostrRpc extends EventEmitter { sendRequest(remotePubkey: string, method: string, params?: string[], kind?: number, cb?: (res: NDKRpcResponse) => void): Promise; } +type NIP46Method = "connect" | "sign_event" | "encrypt" | "decrypt"; +type Nip46PermitCallbackParams = { + /** + * ID of the request + */ + id: string; + pubkey: string; + method: NIP46Method; + params?: any; +}; +type Nip46PermitCallback = (params: Nip46PermitCallbackParams) => Promise; +type Nip46ApplyTokenCallback = (pubkey: string, token: string) => Promise; +interface IEventHandlingStrategy { + handle(backend: NDKNip46Backend, id: string, remotePubkey: string, params: string[]): Promise; +} +/** + * This class implements a NIP-46 backend, meaning that it will hold a private key + * of the npub that wants to be published as. + * + * This backend is meant to be used by an NDKNip46Signer, which is the class that + * should run client-side, where the user wants to sign events from. + */ +declare class NDKNip46Backend { + readonly ndk: NDK; + readonly signer: NDKPrivateKeySigner; + localUser?: NDKUser; + readonly debug: debug.Debugger; + rpc: NDKNostrRpc; + private permitCallback; + /** + * @param ndk The NDK instance to use + * @param privateKey The private key of the npub that wants to be published as + */ + constructor(ndk: NDK, privateKey: string, permitCallback: Nip46PermitCallback); + /** + * This method starts the backend, which will start listening for incoming + * requests. + */ + start(): Promise; + handlers: { + [method: string]: IEventHandlingStrategy; + }; + /** + * Enables the user to set a custom strategy for handling incoming events. + * @param method - The method to set the strategy for + * @param strategy - The strategy to set + */ + setStrategy(method: string, strategy: IEventHandlingStrategy): void; + /** + * Overload this method to apply tokens, which can + * wrap permission sets to be applied to a pubkey. + * @param pubkey public key to apply token to + * @param token token to apply + */ + applyToken(pubkey: string, token: string): Promise; + protected handleIncomingEvent(event: NDKEvent): Promise; + /** + * This method should be overriden by the user to allow or reject incoming + * connections. + */ + pubkeyAllowed(params: Nip46PermitCallbackParams): Promise; +} + /** * This NDKSigner implements NIP-46, which allows remote signing of events. * This class is meant to be used client-side, paired with the NDKNip46Backend or a NIP-46 backend (like Nostr-Connect) + * + * @emits authUrl -- Emitted when the user should take an action in certain URL. + * When a client receives this event, it should direct the user + * to go to that URL to authorize the application. */ -declare class NDKNip46Signer implements NDKSigner { +declare class NDKNip46Signer extends EventEmitter$1 implements NDKSigner { private ndk; remoteUser: NDKUser; - remotePubkey: string; + remotePubkey: string | undefined; token: string | undefined; localSigner: NDKSigner; + private nip05?; private rpc; private debug; /** @@ -1514,6 +1578,12 @@ declare class NDKNip46Signer implements NDKSigner { * @param localSigner - The signer that will be used to request events to be signed */ constructor(ndk: NDK, remoteNpub: string, localSigner?: NDKSigner); + /** + * @param ndk - The NDK instance to use + * @param remoteNip05 - The nip05 that wants to be published as + * @param localSigner - The signer that will be used to request events to be signed + */ + constructor(ndk: NDK, remoteNip05: string, localSigner?: NDKSigner); /** * @param ndk - The NDK instance to use * @param remotePubkey - The public key of the npub that wants to be published as @@ -1567,4 +1637,4 @@ interface NDKZapInvoice { */ declare function zapInvoiceFromEvent(event: NDKEvent): NDKZapInvoice | null; -export { Hexpubkey, IEventHandlingStrategy, NDKAppHandlerEvent, NDKArticle, NDKCacheAdapter, NDKConstructorParams, NDKDVMJobFeedback, NDKDVMJobResult, NDKDVMRequest, NDKDvmJobFeedbackStatus, NDKDvmParam, NDKEvent, NDKEventId, NDKFilter, NDKFilterGroupingId, NDKHighlight, NDKKind, NDKList, NDKListItem, NDKListKinds, NDKNip07Signer, NDKNip46Backend, NDKNip46Signer, NDKNostrRpc, NDKPrivateKeySigner, NDKRelay, NDKRelayConnectionStats, NDKRelayList, NDKRelaySet, NDKRelayStatus, NDKRelayUrl, NDKRepost, NDKRpcRequest, NDKRpcResponse, NDKSigner, NDKSubscription, NDKSubscriptionCacheUsage, NDKSubscriptionOptions, NDKTag, NDKTranscriptionDVM, NDKUser, NDKUserParams, NDKUserProfile, NDKZapInvoice, Nip46ApplyTokenCallback, Nip46PermitCallback, NostrEvent, Npub, calculateGroupableId, NDK as default, defaultOpts, mergeFilters, profileFromEvent, serializeProfile, zapInvoiceFromEvent }; +export { EventPointer, Hexpubkey, IEventHandlingStrategy, NDKAppHandlerEvent, NDKArticle, NDKCacheAdapter, NDKConstructorParams, NDKDVMJobFeedback, NDKDVMJobResult, NDKDVMRequest, NDKDvmJobFeedbackStatus, NDKDvmParam, NDKEvent, NDKEventId, NDKFilter, NDKFilterGroupingId, NDKHighlight, NDKKind, NDKList, NDKListItem, NDKListKinds, NDKNip07Signer, NDKNip46Backend, NDKNip46Signer, NDKNostrRpc, NDKPrivateKeySigner, NDKRelay, NDKRelayConnectionStats, NDKRelayList, NDKRelaySet, NDKRelayStatus, NDKRelayUrl, NDKRepost, NDKRpcRequest, NDKRpcResponse, NDKSigner, NDKSubscription, NDKSubscriptionCacheUsage, NDKSubscriptionOptions, NDKTag, NDKTranscriptionDVM, NDKUser, NDKUserParams, NDKUserProfile, NDKZapInvoice, NIP46Method, Nip46ApplyTokenCallback, Nip46PermitCallback, Nip46PermitCallbackParams, NostrEvent, Npub, ProfilePointer, calculateGroupableId, NDK as default, defaultOpts, mergeFilters, profileFromEvent, serializeProfile, zapInvoiceFromEvent }; diff --git a/node_modules/@nostr-dev-kit/ndk/dist/index.js b/node_modules/@nostr-dev-kit/ndk/dist/index.js index f7b58737..5f2c3130 100644 --- a/node_modules/@nostr-dev-kit/ndk/dist/index.js +++ b/node_modules/@nostr-dev-kit/ndk/dist/index.js @@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); @@ -27,6 +30,188 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +// ../node_modules/eventemitter3/index.js +var require_eventemitter3 = __commonJS({ + "../node_modules/eventemitter3/index.js"(exports, module2) { + "use strict"; + var has = Object.prototype.hasOwnProperty; + var prefix = "~"; + function Events() { + } + if (Object.create) { + Events.prototype = /* @__PURE__ */ Object.create(null); + if (!new Events().__proto__) + prefix = false; + } + function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; + } + function addListener(emitter, event, fn, context, once) { + if (typeof fn !== "function") { + throw new TypeError("The listener must be a function"); + } + var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; + if (!emitter._events[evt]) + emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) + emitter._events[evt].push(listener); + else + emitter._events[evt] = [emitter._events[evt], listener]; + return emitter; + } + function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) + emitter._events = new Events(); + else + delete emitter._events[evt]; + } + function EventEmitter11() { + this._events = new Events(); + this._eventsCount = 0; + } + EventEmitter11.prototype.eventNames = function eventNames() { + var names = [], events, name; + if (this._eventsCount === 0) + return names; + for (name in events = this._events) { + if (has.call(events, name)) + names.push(prefix ? name.slice(1) : name); + } + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + return names; + }; + EventEmitter11.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event, handlers = this._events[evt]; + if (!handlers) + return []; + if (handlers.fn) + return [handlers.fn]; + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + return ee; + }; + EventEmitter11.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event, listeners = this._events[evt]; + if (!listeners) + return 0; + if (listeners.fn) + return 1; + return listeners.length; + }; + EventEmitter11.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return false; + var listeners = this._events[evt], len = arguments.length, args, i; + if (listeners.fn) { + if (listeners.once) + this.removeListener(event, listeners.fn, void 0, true); + switch (len) { + case 1: + return listeners.fn.call(listeners.context), true; + case 2: + return listeners.fn.call(listeners.context, a1), true; + case 3: + return listeners.fn.call(listeners.context, a1, a2), true; + case 4: + return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: + return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: + return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + for (i = 1, args = new Array(len - 1); i < len; i++) { + args[i - 1] = arguments[i]; + } + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length, j; + for (i = 0; i < length; i++) { + if (listeners[i].once) + this.removeListener(event, listeners[i].fn, void 0, true); + switch (len) { + case 1: + listeners[i].fn.call(listeners[i].context); + break; + case 2: + listeners[i].fn.call(listeners[i].context, a1); + break; + case 3: + listeners[i].fn.call(listeners[i].context, a1, a2); + break; + case 4: + listeners[i].fn.call(listeners[i].context, a1, a2, a3); + break; + default: + if (!args) + for (j = 1, args = new Array(len - 1); j < len; j++) { + args[j - 1] = arguments[j]; + } + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + return true; + }; + EventEmitter11.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); + }; + EventEmitter11.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); + }; + EventEmitter11.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + var listeners = this._events[evt]; + if (listeners.fn) { + if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { + events.push(listeners[i]); + } + } + if (events.length) + this._events[evt] = events.length === 1 ? events[0] : events; + else + clearEvent(this, evt); + } + return this; + }; + EventEmitter11.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) + clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + return this; + }; + EventEmitter11.prototype.off = EventEmitter11.prototype.removeListener; + EventEmitter11.prototype.addListener = EventEmitter11.prototype.on; + EventEmitter11.prefixed = prefix; + EventEmitter11.EventEmitter = EventEmitter11; + if ("undefined" !== typeof module2) { + module2.exports = EventEmitter11; + } + } +}); + // src/index.ts var src_exports = {}; __export(src_exports, { @@ -69,12 +254,12 @@ module.exports = __toCommonJS(src_exports); var import_nostr_tools8 = require("nostr-tools"); // src/events/index.ts -var import_eventemitter34 = __toESM(require("eventemitter3")); +var import_tseep4 = require("tseep"); var import_nostr_tools7 = require("nostr-tools"); // src/relay/index.ts var import_debug = __toESM(require("debug")); -var import_eventemitter32 = __toESM(require("eventemitter3")); +var import_tseep2 = require("tseep"); // src/relay/connectivity.ts var import_nostr_tools = require("nostr-tools"); @@ -293,7 +478,7 @@ var NDKRelayPublisher = class { }; // src/relay/subscriptions.ts -var import_eventemitter3 = __toESM(require("eventemitter3")); +var import_tseep = require("tseep"); var import_nostr_tools3 = require("nostr-tools"); // src/subscription/grouping.ts @@ -444,7 +629,7 @@ function relaysFromBech32(bech322) { } // src/relay/subscriptions.ts -var NDKGroupedSubscriptions = class extends import_eventemitter3.default { +var NDKGroupedSubscriptions = class extends import_tseep.EventEmitter { subscriptions; req; debug; @@ -729,7 +914,7 @@ var NDKRelayStatus = /* @__PURE__ */ ((NDKRelayStatus2) => { NDKRelayStatus2[NDKRelayStatus2["FLAPPING"] = 5] = "FLAPPING"; return NDKRelayStatus2; })(NDKRelayStatus || {}); -var NDKRelay = class extends import_eventemitter32.default { +var NDKRelay = class extends import_tseep2.EventEmitter { url; scores; connectivity; @@ -954,7 +1139,7 @@ function calculateRelaySetsFromFilters(ndk, filters) { // src/zap/index.ts var import_base = require("@scure/base"); -var import_eventemitter33 = __toESM(require("eventemitter3")); +var import_tseep3 = require("tseep"); var import_nostr_tools4 = require("nostr-tools"); var DEFAULT_RELAYS = [ "wss://nos.lol", @@ -964,7 +1149,7 @@ var DEFAULT_RELAYS = [ "wss://nostr.mom", "wss://no.str.cr" ]; -var Zap = class extends import_eventemitter33.default { +var Zap = class extends import_tseep3.EventEmitter { ndk; zappedEvent; zappedUser; @@ -1065,6 +1250,26 @@ var Zap = class extends import_eventemitter33.default { // src/events/content-tagger.ts var import_nostr_tools5 = require("nostr-tools"); +function mergeTags(tags1, tags2) { + const tagMap = /* @__PURE__ */ new Map(); + const generateKey = (tag) => tag.join(","); + const isContained = (smaller, larger) => { + return smaller.every((value, index) => value === larger[index]); + }; + const processTag = (tag) => { + for (let [key, existingTag] of tagMap) { + if (isContained(existingTag, tag) || isContained(tag, existingTag)) { + if (tag.length >= existingTag.length) { + tagMap.set(key, tag); + } + return; + } + } + tagMap.set(generateKey(tag), tag); + }; + tags1.concat(tags2).forEach(processTag); + return Array.from(tagMap.values()); +} async function generateContentTags(content, tags = []) { const tagRegex = /(@|nostr:)(npub|nprofile|note|nevent|naddr)[a-zA-Z0-9]+/g; const hashtagRegex = /#(\w+)/g; @@ -1179,6 +1384,8 @@ var NDKKind = /* @__PURE__ */ ((NDKKind2) => { NDKKind2[NDKKind2["Repost"] = 6] = "Repost"; NDKKind2[NDKKind2["Reaction"] = 7] = "Reaction"; NDKKind2[NDKKind2["BadgeAward"] = 8] = "BadgeAward"; + NDKKind2[NDKKind2["GroupNote"] = 9] = "GroupNote"; + NDKKind2[NDKKind2["GroupChat"] = 11] = "GroupChat"; NDKKind2[NDKKind2["GenericRepost"] = 16] = "GenericRepost"; NDKKind2[NDKKind2["ChannelCreation"] = 40] = "ChannelCreation"; NDKKind2[NDKKind2["ChannelMetadata"] = 41] = "ChannelMetadata"; @@ -1194,37 +1401,66 @@ var NDKKind = /* @__PURE__ */ ((NDKKind2) => { NDKKind2[NDKKind2["DVMReqImageGeneration"] = 5100] = "DVMReqImageGeneration"; NDKKind2[NDKKind2["DVMReqDiscoveryNostrContent"] = 5300] = "DVMReqDiscoveryNostrContent"; NDKKind2[NDKKind2["DVMReqDiscoveryNostrPeople"] = 5301] = "DVMReqDiscoveryNostrPeople"; + NDKKind2[NDKKind2["DVMReqTimestamping"] = 5900] = "DVMReqTimestamping"; NDKKind2[NDKKind2["DVMJobFeedback"] = 7e3] = "DVMJobFeedback"; - NDKKind2[NDKKind2["ZapRequest"] = 9734] = "ZapRequest"; - NDKKind2[NDKKind2["Zap"] = 9735] = "Zap"; - NDKKind2[NDKKind2["Highlight"] = 9802] = "Highlight"; NDKKind2[NDKKind2["MuteList"] = 1e4] = "MuteList"; NDKKind2[NDKKind2["PinList"] = 10001] = "PinList"; NDKKind2[NDKKind2["RelayList"] = 10002] = "RelayList"; + NDKKind2[NDKKind2["BookmarkList"] = 10003] = "BookmarkList"; + NDKKind2[NDKKind2["CommunityList"] = 10004] = "CommunityList"; + NDKKind2[NDKKind2["PublicChatList"] = 10005] = "PublicChatList"; + NDKKind2[NDKKind2["BlockRelayList"] = 10006] = "BlockRelayList"; + NDKKind2[NDKKind2["SearchRelayList"] = 10007] = "SearchRelayList"; + NDKKind2[NDKKind2["InterestList"] = 10015] = "InterestList"; + NDKKind2[NDKKind2["EmojiList"] = 10030] = "EmojiList"; + NDKKind2[NDKKind2["FollowSet"] = 3e4] = "FollowSet"; + NDKKind2[NDKKind2["CategorizedPeopleList"] = 3e4 /* FollowSet */] = "CategorizedPeopleList"; + NDKKind2[NDKKind2["CategorizedBookmarkList"] = 30001] = "CategorizedBookmarkList"; + NDKKind2[NDKKind2["RelaySet"] = 30002] = "RelaySet"; + NDKKind2[NDKKind2["CategorizedRelayList"] = 30002 /* RelaySet */] = "CategorizedRelayList"; + NDKKind2[NDKKind2["BookmarkSet"] = 30003] = "BookmarkSet"; + NDKKind2[NDKKind2["CurationSet"] = 30004] = "CurationSet"; + NDKKind2[NDKKind2["InterestSet"] = 30015] = "InterestSet"; + NDKKind2[NDKKind2["InterestsList"] = 30015 /* InterestSet */] = "InterestsList"; + NDKKind2[NDKKind2["EmojiSet"] = 30030] = "EmojiSet"; + NDKKind2[NDKKind2["HighlightSet"] = 39802] = "HighlightSet"; + NDKKind2[NDKKind2["CategorizedHighlightList"] = 39802 /* HighlightSet */] = "CategorizedHighlightList"; + NDKKind2[NDKKind2["ZapRequest"] = 9734] = "ZapRequest"; + NDKKind2[NDKKind2["Zap"] = 9735] = "Zap"; + NDKKind2[NDKKind2["Highlight"] = 9802] = "Highlight"; NDKKind2[NDKKind2["ClientAuth"] = 22242] = "ClientAuth"; NDKKind2[NDKKind2["NostrConnect"] = 24133] = "NostrConnect"; - NDKKind2[NDKKind2["CategorizedPeopleList"] = 3e4] = "CategorizedPeopleList"; - NDKKind2[NDKKind2["CategorizedBookmarkList"] = 30001] = "CategorizedBookmarkList"; NDKKind2[NDKKind2["ProfileBadge"] = 30008] = "ProfileBadge"; NDKKind2[NDKKind2["BadgeDefinition"] = 30009] = "BadgeDefinition"; - NDKKind2[NDKKind2["InterestsList"] = 30015] = "InterestsList"; NDKKind2[NDKKind2["MarketStall"] = 30017] = "MarketStall"; NDKKind2[NDKKind2["MarketProduct"] = 30018] = "MarketProduct"; - NDKKind2[NDKKind2["CategorizedRelayList"] = 30022] = "CategorizedRelayList"; NDKKind2[NDKKind2["Article"] = 30023] = "Article"; NDKKind2[NDKKind2["AppSpecificData"] = 30078] = "AppSpecificData"; NDKKind2[NDKKind2["Classified"] = 30402] = "Classified"; NDKKind2[NDKKind2["AppRecommendation"] = 31989] = "AppRecommendation"; NDKKind2[NDKKind2["AppHandler"] = 31990] = "AppHandler"; - NDKKind2[NDKKind2["CategorizedHighlightList"] = 39802] = "CategorizedHighlightList"; return NDKKind2; })(NDKKind || {}); var NDKListKinds = [ - 3e4 /* CategorizedPeopleList */, + 1e4 /* MuteList */, + 10001 /* PinList */, + 10002 /* RelayList */, + 10003 /* BookmarkList */, + 10004 /* CommunityList */, + 10005 /* PublicChatList */, + 10006 /* BlockRelayList */, + 10007 /* SearchRelayList */, + 10015 /* InterestList */, + 10030 /* EmojiList */, + 3e4 /* FollowSet */, + 30003 /* BookmarkSet */, 30001 /* CategorizedBookmarkList */, - 39802 /* CategorizedHighlightList */, - 30022 /* CategorizedRelayList */, - 30015 /* InterestsList */ + // Backwards compatibility + 30002 /* RelaySet */, + 30004 /* CurationSet */, + 30015 /* InterestSet */, + 30030 /* EmojiSet */, + 39802 /* HighlightSet */ ]; // src/events/nip04.ts @@ -1310,7 +1546,7 @@ function getKind(event) { } // src/events/index.ts -var NDKEvent = class extends import_eventemitter34.default { +var NDKEvent = class extends import_tseep4.EventEmitter { ndk; created_at; content = ""; @@ -1366,15 +1602,10 @@ var NDKEvent = class extends import_eventemitter34.default { return user; } tag(userOrEvent, marker) { - const tags = userOrEvent.referenceTags(); - if (marker) - tags[0].push(marker); - this.tags.push(...tags); + const skipAuthorTag = userOrEvent?.pubkey === this.pubkey; + const tags = userOrEvent.referenceTags(marker, skipAuthorTag); + this.tags = mergeTags(this.tags, tags); if (userOrEvent instanceof NDKEvent) { - const tagEventAuthor = userOrEvent.author; - if (tagEventAuthor && this.pubkey !== tagEventAuthor.hexpubkey) { - this.tag(tagEventAuthor); - } for (const pTag of userOrEvent.getMatchingTags("p")) { if (pTag[1] === this.pubkey) continue; @@ -1505,6 +1736,9 @@ var NDKEvent = class extends import_eventemitter34.default { tags.push(["d", str]); } } + if (this.ndk?.client && !this.tagValue("client")) { + tags.push(["client", this.ndk.client]); + } return { content: content || "", tags }; } muted() { @@ -1565,9 +1799,11 @@ var NDKEvent = class extends import_eventemitter34.default { const dTagId = this.replaceableDTag(); return `${this.kind}:${this.pubkey}:${dTagId}`; } - /** @deprecated Use referenceTags instead. */ /** - * Get the tag that can be used to reference this event from another event + * Get the tag that can be used to reference this event from another event. + * + * Consider using referenceTags() instead (unless you have a good reason to use this) + * * @example * event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] }); * event.tagReference(); // ["a", "30000:pubkey:d-code"] @@ -1576,11 +1812,22 @@ var NDKEvent = class extends import_eventemitter34.default { * event.tagReference(); // ["e", "eventid"] * @returns {NDKTag} The NDKTag object referencing this event */ - tagReference() { + tagReference(marker) { + let tag; if (this.isParamReplaceable()) { - return ["a", this.tagAddress()]; + tag = ["a", this.tagAddress()]; + } else { + tag = ["e", this.tagId()]; } - return ["e", this.tagId()]; + if (this.relay) { + tag.push(this.relay.url); + } else { + tag.push(""); + } + if (marker) { + tag.push(marker); + } + return tag; } /** * Get the tags that can be used to reference this event from another event @@ -1593,7 +1840,7 @@ var NDKEvent = class extends import_eventemitter34.default { * event.referenceTags(); // [["e", "parent-id"]] * @returns {NDKTag} The NDKTag object referencing this event */ - referenceTags(marker) { + referenceTags(marker, skipAuthorTag) { let tags = []; if (this.isParamReplaceable()) { tags = [ @@ -1603,10 +1850,22 @@ var NDKEvent = class extends import_eventemitter34.default { } else { tags = [["e", this.id]]; } + if (this.relay?.url) { + tags = tags.map((tag) => { + tag.push(this.relay?.url); + return tag; + }); + } else if (marker) { + tags = tags.map((tag) => { + tag.push(""); + return tag; + }); + } if (marker) { tags.forEach((tag) => tag.push(marker)); } - tags.push(...this.author.referenceTags()); + if (!skipAuthorTag) + tags.push(...this.author.referenceTags()); return tags; } /** @@ -1746,7 +2005,7 @@ var NDKRelayList = class extends NDKEvent { }; // src/subscription/index.ts -var import_eventemitter35 = __toESM(require("eventemitter3")); +var import_tseep5 = require("tseep"); var NDKSubscriptionCacheUsage = /* @__PURE__ */ ((NDKSubscriptionCacheUsage2) => { NDKSubscriptionCacheUsage2["ONLY_CACHE"] = "ONLY_CACHE"; NDKSubscriptionCacheUsage2["CACHE_FIRST"] = "CACHE_FIRST"; @@ -1760,7 +2019,7 @@ var defaultOpts = { groupable: true, groupableDelay: 100 }; -var NDKSubscription = class extends import_eventemitter35.default { +var NDKSubscription = class extends import_tseep5.EventEmitter { subId; filters; opts; @@ -1986,13 +2245,15 @@ var NDKSubscription = class extends import_eventemitter35.default { async function follows(opts, outbox) { if (!this.ndk) throw new Error("NDK not set"); - const contactListEvent = await this.ndk.fetchEvent( - { - kinds: [3], - authors: [this.hexpubkey] - }, - opts || { groupable: false } - ); + const contactListEvent = Array.from( + await this.ndk.fetchEvents( + { + kinds: [3], + authors: [this.pubkey] + }, + opts || { groupable: false } + ) + )[0]; if (contactListEvent) { const pubkeys = /* @__PURE__ */ new Set(); contactListEvent.tags.forEach((tag) => { @@ -2006,8 +2267,8 @@ async function follows(opts, outbox) { } } }); - return [...pubkeys].reduce((acc, hexpubkey) => { - const user = new NDKUser({ hexpubkey }); + return [...pubkeys].reduce((acc, pubkey) => { + const user = new NDKUser({ pubkey }); user.ndk = this.ndk; acc.add(user); return acc; @@ -2090,6 +2351,283 @@ function serializeProfile(profile) { return JSON.stringify(payload); } +// src/events/kinds/lists/index.ts +var NDKList = class extends NDKEvent { + _encryptedTags; + /** + * Stores the number of bytes the content was before decryption + * to expire the cache when the content changes. + */ + encryptedTagsLength; + constructor(ndk, rawEvent) { + super(ndk, rawEvent); + this.kind ??= 30001 /* CategorizedBookmarkList */; + } + /** + * Wrap a NDKEvent into a NDKList + */ + static from(ndkEvent) { + return new NDKList(ndkEvent.ndk, ndkEvent.rawEvent()); + } + /** + * Returns the title of the list. Falls back on fetching the name tag value. + */ + get title() { + const titleTag = this.tagValue("title") || this.tagValue("name"); + if (this.kind === 3 /* Contacts */ && !titleTag) { + return "Contacts"; + } else if (this.kind === 1e4 /* MuteList */ && !titleTag) { + return "Mute"; + } else if (this.kind === 10001 /* PinList */ && !titleTag) { + return "Pinned Notes"; + } else if (this.kind === 10002 /* RelayList */ && !titleTag) { + return "Relay Metadata"; + } else if (this.kind === 10003 /* BookmarkList */ && !titleTag) { + return "Bookmarks"; + } else if (this.kind === 10004 /* CommunityList */ && !titleTag) { + return "Communities"; + } else if (this.kind === 10005 /* PublicChatList */ && !titleTag) { + return "Public Chats"; + } else if (this.kind === 10006 /* BlockRelayList */ && !titleTag) { + return "Blocked Relays"; + } else if (this.kind === 10007 /* SearchRelayList */ && !titleTag) { + return "Search Relays"; + } else if (this.kind === 10015 /* InterestList */ && !titleTag) { + return "Interests"; + } else if (this.kind === 10030 /* EmojiList */ && !titleTag) { + return "Emojis"; + } else { + return titleTag ?? this.tagValue("d"); + } + } + /** + * Sets the title of the list. + */ + set title(title) { + this.removeTag("title"); + this.removeTag("name"); + if (title) { + this.tags.push(["title", title]); + } else { + throw new Error("Title cannot be empty"); + } + } + /** + * Returns the name of the list. + * @deprecated Please use "title" instead. + */ + get name() { + const nameTag = this.tagValue("name"); + if (this.kind === 3 /* Contacts */ && !nameTag) { + return "Contacts"; + } else if (this.kind === 1e4 /* MuteList */ && !nameTag) { + return "Mute"; + } else if (this.kind === 10001 /* PinList */ && !nameTag) { + return "Pinned Notes"; + } else if (this.kind === 10002 /* RelayList */ && !nameTag) { + return "Relay Metadata"; + } else if (this.kind === 10003 /* BookmarkList */ && !nameTag) { + return "Bookmarks"; + } else if (this.kind === 10004 /* CommunityList */ && !nameTag) { + return "Communities"; + } else if (this.kind === 10005 /* PublicChatList */ && !nameTag) { + return "Public Chats"; + } else if (this.kind === 10006 /* BlockRelayList */ && !nameTag) { + return "Blocked Relays"; + } else if (this.kind === 10007 /* SearchRelayList */ && !nameTag) { + return "Search Relays"; + } else if (this.kind === 10015 /* InterestList */ && !nameTag) { + return "Interests"; + } else if (this.kind === 10030 /* EmojiList */ && !nameTag) { + return "Emojis"; + } else { + return nameTag ?? this.tagValue("d"); + } + } + /** + * Sets the name of the list. + * @deprecated Please use "title" instead. This method will use the `title` tag instead. + */ + set name(name) { + this.removeTag("name"); + if (name) { + this.tags.push(["title", name]); + } else { + throw new Error("Name cannot be empty"); + } + } + /** + * Returns the description of the list. + */ + get description() { + return this.tagValue("description"); + } + /** + * Sets the description of the list. + */ + set description(name) { + if (name) { + this.tags.push(["description", name]); + } else { + this.removeTag("description"); + } + } + isEncryptedTagsCacheValid() { + return !!(this._encryptedTags && this.encryptedTagsLength === this.content.length); + } + /** + * Returns the decrypted content of the list. + */ + async encryptedTags(useCache = true) { + if (useCache && this.isEncryptedTagsCacheValid()) + return this._encryptedTags; + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + const user = await this.ndk.signer.user(); + try { + if (this.content.length > 0) { + try { + const decryptedContent = await this.ndk.signer.decrypt(user, this.content); + const a = JSON.parse(decryptedContent); + if (a && a[0]) { + this.encryptedTagsLength = this.content.length; + return this._encryptedTags = a; + } + this.encryptedTagsLength = this.content.length; + return this._encryptedTags = []; + } catch (e) { + console.log(`error decrypting ${this.content}`); + } + } + } catch (e) { + } + return []; + } + /** + * This method can be overriden to validate that a tag is valid for this list. + * + * (i.e. the NDKPersonList can validate that items are NDKUser instances) + */ + validateTag(tagValue) { + return true; + } + /** + * Returns the unecrypted items in this list. + */ + get items() { + return this.tags.filter((t) => { + return ![ + "d", + "L", + "l", + "title", + "name", + "description", + "summary", + "image", + "thumb", + "alt", + "expiration", + "subject" + ].includes(t[0]); + }); + } + /** + * Adds a new item to the list. + * @param relay Relay to add + * @param mark Optional mark to add to the item + * @param encrypted Whether to encrypt the item + */ + async addItem(item, mark = void 0, encrypted = false) { + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + let tags; + if (item instanceof NDKEvent) { + tags = item.referenceTags(); + } else if (item instanceof NDKUser) { + tags = item.referenceTags(); + } else if (item instanceof NDKRelay) { + tags = item.referenceTags(); + } else if (Array.isArray(item)) { + tags = [item]; + } else { + throw new Error("Invalid object type"); + } + if (mark) + tags[0].push(mark); + if (encrypted) { + const user = await this.ndk.signer.user(); + const currentList = await this.encryptedTags(); + currentList.push(...tags); + this._encryptedTags = currentList; + this.encryptedTagsLength = this.content.length; + this.content = JSON.stringify(currentList); + await this.encrypt(user); + } else { + this.tags.push(...tags); + } + this.created_at = Math.floor(Date.now() / 1e3); + this.emit("change"); + } + /** + * Removes an item from the list. + * + * @param index The index of the item to remove. + * @param encrypted Whether to remove from the encrypted list or not. + */ + async removeItem(index, encrypted) { + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + if (encrypted) { + const user = await this.ndk.signer.user(); + const currentList = await this.encryptedTags(); + currentList.splice(index, 1); + this._encryptedTags = currentList; + this.encryptedTagsLength = this.content.length; + this.content = JSON.stringify(currentList); + await this.encrypt(user); + } else { + this.tags.splice(index, 1); + } + this.created_at = Math.floor(Date.now() / 1e3); + this.emit("change"); + return this; + } +}; +var lists_default = NDKList; + +// src/user/pin.ts +async function pin(event, pinEvent, publish) { + const kind = 10001 /* PinList */; + if (!this.ndk) + throw new Error("No NDK instance found"); + this.ndk.assertSigner(); + if (!pinEvent) { + const events = await this.ndk.fetchEvents( + { kinds: [kind], authors: [this.pubkey] }, + { cacheUsage: "ONLY_RELAY" /* ONLY_RELAY */ } + ); + if (events.size > 0) { + pinEvent = lists_default.from(Array.from(events)[0]); + } else { + pinEvent = new NDKEvent(this.ndk, { + kind + }); + } + } + pinEvent.tag(event); + if (publish) { + await pinEvent.publish(); + } + return pinEvent; +} + // src/user/index.ts var NDKUser = class { ndk; @@ -2112,7 +2650,7 @@ var NDKUser = class { if (!this._npub) { if (!this._pubkey) throw new Error("hexpubkey not set"); - this._npub = import_nostr_tools8.nip19.npubEncode(this.hexpubkey); + this._npub = import_nostr_tools8.nip19.npubEncode(this.pubkey); } return this._npub; } @@ -2164,7 +2702,7 @@ var NDKUser = class { const profile = await import_nostr_tools8.nip05.queryProfile(nip05Id); if (profile) { return new NDKUser({ - hexpubkey: profile.pubkey, + pubkey: profile.pubkey, relayUrls: profile.relays }); } @@ -2181,7 +2719,7 @@ var NDKUser = class { this.profile = {}; let setMetadataEvents = null; if (this.ndk.cacheAdapter && this.ndk.cacheAdapter.fetchProfile && opts?.cacheUsage !== "ONLY_RELAY" /* ONLY_RELAY */) { - const profile = await this.ndk.cacheAdapter.fetchProfile(this.hexpubkey); + const profile = await this.ndk.cacheAdapter.fetchProfile(this.pubkey); if (profile) { this.profile = profile; return profile; @@ -2193,7 +2731,7 @@ var NDKUser = class { setMetadataEvents = await this.ndk.fetchEvents( { kinds: [0], - authors: [this.hexpubkey] + authors: [this.pubkey] }, { cacheUsage: "ONLY_CACHE" /* ONLY_CACHE */, @@ -2212,7 +2750,7 @@ var NDKUser = class { setMetadataEvents = await this.ndk.fetchEvents( { kinds: [0], - authors: [this.hexpubkey] + authors: [this.pubkey] }, opts ); @@ -2224,7 +2762,7 @@ var NDKUser = class { return null; this.profile = profileFromEvent(sortedSetMetadataEvents[0]); if (this.profile && this.ndk.cacheAdapter && this.ndk.cacheAdapter.saveProfile) { - this.ndk.cacheAdapter.saveProfile(this.hexpubkey, this.profile); + this.ndk.cacheAdapter.saveProfile(this.pubkey, this.profile); } return this.profile; } @@ -2232,6 +2770,10 @@ var NDKUser = class { * Returns a set of users that this user follows. */ follows = follows.bind(this); + /** + * Pins a user or an event + */ + pin = pin.bind(this); /** * Returns a set of relay list events for a user. * @returns {Promise>} A set of NDKEvents returned for the given user. @@ -2247,13 +2789,13 @@ var NDKUser = class { const event = await this.ndk.fetchEvent( { kinds: [10002], - authors: [this.hexpubkey] + authors: [this.pubkey] }, { closeOnEose: true, pool, groupable: true, - subId: `relay-list-${this.hexpubkey.slice(0, 6)}` + subId: `relay-list-${this.pubkey.slice(0, 6)}` }, relaySet ); @@ -2266,7 +2808,7 @@ var NDKUser = class { throw new Error("NDK not set"); const followList = await this.ndk.fetchEvent({ kinds: [3], - authors: [this.hexpubkey] + authors: [this.pubkey] }); if (followList) { try { @@ -2300,14 +2842,18 @@ var NDKUser = class { * @returns {NDKTag} an NDKTag */ tagReference() { - return ["p", this.hexpubkey]; + return ["p", this.pubkey]; } /** * Get the tags that can be used to reference this user in an event * @returns {NDKTag[]} an array of NDKTag */ - referenceTags() { - return [["p", this.hexpubkey]]; + referenceTags(marker) { + const tag = [["p", this.pubkey]]; + if (!marker) + return tag; + tag[0].push("", marker); + return tag; } /** * Publishes the current profile. @@ -2355,8 +2901,8 @@ var NDKUser = class { * Validate a user's NIP-05 identifier (usually fetched from their kind:0 profile data) * * @param nip05Id The NIP-05 string to validate - * @returns {Promise} True if the NIP-05 is found and matches this user's hexpubkey, - * False if the NIP-05 is found but doesn't match this user's hexpubkey, + * @returns {Promise} True if the NIP-05 is found and matches this user's pubkey, + * False if the NIP-05 is found but doesn't match this user's pubkey, * null if the NIP-05 isn't found on the domain or we're unable to verify (because of network issues, etc.) */ async validateNip05(nip05Id) { @@ -2365,7 +2911,7 @@ var NDKUser = class { const profilePointer = await import_nostr_tools8.nip05.queryProfile(nip05Id); if (profilePointer === null) return null; - return profilePointer.pubkey === this.hexpubkey; + return profilePointer.pubkey === this.pubkey; } /** * Zap a user @@ -2812,216 +3358,6 @@ var NDKTranscriptionDVM = class extends NDKDVMRequest { } }; -// src/events/kinds/lists/index.ts -var NDKList = class extends NDKEvent { - _encryptedTags; - /** - * Stores the number of bytes the content was before decryption - * to expire the cache when the content changes. - */ - encryptedTagsLength; - constructor(ndk, rawEvent) { - super(ndk, rawEvent); - this.kind ??= 30001 /* CategorizedBookmarkList */; - } - /** - * Wrap a NDKEvent into a NDKList - */ - static from(ndkEvent) { - return new NDKList(ndkEvent.ndk, ndkEvent.rawEvent()); - } - /** - * Returns the title of the list. Falls back on fetching the name tag value. - */ - get title() { - const titleTag = this.tagValue("title") || this.tagValue("name"); - if (this.kind === 3 /* Contacts */ && !titleTag) { - return "Contacts"; - } else if (this.kind === 1e4 /* MuteList */ && !titleTag) { - return "Mute"; - } else if (this.kind === 10001 /* PinList */ && !titleTag) { - return "Pin"; - } else if (this.kind === 10002 /* RelayList */ && !titleTag) { - return "Relay Metadata"; - } else { - return titleTag ?? this.tagValue("d"); - } - } - /** - * Sets the title of the list. - */ - set title(title) { - this.removeTag("title"); - this.removeTag("name"); - if (title) { - this.tags.push(["title", title]); - } else { - throw new Error("Title cannot be empty"); - } - } - /** - * Returns the name of the list. - * @deprecated Please use "title" instead. - */ - get name() { - const nameTag = this.tagValue("name"); - if (this.kind === 3 /* Contacts */ && !nameTag) { - return "Contacts"; - } else if (this.kind === 1e4 /* MuteList */ && !nameTag) { - return "Mute"; - } else if (this.kind === 10001 /* PinList */ && !nameTag) { - return "Pin"; - } else if (this.kind === 10002 /* RelayList */ && !nameTag) { - return "Relay Metadata"; - } else { - return nameTag ?? this.tagValue("d"); - } - } - /** - * Sets the name of the list. - * @deprecated Please use "title" instead. This method will use the `title` tag instead. - */ - set name(name) { - this.removeTag("name"); - if (name) { - this.tags.push(["title", name]); - } else { - throw new Error("Name cannot be empty"); - } - } - /** - * Returns the description of the list. - */ - get description() { - return this.tagValue("description"); - } - /** - * Sets the description of the list. - */ - set description(name) { - if (name) { - this.tags.push(["description", name]); - } else { - this.removeTag("description"); - } - } - isEncryptedTagsCacheValid() { - return !!(this._encryptedTags && this.encryptedTagsLength === this.content.length); - } - /** - * Returns the decrypted content of the list. - */ - async encryptedTags(useCache = true) { - if (useCache && this.isEncryptedTagsCacheValid()) - return this._encryptedTags; - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - const user = await this.ndk.signer.user(); - try { - if (this.content.length > 0) { - try { - const decryptedContent = await this.ndk.signer.decrypt(user, this.content); - const a = JSON.parse(decryptedContent); - if (a && a[0]) { - this.encryptedTagsLength = this.content.length; - return this._encryptedTags = a; - } - this.encryptedTagsLength = this.content.length; - return this._encryptedTags = []; - } catch (e) { - console.log(`error decrypting ${this.content}`); - } - } - } catch (e) { - } - return []; - } - /** - * This method can be overriden to validate that a tag is valid for this list. - * - * (i.e. the NDKPersonList can validate that items are NDKUser instances) - */ - validateTag(tagValue) { - return true; - } - /** - * Returns the unecrypted items in this list. - */ - get items() { - return this.tags.filter((t) => { - return !["d", "name", "description"].includes(t[0]); - }); - } - /** - * Adds a new item to the list. - * @param relay Relay to add - * @param mark Optional mark to add to the item - * @param encrypted Whether to encrypt the item - */ - async addItem(item, mark = void 0, encrypted = false) { - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - let tags; - if (item instanceof NDKEvent) { - tags = item.referenceTags(); - } else if (item instanceof NDKUser) { - tags = item.referenceTags(); - } else if (item instanceof NDKRelay) { - tags = item.referenceTags(); - } else if (Array.isArray(item)) { - tags = [item]; - } else { - throw new Error("Invalid object type"); - } - if (mark) - tags[0].push(mark); - if (encrypted) { - const user = await this.ndk.signer.user(); - const currentList = await this.encryptedTags(); - currentList.push(...tags); - this._encryptedTags = currentList; - this.encryptedTagsLength = this.content.length; - this.content = JSON.stringify(currentList); - await this.encrypt(user); - } else { - this.tags.push(...tags); - } - this.created_at = Math.floor(Date.now() / 1e3); - this.emit("change"); - } - /** - * Removes an item from the list. - * - * @param index The index of the item to remove. - * @param encrypted Whether to remove from the encrypted list or not. - */ - async removeItem(index, encrypted) { - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - if (encrypted) { - const user = await this.ndk.signer.user(); - const currentList = await this.encryptedTags(); - currentList.splice(index, 1); - this._encryptedTags = currentList; - this.encryptedTagsLength = this.content.length; - this.content = JSON.stringify(currentList); - await this.encrypt(user); - } else { - this.tags.splice(index, 1); - } - this.created_at = Math.floor(Date.now() / 1e3); - this.emit("change"); - return this; - } -}; -var lists_default = NDKList; - // src/events/kinds/repost.ts var NDKRepost = class extends NDKEvent { _repostedEvents; @@ -3153,6 +3489,17 @@ var NDKNip07Signer = class { const signedEvent = await window.nostr.signEvent(event); return signedEvent.sig; } + async relays() { + await this.waitForExtension(); + const relays = await window.nostr.getRelays?.() || {}; + const activeRelays = []; + for (const url in Object.keys(relays)) { + if (relays[url].read && relays[url].write) { + activeRelays.push(url); + } + } + return activeRelays.map((url) => new NDKRelay(url)); + } async encrypt(recipient, value) { await this.waitForExtension(); const recipientHexPubKey = recipient.hexpubkey; @@ -3291,8 +3638,8 @@ var NDKPrivateKeySigner = class { }; // src/signers/nip46/rpc.ts -var import_eventemitter36 = __toESM(require("eventemitter3")); -var NDKNostrRpc = class extends import_eventemitter36.default { +var import_tseep6 = require("tseep"); +var NDKNostrRpc = class extends import_tseep6.EventEmitter { ndk; signer; debug; @@ -3305,8 +3652,11 @@ var NDKNostrRpc = class extends import_eventemitter36.default { /** * Subscribe to a filter. This function will resolve once the subscription is ready. */ - async subscribe(filter) { - const sub = this.ndk.subscribe(filter, { closeOnEose: false }); + subscribe(filter) { + const sub = this.ndk.subscribe(filter, { + closeOnEose: false, + groupable: false + }); sub.on("event", async (event) => { try { const parsedEvent = await this.parseEvent(event); @@ -3366,8 +3716,15 @@ var NDKNostrRpc = class extends import_eventemitter36.default { const remoteUser = this.ndk.getUser({ hexpubkey: remotePubkey }); const request = { id, method, params }; const promise = new Promise((resolve) => { - if (cb) - this.once(`response-${id}`, cb); + const responseHandler = (response) => { + if (response.result === "auth_url") { + this.once(`response-${id}`, responseHandler); + this.emit("authUrl", response.error); + } else if (cb) { + cb(response); + } + }; + this.once(`response-${id}`, responseHandler); }); const event = new NDKEvent(this.ndk, { kind, @@ -3385,7 +3742,7 @@ var NDKNostrRpc = class extends import_eventemitter36.default { // src/signers/nip46/backend/connect.ts var ConnectEventHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [pubkey, token] = params; const debug4 = backend.debug.extend("connect"); debug4(`connection request from ${pubkey}`); @@ -3393,7 +3750,7 @@ var ConnectEventHandlingStrategy = class { debug4(`applying token`); await backend.applyToken(pubkey, token); } - if (await backend.pubkeyAllowed(pubkey, "connect", token)) { + if (await backend.pubkeyAllowed({ id, pubkey, method: "connect", params: token })) { debug4(`connection request from ${pubkey} allowed`); return "ack"; } else { @@ -3403,50 +3760,84 @@ var ConnectEventHandlingStrategy = class { } }; -// src/signers/nip46/backend/describe.ts -var DescribeHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - const keys = Object.keys(backend.handlers); - return JSON.stringify(keys); - } -}; - // src/signers/nip46/backend/get-public-key.ts var GetPublicKeyHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - return backend.localUser?.hexpubkey; + async handle(backend, id, remotePubkey, params) { + return backend.localUser?.pubkey; } }; // src/signers/nip46/backend/nip04-decrypt.ts var Nip04DecryptHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [senderPubkey, payload] = params; const senderUser = new NDKUser({ hexpubkey: senderPubkey }); - const decryptedPayload = await backend.decrypt(remotePubkey, senderUser, payload); + const decryptedPayload = await decrypt2(backend, id, remotePubkey, senderUser, payload); return JSON.stringify([decryptedPayload]); } }; +async function decrypt2(backend, id, remotePubkey, senderUser, payload) { + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "decrypt", + params: payload + })) { + backend.debug(`decrypt request from ${remotePubkey} rejected`); + return void 0; + } + return await backend.signer.decrypt(senderUser, payload); +} // src/signers/nip46/backend/nip04-encrypt.ts var Nip04EncryptHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [recipientPubkey, payload] = params; const recipientUser = new NDKUser({ hexpubkey: recipientPubkey }); - const decryptedPayload = await backend.encrypt(remotePubkey, recipientUser, payload); - return decryptedPayload; + const encryptedPayload = await encrypt2(backend, id, remotePubkey, recipientUser, payload); + return encryptedPayload; } }; +async function encrypt2(backend, id, remotePubkey, recipientUser, payload) { + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "encrypt", + params: payload + })) { + backend.debug(`encrypt request from ${remotePubkey} rejected`); + return void 0; + } + return await backend.signer.encrypt(recipientUser, payload); +} // src/signers/nip46/backend/sign-event.ts var SignEventHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - const event = await backend.signEvent(remotePubkey, params); + async handle(backend, id, remotePubkey, params) { + const event = await signEvent(backend, id, remotePubkey, params); if (!event) return void 0; return JSON.stringify(await event.toNostrEvent()); } }; +async function signEvent(backend, id, remotePubkey, params) { + const [eventString] = params; + backend.debug(`sign event request from ${remotePubkey}`); + const event = new NDKEvent(backend.ndk, JSON.parse(eventString)); + backend.debug("event to sign", event.rawEvent()); + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "sign_event", + params: event + })) { + backend.debug(`sign event request from ${remotePubkey} rejected`); + return void 0; + } + backend.debug(`sign event request from ${remotePubkey} allowed`); + await event.sign(backend.signer); + return event; +} // src/signers/nip46/backend/index.ts var NDKNip46Backend = class { @@ -3487,8 +3878,7 @@ var NDKNip46Backend = class { sign_event: new SignEventHandlingStrategy(), nip04_encrypt: new Nip04EncryptHandlingStrategy(), nip04_decrypt: new Nip04DecryptHandlingStrategy(), - get_public_key: new GetPublicKeyHandlingStrategy(), - describe: new DescribeHandlingStrategy() + get_public_key: new GetPublicKeyHandlingStrategy() }; /** * Enables the user to set a custom strategy for handling incoming events. @@ -3519,7 +3909,7 @@ var NDKNip46Backend = class { const strategy = this.handlers[method]; if (strategy) { try { - response = await strategy.handle(this, remotePubkey, params); + response = await strategy.handle(this, id, remotePubkey, params); } catch (e) { this.debug("error handling event", e, { id, method, params }); this.rpc.sendResponse(id, remotePubkey, "error", void 0, e.message); @@ -3534,82 +3924,66 @@ var NDKNip46Backend = class { this.rpc.sendResponse(id, remotePubkey, "error", void 0, "Not authorized"); } } - async decrypt(remotePubkey, senderUser, payload) { - if (!await this.pubkeyAllowed(remotePubkey, "decrypt", payload)) { - this.debug(`decrypt request from ${remotePubkey} rejected`); - return void 0; - } - return await this.signer.decrypt(senderUser, payload); - } - async encrypt(remotePubkey, recipientUser, payload) { - if (!await this.pubkeyAllowed(remotePubkey, "encrypt", payload)) { - this.debug(`encrypt request from ${remotePubkey} rejected`); - return void 0; - } - return await this.signer.encrypt(recipientUser, payload); - } - async signEvent(remotePubkey, params) { - const [eventString] = params; - this.debug(`sign event request from ${remotePubkey}`); - const event = new NDKEvent(this.ndk, JSON.parse(eventString)); - this.debug("event to sign", event.rawEvent()); - if (!await this.pubkeyAllowed(remotePubkey, "sign_event", event)) { - this.debug(`sign event request from ${remotePubkey} rejected`); - return void 0; - } - this.debug(`sign event request from ${remotePubkey} allowed`); - await event.sign(this.signer); - return event; - } /** * This method should be overriden by the user to allow or reject incoming * connections. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - async pubkeyAllowed(pubkey, method, params) { - return this.permitCallback(pubkey, method, params); + async pubkeyAllowed(params) { + return this.permitCallback(params); } }; +// ../node_modules/eventemitter3/index.mjs +var import_index6 = __toESM(require_eventemitter3(), 1); +var eventemitter3_default = import_index6.default; + // src/signers/nip46/index.ts -var NDKNip46Signer = class { +var NDKNip46Signer = class extends eventemitter3_default { ndk; remoteUser; remotePubkey; token; localSigner; + nip05; rpc; debug; /** * @param ndk - The NDK instance to use - * @param tokenOrRemotePubkey - The public key, or a connection token, of the npub that wants to be published as + * @param tokenOrRemoteUser - The public key, or a connection token, of the npub that wants to be published as * @param localSigner - The signer that will be used to request events to be signed */ - constructor(ndk, tokenOrRemotePubkey, localSigner) { + constructor(ndk, tokenOrRemoteUser, localSigner) { + super(); let remotePubkey; let token; - if (tokenOrRemotePubkey.includes("#")) { - const parts = tokenOrRemotePubkey.split("#"); - remotePubkey = new NDKUser({ npub: parts[0] }).hexpubkey; + if (tokenOrRemoteUser.includes("#")) { + const parts = tokenOrRemoteUser.split("#"); + remotePubkey = new NDKUser({ npub: parts[0] }).pubkey; token = parts[1]; - } else if (tokenOrRemotePubkey.startsWith("npub")) { + } else if (tokenOrRemoteUser.startsWith("npub")) { remotePubkey = new NDKUser({ - npub: tokenOrRemotePubkey - }).hexpubkey; + npub: tokenOrRemoteUser + }).pubkey; + } else if (tokenOrRemoteUser.match(/\./)) { + this.nip05 = tokenOrRemoteUser; } else { - remotePubkey = tokenOrRemotePubkey; + remotePubkey = tokenOrRemoteUser; } this.ndk = ndk; - this.remotePubkey = remotePubkey; + if (remotePubkey) + this.remotePubkey = remotePubkey; this.token = token; this.debug = ndk.debug.extend("nip46:signer"); - this.remoteUser = new NDKUser({ hexpubkey: remotePubkey }); + this.remoteUser = new NDKUser({ pubkey: remotePubkey }); if (!localSigner) { this.localSigner = NDKPrivateKeySigner.generate(); } else { this.localSigner = localSigner; } this.rpc = new NDKNostrRpc(ndk, this.localSigner, this.debug); + this.rpc.on("authUrl", (...props) => { + this.emit("authUrl", ...props); + }); } /** * Get the user that is being published as @@ -3619,14 +3993,25 @@ var NDKNip46Signer = class { } async blockUntilReady() { const localUser = await this.localSigner.user(); - const user = this.ndk.getUser({ npub: localUser.npub }); + const remoteUser = this.ndk.getUser({ pubkey: this.remotePubkey }); + if (this.nip05 && !this.remotePubkey) { + const remoteUser2 = NDKUser.fromNip05(this.nip05).then((user) => { + if (user) { + this.remoteUser = user; + this.remotePubkey = user.pubkey; + } + }); + } + if (!this.remotePubkey) { + throw new Error("Remote pubkey not set"); + } await this.rpc.subscribe({ kinds: [24133], - "#p": [localUser.hexpubkey] + "#p": [localUser.pubkey] }); return new Promise((resolve, reject) => { setTimeout(() => { - const connectParams = [localUser.hexpubkey]; + const connectParams = [localUser.pubkey]; if (this.token) { connectParams.push(this.token); } @@ -3637,7 +4022,7 @@ var NDKNip46Signer = class { 24133, (response) => { if (response.result === "ack") { - resolve(user); + resolve(remoteUser); } else { reject(response.error); } @@ -3652,7 +4037,7 @@ var NDKNip46Signer = class { this.rpc.sendRequest( this.remotePubkey, "nip04_encrypt", - [recipient.hexpubkey, value], + [recipient.pubkey, value], 24133, (response) => { if (!response.error) { @@ -3671,7 +4056,7 @@ var NDKNip46Signer = class { this.rpc.sendRequest( this.remotePubkey, "nip04_decrypt", - [sender.hexpubkey, value], + [sender.pubkey, value], 24133, (response) => { if (!response.error) { @@ -3710,7 +4095,7 @@ var NDKNip46Signer = class { // src/ndk/index.ts var import_debug3 = __toESM(require("debug")); -var import_eventemitter39 = __toESM(require("eventemitter3")); +var import_tseep9 = require("tseep"); // src/events/dedup.ts function dedup(event1, event2) { @@ -3721,7 +4106,7 @@ function dedup(event1, event2) { } // src/outbox/tracker.ts -var import_eventemitter37 = __toESM(require("eventemitter3")); +var import_tseep7 = require("tseep"); var import_typescript_lru_cache = require("typescript-lru-cache"); var OutboxItem = class { /** @@ -3741,7 +4126,7 @@ var OutboxItem = class { this.writeRelays = /* @__PURE__ */ new Set(); } }; -var OutboxTracker = class extends import_eventemitter37.default { +var OutboxTracker = class extends import_tseep7.EventEmitter { data; ndk; debug; @@ -3817,8 +4202,8 @@ function getTypeFromItem(item) { } // src/relay/pool/index.ts -var import_eventemitter38 = __toESM(require("eventemitter3")); -var NDKPool = class extends import_eventemitter38.default { +var import_tseep8 = require("tseep"); +var NDKPool = class extends import_tseep8.EventEmitter { // TODO: This should probably be an LRU cache relays = /* @__PURE__ */ new Map(); blacklistRelayUrls; @@ -3869,9 +4254,9 @@ var NDKPool = class extends import_eventemitter38.default { this.debug(`Relay ${relayUrl} is blacklisted`); return; } - relay.on("notice", (relay2, notice) => this.emit("notice", relay2, notice)); + relay.on("notice", async (relay2, notice) => this.emit("notice", relay2, notice)); relay.on("connect", () => this.handleRelayConnect(relayUrl)); - relay.on("disconnect", () => this.emit("relay:disconnect", relay)); + relay.on("disconnect", async () => this.emit("relay:disconnect", relay)); relay.on("flapping", () => this.handleFlapping(relay)); this.relays.set(relayUrl, relay); if (connect) { @@ -4047,7 +4432,7 @@ var DEFAULT_BLACKLISTED_RELAYS = [ "wss://brb.io" // BRB ]; -var NDK = class extends import_eventemitter39.default { +var NDK = class extends import_tseep9.EventEmitter { explicitRelayUrls; pool; outboxPool; @@ -4058,6 +4443,7 @@ var NDK = class extends import_eventemitter39.default { devWriteRelaySet; outboxTracker; mutedIds; + client; autoConnectUserRelays = true; autoFetchUserMutelist = true; constructor(opts = {}) { @@ -4068,6 +4454,7 @@ var NDK = class extends import_eventemitter39.default { this.debug(`Starting with explicit relays: ${JSON.stringify(this.explicitRelayUrls)}`); this.autoConnectUserRelays = opts.autoConnectUserRelays ?? true; this.autoFetchUserMutelist = opts.autoFetchUserMutelist ?? true; + this.client = opts.client; if (opts.enableOutboxModel) { this.outboxPool = new NDKPool( opts.outboxRelayUrls || DEFAULT_OUTBOX_RELAYS, @@ -4125,7 +4512,7 @@ var NDK = class extends import_eventemitter39.default { const muteLists = await this.fetchEvents([ { kinds: [1e4 /* MuteList */], authors: [user2.pubkey] }, { - kinds: [3e4 /* CategorizedPeopleList */], + kinds: [3e4 /* FollowSet */], authors: [user2.pubkey], "#d": ["mute"], limit: 1 @@ -4182,6 +4569,13 @@ var NDK = class extends import_eventemitter39.default { * If the timeout is reached, the connection will be continued to be established in the background. */ async connect(timeoutMs) { + if (this._signer && this.autoConnectUserRelays) { + this.debug("Attempting to connect to user relays specified by signer"); + if (this._signer.relays) { + const relays = await this._signer.relays(); + relays.forEach((relay) => this.pool.addRelay(relay)); + } + } const connections = [this.pool.connect(timeoutMs)]; if (this.outboxPool) { connections.push(this.outboxPool.connect(timeoutMs)); diff --git a/node_modules/@nostr-dev-kit/ndk/dist/index.mjs b/node_modules/@nostr-dev-kit/ndk/dist/index.mjs index 574401d7..69561c63 100644 --- a/node_modules/@nostr-dev-kit/ndk/dist/index.mjs +++ b/node_modules/@nostr-dev-kit/ndk/dist/index.mjs @@ -1,13 +1,221 @@ +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); + +// ../node_modules/eventemitter3/index.js +var require_eventemitter3 = __commonJS({ + "../node_modules/eventemitter3/index.js"(exports, module) { + "use strict"; + var has = Object.prototype.hasOwnProperty; + var prefix = "~"; + function Events() { + } + if (Object.create) { + Events.prototype = /* @__PURE__ */ Object.create(null); + if (!new Events().__proto__) + prefix = false; + } + function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; + } + function addListener(emitter, event, fn, context, once) { + if (typeof fn !== "function") { + throw new TypeError("The listener must be a function"); + } + var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; + if (!emitter._events[evt]) + emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) + emitter._events[evt].push(listener); + else + emitter._events[evt] = [emitter._events[evt], listener]; + return emitter; + } + function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) + emitter._events = new Events(); + else + delete emitter._events[evt]; + } + function EventEmitter11() { + this._events = new Events(); + this._eventsCount = 0; + } + EventEmitter11.prototype.eventNames = function eventNames() { + var names = [], events, name; + if (this._eventsCount === 0) + return names; + for (name in events = this._events) { + if (has.call(events, name)) + names.push(prefix ? name.slice(1) : name); + } + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + return names; + }; + EventEmitter11.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event, handlers = this._events[evt]; + if (!handlers) + return []; + if (handlers.fn) + return [handlers.fn]; + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + return ee; + }; + EventEmitter11.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event, listeners = this._events[evt]; + if (!listeners) + return 0; + if (listeners.fn) + return 1; + return listeners.length; + }; + EventEmitter11.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return false; + var listeners = this._events[evt], len = arguments.length, args, i; + if (listeners.fn) { + if (listeners.once) + this.removeListener(event, listeners.fn, void 0, true); + switch (len) { + case 1: + return listeners.fn.call(listeners.context), true; + case 2: + return listeners.fn.call(listeners.context, a1), true; + case 3: + return listeners.fn.call(listeners.context, a1, a2), true; + case 4: + return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: + return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: + return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + for (i = 1, args = new Array(len - 1); i < len; i++) { + args[i - 1] = arguments[i]; + } + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length, j; + for (i = 0; i < length; i++) { + if (listeners[i].once) + this.removeListener(event, listeners[i].fn, void 0, true); + switch (len) { + case 1: + listeners[i].fn.call(listeners[i].context); + break; + case 2: + listeners[i].fn.call(listeners[i].context, a1); + break; + case 3: + listeners[i].fn.call(listeners[i].context, a1, a2); + break; + case 4: + listeners[i].fn.call(listeners[i].context, a1, a2, a3); + break; + default: + if (!args) + for (j = 1, args = new Array(len - 1); j < len; j++) { + args[j - 1] = arguments[j]; + } + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + return true; + }; + EventEmitter11.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); + }; + EventEmitter11.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); + }; + EventEmitter11.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + var listeners = this._events[evt]; + if (listeners.fn) { + if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { + events.push(listeners[i]); + } + } + if (events.length) + this._events[evt] = events.length === 1 ? events[0] : events; + else + clearEvent(this, evt); + } + return this; + }; + EventEmitter11.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) + clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + return this; + }; + EventEmitter11.prototype.off = EventEmitter11.prototype.removeListener; + EventEmitter11.prototype.addListener = EventEmitter11.prototype.on; + EventEmitter11.prefixed = prefix; + EventEmitter11.EventEmitter = EventEmitter11; + if ("undefined" !== typeof module) { + module.exports = EventEmitter11; + } + } +}); + // src/user/index.ts import { nip05, nip19 as nip194 } from "nostr-tools"; // src/events/index.ts -import EventEmitter4 from "eventemitter3"; +import { EventEmitter as EventEmitter4 } from "tseep"; import { getEventHash } from "nostr-tools"; // src/relay/index.ts import debug from "debug"; -import EventEmitter2 from "eventemitter3"; +import { EventEmitter as EventEmitter2 } from "tseep"; // src/relay/connectivity.ts import { relayInit } from "nostr-tools"; @@ -226,7 +434,7 @@ var NDKRelayPublisher = class { }; // src/relay/subscriptions.ts -import EventEmitter from "eventemitter3"; +import { EventEmitter } from "tseep"; import { matchFilter } from "nostr-tools"; // src/subscription/grouping.ts @@ -887,7 +1095,7 @@ function calculateRelaySetsFromFilters(ndk, filters) { // src/zap/index.ts import { bech32 } from "@scure/base"; -import EventEmitter3 from "eventemitter3"; +import { EventEmitter as EventEmitter3 } from "tseep"; import { nip57 } from "nostr-tools"; var DEFAULT_RELAYS = [ "wss://nos.lol", @@ -998,6 +1206,26 @@ var Zap = class extends EventEmitter3 { // src/events/content-tagger.ts import { nip19 as nip192 } from "nostr-tools"; +function mergeTags(tags1, tags2) { + const tagMap = /* @__PURE__ */ new Map(); + const generateKey = (tag) => tag.join(","); + const isContained = (smaller, larger) => { + return smaller.every((value, index) => value === larger[index]); + }; + const processTag = (tag) => { + for (let [key, existingTag] of tagMap) { + if (isContained(existingTag, tag) || isContained(tag, existingTag)) { + if (tag.length >= existingTag.length) { + tagMap.set(key, tag); + } + return; + } + } + tagMap.set(generateKey(tag), tag); + }; + tags1.concat(tags2).forEach(processTag); + return Array.from(tagMap.values()); +} async function generateContentTags(content, tags = []) { const tagRegex = /(@|nostr:)(npub|nprofile|note|nevent|naddr)[a-zA-Z0-9]+/g; const hashtagRegex = /#(\w+)/g; @@ -1112,6 +1340,8 @@ var NDKKind = /* @__PURE__ */ ((NDKKind2) => { NDKKind2[NDKKind2["Repost"] = 6] = "Repost"; NDKKind2[NDKKind2["Reaction"] = 7] = "Reaction"; NDKKind2[NDKKind2["BadgeAward"] = 8] = "BadgeAward"; + NDKKind2[NDKKind2["GroupNote"] = 9] = "GroupNote"; + NDKKind2[NDKKind2["GroupChat"] = 11] = "GroupChat"; NDKKind2[NDKKind2["GenericRepost"] = 16] = "GenericRepost"; NDKKind2[NDKKind2["ChannelCreation"] = 40] = "ChannelCreation"; NDKKind2[NDKKind2["ChannelMetadata"] = 41] = "ChannelMetadata"; @@ -1127,37 +1357,66 @@ var NDKKind = /* @__PURE__ */ ((NDKKind2) => { NDKKind2[NDKKind2["DVMReqImageGeneration"] = 5100] = "DVMReqImageGeneration"; NDKKind2[NDKKind2["DVMReqDiscoveryNostrContent"] = 5300] = "DVMReqDiscoveryNostrContent"; NDKKind2[NDKKind2["DVMReqDiscoveryNostrPeople"] = 5301] = "DVMReqDiscoveryNostrPeople"; + NDKKind2[NDKKind2["DVMReqTimestamping"] = 5900] = "DVMReqTimestamping"; NDKKind2[NDKKind2["DVMJobFeedback"] = 7e3] = "DVMJobFeedback"; - NDKKind2[NDKKind2["ZapRequest"] = 9734] = "ZapRequest"; - NDKKind2[NDKKind2["Zap"] = 9735] = "Zap"; - NDKKind2[NDKKind2["Highlight"] = 9802] = "Highlight"; NDKKind2[NDKKind2["MuteList"] = 1e4] = "MuteList"; NDKKind2[NDKKind2["PinList"] = 10001] = "PinList"; NDKKind2[NDKKind2["RelayList"] = 10002] = "RelayList"; + NDKKind2[NDKKind2["BookmarkList"] = 10003] = "BookmarkList"; + NDKKind2[NDKKind2["CommunityList"] = 10004] = "CommunityList"; + NDKKind2[NDKKind2["PublicChatList"] = 10005] = "PublicChatList"; + NDKKind2[NDKKind2["BlockRelayList"] = 10006] = "BlockRelayList"; + NDKKind2[NDKKind2["SearchRelayList"] = 10007] = "SearchRelayList"; + NDKKind2[NDKKind2["InterestList"] = 10015] = "InterestList"; + NDKKind2[NDKKind2["EmojiList"] = 10030] = "EmojiList"; + NDKKind2[NDKKind2["FollowSet"] = 3e4] = "FollowSet"; + NDKKind2[NDKKind2["CategorizedPeopleList"] = 3e4 /* FollowSet */] = "CategorizedPeopleList"; + NDKKind2[NDKKind2["CategorizedBookmarkList"] = 30001] = "CategorizedBookmarkList"; + NDKKind2[NDKKind2["RelaySet"] = 30002] = "RelaySet"; + NDKKind2[NDKKind2["CategorizedRelayList"] = 30002 /* RelaySet */] = "CategorizedRelayList"; + NDKKind2[NDKKind2["BookmarkSet"] = 30003] = "BookmarkSet"; + NDKKind2[NDKKind2["CurationSet"] = 30004] = "CurationSet"; + NDKKind2[NDKKind2["InterestSet"] = 30015] = "InterestSet"; + NDKKind2[NDKKind2["InterestsList"] = 30015 /* InterestSet */] = "InterestsList"; + NDKKind2[NDKKind2["EmojiSet"] = 30030] = "EmojiSet"; + NDKKind2[NDKKind2["HighlightSet"] = 39802] = "HighlightSet"; + NDKKind2[NDKKind2["CategorizedHighlightList"] = 39802 /* HighlightSet */] = "CategorizedHighlightList"; + NDKKind2[NDKKind2["ZapRequest"] = 9734] = "ZapRequest"; + NDKKind2[NDKKind2["Zap"] = 9735] = "Zap"; + NDKKind2[NDKKind2["Highlight"] = 9802] = "Highlight"; NDKKind2[NDKKind2["ClientAuth"] = 22242] = "ClientAuth"; NDKKind2[NDKKind2["NostrConnect"] = 24133] = "NostrConnect"; - NDKKind2[NDKKind2["CategorizedPeopleList"] = 3e4] = "CategorizedPeopleList"; - NDKKind2[NDKKind2["CategorizedBookmarkList"] = 30001] = "CategorizedBookmarkList"; NDKKind2[NDKKind2["ProfileBadge"] = 30008] = "ProfileBadge"; NDKKind2[NDKKind2["BadgeDefinition"] = 30009] = "BadgeDefinition"; - NDKKind2[NDKKind2["InterestsList"] = 30015] = "InterestsList"; NDKKind2[NDKKind2["MarketStall"] = 30017] = "MarketStall"; NDKKind2[NDKKind2["MarketProduct"] = 30018] = "MarketProduct"; - NDKKind2[NDKKind2["CategorizedRelayList"] = 30022] = "CategorizedRelayList"; NDKKind2[NDKKind2["Article"] = 30023] = "Article"; NDKKind2[NDKKind2["AppSpecificData"] = 30078] = "AppSpecificData"; NDKKind2[NDKKind2["Classified"] = 30402] = "Classified"; NDKKind2[NDKKind2["AppRecommendation"] = 31989] = "AppRecommendation"; NDKKind2[NDKKind2["AppHandler"] = 31990] = "AppHandler"; - NDKKind2[NDKKind2["CategorizedHighlightList"] = 39802] = "CategorizedHighlightList"; return NDKKind2; })(NDKKind || {}); var NDKListKinds = [ - 3e4 /* CategorizedPeopleList */, + 1e4 /* MuteList */, + 10001 /* PinList */, + 10002 /* RelayList */, + 10003 /* BookmarkList */, + 10004 /* CommunityList */, + 10005 /* PublicChatList */, + 10006 /* BlockRelayList */, + 10007 /* SearchRelayList */, + 10015 /* InterestList */, + 10030 /* EmojiList */, + 3e4 /* FollowSet */, + 30003 /* BookmarkSet */, 30001 /* CategorizedBookmarkList */, - 39802 /* CategorizedHighlightList */, - 30022 /* CategorizedRelayList */, - 30015 /* InterestsList */ + // Backwards compatibility + 30002 /* RelaySet */, + 30004 /* CurationSet */, + 30015 /* InterestSet */, + 30030 /* EmojiSet */, + 39802 /* HighlightSet */ ]; // src/events/nip04.ts @@ -1299,15 +1558,10 @@ var NDKEvent = class extends EventEmitter4 { return user; } tag(userOrEvent, marker) { - const tags = userOrEvent.referenceTags(); - if (marker) - tags[0].push(marker); - this.tags.push(...tags); + const skipAuthorTag = userOrEvent?.pubkey === this.pubkey; + const tags = userOrEvent.referenceTags(marker, skipAuthorTag); + this.tags = mergeTags(this.tags, tags); if (userOrEvent instanceof NDKEvent) { - const tagEventAuthor = userOrEvent.author; - if (tagEventAuthor && this.pubkey !== tagEventAuthor.hexpubkey) { - this.tag(tagEventAuthor); - } for (const pTag of userOrEvent.getMatchingTags("p")) { if (pTag[1] === this.pubkey) continue; @@ -1438,6 +1692,9 @@ var NDKEvent = class extends EventEmitter4 { tags.push(["d", str]); } } + if (this.ndk?.client && !this.tagValue("client")) { + tags.push(["client", this.ndk.client]); + } return { content: content || "", tags }; } muted() { @@ -1498,9 +1755,11 @@ var NDKEvent = class extends EventEmitter4 { const dTagId = this.replaceableDTag(); return `${this.kind}:${this.pubkey}:${dTagId}`; } - /** @deprecated Use referenceTags instead. */ /** - * Get the tag that can be used to reference this event from another event + * Get the tag that can be used to reference this event from another event. + * + * Consider using referenceTags() instead (unless you have a good reason to use this) + * * @example * event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] }); * event.tagReference(); // ["a", "30000:pubkey:d-code"] @@ -1509,11 +1768,22 @@ var NDKEvent = class extends EventEmitter4 { * event.tagReference(); // ["e", "eventid"] * @returns {NDKTag} The NDKTag object referencing this event */ - tagReference() { + tagReference(marker) { + let tag; if (this.isParamReplaceable()) { - return ["a", this.tagAddress()]; + tag = ["a", this.tagAddress()]; + } else { + tag = ["e", this.tagId()]; } - return ["e", this.tagId()]; + if (this.relay) { + tag.push(this.relay.url); + } else { + tag.push(""); + } + if (marker) { + tag.push(marker); + } + return tag; } /** * Get the tags that can be used to reference this event from another event @@ -1526,7 +1796,7 @@ var NDKEvent = class extends EventEmitter4 { * event.referenceTags(); // [["e", "parent-id"]] * @returns {NDKTag} The NDKTag object referencing this event */ - referenceTags(marker) { + referenceTags(marker, skipAuthorTag) { let tags = []; if (this.isParamReplaceable()) { tags = [ @@ -1536,10 +1806,22 @@ var NDKEvent = class extends EventEmitter4 { } else { tags = [["e", this.id]]; } + if (this.relay?.url) { + tags = tags.map((tag) => { + tag.push(this.relay?.url); + return tag; + }); + } else if (marker) { + tags = tags.map((tag) => { + tag.push(""); + return tag; + }); + } if (marker) { tags.forEach((tag) => tag.push(marker)); } - tags.push(...this.author.referenceTags()); + if (!skipAuthorTag) + tags.push(...this.author.referenceTags()); return tags; } /** @@ -1679,7 +1961,7 @@ var NDKRelayList = class extends NDKEvent { }; // src/subscription/index.ts -import EventEmitter5 from "eventemitter3"; +import { EventEmitter as EventEmitter5 } from "tseep"; var NDKSubscriptionCacheUsage = /* @__PURE__ */ ((NDKSubscriptionCacheUsage2) => { NDKSubscriptionCacheUsage2["ONLY_CACHE"] = "ONLY_CACHE"; NDKSubscriptionCacheUsage2["CACHE_FIRST"] = "CACHE_FIRST"; @@ -1919,13 +2201,15 @@ var NDKSubscription = class extends EventEmitter5 { async function follows(opts, outbox) { if (!this.ndk) throw new Error("NDK not set"); - const contactListEvent = await this.ndk.fetchEvent( - { - kinds: [3], - authors: [this.hexpubkey] - }, - opts || { groupable: false } - ); + const contactListEvent = Array.from( + await this.ndk.fetchEvents( + { + kinds: [3], + authors: [this.pubkey] + }, + opts || { groupable: false } + ) + )[0]; if (contactListEvent) { const pubkeys = /* @__PURE__ */ new Set(); contactListEvent.tags.forEach((tag) => { @@ -1939,8 +2223,8 @@ async function follows(opts, outbox) { } } }); - return [...pubkeys].reduce((acc, hexpubkey) => { - const user = new NDKUser({ hexpubkey }); + return [...pubkeys].reduce((acc, pubkey) => { + const user = new NDKUser({ pubkey }); user.ndk = this.ndk; acc.add(user); return acc; @@ -2023,6 +2307,283 @@ function serializeProfile(profile) { return JSON.stringify(payload); } +// src/events/kinds/lists/index.ts +var NDKList = class extends NDKEvent { + _encryptedTags; + /** + * Stores the number of bytes the content was before decryption + * to expire the cache when the content changes. + */ + encryptedTagsLength; + constructor(ndk, rawEvent) { + super(ndk, rawEvent); + this.kind ??= 30001 /* CategorizedBookmarkList */; + } + /** + * Wrap a NDKEvent into a NDKList + */ + static from(ndkEvent) { + return new NDKList(ndkEvent.ndk, ndkEvent.rawEvent()); + } + /** + * Returns the title of the list. Falls back on fetching the name tag value. + */ + get title() { + const titleTag = this.tagValue("title") || this.tagValue("name"); + if (this.kind === 3 /* Contacts */ && !titleTag) { + return "Contacts"; + } else if (this.kind === 1e4 /* MuteList */ && !titleTag) { + return "Mute"; + } else if (this.kind === 10001 /* PinList */ && !titleTag) { + return "Pinned Notes"; + } else if (this.kind === 10002 /* RelayList */ && !titleTag) { + return "Relay Metadata"; + } else if (this.kind === 10003 /* BookmarkList */ && !titleTag) { + return "Bookmarks"; + } else if (this.kind === 10004 /* CommunityList */ && !titleTag) { + return "Communities"; + } else if (this.kind === 10005 /* PublicChatList */ && !titleTag) { + return "Public Chats"; + } else if (this.kind === 10006 /* BlockRelayList */ && !titleTag) { + return "Blocked Relays"; + } else if (this.kind === 10007 /* SearchRelayList */ && !titleTag) { + return "Search Relays"; + } else if (this.kind === 10015 /* InterestList */ && !titleTag) { + return "Interests"; + } else if (this.kind === 10030 /* EmojiList */ && !titleTag) { + return "Emojis"; + } else { + return titleTag ?? this.tagValue("d"); + } + } + /** + * Sets the title of the list. + */ + set title(title) { + this.removeTag("title"); + this.removeTag("name"); + if (title) { + this.tags.push(["title", title]); + } else { + throw new Error("Title cannot be empty"); + } + } + /** + * Returns the name of the list. + * @deprecated Please use "title" instead. + */ + get name() { + const nameTag = this.tagValue("name"); + if (this.kind === 3 /* Contacts */ && !nameTag) { + return "Contacts"; + } else if (this.kind === 1e4 /* MuteList */ && !nameTag) { + return "Mute"; + } else if (this.kind === 10001 /* PinList */ && !nameTag) { + return "Pinned Notes"; + } else if (this.kind === 10002 /* RelayList */ && !nameTag) { + return "Relay Metadata"; + } else if (this.kind === 10003 /* BookmarkList */ && !nameTag) { + return "Bookmarks"; + } else if (this.kind === 10004 /* CommunityList */ && !nameTag) { + return "Communities"; + } else if (this.kind === 10005 /* PublicChatList */ && !nameTag) { + return "Public Chats"; + } else if (this.kind === 10006 /* BlockRelayList */ && !nameTag) { + return "Blocked Relays"; + } else if (this.kind === 10007 /* SearchRelayList */ && !nameTag) { + return "Search Relays"; + } else if (this.kind === 10015 /* InterestList */ && !nameTag) { + return "Interests"; + } else if (this.kind === 10030 /* EmojiList */ && !nameTag) { + return "Emojis"; + } else { + return nameTag ?? this.tagValue("d"); + } + } + /** + * Sets the name of the list. + * @deprecated Please use "title" instead. This method will use the `title` tag instead. + */ + set name(name) { + this.removeTag("name"); + if (name) { + this.tags.push(["title", name]); + } else { + throw new Error("Name cannot be empty"); + } + } + /** + * Returns the description of the list. + */ + get description() { + return this.tagValue("description"); + } + /** + * Sets the description of the list. + */ + set description(name) { + if (name) { + this.tags.push(["description", name]); + } else { + this.removeTag("description"); + } + } + isEncryptedTagsCacheValid() { + return !!(this._encryptedTags && this.encryptedTagsLength === this.content.length); + } + /** + * Returns the decrypted content of the list. + */ + async encryptedTags(useCache = true) { + if (useCache && this.isEncryptedTagsCacheValid()) + return this._encryptedTags; + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + const user = await this.ndk.signer.user(); + try { + if (this.content.length > 0) { + try { + const decryptedContent = await this.ndk.signer.decrypt(user, this.content); + const a = JSON.parse(decryptedContent); + if (a && a[0]) { + this.encryptedTagsLength = this.content.length; + return this._encryptedTags = a; + } + this.encryptedTagsLength = this.content.length; + return this._encryptedTags = []; + } catch (e) { + console.log(`error decrypting ${this.content}`); + } + } + } catch (e) { + } + return []; + } + /** + * This method can be overriden to validate that a tag is valid for this list. + * + * (i.e. the NDKPersonList can validate that items are NDKUser instances) + */ + validateTag(tagValue) { + return true; + } + /** + * Returns the unecrypted items in this list. + */ + get items() { + return this.tags.filter((t) => { + return ![ + "d", + "L", + "l", + "title", + "name", + "description", + "summary", + "image", + "thumb", + "alt", + "expiration", + "subject" + ].includes(t[0]); + }); + } + /** + * Adds a new item to the list. + * @param relay Relay to add + * @param mark Optional mark to add to the item + * @param encrypted Whether to encrypt the item + */ + async addItem(item, mark = void 0, encrypted = false) { + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + let tags; + if (item instanceof NDKEvent) { + tags = item.referenceTags(); + } else if (item instanceof NDKUser) { + tags = item.referenceTags(); + } else if (item instanceof NDKRelay) { + tags = item.referenceTags(); + } else if (Array.isArray(item)) { + tags = [item]; + } else { + throw new Error("Invalid object type"); + } + if (mark) + tags[0].push(mark); + if (encrypted) { + const user = await this.ndk.signer.user(); + const currentList = await this.encryptedTags(); + currentList.push(...tags); + this._encryptedTags = currentList; + this.encryptedTagsLength = this.content.length; + this.content = JSON.stringify(currentList); + await this.encrypt(user); + } else { + this.tags.push(...tags); + } + this.created_at = Math.floor(Date.now() / 1e3); + this.emit("change"); + } + /** + * Removes an item from the list. + * + * @param index The index of the item to remove. + * @param encrypted Whether to remove from the encrypted list or not. + */ + async removeItem(index, encrypted) { + if (!this.ndk) + throw new Error("NDK instance not set"); + if (!this.ndk.signer) + throw new Error("NDK signer not set"); + if (encrypted) { + const user = await this.ndk.signer.user(); + const currentList = await this.encryptedTags(); + currentList.splice(index, 1); + this._encryptedTags = currentList; + this.encryptedTagsLength = this.content.length; + this.content = JSON.stringify(currentList); + await this.encrypt(user); + } else { + this.tags.splice(index, 1); + } + this.created_at = Math.floor(Date.now() / 1e3); + this.emit("change"); + return this; + } +}; +var lists_default = NDKList; + +// src/user/pin.ts +async function pin(event, pinEvent, publish) { + const kind = 10001 /* PinList */; + if (!this.ndk) + throw new Error("No NDK instance found"); + this.ndk.assertSigner(); + if (!pinEvent) { + const events = await this.ndk.fetchEvents( + { kinds: [kind], authors: [this.pubkey] }, + { cacheUsage: "ONLY_RELAY" /* ONLY_RELAY */ } + ); + if (events.size > 0) { + pinEvent = lists_default.from(Array.from(events)[0]); + } else { + pinEvent = new NDKEvent(this.ndk, { + kind + }); + } + } + pinEvent.tag(event); + if (publish) { + await pinEvent.publish(); + } + return pinEvent; +} + // src/user/index.ts var NDKUser = class { ndk; @@ -2045,7 +2606,7 @@ var NDKUser = class { if (!this._npub) { if (!this._pubkey) throw new Error("hexpubkey not set"); - this._npub = nip194.npubEncode(this.hexpubkey); + this._npub = nip194.npubEncode(this.pubkey); } return this._npub; } @@ -2097,7 +2658,7 @@ var NDKUser = class { const profile = await nip05.queryProfile(nip05Id); if (profile) { return new NDKUser({ - hexpubkey: profile.pubkey, + pubkey: profile.pubkey, relayUrls: profile.relays }); } @@ -2114,7 +2675,7 @@ var NDKUser = class { this.profile = {}; let setMetadataEvents = null; if (this.ndk.cacheAdapter && this.ndk.cacheAdapter.fetchProfile && opts?.cacheUsage !== "ONLY_RELAY" /* ONLY_RELAY */) { - const profile = await this.ndk.cacheAdapter.fetchProfile(this.hexpubkey); + const profile = await this.ndk.cacheAdapter.fetchProfile(this.pubkey); if (profile) { this.profile = profile; return profile; @@ -2126,7 +2687,7 @@ var NDKUser = class { setMetadataEvents = await this.ndk.fetchEvents( { kinds: [0], - authors: [this.hexpubkey] + authors: [this.pubkey] }, { cacheUsage: "ONLY_CACHE" /* ONLY_CACHE */, @@ -2145,7 +2706,7 @@ var NDKUser = class { setMetadataEvents = await this.ndk.fetchEvents( { kinds: [0], - authors: [this.hexpubkey] + authors: [this.pubkey] }, opts ); @@ -2157,7 +2718,7 @@ var NDKUser = class { return null; this.profile = profileFromEvent(sortedSetMetadataEvents[0]); if (this.profile && this.ndk.cacheAdapter && this.ndk.cacheAdapter.saveProfile) { - this.ndk.cacheAdapter.saveProfile(this.hexpubkey, this.profile); + this.ndk.cacheAdapter.saveProfile(this.pubkey, this.profile); } return this.profile; } @@ -2165,6 +2726,10 @@ var NDKUser = class { * Returns a set of users that this user follows. */ follows = follows.bind(this); + /** + * Pins a user or an event + */ + pin = pin.bind(this); /** * Returns a set of relay list events for a user. * @returns {Promise>} A set of NDKEvents returned for the given user. @@ -2180,13 +2745,13 @@ var NDKUser = class { const event = await this.ndk.fetchEvent( { kinds: [10002], - authors: [this.hexpubkey] + authors: [this.pubkey] }, { closeOnEose: true, pool, groupable: true, - subId: `relay-list-${this.hexpubkey.slice(0, 6)}` + subId: `relay-list-${this.pubkey.slice(0, 6)}` }, relaySet ); @@ -2199,7 +2764,7 @@ var NDKUser = class { throw new Error("NDK not set"); const followList = await this.ndk.fetchEvent({ kinds: [3], - authors: [this.hexpubkey] + authors: [this.pubkey] }); if (followList) { try { @@ -2233,14 +2798,18 @@ var NDKUser = class { * @returns {NDKTag} an NDKTag */ tagReference() { - return ["p", this.hexpubkey]; + return ["p", this.pubkey]; } /** * Get the tags that can be used to reference this user in an event * @returns {NDKTag[]} an array of NDKTag */ - referenceTags() { - return [["p", this.hexpubkey]]; + referenceTags(marker) { + const tag = [["p", this.pubkey]]; + if (!marker) + return tag; + tag[0].push("", marker); + return tag; } /** * Publishes the current profile. @@ -2288,8 +2857,8 @@ var NDKUser = class { * Validate a user's NIP-05 identifier (usually fetched from their kind:0 profile data) * * @param nip05Id The NIP-05 string to validate - * @returns {Promise} True if the NIP-05 is found and matches this user's hexpubkey, - * False if the NIP-05 is found but doesn't match this user's hexpubkey, + * @returns {Promise} True if the NIP-05 is found and matches this user's pubkey, + * False if the NIP-05 is found but doesn't match this user's pubkey, * null if the NIP-05 isn't found on the domain or we're unable to verify (because of network issues, etc.) */ async validateNip05(nip05Id) { @@ -2298,7 +2867,7 @@ var NDKUser = class { const profilePointer = await nip05.queryProfile(nip05Id); if (profilePointer === null) return null; - return profilePointer.pubkey === this.hexpubkey; + return profilePointer.pubkey === this.pubkey; } /** * Zap a user @@ -2745,216 +3314,6 @@ var NDKTranscriptionDVM = class extends NDKDVMRequest { } }; -// src/events/kinds/lists/index.ts -var NDKList = class extends NDKEvent { - _encryptedTags; - /** - * Stores the number of bytes the content was before decryption - * to expire the cache when the content changes. - */ - encryptedTagsLength; - constructor(ndk, rawEvent) { - super(ndk, rawEvent); - this.kind ??= 30001 /* CategorizedBookmarkList */; - } - /** - * Wrap a NDKEvent into a NDKList - */ - static from(ndkEvent) { - return new NDKList(ndkEvent.ndk, ndkEvent.rawEvent()); - } - /** - * Returns the title of the list. Falls back on fetching the name tag value. - */ - get title() { - const titleTag = this.tagValue("title") || this.tagValue("name"); - if (this.kind === 3 /* Contacts */ && !titleTag) { - return "Contacts"; - } else if (this.kind === 1e4 /* MuteList */ && !titleTag) { - return "Mute"; - } else if (this.kind === 10001 /* PinList */ && !titleTag) { - return "Pin"; - } else if (this.kind === 10002 /* RelayList */ && !titleTag) { - return "Relay Metadata"; - } else { - return titleTag ?? this.tagValue("d"); - } - } - /** - * Sets the title of the list. - */ - set title(title) { - this.removeTag("title"); - this.removeTag("name"); - if (title) { - this.tags.push(["title", title]); - } else { - throw new Error("Title cannot be empty"); - } - } - /** - * Returns the name of the list. - * @deprecated Please use "title" instead. - */ - get name() { - const nameTag = this.tagValue("name"); - if (this.kind === 3 /* Contacts */ && !nameTag) { - return "Contacts"; - } else if (this.kind === 1e4 /* MuteList */ && !nameTag) { - return "Mute"; - } else if (this.kind === 10001 /* PinList */ && !nameTag) { - return "Pin"; - } else if (this.kind === 10002 /* RelayList */ && !nameTag) { - return "Relay Metadata"; - } else { - return nameTag ?? this.tagValue("d"); - } - } - /** - * Sets the name of the list. - * @deprecated Please use "title" instead. This method will use the `title` tag instead. - */ - set name(name) { - this.removeTag("name"); - if (name) { - this.tags.push(["title", name]); - } else { - throw new Error("Name cannot be empty"); - } - } - /** - * Returns the description of the list. - */ - get description() { - return this.tagValue("description"); - } - /** - * Sets the description of the list. - */ - set description(name) { - if (name) { - this.tags.push(["description", name]); - } else { - this.removeTag("description"); - } - } - isEncryptedTagsCacheValid() { - return !!(this._encryptedTags && this.encryptedTagsLength === this.content.length); - } - /** - * Returns the decrypted content of the list. - */ - async encryptedTags(useCache = true) { - if (useCache && this.isEncryptedTagsCacheValid()) - return this._encryptedTags; - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - const user = await this.ndk.signer.user(); - try { - if (this.content.length > 0) { - try { - const decryptedContent = await this.ndk.signer.decrypt(user, this.content); - const a = JSON.parse(decryptedContent); - if (a && a[0]) { - this.encryptedTagsLength = this.content.length; - return this._encryptedTags = a; - } - this.encryptedTagsLength = this.content.length; - return this._encryptedTags = []; - } catch (e) { - console.log(`error decrypting ${this.content}`); - } - } - } catch (e) { - } - return []; - } - /** - * This method can be overriden to validate that a tag is valid for this list. - * - * (i.e. the NDKPersonList can validate that items are NDKUser instances) - */ - validateTag(tagValue) { - return true; - } - /** - * Returns the unecrypted items in this list. - */ - get items() { - return this.tags.filter((t) => { - return !["d", "name", "description"].includes(t[0]); - }); - } - /** - * Adds a new item to the list. - * @param relay Relay to add - * @param mark Optional mark to add to the item - * @param encrypted Whether to encrypt the item - */ - async addItem(item, mark = void 0, encrypted = false) { - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - let tags; - if (item instanceof NDKEvent) { - tags = item.referenceTags(); - } else if (item instanceof NDKUser) { - tags = item.referenceTags(); - } else if (item instanceof NDKRelay) { - tags = item.referenceTags(); - } else if (Array.isArray(item)) { - tags = [item]; - } else { - throw new Error("Invalid object type"); - } - if (mark) - tags[0].push(mark); - if (encrypted) { - const user = await this.ndk.signer.user(); - const currentList = await this.encryptedTags(); - currentList.push(...tags); - this._encryptedTags = currentList; - this.encryptedTagsLength = this.content.length; - this.content = JSON.stringify(currentList); - await this.encrypt(user); - } else { - this.tags.push(...tags); - } - this.created_at = Math.floor(Date.now() / 1e3); - this.emit("change"); - } - /** - * Removes an item from the list. - * - * @param index The index of the item to remove. - * @param encrypted Whether to remove from the encrypted list or not. - */ - async removeItem(index, encrypted) { - if (!this.ndk) - throw new Error("NDK instance not set"); - if (!this.ndk.signer) - throw new Error("NDK signer not set"); - if (encrypted) { - const user = await this.ndk.signer.user(); - const currentList = await this.encryptedTags(); - currentList.splice(index, 1); - this._encryptedTags = currentList; - this.encryptedTagsLength = this.content.length; - this.content = JSON.stringify(currentList); - await this.encrypt(user); - } else { - this.tags.splice(index, 1); - } - this.created_at = Math.floor(Date.now() / 1e3); - this.emit("change"); - return this; - } -}; -var lists_default = NDKList; - // src/events/kinds/repost.ts var NDKRepost = class extends NDKEvent { _repostedEvents; @@ -3086,6 +3445,17 @@ var NDKNip07Signer = class { const signedEvent = await window.nostr.signEvent(event); return signedEvent.sig; } + async relays() { + await this.waitForExtension(); + const relays = await window.nostr.getRelays?.() || {}; + const activeRelays = []; + for (const url in Object.keys(relays)) { + if (relays[url].read && relays[url].write) { + activeRelays.push(url); + } + } + return activeRelays.map((url) => new NDKRelay(url)); + } async encrypt(recipient, value) { await this.waitForExtension(); const recipientHexPubKey = recipient.hexpubkey; @@ -3224,7 +3594,7 @@ var NDKPrivateKeySigner = class { }; // src/signers/nip46/rpc.ts -import EventEmitter6 from "eventemitter3"; +import { EventEmitter as EventEmitter6 } from "tseep"; var NDKNostrRpc = class extends EventEmitter6 { ndk; signer; @@ -3238,8 +3608,11 @@ var NDKNostrRpc = class extends EventEmitter6 { /** * Subscribe to a filter. This function will resolve once the subscription is ready. */ - async subscribe(filter) { - const sub = this.ndk.subscribe(filter, { closeOnEose: false }); + subscribe(filter) { + const sub = this.ndk.subscribe(filter, { + closeOnEose: false, + groupable: false + }); sub.on("event", async (event) => { try { const parsedEvent = await this.parseEvent(event); @@ -3299,8 +3672,15 @@ var NDKNostrRpc = class extends EventEmitter6 { const remoteUser = this.ndk.getUser({ hexpubkey: remotePubkey }); const request = { id, method, params }; const promise = new Promise((resolve) => { - if (cb) - this.once(`response-${id}`, cb); + const responseHandler = (response) => { + if (response.result === "auth_url") { + this.once(`response-${id}`, responseHandler); + this.emit("authUrl", response.error); + } else if (cb) { + cb(response); + } + }; + this.once(`response-${id}`, responseHandler); }); const event = new NDKEvent(this.ndk, { kind, @@ -3318,7 +3698,7 @@ var NDKNostrRpc = class extends EventEmitter6 { // src/signers/nip46/backend/connect.ts var ConnectEventHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [pubkey, token] = params; const debug4 = backend.debug.extend("connect"); debug4(`connection request from ${pubkey}`); @@ -3326,7 +3706,7 @@ var ConnectEventHandlingStrategy = class { debug4(`applying token`); await backend.applyToken(pubkey, token); } - if (await backend.pubkeyAllowed(pubkey, "connect", token)) { + if (await backend.pubkeyAllowed({ id, pubkey, method: "connect", params: token })) { debug4(`connection request from ${pubkey} allowed`); return "ack"; } else { @@ -3336,50 +3716,84 @@ var ConnectEventHandlingStrategy = class { } }; -// src/signers/nip46/backend/describe.ts -var DescribeHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - const keys = Object.keys(backend.handlers); - return JSON.stringify(keys); - } -}; - // src/signers/nip46/backend/get-public-key.ts var GetPublicKeyHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - return backend.localUser?.hexpubkey; + async handle(backend, id, remotePubkey, params) { + return backend.localUser?.pubkey; } }; // src/signers/nip46/backend/nip04-decrypt.ts var Nip04DecryptHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [senderPubkey, payload] = params; const senderUser = new NDKUser({ hexpubkey: senderPubkey }); - const decryptedPayload = await backend.decrypt(remotePubkey, senderUser, payload); + const decryptedPayload = await decrypt2(backend, id, remotePubkey, senderUser, payload); return JSON.stringify([decryptedPayload]); } }; +async function decrypt2(backend, id, remotePubkey, senderUser, payload) { + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "decrypt", + params: payload + })) { + backend.debug(`decrypt request from ${remotePubkey} rejected`); + return void 0; + } + return await backend.signer.decrypt(senderUser, payload); +} // src/signers/nip46/backend/nip04-encrypt.ts var Nip04EncryptHandlingStrategy = class { - async handle(backend, remotePubkey, params) { + async handle(backend, id, remotePubkey, params) { const [recipientPubkey, payload] = params; const recipientUser = new NDKUser({ hexpubkey: recipientPubkey }); - const decryptedPayload = await backend.encrypt(remotePubkey, recipientUser, payload); - return decryptedPayload; + const encryptedPayload = await encrypt2(backend, id, remotePubkey, recipientUser, payload); + return encryptedPayload; } }; +async function encrypt2(backend, id, remotePubkey, recipientUser, payload) { + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "encrypt", + params: payload + })) { + backend.debug(`encrypt request from ${remotePubkey} rejected`); + return void 0; + } + return await backend.signer.encrypt(recipientUser, payload); +} // src/signers/nip46/backend/sign-event.ts var SignEventHandlingStrategy = class { - async handle(backend, remotePubkey, params) { - const event = await backend.signEvent(remotePubkey, params); + async handle(backend, id, remotePubkey, params) { + const event = await signEvent(backend, id, remotePubkey, params); if (!event) return void 0; return JSON.stringify(await event.toNostrEvent()); } }; +async function signEvent(backend, id, remotePubkey, params) { + const [eventString] = params; + backend.debug(`sign event request from ${remotePubkey}`); + const event = new NDKEvent(backend.ndk, JSON.parse(eventString)); + backend.debug("event to sign", event.rawEvent()); + if (!await backend.pubkeyAllowed({ + id, + pubkey: remotePubkey, + method: "sign_event", + params: event + })) { + backend.debug(`sign event request from ${remotePubkey} rejected`); + return void 0; + } + backend.debug(`sign event request from ${remotePubkey} allowed`); + await event.sign(backend.signer); + return event; +} // src/signers/nip46/backend/index.ts var NDKNip46Backend = class { @@ -3420,8 +3834,7 @@ var NDKNip46Backend = class { sign_event: new SignEventHandlingStrategy(), nip04_encrypt: new Nip04EncryptHandlingStrategy(), nip04_decrypt: new Nip04DecryptHandlingStrategy(), - get_public_key: new GetPublicKeyHandlingStrategy(), - describe: new DescribeHandlingStrategy() + get_public_key: new GetPublicKeyHandlingStrategy() }; /** * Enables the user to set a custom strategy for handling incoming events. @@ -3452,7 +3865,7 @@ var NDKNip46Backend = class { const strategy = this.handlers[method]; if (strategy) { try { - response = await strategy.handle(this, remotePubkey, params); + response = await strategy.handle(this, id, remotePubkey, params); } catch (e) { this.debug("error handling event", e, { id, method, params }); this.rpc.sendResponse(id, remotePubkey, "error", void 0, e.message); @@ -3467,82 +3880,66 @@ var NDKNip46Backend = class { this.rpc.sendResponse(id, remotePubkey, "error", void 0, "Not authorized"); } } - async decrypt(remotePubkey, senderUser, payload) { - if (!await this.pubkeyAllowed(remotePubkey, "decrypt", payload)) { - this.debug(`decrypt request from ${remotePubkey} rejected`); - return void 0; - } - return await this.signer.decrypt(senderUser, payload); - } - async encrypt(remotePubkey, recipientUser, payload) { - if (!await this.pubkeyAllowed(remotePubkey, "encrypt", payload)) { - this.debug(`encrypt request from ${remotePubkey} rejected`); - return void 0; - } - return await this.signer.encrypt(recipientUser, payload); - } - async signEvent(remotePubkey, params) { - const [eventString] = params; - this.debug(`sign event request from ${remotePubkey}`); - const event = new NDKEvent(this.ndk, JSON.parse(eventString)); - this.debug("event to sign", event.rawEvent()); - if (!await this.pubkeyAllowed(remotePubkey, "sign_event", event)) { - this.debug(`sign event request from ${remotePubkey} rejected`); - return void 0; - } - this.debug(`sign event request from ${remotePubkey} allowed`); - await event.sign(this.signer); - return event; - } /** * This method should be overriden by the user to allow or reject incoming * connections. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - async pubkeyAllowed(pubkey, method, params) { - return this.permitCallback(pubkey, method, params); + async pubkeyAllowed(params) { + return this.permitCallback(params); } }; +// ../node_modules/eventemitter3/index.mjs +var import_index6 = __toESM(require_eventemitter3(), 1); +var eventemitter3_default = import_index6.default; + // src/signers/nip46/index.ts -var NDKNip46Signer = class { +var NDKNip46Signer = class extends eventemitter3_default { ndk; remoteUser; remotePubkey; token; localSigner; + nip05; rpc; debug; /** * @param ndk - The NDK instance to use - * @param tokenOrRemotePubkey - The public key, or a connection token, of the npub that wants to be published as + * @param tokenOrRemoteUser - The public key, or a connection token, of the npub that wants to be published as * @param localSigner - The signer that will be used to request events to be signed */ - constructor(ndk, tokenOrRemotePubkey, localSigner) { + constructor(ndk, tokenOrRemoteUser, localSigner) { + super(); let remotePubkey; let token; - if (tokenOrRemotePubkey.includes("#")) { - const parts = tokenOrRemotePubkey.split("#"); - remotePubkey = new NDKUser({ npub: parts[0] }).hexpubkey; + if (tokenOrRemoteUser.includes("#")) { + const parts = tokenOrRemoteUser.split("#"); + remotePubkey = new NDKUser({ npub: parts[0] }).pubkey; token = parts[1]; - } else if (tokenOrRemotePubkey.startsWith("npub")) { + } else if (tokenOrRemoteUser.startsWith("npub")) { remotePubkey = new NDKUser({ - npub: tokenOrRemotePubkey - }).hexpubkey; + npub: tokenOrRemoteUser + }).pubkey; + } else if (tokenOrRemoteUser.match(/\./)) { + this.nip05 = tokenOrRemoteUser; } else { - remotePubkey = tokenOrRemotePubkey; + remotePubkey = tokenOrRemoteUser; } this.ndk = ndk; - this.remotePubkey = remotePubkey; + if (remotePubkey) + this.remotePubkey = remotePubkey; this.token = token; this.debug = ndk.debug.extend("nip46:signer"); - this.remoteUser = new NDKUser({ hexpubkey: remotePubkey }); + this.remoteUser = new NDKUser({ pubkey: remotePubkey }); if (!localSigner) { this.localSigner = NDKPrivateKeySigner.generate(); } else { this.localSigner = localSigner; } this.rpc = new NDKNostrRpc(ndk, this.localSigner, this.debug); + this.rpc.on("authUrl", (...props) => { + this.emit("authUrl", ...props); + }); } /** * Get the user that is being published as @@ -3552,14 +3949,25 @@ var NDKNip46Signer = class { } async blockUntilReady() { const localUser = await this.localSigner.user(); - const user = this.ndk.getUser({ npub: localUser.npub }); + const remoteUser = this.ndk.getUser({ pubkey: this.remotePubkey }); + if (this.nip05 && !this.remotePubkey) { + const remoteUser2 = NDKUser.fromNip05(this.nip05).then((user) => { + if (user) { + this.remoteUser = user; + this.remotePubkey = user.pubkey; + } + }); + } + if (!this.remotePubkey) { + throw new Error("Remote pubkey not set"); + } await this.rpc.subscribe({ kinds: [24133], - "#p": [localUser.hexpubkey] + "#p": [localUser.pubkey] }); return new Promise((resolve, reject) => { setTimeout(() => { - const connectParams = [localUser.hexpubkey]; + const connectParams = [localUser.pubkey]; if (this.token) { connectParams.push(this.token); } @@ -3570,7 +3978,7 @@ var NDKNip46Signer = class { 24133, (response) => { if (response.result === "ack") { - resolve(user); + resolve(remoteUser); } else { reject(response.error); } @@ -3585,7 +3993,7 @@ var NDKNip46Signer = class { this.rpc.sendRequest( this.remotePubkey, "nip04_encrypt", - [recipient.hexpubkey, value], + [recipient.pubkey, value], 24133, (response) => { if (!response.error) { @@ -3604,7 +4012,7 @@ var NDKNip46Signer = class { this.rpc.sendRequest( this.remotePubkey, "nip04_decrypt", - [sender.hexpubkey, value], + [sender.pubkey, value], 24133, (response) => { if (!response.error) { @@ -3643,7 +4051,7 @@ var NDKNip46Signer = class { // src/ndk/index.ts import debug3 from "debug"; -import EventEmitter9 from "eventemitter3"; +import { EventEmitter as EventEmitter10 } from "tseep"; // src/events/dedup.ts function dedup(event1, event2) { @@ -3654,7 +4062,7 @@ function dedup(event1, event2) { } // src/outbox/tracker.ts -import EventEmitter7 from "eventemitter3"; +import { EventEmitter as EventEmitter8 } from "tseep"; import { LRUCache } from "typescript-lru-cache"; var OutboxItem = class { /** @@ -3674,7 +4082,7 @@ var OutboxItem = class { this.writeRelays = /* @__PURE__ */ new Set(); } }; -var OutboxTracker = class extends EventEmitter7 { +var OutboxTracker = class extends EventEmitter8 { data; ndk; debug; @@ -3750,8 +4158,8 @@ function getTypeFromItem(item) { } // src/relay/pool/index.ts -import EventEmitter8 from "eventemitter3"; -var NDKPool = class extends EventEmitter8 { +import { EventEmitter as EventEmitter9 } from "tseep"; +var NDKPool = class extends EventEmitter9 { // TODO: This should probably be an LRU cache relays = /* @__PURE__ */ new Map(); blacklistRelayUrls; @@ -3802,9 +4210,9 @@ var NDKPool = class extends EventEmitter8 { this.debug(`Relay ${relayUrl} is blacklisted`); return; } - relay.on("notice", (relay2, notice) => this.emit("notice", relay2, notice)); + relay.on("notice", async (relay2, notice) => this.emit("notice", relay2, notice)); relay.on("connect", () => this.handleRelayConnect(relayUrl)); - relay.on("disconnect", () => this.emit("relay:disconnect", relay)); + relay.on("disconnect", async () => this.emit("relay:disconnect", relay)); relay.on("flapping", () => this.handleFlapping(relay)); this.relays.set(relayUrl, relay); if (connect) { @@ -3980,7 +4388,7 @@ var DEFAULT_BLACKLISTED_RELAYS = [ "wss://brb.io" // BRB ]; -var NDK = class extends EventEmitter9 { +var NDK = class extends EventEmitter10 { explicitRelayUrls; pool; outboxPool; @@ -3991,6 +4399,7 @@ var NDK = class extends EventEmitter9 { devWriteRelaySet; outboxTracker; mutedIds; + client; autoConnectUserRelays = true; autoFetchUserMutelist = true; constructor(opts = {}) { @@ -4001,6 +4410,7 @@ var NDK = class extends EventEmitter9 { this.debug(`Starting with explicit relays: ${JSON.stringify(this.explicitRelayUrls)}`); this.autoConnectUserRelays = opts.autoConnectUserRelays ?? true; this.autoFetchUserMutelist = opts.autoFetchUserMutelist ?? true; + this.client = opts.client; if (opts.enableOutboxModel) { this.outboxPool = new NDKPool( opts.outboxRelayUrls || DEFAULT_OUTBOX_RELAYS, @@ -4058,7 +4468,7 @@ var NDK = class extends EventEmitter9 { const muteLists = await this.fetchEvents([ { kinds: [1e4 /* MuteList */], authors: [user2.pubkey] }, { - kinds: [3e4 /* CategorizedPeopleList */], + kinds: [3e4 /* FollowSet */], authors: [user2.pubkey], "#d": ["mute"], limit: 1 @@ -4115,6 +4525,13 @@ var NDK = class extends EventEmitter9 { * If the timeout is reached, the connection will be continued to be established in the background. */ async connect(timeoutMs) { + if (this._signer && this.autoConnectUserRelays) { + this.debug("Attempting to connect to user relays specified by signer"); + if (this._signer.relays) { + const relays = await this._signer.relays(); + relays.forEach((relay) => this.pool.addRelay(relay)); + } + } const connections = [this.pool.connect(timeoutMs)]; if (this.outboxPool) { connections.push(this.outboxPool.connect(timeoutMs)); diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/README.md b/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/README.md deleted file mode 100644 index badc2b19..00000000 --- a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/README.md +++ /dev/null @@ -1,872 +0,0 @@ -
- Node Fetch -
-

A light-weight module that brings Fetch API to Node.js.

- Build status - Coverage status - Current version - Install size - Mentioned in Awesome Node.js - Discord -
-
- Consider supporting us on our Open Collective: -
-
- Open Collective -
- ---- - -**You might be looking for the [v2 docs](https://github.com/node-fetch/node-fetch/tree/2.x#readme)** - - - -- [Motivation](#motivation) -- [Features](#features) -- [Difference from client-side fetch](#difference-from-client-side-fetch) -- [Installation](#installation) -- [Loading and configuring the module](#loading-and-configuring-the-module) -- [Upgrading](#upgrading) -- [Common Usage](#common-usage) - - [Plain text or HTML](#plain-text-or-html) - - [JSON](#json) - - [Simple Post](#simple-post) - - [Post with JSON](#post-with-json) - - [Post with form parameters](#post-with-form-parameters) - - [Handling exceptions](#handling-exceptions) - - [Handling client and server errors](#handling-client-and-server-errors) - - [Handling cookies](#handling-cookies) -- [Advanced Usage](#advanced-usage) - - [Streams](#streams) - - [Accessing Headers and other Metadata](#accessing-headers-and-other-metadata) - - [Extract Set-Cookie Header](#extract-set-cookie-header) - - [Post data using a file](#post-data-using-a-file) - - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal) -- [API](#api) - - [fetch(url[, options])](#fetchurl-options) - - [Options](#options) - - [Default Headers](#default-headers) - - [Custom Agent](#custom-agent) - - [Custom highWaterMark](#custom-highwatermark) - - [Insecure HTTP Parser](#insecure-http-parser) - - [Class: Request](#class-request) - - [new Request(input[, options])](#new-requestinput-options) - - [Class: Response](#class-response) - - [new Response([body[, options]])](#new-responsebody-options) - - [response.ok](#responseok) - - [response.redirected](#responseredirected) - - [response.type](#responsetype) - - [Class: Headers](#class-headers) - - [new Headers([init])](#new-headersinit) - - [Interface: Body](#interface-body) - - [body.body](#bodybody) - - [body.bodyUsed](#bodybodyused) - - [body.arrayBuffer()](#bodyarraybuffer) - - [body.blob()](#bodyblob) - - [body.formData()](#formdata) - - [body.json()](#bodyjson) - - [body.text()](#bodytext) - - [Class: FetchError](#class-fetcherror) - - [Class: AbortError](#class-aborterror) -- [TypeScript](#typescript) -- [Acknowledgement](#acknowledgement) -- [Team](#team) - - [Former](#former) -- [License](#license) - - - -## Motivation - -Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. - -See Jason Miller's [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). - -## Features - -- Stay consistent with `window.fetch` API. -- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences. -- Use native promise and async functions. -- Use native Node streams for body, on both request and response. -- Decode content encoding (gzip/deflate/brotli) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. -- Useful extensions such as redirect limit, response size limit, [explicit errors][error-handling.md] for troubleshooting. - -## Difference from client-side fetch - -- See known differences: - - [As of v3.x](docs/v3-LIMITS.md) - - [As of v2.x](docs/v2-LIMITS.md) -- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue. -- Pull requests are welcomed too! - -## Installation - -Current stable release (`3.x`) requires at least Node.js 12.20.0. - -```sh -npm install node-fetch -``` - -## Loading and configuring the module - -### ES Modules (ESM) - -```js -import fetch from 'node-fetch'; -``` - -### CommonJS - -`node-fetch` from v3 is an ESM-only module - you are not able to import it with `require()`. - -If you cannot switch to ESM, please use v2 which remains compatible with CommonJS. Critical bug fixes will continue to be published for v2. - -```sh -npm install node-fetch@2 -``` - -Alternatively, you can use the async `import()` function from CommonJS to load `node-fetch` asynchronously: - -```js -// mod.cjs -const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); -``` - -### Providing global access - -To use `fetch()` without importing it, you can patch the `global` object in node: - -```js -// fetch-polyfill.js -import fetch, { - Blob, - blobFrom, - blobFromSync, - File, - fileFrom, - fileFromSync, - FormData, - Headers, - Request, - Response, -} from 'node-fetch' - -if (!globalThis.fetch) { - globalThis.fetch = fetch - globalThis.Headers = Headers - globalThis.Request = Request - globalThis.Response = Response -} - -// index.js -import './fetch-polyfill' - -// ... -``` - -## Upgrading - -Using an old version of node-fetch? Check out the following files: - -- [2.x to 3.x upgrade guide](docs/v3-UPGRADE-GUIDE.md) -- [1.x to 2.x upgrade guide](docs/v2-UPGRADE-GUIDE.md) -- [Changelog](https://github.com/node-fetch/node-fetch/releases) - -## Common Usage - -NOTE: The documentation below is up-to-date with `3.x` releases, if you are using an older version, please check how to [upgrade](#upgrading). - -### Plain text or HTML - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://github.com/'); -const body = await response.text(); - -console.log(body); -``` - -### JSON - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://api.github.com/users/github'); -const data = await response.json(); - -console.log(data); -``` - -### Simple Post - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://httpbin.org/post', {method: 'POST', body: 'a=1'}); -const data = await response.json(); - -console.log(data); -``` - -### Post with JSON - -```js -import fetch from 'node-fetch'; - -const body = {a: 1}; - -const response = await fetch('https://httpbin.org/post', { - method: 'post', - body: JSON.stringify(body), - headers: {'Content-Type': 'application/json'} -}); -const data = await response.json(); - -console.log(data); -``` - -### Post with form parameters - -`URLSearchParams` is available on the global object in Node.js as of v10.0.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods. - -NOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such: - -```js -import fetch from 'node-fetch'; - -const params = new URLSearchParams(); -params.append('a', 1); - -const response = await fetch('https://httpbin.org/post', {method: 'POST', body: params}); -const data = await response.json(); - -console.log(data); -``` - -### Handling exceptions - -NOTE: 3xx-5xx responses are _NOT_ exceptions, and should be handled in `then()`, see the next section. - -Wrapping the fetch function into a `try/catch` block will catch _all_ exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document][error-handling.md] for more details. - -```js -import fetch from 'node-fetch'; - -try { - await fetch('https://domain.invalid/'); -} catch (error) { - console.log(error); -} -``` - -### Handling client and server errors - -It is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses: - -```js -import fetch from 'node-fetch'; - -class HTTPResponseError extends Error { - constructor(response) { - super(`HTTP Error Response: ${response.status} ${response.statusText}`); - this.response = response; - } -} - -const checkStatus = response => { - if (response.ok) { - // response.status >= 200 && response.status < 300 - return response; - } else { - throw new HTTPResponseError(response); - } -} - -const response = await fetch('https://httpbin.org/status/400'); - -try { - checkStatus(response); -} catch (error) { - console.error(error); - - const errorBody = await error.response.text(); - console.error(`Error body: ${errorBody}`); -} -``` - -### Handling cookies - -Cookies are not stored by default. However, cookies can be extracted and passed by manipulating request and response headers. See [Extract Set-Cookie Header](#extract-set-cookie-header) for details. - -## Advanced Usage - -### Streams - -The "Node.js way" is to use streams when possible. You can pipe `res.body` to another stream. This example uses [stream.pipeline](https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback) to attach stream error handlers and wait for the download to complete. - -```js -import {createWriteStream} from 'node:fs'; -import {pipeline} from 'node:stream'; -import {promisify} from 'node:util' -import fetch from 'node-fetch'; - -const streamPipeline = promisify(pipeline); - -const response = await fetch('https://github.githubassets.com/images/modules/logos_page/Octocat.png'); - -if (!response.ok) throw new Error(`unexpected response ${response.statusText}`); - -await streamPipeline(response.body, createWriteStream('./octocat.png')); -``` - -In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch -errors -- the longer a response runs, the more likely it is to encounter an error. - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://httpbin.org/stream/3'); - -try { - for await (const chunk of response.body) { - console.dir(JSON.parse(chunk.toString())); - } -} catch (err) { - console.error(err.stack); -} -``` - -In Node.js 12 you can also use async iterators to read `body`; however, async iterators with streams -did not mature until Node.js 14, so you need to do some extra work to ensure you handle errors -directly from the stream and wait on it response to fully close. - -```js -import fetch from 'node-fetch'; - -const read = async body => { - let error; - body.on('error', err => { - error = err; - }); - - for await (const chunk of body) { - console.dir(JSON.parse(chunk.toString())); - } - - return new Promise((resolve, reject) => { - body.on('close', () => { - error ? reject(error) : resolve(); - }); - }); -}; - -try { - const response = await fetch('https://httpbin.org/stream/3'); - await read(response.body); -} catch (err) { - console.error(err.stack); -} -``` - -### Accessing Headers and other Metadata - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://github.com/'); - -console.log(response.ok); -console.log(response.status); -console.log(response.statusText); -console.log(response.headers.raw()); -console.log(response.headers.get('content-type')); -``` - -### Extract Set-Cookie Header - -Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API. - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://example.com'); - -// Returns an array of values, instead of a string of comma-separated values -console.log(response.headers.raw()['set-cookie']); -``` - -### Post data using a file - -```js -import fetch, { - Blob, - blobFrom, - blobFromSync, - File, - fileFrom, - fileFromSync, -} from 'node-fetch' - -const mimetype = 'text/plain' -const blob = fileFromSync('./input.txt', mimetype) -const url = 'https://httpbin.org/post' - -const response = await fetch(url, { method: 'POST', body: blob }) -const data = await response.json() - -console.log(data) -``` - -node-fetch comes with a spec-compliant [FormData] implementations for posting -multipart/form-data payloads - -```js -import fetch, { FormData, File, fileFrom } from 'node-fetch' - -const httpbin = 'https://httpbin.org/post' -const formData = new FormData() -const binary = new Uint8Array([ 97, 98, 99 ]) -const abc = new File([binary], 'abc.txt', { type: 'text/plain' }) - -formData.set('greeting', 'Hello, world!') -formData.set('file-upload', abc, 'new name.txt') - -const response = await fetch(httpbin, { method: 'POST', body: formData }) -const data = await response.json() - -console.log(data) -``` - -If you for some reason need to post a stream coming from any arbitrary place, -then you can append a [Blob] or a [File] look-a-like item. - -The minimum requirement is that it has: -1. A `Symbol.toStringTag` getter or property that is either `Blob` or `File` -2. A known size. -3. And either a `stream()` method or a `arrayBuffer()` method that returns a ArrayBuffer. - -The `stream()` must return any async iterable object as long as it yields Uint8Array (or Buffer) -so Node.Readable streams and whatwg streams works just fine. - -```js -formData.append('upload', { - [Symbol.toStringTag]: 'Blob', - size: 3, - *stream() { - yield new Uint8Array([97, 98, 99]) - }, - arrayBuffer() { - return new Uint8Array([97, 98, 99]).buffer - } -}, 'abc.txt') -``` - -### Request cancellation with AbortSignal - -You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller). - -An example of timing out a request after 150ms could be achieved as the following: - -```js -import fetch, { AbortError } from 'node-fetch'; - -// AbortController was added in node v14.17.0 globally -const AbortController = globalThis.AbortController || await import('abort-controller') - -const controller = new AbortController(); -const timeout = setTimeout(() => { - controller.abort(); -}, 150); - -try { - const response = await fetch('https://example.com', {signal: controller.signal}); - const data = await response.json(); -} catch (error) { - if (error instanceof AbortError) { - console.log('request was aborted'); - } -} finally { - clearTimeout(timeout); -} -``` - -See [test cases](https://github.com/node-fetch/node-fetch/blob/master/test/) for more examples. - -## API - -### fetch(url[, options]) - -- `url` A string representing the URL for fetching -- `options` [Options](#fetch-options) for the HTTP(S) request -- Returns: Promise<[Response](#class-response)> - -Perform an HTTP(S) fetch. - -`url` should be an absolute URL, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. - - - -### Options - -The default values are shown after each option key. - -```js -{ - // These properties are part of the Fetch Standard - method: 'GET', - headers: {}, // Request headers. format is the identical to that accepted by the Headers constructor (see below) - body: null, // Request body. can be null, or a Node.js Readable stream - redirect: 'follow', // Set to `manual` to extract redirect headers, `error` to reject redirect - signal: null, // Pass an instance of AbortSignal to optionally abort requests - - // The following properties are node-fetch extensions - follow: 20, // maximum redirect count. 0 to not follow redirect - compress: true, // support gzip/deflate content encoding. false to disable - size: 0, // maximum response body size in bytes. 0 to disable - agent: null, // http(s).Agent instance or function that returns an instance (see below) - highWaterMark: 16384, // the maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. - insecureHTTPParser: false // Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. -} -``` - -#### Default Headers - -If no values are set, the following request headers will be sent automatically: - -| Header | Value | -| ------------------- | ------------------------------------------------------ | -| `Accept-Encoding` | `gzip, deflate, br` (when `options.compress === true`) | -| `Accept` | `*/*` | -| `Content-Length` | _(automatically calculated, if possible)_ | -| `Host` | _(host and port information from the target URI)_ | -| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ | -| `User-Agent` | `node-fetch` | - - -Note: when `body` is a `Stream`, `Content-Length` is not set automatically. - -#### Custom Agent - -The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following: - -- Support self-signed certificate -- Use only IPv4 or IPv6 -- Custom DNS Lookup - -See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information. - -If no agent is specified, the default agent provided by Node.js is used. Note that [this changed in Node.js 19](https://github.com/nodejs/node/blob/4267b92604ad78584244488e7f7508a690cb80d0/lib/_http_agent.js#L564) to have `keepalive` true by default. If you wish to enable `keepalive` in an earlier version of Node.js, you can override the agent as per the following code sample. - -In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. - -```js -import http from 'node:http'; -import https from 'node:https'; - -const httpAgent = new http.Agent({ - keepAlive: true -}); -const httpsAgent = new https.Agent({ - keepAlive: true -}); - -const options = { - agent: function(_parsedURL) { - if (_parsedURL.protocol == 'http:') { - return httpAgent; - } else { - return httpsAgent; - } - } -}; -``` - - - -#### Custom highWaterMark - -Stream on Node.js have a smaller internal buffer size (16kB, aka `highWaterMark`) from client-side browsers (>1MB, not consistent across browsers). Because of that, when you are writing an isomorphic app and using `res.clone()`, it will hang with large response in Node. - -The recommended way to fix this problem is to resolve cloned response in parallel: - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://example.com'); -const r1 = response.clone(); - -const results = await Promise.all([response.json(), r1.text()]); - -console.log(results[0]); -console.log(results[1]); -``` - -If for some reason you don't like the solution above, since `3.x` you are able to modify the `highWaterMark` option: - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://example.com', { - // About 1MB - highWaterMark: 1024 * 1024 -}); - -const result = await res.clone().arrayBuffer(); -console.dir(result); -``` - -#### Insecure HTTP Parser - -Passed through to the `insecureHTTPParser` option on http(s).request. See [`http.request`](https://nodejs.org/api/http.html#http_http_request_url_options_callback) for more information. - -#### Manual Redirect - -The `redirect: 'manual'` option for node-fetch is different from the browser & specification, which -results in an [opaque-redirect filtered response](https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect). -node-fetch gives you the typical [basic filtered response](https://fetch.spec.whatwg.org/#concept-filtered-response-basic) instead. - -```js -import fetch from 'node-fetch'; - -const response = await fetch('https://httpbin.org/status/301', { redirect: 'manual' }); - -if (response.status === 301 || response.status === 302) { - const locationURL = new URL(response.headers.get('location'), response.url); - const response2 = await fetch(locationURL, { redirect: 'manual' }); - console.dir(response2); -} -``` - - - -### Class: Request - -An HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface. - -Due to the nature of Node.js, the following properties are not implemented at this moment: - -- `type` -- `destination` -- `mode` -- `credentials` -- `cache` -- `integrity` -- `keepalive` - -The following node-fetch extension properties are provided: - -- `follow` -- `compress` -- `counter` -- `agent` -- `highWaterMark` - -See [options](#fetch-options) for exact meaning of these extensions. - -#### new Request(input[, options]) - -_(spec-compliant)_ - -- `input` A string representing a URL, or another `Request` (which will be cloned) -- `options` [Options](#fetch-options) for the HTTP(S) request - -Constructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). - -In most cases, directly `fetch(url, options)` is simpler than creating a `Request` object. - - - -### Class: Response - -An HTTP(S) response. This class implements the [Body](#iface-body) interface. - -The following properties are not implemented in node-fetch at this moment: - -- `trailer` - -#### new Response([body[, options]]) - -_(spec-compliant)_ - -- `body` A `String` or [`Readable` stream][node-readable] -- `options` A [`ResponseInit`][response-init] options dictionary - -Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response). - -Because Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly. - -#### response.ok - -_(spec-compliant)_ - -Convenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300. - -#### response.redirected - -_(spec-compliant)_ - -Convenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0. - -#### response.type - -_(deviation from spec)_ - -Convenience property representing the response's type. node-fetch only supports `'default'` and `'error'` and does not make use of [filtered responses](https://fetch.spec.whatwg.org/#concept-filtered-response). - - - -### Class: Headers - -This class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented. - -#### new Headers([init]) - -_(spec-compliant)_ - -- `init` Optional argument to pre-fill the `Headers` object - -Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object. - -```js -// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class -import {Headers} from 'node-fetch'; - -const meta = { - 'Content-Type': 'text/xml' -}; -const headers = new Headers(meta); - -// The above is equivalent to -const meta = [['Content-Type', 'text/xml']]; -const headers = new Headers(meta); - -// You can in fact use any iterable objects, like a Map or even another Headers -const meta = new Map(); -meta.set('Content-Type', 'text/xml'); -const headers = new Headers(meta); -const copyOfHeaders = new Headers(headers); -``` - - - -### Interface: Body - -`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes. - -#### body.body - -_(deviation from spec)_ - -- Node.js [`Readable` stream][node-readable] - -Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. - -#### body.bodyUsed - -_(spec-compliant)_ - -- `Boolean` - -A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again. - -#### body.arrayBuffer() - -#### body.formData() - -#### body.blob() - -#### body.json() - -#### body.text() - -`fetch` comes with methods to parse `multipart/form-data` payloads as well as -`x-www-form-urlencoded` bodies using `.formData()` this comes from the idea that -Service Worker can intercept such messages before it's sent to the server to -alter them. This is useful for anybody building a server so you can use it to -parse & consume payloads. - -
-Code example - -```js -import http from 'node:http' -import { Response } from 'node-fetch' - -http.createServer(async function (req, res) { - const formData = await new Response(req, { - headers: req.headers // Pass along the boundary value - }).formData() - const allFields = [...formData] - - const file = formData.get('uploaded-files') - const arrayBuffer = await file.arrayBuffer() - const text = await file.text() - const whatwgReadableStream = file.stream() - - // other was to consume the request could be to do: - const json = await new Response(req).json() - const text = await new Response(req).text() - const arrayBuffer = await new Response(req).arrayBuffer() - const blob = await new Response(req, { - headers: req.headers // So that `type` inherits `Content-Type` - }.blob() -}) -``` - -
- - - -### Class: FetchError - -_(node-fetch extension)_ - -An operational error in the fetching process. See [ERROR-HANDLING.md][] for more info. - - - -### Class: AbortError - -_(node-fetch extension)_ - -An Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info. - -## TypeScript - -**Since `3.x` types are bundled with `node-fetch`, so you don't need to install any additional packages.** - -For older versions please use the type definitions from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped): - -```sh -npm install --save-dev @types/node-fetch@2.x -``` - -## Acknowledgement - -Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference. - -## Team - -| [![David Frank](https://github.com/bitinn.png?size=100)](https://github.com/bitinn) | [![Jimmy Wärting](https://github.com/jimmywarting.png?size=100)](https://github.com/jimmywarting) | [![Antoni Kepinski](https://github.com/xxczaki.png?size=100)](https://github.com/xxczaki) | [![Richie Bendall](https://github.com/Richienb.png?size=100)](https://github.com/Richienb) | [![Gregor Martynus](https://github.com/gr2m.png?size=100)](https://github.com/gr2m) | -| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | -| [David Frank](https://bitinn.net/) | [Jimmy Wärting](https://jimmy.warting.se/) | [Antoni Kepinski](https://kepinski.ch) | [Richie Bendall](https://www.richie-bendall.ml/) | [Gregor Martynus](https://twitter.com/gr2m) | - -###### Former - -- [Timothy Gu](https://github.com/timothygu) -- [Jared Kantrowitz](https://github.com/jkantr) - -## License - -[MIT](LICENSE.md) - -[whatwg-fetch]: https://fetch.spec.whatwg.org/ -[response-init]: https://fetch.spec.whatwg.org/#responseinit -[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams -[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers -[error-handling.md]: https://github.com/node-fetch/node-fetch/blob/master/docs/ERROR-HANDLING.md -[FormData]: https://developer.mozilla.org/en-US/docs/Web/API/FormData -[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob -[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/package.json b/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/package.json deleted file mode 100644 index 2b4e8583..00000000 --- a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/package.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "name": "node-fetch", - "version": "3.3.2", - "description": "A light-weight module that brings Fetch API to node.js", - "main": "./src/index.js", - "sideEffects": false, - "type": "module", - "files": [ - "src", - "@types/index.d.ts" - ], - "types": "./@types/index.d.ts", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "scripts": { - "test": "mocha", - "coverage": "c8 report --reporter=text-lcov | coveralls", - "test-types": "tsd", - "lint": "xo" - }, - "repository": { - "type": "git", - "url": "https://github.com/node-fetch/node-fetch.git" - }, - "keywords": [ - "fetch", - "http", - "promise", - "request", - "curl", - "wget", - "xhr", - "whatwg" - ], - "author": "David Frank", - "license": "MIT", - "bugs": { - "url": "https://github.com/node-fetch/node-fetch/issues" - }, - "homepage": "https://github.com/node-fetch/node-fetch", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - }, - "devDependencies": { - "abort-controller": "^3.0.0", - "abortcontroller-polyfill": "^1.7.1", - "busboy": "^1.4.0", - "c8": "^7.7.2", - "chai": "^4.3.4", - "chai-as-promised": "^7.1.1", - "chai-iterator": "^3.0.2", - "chai-string": "^1.5.0", - "coveralls": "^3.1.0", - "form-data": "^4.0.0", - "formdata-node": "^4.2.4", - "mocha": "^9.1.3", - "p-timeout": "^5.0.0", - "stream-consumers": "^1.0.1", - "tsd": "^0.14.0", - "xo": "^0.39.1" - }, - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "tsd": { - "cwd": "@types", - "compilerOptions": { - "esModuleInterop": true - } - }, - "xo": { - "envs": [ - "node", - "browser" - ], - "ignores": [ - "example.js" - ], - "rules": { - "complexity": 0, - "import/extensions": 0, - "import/no-useless-path-segments": 0, - "import/no-anonymous-default-export": 0, - "import/no-named-as-default": 0, - "unicorn/import-index": 0, - "unicorn/no-array-reduce": 0, - "unicorn/prefer-node-protocol": 0, - "unicorn/numeric-separators-style": 0, - "unicorn/explicit-length-check": 0, - "capitalized-comments": 0, - "node/no-unsupported-features/es-syntax": 0, - "@typescript-eslint/member-ordering": 0 - }, - "overrides": [ - { - "files": "test/**/*.js", - "envs": [ - "node", - "mocha" - ], - "rules": { - "max-nested-callbacks": 0, - "no-unused-expressions": 0, - "no-warning-comments": 0, - "new-cap": 0, - "guard-for-in": 0, - "unicorn/no-array-for-each": 0, - "unicorn/prevent-abbreviations": 0, - "promise/prefer-await-to-then": 0, - "ava/no-import-test-files": 0 - } - } - ] - }, - "runkitExampleFilename": "example.js", - "release": { - "branches": [ - "+([0-9]).x", - "main", - "next", - { - "name": "beta", - "prerelease": true - } - ] - } -} diff --git a/node_modules/@nostr-dev-kit/ndk/package.json b/node_modules/@nostr-dev-kit/ndk/package.json index 5af807b3..e20d9163 100644 --- a/node_modules/@nostr-dev-kit/ndk/package.json +++ b/node_modules/@nostr-dev-kit/ndk/package.json @@ -1,6 +1,6 @@ { "name": "@nostr-dev-kit/ndk", - "version": "2.0.5", + "version": "2.1.1", "description": "NDK - Nostr Development Kit", "homepage": "https://ndk.fyi", "documentation": "https://github.com/nostr-dev-kit/ndk/blob/master/docs/modules.md", @@ -48,10 +48,10 @@ "@noble/secp256k1": "^2.0.0", "@scure/base": "^1.1.1", "debug": "^4.3.4", - "eventemitter3": "^5.0.1", "light-bolt11-decoder": "^3.0.0", "node-fetch": "^3.3.1", "nostr-tools": "^1.15.0", + "tseep": "^1.1.1", "typescript-lru-cache": "^2.0.0", "utf8-buffer": "^1.0.0", "websocket-polyfill": "^0.0.3" diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/LICENSE.md b/node_modules/cross-fetch/node_modules/node-fetch/LICENSE.md similarity index 96% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/LICENSE.md rename to node_modules/cross-fetch/node_modules/node-fetch/LICENSE.md index 41ca1b6e..660ffecb 100644 --- a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/LICENSE.md +++ b/node_modules/cross-fetch/node_modules/node-fetch/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 - 2020 Node Fetch Team +Copyright (c) 2016 David Frank Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/node_modules/cross-fetch/node_modules/node-fetch/README.md b/node_modules/cross-fetch/node_modules/node-fetch/README.md new file mode 100644 index 00000000..55f09b7f --- /dev/null +++ b/node_modules/cross-fetch/node_modules/node-fetch/README.md @@ -0,0 +1,634 @@ +node-fetch +========== + +[![npm version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![coverage status][codecov-image]][codecov-url] +[![install size][install-size-image]][install-size-url] +[![Discord][discord-image]][discord-url] + +A light-weight module that brings `window.fetch` to Node.js + +(We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567)) + +[![Backers][opencollective-image]][opencollective-url] + + + +- [Motivation](#motivation) +- [Features](#features) +- [Difference from client-side fetch](#difference-from-client-side-fetch) +- [Installation](#installation) +- [Loading and configuring the module](#loading-and-configuring-the-module) +- [Common Usage](#common-usage) + - [Plain text or HTML](#plain-text-or-html) + - [JSON](#json) + - [Simple Post](#simple-post) + - [Post with JSON](#post-with-json) + - [Post with form parameters](#post-with-form-parameters) + - [Handling exceptions](#handling-exceptions) + - [Handling client and server errors](#handling-client-and-server-errors) +- [Advanced Usage](#advanced-usage) + - [Streams](#streams) + - [Buffer](#buffer) + - [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data) + - [Extract Set-Cookie Header](#extract-set-cookie-header) + - [Post data using a file stream](#post-data-using-a-file-stream) + - [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart) + - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal) +- [API](#api) + - [fetch(url[, options])](#fetchurl-options) + - [Options](#options) + - [Class: Request](#class-request) + - [Class: Response](#class-response) + - [Class: Headers](#class-headers) + - [Interface: Body](#interface-body) + - [Class: FetchError](#class-fetcherror) +- [License](#license) +- [Acknowledgement](#acknowledgement) + + + +## Motivation + +Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. + +See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). + +## Features + +- Stay consistent with `window.fetch` API. +- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences. +- Use native promise but allow substituting it with [insert your favorite promise library]. +- Use native Node streams for body on both request and response. +- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. +- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting. + +## Difference from client-side fetch + +- See [Known Differences](LIMITS.md) for details. +- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue. +- Pull requests are welcomed too! + +## Installation + +Current stable release (`2.x`) + +```sh +$ npm install node-fetch +``` + +## Loading and configuring the module +We suggest you load the module via `require` until the stabilization of ES modules in node: +```js +const fetch = require('node-fetch'); +``` + +If you are using a Promise library other than native, set it through `fetch.Promise`: +```js +const Bluebird = require('bluebird'); + +fetch.Promise = Bluebird; +``` + +## Common Usage + +NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences. + +#### Plain text or HTML +```js +fetch('https://github.com/') + .then(res => res.text()) + .then(body => console.log(body)); +``` + +#### JSON + +```js + +fetch('https://api.github.com/users/github') + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Simple Post +```js +fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) + .then(res => res.json()) // expecting a json response + .then(json => console.log(json)); +``` + +#### Post with JSON + +```js +const body = { a: 1 }; + +fetch('https://httpbin.org/post', { + method: 'post', + body: JSON.stringify(body), + headers: { 'Content-Type': 'application/json' }, + }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Post with form parameters +`URLSearchParams` is available in Node.js as of v7.5.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods. + +NOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such: + +```js +const { URLSearchParams } = require('url'); + +const params = new URLSearchParams(); +params.append('a', 1); + +fetch('https://httpbin.org/post', { method: 'POST', body: params }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Handling exceptions +NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information. + +Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details. + +```js +fetch('https://domain.invalid/') + .catch(err => console.error(err)); +``` + +#### Handling client and server errors +It is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses: + +```js +function checkStatus(res) { + if (res.ok) { // res.status >= 200 && res.status < 300 + return res; + } else { + throw MyCustomError(res.statusText); + } +} + +fetch('https://httpbin.org/status/400') + .then(checkStatus) + .then(res => console.log('will not get here...')) +``` + +## Advanced Usage + +#### Streams +The "Node.js way" is to use streams when possible: + +```js +fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') + .then(res => { + const dest = fs.createWriteStream('./octocat.png'); + res.body.pipe(dest); + }); +``` + +In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch +errors -- the longer a response runs, the more likely it is to encounter an error. + +```js +const fetch = require('node-fetch'); +const response = await fetch('https://httpbin.org/stream/3'); +try { + for await (const chunk of response.body) { + console.dir(JSON.parse(chunk.toString())); + } +} catch (err) { + console.error(err.stack); +} +``` + +In Node.js 12 you can also use async iterators to read `body`; however, async iterators with streams +did not mature until Node.js 14, so you need to do some extra work to ensure you handle errors +directly from the stream and wait on it response to fully close. + +```js +const fetch = require('node-fetch'); +const read = async body => { + let error; + body.on('error', err => { + error = err; + }); + for await (const chunk of body) { + console.dir(JSON.parse(chunk.toString())); + } + return new Promise((resolve, reject) => { + body.on('close', () => { + error ? reject(error) : resolve(); + }); + }); +}; +try { + const response = await fetch('https://httpbin.org/stream/3'); + await read(response.body); +} catch (err) { + console.error(err.stack); +} +``` + +#### Buffer +If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API) + +```js +const fileType = require('file-type'); + +fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') + .then(res => res.buffer()) + .then(buffer => fileType(buffer)) + .then(type => { /* ... */ }); +``` + +#### Accessing Headers and other Meta data +```js +fetch('https://github.com/') + .then(res => { + console.log(res.ok); + console.log(res.status); + console.log(res.statusText); + console.log(res.headers.raw()); + console.log(res.headers.get('content-type')); + }); +``` + +#### Extract Set-Cookie Header + +Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API. + +```js +fetch(url).then(res => { + // returns an array of values, instead of a string of comma-separated values + console.log(res.headers.raw()['set-cookie']); +}); +``` + +#### Post data using a file stream + +```js +const { createReadStream } = require('fs'); + +const stream = createReadStream('input.txt'); + +fetch('https://httpbin.org/post', { method: 'POST', body: stream }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Post with form-data (detect multipart) + +```js +const FormData = require('form-data'); + +const form = new FormData(); +form.append('a', 1); + +fetch('https://httpbin.org/post', { method: 'POST', body: form }) + .then(res => res.json()) + .then(json => console.log(json)); + +// OR, using custom headers +// NOTE: getHeaders() is non-standard API + +const form = new FormData(); +form.append('a', 1); + +const options = { + method: 'POST', + body: form, + headers: form.getHeaders() +} + +fetch('https://httpbin.org/post', options) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Request cancellation with AbortSignal + +> NOTE: You may cancel streamed requests only on Node >= v8.0.0 + +You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller). + +An example of timing out a request after 150ms could be achieved as the following: + +```js +import AbortController from 'abort-controller'; + +const controller = new AbortController(); +const timeout = setTimeout( + () => { controller.abort(); }, + 150, +); + +fetch(url, { signal: controller.signal }) + .then(res => res.json()) + .then( + data => { + useData(data) + }, + err => { + if (err.name === 'AbortError') { + // request was aborted + } + }, + ) + .finally(() => { + clearTimeout(timeout); + }); +``` + +See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples. + + +## API + +### fetch(url[, options]) + +- `url` A string representing the URL for fetching +- `options` [Options](#fetch-options) for the HTTP(S) request +- Returns: Promise<[Response](#class-response)> + +Perform an HTTP(S) fetch. + +`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. + + +### Options + +The default values are shown after each option key. + +```js +{ + // These properties are part of the Fetch Standard + method: 'GET', + headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below) + body: null, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream + redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect + signal: null, // pass an instance of AbortSignal to optionally abort requests + + // The following properties are node-fetch extensions + follow: 20, // maximum redirect count. 0 to not follow redirect + timeout: 0, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead. + compress: true, // support gzip/deflate content encoding. false to disable + size: 0, // maximum response body size in bytes. 0 to disable + agent: null // http(s).Agent instance or function that returns an instance (see below) +} +``` + +##### Default Headers + +If no values are set, the following request headers will be sent automatically: + +Header | Value +------------------- | -------------------------------------------------------- +`Accept-Encoding` | `gzip,deflate` _(when `options.compress === true`)_ +`Accept` | `*/*` +`Content-Length` | _(automatically calculated, if possible)_ +`Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ +`User-Agent` | `node-fetch/1.0 (+https://github.com/bitinn/node-fetch)` + +Note: when `body` is a `Stream`, `Content-Length` is not set automatically. + +##### Custom Agent + +The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following: + +- Support self-signed certificate +- Use only IPv4 or IPv6 +- Custom DNS Lookup + +See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information. + +If no agent is specified, the default agent provided by Node.js is used. Note that [this changed in Node.js 19](https://github.com/nodejs/node/blob/4267b92604ad78584244488e7f7508a690cb80d0/lib/_http_agent.js#L564) to have `keepalive` true by default. If you wish to enable `keepalive` in an earlier version of Node.js, you can override the agent as per the following code sample. + +In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. + +```js +const httpAgent = new http.Agent({ + keepAlive: true +}); +const httpsAgent = new https.Agent({ + keepAlive: true +}); + +const options = { + agent: function (_parsedURL) { + if (_parsedURL.protocol == 'http:') { + return httpAgent; + } else { + return httpsAgent; + } + } +} +``` + + +### Class: Request + +An HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface. + +Due to the nature of Node.js, the following properties are not implemented at this moment: + +- `type` +- `destination` +- `referrer` +- `referrerPolicy` +- `mode` +- `credentials` +- `cache` +- `integrity` +- `keepalive` + +The following node-fetch extension properties are provided: + +- `follow` +- `compress` +- `counter` +- `agent` + +See [options](#fetch-options) for exact meaning of these extensions. + +#### new Request(input[, options]) + +*(spec-compliant)* + +- `input` A string representing a URL, or another `Request` (which will be cloned) +- `options` [Options][#fetch-options] for the HTTP(S) request + +Constructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + +In most cases, directly `fetch(url, options)` is simpler than creating a `Request` object. + + +### Class: Response + +An HTTP(S) response. This class implements the [Body](#iface-body) interface. + +The following properties are not implemented in node-fetch at this moment: + +- `Response.error()` +- `Response.redirect()` +- `type` +- `trailer` + +#### new Response([body[, options]]) + +*(spec-compliant)* + +- `body` A `String` or [`Readable` stream][node-readable] +- `options` A [`ResponseInit`][response-init] options dictionary + +Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response). + +Because Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly. + +#### response.ok + +*(spec-compliant)* + +Convenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300. + +#### response.redirected + +*(spec-compliant)* + +Convenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0. + + +### Class: Headers + +This class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented. + +#### new Headers([init]) + +*(spec-compliant)* + +- `init` Optional argument to pre-fill the `Headers` object + +Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object. + +```js +// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class + +const meta = { + 'Content-Type': 'text/xml', + 'Breaking-Bad': '<3' +}; +const headers = new Headers(meta); + +// The above is equivalent to +const meta = [ + [ 'Content-Type', 'text/xml' ], + [ 'Breaking-Bad', '<3' ] +]; +const headers = new Headers(meta); + +// You can in fact use any iterable objects, like a Map or even another Headers +const meta = new Map(); +meta.set('Content-Type', 'text/xml'); +meta.set('Breaking-Bad', '<3'); +const headers = new Headers(meta); +const copyOfHeaders = new Headers(headers); +``` + + +### Interface: Body + +`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes. + +The following methods are not yet implemented in node-fetch at this moment: + +- `formData()` + +#### body.body + +*(deviation from spec)* + +* Node.js [`Readable` stream][node-readable] + +Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. + +#### body.bodyUsed + +*(spec-compliant)* + +* `Boolean` + +A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again. + +#### body.arrayBuffer() +#### body.blob() +#### body.json() +#### body.text() + +*(spec-compliant)* + +* Returns: Promise + +Consume the body and return a promise that will resolve to one of these formats. + +#### body.buffer() + +*(node-fetch extension)* + +* Returns: Promise<Buffer> + +Consume the body and return a promise that will resolve to a Buffer. + +#### body.textConverted() + +*(node-fetch extension)* + +* Returns: Promise<String> + +Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible. + +(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.) + + +### Class: FetchError + +*(node-fetch extension)* + +An operational error in the fetching process. See [ERROR-HANDLING.md][] for more info. + + +### Class: AbortError + +*(node-fetch extension)* + +An Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info. + +## Acknowledgement + +Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference. + +`node-fetch` v1 was maintained by [@bitinn](https://github.com/bitinn); v2 was maintained by [@TimothyGu](https://github.com/timothygu), [@bitinn](https://github.com/bitinn) and [@jimmywarting](https://github.com/jimmywarting); v2 readme is written by [@jkantr](https://github.com/jkantr). + +## License + +MIT + +[npm-image]: https://flat.badgen.net/npm/v/node-fetch +[npm-url]: https://www.npmjs.com/package/node-fetch +[travis-image]: https://flat.badgen.net/travis/bitinn/node-fetch +[travis-url]: https://travis-ci.org/bitinn/node-fetch +[codecov-image]: https://flat.badgen.net/codecov/c/github/bitinn/node-fetch/master +[codecov-url]: https://codecov.io/gh/bitinn/node-fetch +[install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch +[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch +[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA&label=Discord&style=flat-square +[discord-url]: https://discord.gg/Zxbndcm +[opencollective-image]: https://opencollective.com/node-fetch/backers.svg +[opencollective-url]: https://opencollective.com/node-fetch +[whatwg-fetch]: https://fetch.spec.whatwg.org/ +[response-init]: https://fetch.spec.whatwg.org/#responseinit +[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams +[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers +[LIMITS.md]: https://github.com/bitinn/node-fetch/blob/master/LIMITS.md +[ERROR-HANDLING.md]: https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md +[UPGRADE-GUIDE.md]: https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md diff --git a/node_modules/node-fetch/browser.js b/node_modules/cross-fetch/node_modules/node-fetch/browser.js similarity index 100% rename from node_modules/node-fetch/browser.js rename to node_modules/cross-fetch/node_modules/node-fetch/browser.js diff --git a/node_modules/node-fetch/lib/index.es.js b/node_modules/cross-fetch/node_modules/node-fetch/lib/index.es.js similarity index 100% rename from node_modules/node-fetch/lib/index.es.js rename to node_modules/cross-fetch/node_modules/node-fetch/lib/index.es.js diff --git a/node_modules/node-fetch/lib/index.js b/node_modules/cross-fetch/node_modules/node-fetch/lib/index.js similarity index 100% rename from node_modules/node-fetch/lib/index.js rename to node_modules/cross-fetch/node_modules/node-fetch/lib/index.js diff --git a/node_modules/node-fetch/lib/index.mjs b/node_modules/cross-fetch/node_modules/node-fetch/lib/index.mjs similarity index 100% rename from node_modules/node-fetch/lib/index.mjs rename to node_modules/cross-fetch/node_modules/node-fetch/lib/index.mjs diff --git a/node_modules/cross-fetch/node_modules/node-fetch/package.json b/node_modules/cross-fetch/node_modules/node-fetch/package.json new file mode 100644 index 00000000..e0be1768 --- /dev/null +++ b/node_modules/cross-fetch/node_modules/node-fetch/package.json @@ -0,0 +1,89 @@ +{ + "name": "node-fetch", + "version": "2.7.0", + "description": "A light-weight module that brings window.fetch to node.js", + "main": "lib/index.js", + "browser": "./browser.js", + "module": "lib/index.mjs", + "files": [ + "lib/index.js", + "lib/index.mjs", + "lib/index.es.js", + "browser.js" + ], + "engines": { + "node": "4.x || >=6.0.0" + }, + "scripts": { + "build": "cross-env BABEL_ENV=rollup rollup -c", + "prepare": "npm run build", + "test": "cross-env BABEL_ENV=test mocha --require babel-register --throw-deprecation test/test.js", + "report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js", + "coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json" + }, + "repository": { + "type": "git", + "url": "https://github.com/bitinn/node-fetch.git" + }, + "keywords": [ + "fetch", + "http", + "promise" + ], + "author": "David Frank", + "license": "MIT", + "bugs": { + "url": "https://github.com/bitinn/node-fetch/issues" + }, + "homepage": "https://github.com/bitinn/node-fetch", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + }, + "devDependencies": { + "@ungap/url-search-params": "^0.1.2", + "abort-controller": "^1.1.0", + "abortcontroller-polyfill": "^1.3.0", + "babel-core": "^6.26.3", + "babel-plugin-istanbul": "^4.1.6", + "babel-plugin-transform-async-generator-functions": "^6.24.1", + "babel-polyfill": "^6.26.0", + "babel-preset-env": "1.4.0", + "babel-register": "^6.16.3", + "chai": "^3.5.0", + "chai-as-promised": "^7.1.1", + "chai-iterator": "^1.1.1", + "chai-string": "~1.3.0", + "codecov": "3.3.0", + "cross-env": "^5.2.0", + "form-data": "^2.3.3", + "is-builtin-module": "^1.0.0", + "mocha": "^5.0.0", + "nyc": "11.9.0", + "parted": "^0.1.1", + "promise": "^8.0.3", + "resumer": "0.0.0", + "rollup": "^0.63.4", + "rollup-plugin-babel": "^3.0.7", + "string-to-arraybuffer": "^1.0.2", + "teeny-request": "3.7.0" + }, + "release": { + "branches": [ + "+([0-9]).x", + "main", + "next", + { + "name": "beta", + "prerelease": true + } + ] + } +} diff --git a/node_modules/eventemitter3/README.md b/node_modules/eventemitter3/README.md deleted file mode 100644 index 5413fc9b..00000000 --- a/node_modules/eventemitter3/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# EventEmitter3 - -[![Version npm](https://img.shields.io/npm/v/eventemitter3.svg?style=flat-square)](https://www.npmjs.com/package/eventemitter3)[![CI](https://img.shields.io/github/actions/workflow/status/primus/eventemitter3/ci.yml?branch=master&label=CI&style=flat-square)](https://github.com/primus/eventemitter3/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/primus/eventemitter3/master.svg?style=flat-square)](https://coveralls.io/r/primus/eventemitter3?branch=master) - -[![Sauce Test Status](https://saucelabs.com/browser-matrix/eventemitter3.svg)](https://saucelabs.com/u/eventemitter3) - -EventEmitter3 is a high performance EventEmitter. It has been micro-optimized -for various of code paths making this, one of, if not the fastest EventEmitter -available for Node.js and browsers. The module is API compatible with the -EventEmitter that ships by default with Node.js but there are some slight -differences: - -- Domain support has been removed. -- We do not `throw` an error when you emit an `error` event and nobody is - listening. -- The `newListener` and `removeListener` events have been removed as they - are useful only in some uncommon use-cases. -- The `setMaxListeners`, `getMaxListeners`, `prependListener` and - `prependOnceListener` methods are not available. -- Support for custom context for events so there is no need to use `fn.bind`. -- The `removeListener` method removes all matching listeners, not only the - first. - -It's a drop in replacement for existing EventEmitters, but just faster. Free -performance, who wouldn't want that? The EventEmitter is written in EcmaScript 3 -so it will work in the oldest browsers and node versions that you need to -support. - -## Installation - -```bash -$ npm install --save eventemitter3 -``` - -## CDN - -Recommended CDN: - -```text -https://unpkg.com/eventemitter3@latest/dist/eventemitter3.umd.min.js -``` - -## Usage - -After installation the only thing you need to do is require the module: - -```js -var EventEmitter = require('eventemitter3'); -``` - -And you're ready to create your own EventEmitter instances. For the API -documentation, please follow the official Node.js documentation: - -http://nodejs.org/api/events.html - -### Contextual emits - -We've upgraded the API of the `EventEmitter.on`, `EventEmitter.once` and -`EventEmitter.removeListener` to accept an extra argument which is the `context` -or `this` value that should be set for the emitted events. This means you no -longer have the overhead of an event that required `fn.bind` in order to get a -custom `this` value. - -```js -var EE = new EventEmitter() - , context = { foo: 'bar' }; - -function emitted() { - console.log(this === context); // true -} - -EE.once('event-name', emitted, context); -EE.on('another-event', emitted, context); -EE.removeListener('another-event', emitted, context); -``` - -### Tests and benchmarks - -This module is well tested. You can run: - -- `npm test` to run the tests under Node.js. -- `npm run test-browser` to run the tests in real browsers via Sauce Labs. - -We also have a set of benchmarks to compare EventEmitter3 with some available -alternatives. To run the benchmarks run `npm run benchmark`. - -Tests and benchmarks are not included in the npm package. If you want to play -with them you have to clone the GitHub repository. -Note that you will have to run an additional `npm i` in the benchmarks folder -before `npm run benchmark`. - -## License - -[MIT](LICENSE) diff --git a/node_modules/eventemitter3/dist/eventemitter3.esm.js b/node_modules/eventemitter3/dist/eventemitter3.esm.js deleted file mode 100644 index f44b76c2..00000000 --- a/node_modules/eventemitter3/dist/eventemitter3.esm.js +++ /dev/null @@ -1,347 +0,0 @@ -var eventemitter3Exports = {}; -var eventemitter3 = { - get exports(){ return eventemitter3Exports; }, - set exports(v){ eventemitter3Exports = v; }, -}; - -(function (module) { - - var has = Object.prototype.hasOwnProperty - , prefix = '~'; - - /** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @private - */ - function Events() {} - - // - // We try to not inherit from `Object.prototype`. In some engines creating an - // instance in this way is faster than calling `Object.create(null)` directly. - // If `Object.create(null)` is not supported we prefix the event names with a - // character to make sure that the built-in object properties are not - // overridden or used as an attack vector. - // - if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; - } - - /** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @private - */ - function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; - } - - /** - * Add a listener for a given event. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} once Specify if the listener is a one-time listener. - * @returns {EventEmitter} - * @private - */ - function addListener(emitter, event, fn, context, once) { - if (typeof fn !== 'function') { - throw new TypeError('The listener must be a function'); - } - - var listener = new EE(fn, context || emitter, once) - , evt = prefix ? prefix + event : event; - - if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; - else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); - else emitter._events[evt] = [emitter._events[evt], listener]; - - return emitter; - } - - /** - * Clear event by name. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} evt The Event name. - * @private - */ - function clearEvent(emitter, evt) { - if (--emitter._eventsCount === 0) emitter._events = new Events(); - else delete emitter._events[evt]; - } - - /** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @public - */ - function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; - } - - /** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @public - */ - EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; - }; - - /** - * Return the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Array} The registered listeners. - * @public - */ - EventEmitter.prototype.listeners = function listeners(event) { - var evt = prefix ? prefix + event : event - , handlers = this._events[evt]; - - if (!handlers) return []; - if (handlers.fn) return [handlers.fn]; - - for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { - ee[i] = handlers[i].fn; - } - - return ee; - }; - - /** - * Return the number of listeners listening to a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Number} The number of listeners. - * @public - */ - EventEmitter.prototype.listenerCount = function listenerCount(event) { - var evt = prefix ? prefix + event : event - , listeners = this._events[evt]; - - if (!listeners) return 0; - if (listeners.fn) return 1; - return listeners.length; - }; - - /** - * Calls each of the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @public - */ - EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; - }; - - /** - * Add a listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ - EventEmitter.prototype.on = function on(event, fn, context) { - return addListener(this, event, fn, context, false); - }; - - /** - * Add a one-time listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ - EventEmitter.prototype.once = function once(event, fn, context) { - return addListener(this, event, fn, context, true); - }; - - /** - * Remove the listeners of a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {*} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @public - */ - EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - clearEvent(this, evt); - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn && - (!once || listeners.once) && - (!context || listeners.context === context) - ) { - clearEvent(this, evt); - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn || - (once && !listeners[i].once) || - (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else clearEvent(this, evt); - } - - return this; - }; - - /** - * Remove all listeners, or those of the specified event. - * - * @param {(String|Symbol)} [event] The event name. - * @returns {EventEmitter} `this`. - * @public - */ - EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) clearEvent(this, evt); - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; - }; - - // - // Alias methods names because people roll like that. - // - EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - - // - // Expose the prefix. - // - EventEmitter.prefixed = prefix; - - // - // Allow `EventEmitter` to be imported as module namespace. - // - EventEmitter.EventEmitter = EventEmitter; - - // - // Expose the module. - // - { - module.exports = EventEmitter; - } -} (eventemitter3)); - -var EventEmitter = eventemitter3Exports; - -export { EventEmitter, EventEmitter as default }; diff --git a/node_modules/eventemitter3/dist/eventemitter3.esm.min.js b/node_modules/eventemitter3/dist/eventemitter3.esm.min.js deleted file mode 100644 index 7612ed09..00000000 --- a/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +++ /dev/null @@ -1 +0,0 @@ -var e={};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o { - static prefixed: string | boolean; - - /** - * Return an array listing the events for which the emitter has registered - * listeners. - */ - eventNames(): Array>; - - /** - * Return the listeners registered for a given event. - */ - listeners>( - event: T - ): Array>; - - /** - * Return the number of listeners listening to a given event. - */ - listenerCount(event: EventEmitter.EventNames): number; - - /** - * Calls each of the listeners registered for a given event. - */ - emit>( - event: T, - ...args: EventEmitter.EventArgs - ): boolean; - - /** - * Add a listener for a given event. - */ - on>( - event: T, - fn: EventEmitter.EventListener, - context?: Context - ): this; - addListener>( - event: T, - fn: EventEmitter.EventListener, - context?: Context - ): this; - - /** - * Add a one-time listener for a given event. - */ - once>( - event: T, - fn: EventEmitter.EventListener, - context?: Context - ): this; - - /** - * Remove the listeners of a given event. - */ - removeListener>( - event: T, - fn?: EventEmitter.EventListener, - context?: Context, - once?: boolean - ): this; - off>( - event: T, - fn?: EventEmitter.EventListener, - context?: Context, - once?: boolean - ): this; - - /** - * Remove all listeners, or those of the specified event. - */ - removeAllListeners(event?: EventEmitter.EventNames): this; -} - -declare namespace EventEmitter { - export interface ListenerFn { - (...args: Args): void; - } - - export interface EventEmitterStatic { - new < - EventTypes extends ValidEventTypes = string | symbol, - Context = any - >(): EventEmitter; - } - - /** - * `object` should be in either of the following forms: - * ``` - * interface EventTypes { - * 'event-with-parameters': any[] - * 'event-with-example-handler': (...args: any[]) => void - * } - * ``` - */ - export type ValidEventTypes = string | symbol | object; - - export type EventNames = T extends string | symbol - ? T - : keyof T; - - export type ArgumentMap = { - [K in keyof T]: T[K] extends (...args: any[]) => void - ? Parameters - : T[K] extends any[] - ? T[K] - : any[]; - }; - - export type EventListener< - T extends ValidEventTypes, - K extends EventNames - > = T extends string | symbol - ? (...args: any[]) => void - : ( - ...args: ArgumentMap>[Extract] - ) => void; - - export type EventArgs< - T extends ValidEventTypes, - K extends EventNames - > = Parameters>; - - export const EventEmitter: EventEmitterStatic; -} - -export { EventEmitter } -export default EventEmitter; diff --git a/node_modules/eventemitter3/index.js b/node_modules/eventemitter3/index.js deleted file mode 100644 index 6ea485c4..00000000 --- a/node_modules/eventemitter3/index.js +++ /dev/null @@ -1,336 +0,0 @@ -'use strict'; - -var has = Object.prototype.hasOwnProperty - , prefix = '~'; - -/** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @private - */ -function Events() {} - -// -// We try to not inherit from `Object.prototype`. In some engines creating an -// instance in this way is faster than calling `Object.create(null)` directly. -// If `Object.create(null)` is not supported we prefix the event names with a -// character to make sure that the built-in object properties are not -// overridden or used as an attack vector. -// -if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; -} - -/** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @private - */ -function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; -} - -/** - * Add a listener for a given event. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} once Specify if the listener is a one-time listener. - * @returns {EventEmitter} - * @private - */ -function addListener(emitter, event, fn, context, once) { - if (typeof fn !== 'function') { - throw new TypeError('The listener must be a function'); - } - - var listener = new EE(fn, context || emitter, once) - , evt = prefix ? prefix + event : event; - - if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; - else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); - else emitter._events[evt] = [emitter._events[evt], listener]; - - return emitter; -} - -/** - * Clear event by name. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} evt The Event name. - * @private - */ -function clearEvent(emitter, evt) { - if (--emitter._eventsCount === 0) emitter._events = new Events(); - else delete emitter._events[evt]; -} - -/** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @public - */ -function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; -} - -/** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @public - */ -EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; -}; - -/** - * Return the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Array} The registered listeners. - * @public - */ -EventEmitter.prototype.listeners = function listeners(event) { - var evt = prefix ? prefix + event : event - , handlers = this._events[evt]; - - if (!handlers) return []; - if (handlers.fn) return [handlers.fn]; - - for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { - ee[i] = handlers[i].fn; - } - - return ee; -}; - -/** - * Return the number of listeners listening to a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Number} The number of listeners. - * @public - */ -EventEmitter.prototype.listenerCount = function listenerCount(event) { - var evt = prefix ? prefix + event : event - , listeners = this._events[evt]; - - if (!listeners) return 0; - if (listeners.fn) return 1; - return listeners.length; -}; - -/** - * Calls each of the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @public - */ -EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; -}; - -/** - * Add a listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.on = function on(event, fn, context) { - return addListener(this, event, fn, context, false); -}; - -/** - * Add a one-time listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.once = function once(event, fn, context) { - return addListener(this, event, fn, context, true); -}; - -/** - * Remove the listeners of a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {*} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - clearEvent(this, evt); - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn && - (!once || listeners.once) && - (!context || listeners.context === context) - ) { - clearEvent(this, evt); - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn || - (once && !listeners[i].once) || - (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else clearEvent(this, evt); - } - - return this; -}; - -/** - * Remove all listeners, or those of the specified event. - * - * @param {(String|Symbol)} [event] The event name. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) clearEvent(this, evt); - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; -}; - -// -// Alias methods names because people roll like that. -// -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -// -// Expose the prefix. -// -EventEmitter.prefixed = prefix; - -// -// Allow `EventEmitter` to be imported as module namespace. -// -EventEmitter.EventEmitter = EventEmitter; - -// -// Expose the module. -// -if ('undefined' !== typeof module) { - module.exports = EventEmitter; -} diff --git a/node_modules/eventemitter3/index.mjs b/node_modules/eventemitter3/index.mjs deleted file mode 100644 index 89bb4050..00000000 --- a/node_modules/eventemitter3/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import EventEmitter from './index.js' - -export { EventEmitter } -export default EventEmitter diff --git a/node_modules/eventemitter3/package.json b/node_modules/eventemitter3/package.json deleted file mode 100644 index 47843d2e..00000000 --- a/node_modules/eventemitter3/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "eventemitter3", - "version": "5.0.1", - "description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.", - "exports": { - ".": { - "types": "./index.d.ts", - "import": "./index.mjs", - "require": "./index.js" - }, - "./package.json": "./package.json" - }, - "main": "index.js", - "types": "index.d.ts", - "scripts": { - "rollup": "rimraf dist umd && rollup -c", - "benchmark": "find benchmarks/run -name '*.js' -exec benchmarks/start.sh {} \\;", - "test": "c8 --reporter=lcov --reporter=text mocha test/test.js", - "test-esm": "mocha test/test.mjs", - "prepublishOnly": "npm run rollup", - "test-browser": "node test/browser.js" - }, - "files": [ - "index.js", - "index.mjs", - "index.d.ts", - "dist" - ], - "repository": { - "type": "git", - "url": "git://github.com/primus/eventemitter3.git" - }, - "keywords": [ - "EventEmitter", - "EventEmitter2", - "EventEmitter3", - "Events", - "addEventListener", - "addListener", - "emit", - "emits", - "emitter", - "event", - "once", - "pub/sub", - "publish", - "reactor", - "subscribe" - ], - "author": "Arnout Kazemier", - "license": "MIT", - "bugs": { - "url": "https://github.com/primus/eventemitter3/issues" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "^24.0.0", - "@rollup/plugin-terser": "^0.4.0", - "assume": "^2.2.0", - "c8": "^7.3.1", - "mocha": "^10.0.0", - "pre-commit": "^1.2.0", - "rimraf": "^4.1.2", - "rollup": "^3.4.0", - "sauce-browsers": "^3.0.0", - "sauce-test": "^1.3.3" - } -} diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/@types/index.d.ts b/node_modules/node-fetch/@types/index.d.ts similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/@types/index.d.ts rename to node_modules/node-fetch/@types/index.d.ts diff --git a/node_modules/node-fetch/LICENSE.md b/node_modules/node-fetch/LICENSE.md index 660ffecb..41ca1b6e 100644 --- a/node_modules/node-fetch/LICENSE.md +++ b/node_modules/node-fetch/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 David Frank +Copyright (c) 2016 - 2020 Node Fetch Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/node_modules/node-fetch/README.md b/node_modules/node-fetch/README.md index 55f09b7f..badc2b19 100644 --- a/node_modules/node-fetch/README.md +++ b/node_modules/node-fetch/README.md @@ -1,17 +1,24 @@ -node-fetch -========== +
+ Node Fetch +
+

A light-weight module that brings Fetch API to Node.js.

+ Build status + Coverage status + Current version + Install size + Mentioned in Awesome Node.js + Discord +
+
+ Consider supporting us on our Open Collective: +
+
+ Open Collective +
-[![npm version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] -[![coverage status][codecov-image]][codecov-url] -[![install size][install-size-image]][install-size-url] -[![Discord][discord-image]][discord-url] +--- -A light-weight module that brings `window.fetch` to Node.js - -(We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567)) - -[![Backers][opencollective-image]][opencollective-url] +**You might be looking for the [v2 docs](https://github.com/node-fetch/node-fetch/tree/2.x#readme)** @@ -20,32 +27,53 @@ A light-weight module that brings `window.fetch` to Node.js - [Difference from client-side fetch](#difference-from-client-side-fetch) - [Installation](#installation) - [Loading and configuring the module](#loading-and-configuring-the-module) +- [Upgrading](#upgrading) - [Common Usage](#common-usage) - - [Plain text or HTML](#plain-text-or-html) - - [JSON](#json) - - [Simple Post](#simple-post) - - [Post with JSON](#post-with-json) - - [Post with form parameters](#post-with-form-parameters) - - [Handling exceptions](#handling-exceptions) - - [Handling client and server errors](#handling-client-and-server-errors) + - [Plain text or HTML](#plain-text-or-html) + - [JSON](#json) + - [Simple Post](#simple-post) + - [Post with JSON](#post-with-json) + - [Post with form parameters](#post-with-form-parameters) + - [Handling exceptions](#handling-exceptions) + - [Handling client and server errors](#handling-client-and-server-errors) + - [Handling cookies](#handling-cookies) - [Advanced Usage](#advanced-usage) - - [Streams](#streams) - - [Buffer](#buffer) - - [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data) - - [Extract Set-Cookie Header](#extract-set-cookie-header) - - [Post data using a file stream](#post-data-using-a-file-stream) - - [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart) - - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal) + - [Streams](#streams) + - [Accessing Headers and other Metadata](#accessing-headers-and-other-metadata) + - [Extract Set-Cookie Header](#extract-set-cookie-header) + - [Post data using a file](#post-data-using-a-file) + - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal) - [API](#api) - - [fetch(url[, options])](#fetchurl-options) - - [Options](#options) - - [Class: Request](#class-request) - - [Class: Response](#class-response) - - [Class: Headers](#class-headers) - - [Interface: Body](#interface-body) - - [Class: FetchError](#class-fetcherror) -- [License](#license) + - [fetch(url[, options])](#fetchurl-options) + - [Options](#options) + - [Default Headers](#default-headers) + - [Custom Agent](#custom-agent) + - [Custom highWaterMark](#custom-highwatermark) + - [Insecure HTTP Parser](#insecure-http-parser) + - [Class: Request](#class-request) + - [new Request(input[, options])](#new-requestinput-options) + - [Class: Response](#class-response) + - [new Response([body[, options]])](#new-responsebody-options) + - [response.ok](#responseok) + - [response.redirected](#responseredirected) + - [response.type](#responsetype) + - [Class: Headers](#class-headers) + - [new Headers([init])](#new-headersinit) + - [Interface: Body](#interface-body) + - [body.body](#bodybody) + - [body.bodyUsed](#bodybodyused) + - [body.arrayBuffer()](#bodyarraybuffer) + - [body.blob()](#bodyblob) + - [body.formData()](#formdata) + - [body.json()](#bodyjson) + - [body.text()](#bodytext) + - [Class: FetchError](#class-fetcherror) + - [Class: AbortError](#class-aborterror) +- [TypeScript](#typescript) - [Acknowledgement](#acknowledgement) +- [Team](#team) + - [Former](#former) +- [License](#license) @@ -53,147 +81,254 @@ A light-weight module that brings `window.fetch` to Node.js Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. -See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). +See Jason Miller's [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). ## Features - Stay consistent with `window.fetch` API. - Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences. -- Use native promise but allow substituting it with [insert your favorite promise library]. -- Use native Node streams for body on both request and response. -- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. -- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting. +- Use native promise and async functions. +- Use native Node streams for body, on both request and response. +- Decode content encoding (gzip/deflate/brotli) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. +- Useful extensions such as redirect limit, response size limit, [explicit errors][error-handling.md] for troubleshooting. ## Difference from client-side fetch -- See [Known Differences](LIMITS.md) for details. +- See known differences: + - [As of v3.x](docs/v3-LIMITS.md) + - [As of v2.x](docs/v2-LIMITS.md) - If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue. - Pull requests are welcomed too! ## Installation -Current stable release (`2.x`) +Current stable release (`3.x`) requires at least Node.js 12.20.0. ```sh -$ npm install node-fetch +npm install node-fetch ``` ## Loading and configuring the module -We suggest you load the module via `require` until the stabilization of ES modules in node: + +### ES Modules (ESM) + ```js -const fetch = require('node-fetch'); +import fetch from 'node-fetch'; ``` -If you are using a Promise library other than native, set it through `fetch.Promise`: -```js -const Bluebird = require('bluebird'); +### CommonJS -fetch.Promise = Bluebird; +`node-fetch` from v3 is an ESM-only module - you are not able to import it with `require()`. + +If you cannot switch to ESM, please use v2 which remains compatible with CommonJS. Critical bug fixes will continue to be published for v2. + +```sh +npm install node-fetch@2 ``` +Alternatively, you can use the async `import()` function from CommonJS to load `node-fetch` asynchronously: + +```js +// mod.cjs +const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); +``` + +### Providing global access + +To use `fetch()` without importing it, you can patch the `global` object in node: + +```js +// fetch-polyfill.js +import fetch, { + Blob, + blobFrom, + blobFromSync, + File, + fileFrom, + fileFromSync, + FormData, + Headers, + Request, + Response, +} from 'node-fetch' + +if (!globalThis.fetch) { + globalThis.fetch = fetch + globalThis.Headers = Headers + globalThis.Request = Request + globalThis.Response = Response +} + +// index.js +import './fetch-polyfill' + +// ... +``` + +## Upgrading + +Using an old version of node-fetch? Check out the following files: + +- [2.x to 3.x upgrade guide](docs/v3-UPGRADE-GUIDE.md) +- [1.x to 2.x upgrade guide](docs/v2-UPGRADE-GUIDE.md) +- [Changelog](https://github.com/node-fetch/node-fetch/releases) + ## Common Usage -NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences. +NOTE: The documentation below is up-to-date with `3.x` releases, if you are using an older version, please check how to [upgrade](#upgrading). -#### Plain text or HTML -```js -fetch('https://github.com/') - .then(res => res.text()) - .then(body => console.log(body)); -``` - -#### JSON +### Plain text or HTML ```js +import fetch from 'node-fetch'; -fetch('https://api.github.com/users/github') - .then(res => res.json()) - .then(json => console.log(json)); +const response = await fetch('https://github.com/'); +const body = await response.text(); + +console.log(body); ``` -#### Simple Post -```js -fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) - .then(res => res.json()) // expecting a json response - .then(json => console.log(json)); -``` - -#### Post with JSON +### JSON ```js -const body = { a: 1 }; +import fetch from 'node-fetch'; -fetch('https://httpbin.org/post', { - method: 'post', - body: JSON.stringify(body), - headers: { 'Content-Type': 'application/json' }, - }) - .then(res => res.json()) - .then(json => console.log(json)); +const response = await fetch('https://api.github.com/users/github'); +const data = await response.json(); + +console.log(data); ``` -#### Post with form parameters -`URLSearchParams` is available in Node.js as of v7.5.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods. +### Simple Post + +```js +import fetch from 'node-fetch'; + +const response = await fetch('https://httpbin.org/post', {method: 'POST', body: 'a=1'}); +const data = await response.json(); + +console.log(data); +``` + +### Post with JSON + +```js +import fetch from 'node-fetch'; + +const body = {a: 1}; + +const response = await fetch('https://httpbin.org/post', { + method: 'post', + body: JSON.stringify(body), + headers: {'Content-Type': 'application/json'} +}); +const data = await response.json(); + +console.log(data); +``` + +### Post with form parameters + +`URLSearchParams` is available on the global object in Node.js as of v10.0.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods. NOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such: ```js -const { URLSearchParams } = require('url'); +import fetch from 'node-fetch'; const params = new URLSearchParams(); params.append('a', 1); -fetch('https://httpbin.org/post', { method: 'POST', body: params }) - .then(res => res.json()) - .then(json => console.log(json)); +const response = await fetch('https://httpbin.org/post', {method: 'POST', body: params}); +const data = await response.json(); + +console.log(data); ``` -#### Handling exceptions -NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information. +### Handling exceptions -Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details. +NOTE: 3xx-5xx responses are _NOT_ exceptions, and should be handled in `then()`, see the next section. + +Wrapping the fetch function into a `try/catch` block will catch _all_ exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document][error-handling.md] for more details. ```js -fetch('https://domain.invalid/') - .catch(err => console.error(err)); +import fetch from 'node-fetch'; + +try { + await fetch('https://domain.invalid/'); +} catch (error) { + console.log(error); +} ``` -#### Handling client and server errors +### Handling client and server errors + It is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses: ```js -function checkStatus(res) { - if (res.ok) { // res.status >= 200 && res.status < 300 - return res; - } else { - throw MyCustomError(res.statusText); - } +import fetch from 'node-fetch'; + +class HTTPResponseError extends Error { + constructor(response) { + super(`HTTP Error Response: ${response.status} ${response.statusText}`); + this.response = response; + } } -fetch('https://httpbin.org/status/400') - .then(checkStatus) - .then(res => console.log('will not get here...')) +const checkStatus = response => { + if (response.ok) { + // response.status >= 200 && response.status < 300 + return response; + } else { + throw new HTTPResponseError(response); + } +} + +const response = await fetch('https://httpbin.org/status/400'); + +try { + checkStatus(response); +} catch (error) { + console.error(error); + + const errorBody = await error.response.text(); + console.error(`Error body: ${errorBody}`); +} ``` +### Handling cookies + +Cookies are not stored by default. However, cookies can be extracted and passed by manipulating request and response headers. See [Extract Set-Cookie Header](#extract-set-cookie-header) for details. + ## Advanced Usage -#### Streams -The "Node.js way" is to use streams when possible: +### Streams + +The "Node.js way" is to use streams when possible. You can pipe `res.body` to another stream. This example uses [stream.pipeline](https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback) to attach stream error handlers and wait for the download to complete. ```js -fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') - .then(res => { - const dest = fs.createWriteStream('./octocat.png'); - res.body.pipe(dest); - }); +import {createWriteStream} from 'node:fs'; +import {pipeline} from 'node:stream'; +import {promisify} from 'node:util' +import fetch from 'node-fetch'; + +const streamPipeline = promisify(pipeline); + +const response = await fetch('https://github.githubassets.com/images/modules/logos_page/Octocat.png'); + +if (!response.ok) throw new Error(`unexpected response ${response.statusText}`); + +await streamPipeline(response.body, createWriteStream('./octocat.png')); ``` In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch errors -- the longer a response runs, the more likely it is to encounter an error. ```js -const fetch = require('node-fetch'); +import fetch from 'node-fetch'; + const response = await fetch('https://httpbin.org/stream/3'); + try { for await (const chunk of response.body) { console.dir(JSON.parse(chunk.toString())); @@ -208,141 +343,156 @@ did not mature until Node.js 14, so you need to do some extra work to ensure you directly from the stream and wait on it response to fully close. ```js -const fetch = require('node-fetch'); +import fetch from 'node-fetch'; + const read = async body => { - let error; - body.on('error', err => { - error = err; - }); - for await (const chunk of body) { - console.dir(JSON.parse(chunk.toString())); - } - return new Promise((resolve, reject) => { - body.on('close', () => { - error ? reject(error) : resolve(); - }); - }); + let error; + body.on('error', err => { + error = err; + }); + + for await (const chunk of body) { + console.dir(JSON.parse(chunk.toString())); + } + + return new Promise((resolve, reject) => { + body.on('close', () => { + error ? reject(error) : resolve(); + }); + }); }; + try { - const response = await fetch('https://httpbin.org/stream/3'); - await read(response.body); + const response = await fetch('https://httpbin.org/stream/3'); + await read(response.body); } catch (err) { - console.error(err.stack); + console.error(err.stack); } ``` -#### Buffer -If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API) +### Accessing Headers and other Metadata ```js -const fileType = require('file-type'); +import fetch from 'node-fetch'; -fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') - .then(res => res.buffer()) - .then(buffer => fileType(buffer)) - .then(type => { /* ... */ }); +const response = await fetch('https://github.com/'); + +console.log(response.ok); +console.log(response.status); +console.log(response.statusText); +console.log(response.headers.raw()); +console.log(response.headers.get('content-type')); ``` -#### Accessing Headers and other Meta data -```js -fetch('https://github.com/') - .then(res => { - console.log(res.ok); - console.log(res.status); - console.log(res.statusText); - console.log(res.headers.raw()); - console.log(res.headers.get('content-type')); - }); -``` - -#### Extract Set-Cookie Header +### Extract Set-Cookie Header Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API. ```js -fetch(url).then(res => { - // returns an array of values, instead of a string of comma-separated values - console.log(res.headers.raw()['set-cookie']); -}); +import fetch from 'node-fetch'; + +const response = await fetch('https://example.com'); + +// Returns an array of values, instead of a string of comma-separated values +console.log(response.headers.raw()['set-cookie']); ``` -#### Post data using a file stream +### Post data using a file ```js -const { createReadStream } = require('fs'); +import fetch, { + Blob, + blobFrom, + blobFromSync, + File, + fileFrom, + fileFromSync, +} from 'node-fetch' -const stream = createReadStream('input.txt'); +const mimetype = 'text/plain' +const blob = fileFromSync('./input.txt', mimetype) +const url = 'https://httpbin.org/post' -fetch('https://httpbin.org/post', { method: 'POST', body: stream }) - .then(res => res.json()) - .then(json => console.log(json)); +const response = await fetch(url, { method: 'POST', body: blob }) +const data = await response.json() + +console.log(data) ``` -#### Post with form-data (detect multipart) +node-fetch comes with a spec-compliant [FormData] implementations for posting +multipart/form-data payloads ```js -const FormData = require('form-data'); +import fetch, { FormData, File, fileFrom } from 'node-fetch' -const form = new FormData(); -form.append('a', 1); +const httpbin = 'https://httpbin.org/post' +const formData = new FormData() +const binary = new Uint8Array([ 97, 98, 99 ]) +const abc = new File([binary], 'abc.txt', { type: 'text/plain' }) -fetch('https://httpbin.org/post', { method: 'POST', body: form }) - .then(res => res.json()) - .then(json => console.log(json)); +formData.set('greeting', 'Hello, world!') +formData.set('file-upload', abc, 'new name.txt') -// OR, using custom headers -// NOTE: getHeaders() is non-standard API +const response = await fetch(httpbin, { method: 'POST', body: formData }) +const data = await response.json() -const form = new FormData(); -form.append('a', 1); - -const options = { - method: 'POST', - body: form, - headers: form.getHeaders() -} - -fetch('https://httpbin.org/post', options) - .then(res => res.json()) - .then(json => console.log(json)); +console.log(data) ``` -#### Request cancellation with AbortSignal +If you for some reason need to post a stream coming from any arbitrary place, +then you can append a [Blob] or a [File] look-a-like item. -> NOTE: You may cancel streamed requests only on Node >= v8.0.0 +The minimum requirement is that it has: +1. A `Symbol.toStringTag` getter or property that is either `Blob` or `File` +2. A known size. +3. And either a `stream()` method or a `arrayBuffer()` method that returns a ArrayBuffer. + +The `stream()` must return any async iterable object as long as it yields Uint8Array (or Buffer) +so Node.Readable streams and whatwg streams works just fine. + +```js +formData.append('upload', { + [Symbol.toStringTag]: 'Blob', + size: 3, + *stream() { + yield new Uint8Array([97, 98, 99]) + }, + arrayBuffer() { + return new Uint8Array([97, 98, 99]).buffer + } +}, 'abc.txt') +``` + +### Request cancellation with AbortSignal You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller). An example of timing out a request after 150ms could be achieved as the following: ```js -import AbortController from 'abort-controller'; +import fetch, { AbortError } from 'node-fetch'; + +// AbortController was added in node v14.17.0 globally +const AbortController = globalThis.AbortController || await import('abort-controller') const controller = new AbortController(); -const timeout = setTimeout( - () => { controller.abort(); }, - 150, -); +const timeout = setTimeout(() => { + controller.abort(); +}, 150); -fetch(url, { signal: controller.signal }) - .then(res => res.json()) - .then( - data => { - useData(data) - }, - err => { - if (err.name === 'AbortError') { - // request was aborted - } - }, - ) - .finally(() => { - clearTimeout(timeout); - }); +try { + const response = await fetch('https://example.com', {signal: controller.signal}); + const data = await response.json(); +} catch (error) { + if (error instanceof AbortError) { + console.log('request was aborted'); + } +} finally { + clearTimeout(timeout); +} ``` -See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples. - +See [test cases](https://github.com/node-fetch/node-fetch/blob/master/test/) for more examples. ## API @@ -354,46 +504,50 @@ See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) Perform an HTTP(S) fetch. -`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. +`url` should be an absolute URL, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. + ### Options The default values are shown after each option key. ```js { - // These properties are part of the Fetch Standard - method: 'GET', - headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below) - body: null, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream - redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect - signal: null, // pass an instance of AbortSignal to optionally abort requests + // These properties are part of the Fetch Standard + method: 'GET', + headers: {}, // Request headers. format is the identical to that accepted by the Headers constructor (see below) + body: null, // Request body. can be null, or a Node.js Readable stream + redirect: 'follow', // Set to `manual` to extract redirect headers, `error` to reject redirect + signal: null, // Pass an instance of AbortSignal to optionally abort requests - // The following properties are node-fetch extensions - follow: 20, // maximum redirect count. 0 to not follow redirect - timeout: 0, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead. - compress: true, // support gzip/deflate content encoding. false to disable - size: 0, // maximum response body size in bytes. 0 to disable - agent: null // http(s).Agent instance or function that returns an instance (see below) + // The following properties are node-fetch extensions + follow: 20, // maximum redirect count. 0 to not follow redirect + compress: true, // support gzip/deflate content encoding. false to disable + size: 0, // maximum response body size in bytes. 0 to disable + agent: null, // http(s).Agent instance or function that returns an instance (see below) + highWaterMark: 16384, // the maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. + insecureHTTPParser: false // Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. } ``` -##### Default Headers +#### Default Headers If no values are set, the following request headers will be sent automatically: -Header | Value -------------------- | -------------------------------------------------------- -`Accept-Encoding` | `gzip,deflate` _(when `options.compress === true`)_ -`Accept` | `*/*` -`Content-Length` | _(automatically calculated, if possible)_ -`Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ -`User-Agent` | `node-fetch/1.0 (+https://github.com/bitinn/node-fetch)` +| Header | Value | +| ------------------- | ------------------------------------------------------ | +| `Accept-Encoding` | `gzip, deflate, br` (when `options.compress === true`) | +| `Accept` | `*/*` | +| `Content-Length` | _(automatically calculated, if possible)_ | +| `Host` | _(host and port information from the target URI)_ | +| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ | +| `User-Agent` | `node-fetch` | + Note: when `body` is a `Stream`, `Content-Length` is not set automatically. -##### Custom Agent +#### Custom Agent The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following: @@ -408,25 +562,85 @@ If no agent is specified, the default agent provided by Node.js is used. Note th In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. ```js +import http from 'node:http'; +import https from 'node:https'; + const httpAgent = new http.Agent({ - keepAlive: true + keepAlive: true }); const httpsAgent = new https.Agent({ - keepAlive: true + keepAlive: true }); const options = { - agent: function (_parsedURL) { - if (_parsedURL.protocol == 'http:') { - return httpAgent; - } else { - return httpsAgent; - } - } + agent: function(_parsedURL) { + if (_parsedURL.protocol == 'http:') { + return httpAgent; + } else { + return httpsAgent; + } + } +}; +``` + + + +#### Custom highWaterMark + +Stream on Node.js have a smaller internal buffer size (16kB, aka `highWaterMark`) from client-side browsers (>1MB, not consistent across browsers). Because of that, when you are writing an isomorphic app and using `res.clone()`, it will hang with large response in Node. + +The recommended way to fix this problem is to resolve cloned response in parallel: + +```js +import fetch from 'node-fetch'; + +const response = await fetch('https://example.com'); +const r1 = response.clone(); + +const results = await Promise.all([response.json(), r1.text()]); + +console.log(results[0]); +console.log(results[1]); +``` + +If for some reason you don't like the solution above, since `3.x` you are able to modify the `highWaterMark` option: + +```js +import fetch from 'node-fetch'; + +const response = await fetch('https://example.com', { + // About 1MB + highWaterMark: 1024 * 1024 +}); + +const result = await res.clone().arrayBuffer(); +console.dir(result); +``` + +#### Insecure HTTP Parser + +Passed through to the `insecureHTTPParser` option on http(s).request. See [`http.request`](https://nodejs.org/api/http.html#http_http_request_url_options_callback) for more information. + +#### Manual Redirect + +The `redirect: 'manual'` option for node-fetch is different from the browser & specification, which +results in an [opaque-redirect filtered response](https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect). +node-fetch gives you the typical [basic filtered response](https://fetch.spec.whatwg.org/#concept-filtered-response-basic) instead. + +```js +import fetch from 'node-fetch'; + +const response = await fetch('https://httpbin.org/status/301', { redirect: 'manual' }); + +if (response.status === 301 || response.status === 302) { + const locationURL = new URL(response.headers.get('location'), response.url); + const response2 = await fetch(locationURL, { redirect: 'manual' }); + console.dir(response2); } ``` + ### Class: Request An HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface. @@ -435,8 +649,6 @@ Due to the nature of Node.js, the following properties are not implemented at th - `type` - `destination` -- `referrer` -- `referrerPolicy` - `mode` - `credentials` - `cache` @@ -449,35 +661,34 @@ The following node-fetch extension properties are provided: - `compress` - `counter` - `agent` +- `highWaterMark` See [options](#fetch-options) for exact meaning of these extensions. #### new Request(input[, options]) -*(spec-compliant)* +_(spec-compliant)_ - `input` A string representing a URL, or another `Request` (which will be cloned) -- `options` [Options][#fetch-options] for the HTTP(S) request +- `options` [Options](#fetch-options) for the HTTP(S) request Constructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). In most cases, directly `fetch(url, options)` is simpler than creating a `Request` object. + ### Class: Response An HTTP(S) response. This class implements the [Body](#iface-body) interface. The following properties are not implemented in node-fetch at this moment: -- `Response.error()` -- `Response.redirect()` -- `type` - `trailer` #### new Response([body[, options]]) -*(spec-compliant)* +_(spec-compliant)_ - `body` A `String` or [`Readable` stream][node-readable] - `options` A [`ResponseInit`][response-init] options dictionary @@ -488,24 +699,31 @@ Because Node.js does not implement service workers (for which this class was des #### response.ok -*(spec-compliant)* +_(spec-compliant)_ Convenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300. #### response.redirected -*(spec-compliant)* +_(spec-compliant)_ Convenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0. +#### response.type + +_(deviation from spec)_ + +Convenience property representing the response's type. node-fetch only supports `'default'` and `'error'` and does not make use of [filtered responses](https://fetch.spec.whatwg.org/#concept-filtered-response). + + ### Class: Headers This class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented. #### new Headers([init]) -*(spec-compliant)* +_(spec-compliant)_ - `init` Optional argument to pre-fill the `Headers` object @@ -513,122 +731,142 @@ Construct a new `Headers` object. `init` can be either `null`, a `Headers` objec ```js // Example adapted from https://fetch.spec.whatwg.org/#example-headers-class +import {Headers} from 'node-fetch'; const meta = { - 'Content-Type': 'text/xml', - 'Breaking-Bad': '<3' + 'Content-Type': 'text/xml' }; const headers = new Headers(meta); // The above is equivalent to -const meta = [ - [ 'Content-Type', 'text/xml' ], - [ 'Breaking-Bad', '<3' ] -]; +const meta = [['Content-Type', 'text/xml']]; const headers = new Headers(meta); // You can in fact use any iterable objects, like a Map or even another Headers const meta = new Map(); meta.set('Content-Type', 'text/xml'); -meta.set('Breaking-Bad', '<3'); const headers = new Headers(meta); const copyOfHeaders = new Headers(headers); ``` + ### Interface: Body `Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes. -The following methods are not yet implemented in node-fetch at this moment: - -- `formData()` - #### body.body -*(deviation from spec)* +_(deviation from spec)_ -* Node.js [`Readable` stream][node-readable] +- Node.js [`Readable` stream][node-readable] Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. #### body.bodyUsed -*(spec-compliant)* +_(spec-compliant)_ -* `Boolean` +- `Boolean` A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again. #### body.arrayBuffer() + +#### body.formData() + #### body.blob() + #### body.json() + #### body.text() -*(spec-compliant)* +`fetch` comes with methods to parse `multipart/form-data` payloads as well as +`x-www-form-urlencoded` bodies using `.formData()` this comes from the idea that +Service Worker can intercept such messages before it's sent to the server to +alter them. This is useful for anybody building a server so you can use it to +parse & consume payloads. -* Returns: Promise +
+Code example -Consume the body and return a promise that will resolve to one of these formats. +```js +import http from 'node:http' +import { Response } from 'node-fetch' -#### body.buffer() +http.createServer(async function (req, res) { + const formData = await new Response(req, { + headers: req.headers // Pass along the boundary value + }).formData() + const allFields = [...formData] -*(node-fetch extension)* + const file = formData.get('uploaded-files') + const arrayBuffer = await file.arrayBuffer() + const text = await file.text() + const whatwgReadableStream = file.stream() -* Returns: Promise<Buffer> + // other was to consume the request could be to do: + const json = await new Response(req).json() + const text = await new Response(req).text() + const arrayBuffer = await new Response(req).arrayBuffer() + const blob = await new Response(req, { + headers: req.headers // So that `type` inherits `Content-Type` + }.blob() +}) +``` -Consume the body and return a promise that will resolve to a Buffer. - -#### body.textConverted() - -*(node-fetch extension)* - -* Returns: Promise<String> - -Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible. - -(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.) +
+ ### Class: FetchError -*(node-fetch extension)* +_(node-fetch extension)_ An operational error in the fetching process. See [ERROR-HANDLING.md][] for more info. + ### Class: AbortError -*(node-fetch extension)* +_(node-fetch extension)_ An Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info. +## TypeScript + +**Since `3.x` types are bundled with `node-fetch`, so you don't need to install any additional packages.** + +For older versions please use the type definitions from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped): + +```sh +npm install --save-dev @types/node-fetch@2.x +``` + ## Acknowledgement Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference. -`node-fetch` v1 was maintained by [@bitinn](https://github.com/bitinn); v2 was maintained by [@TimothyGu](https://github.com/timothygu), [@bitinn](https://github.com/bitinn) and [@jimmywarting](https://github.com/jimmywarting); v2 readme is written by [@jkantr](https://github.com/jkantr). +## Team + +| [![David Frank](https://github.com/bitinn.png?size=100)](https://github.com/bitinn) | [![Jimmy Wärting](https://github.com/jimmywarting.png?size=100)](https://github.com/jimmywarting) | [![Antoni Kepinski](https://github.com/xxczaki.png?size=100)](https://github.com/xxczaki) | [![Richie Bendall](https://github.com/Richienb.png?size=100)](https://github.com/Richienb) | [![Gregor Martynus](https://github.com/gr2m.png?size=100)](https://github.com/gr2m) | +| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | +| [David Frank](https://bitinn.net/) | [Jimmy Wärting](https://jimmy.warting.se/) | [Antoni Kepinski](https://kepinski.ch) | [Richie Bendall](https://www.richie-bendall.ml/) | [Gregor Martynus](https://twitter.com/gr2m) | + +###### Former + +- [Timothy Gu](https://github.com/timothygu) +- [Jared Kantrowitz](https://github.com/jkantr) ## License -MIT +[MIT](LICENSE.md) -[npm-image]: https://flat.badgen.net/npm/v/node-fetch -[npm-url]: https://www.npmjs.com/package/node-fetch -[travis-image]: https://flat.badgen.net/travis/bitinn/node-fetch -[travis-url]: https://travis-ci.org/bitinn/node-fetch -[codecov-image]: https://flat.badgen.net/codecov/c/github/bitinn/node-fetch/master -[codecov-url]: https://codecov.io/gh/bitinn/node-fetch -[install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch -[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch -[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA&label=Discord&style=flat-square -[discord-url]: https://discord.gg/Zxbndcm -[opencollective-image]: https://opencollective.com/node-fetch/backers.svg -[opencollective-url]: https://opencollective.com/node-fetch [whatwg-fetch]: https://fetch.spec.whatwg.org/ [response-init]: https://fetch.spec.whatwg.org/#responseinit [node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams [mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers -[LIMITS.md]: https://github.com/bitinn/node-fetch/blob/master/LIMITS.md -[ERROR-HANDLING.md]: https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md -[UPGRADE-GUIDE.md]: https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md +[error-handling.md]: https://github.com/node-fetch/node-fetch/blob/master/docs/ERROR-HANDLING.md +[FormData]: https://developer.mozilla.org/en-US/docs/Web/API/FormData +[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob +[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/node_modules/node-fetch/package.json b/node_modules/node-fetch/package.json index e0be1768..2b4e8583 100644 --- a/node_modules/node-fetch/package.json +++ b/node_modules/node-fetch/package.json @@ -1,89 +1,131 @@ { - "name": "node-fetch", - "version": "2.7.0", - "description": "A light-weight module that brings window.fetch to node.js", - "main": "lib/index.js", - "browser": "./browser.js", - "module": "lib/index.mjs", - "files": [ - "lib/index.js", - "lib/index.mjs", - "lib/index.es.js", - "browser.js" - ], - "engines": { - "node": "4.x || >=6.0.0" - }, - "scripts": { - "build": "cross-env BABEL_ENV=rollup rollup -c", - "prepare": "npm run build", - "test": "cross-env BABEL_ENV=test mocha --require babel-register --throw-deprecation test/test.js", - "report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js", - "coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json" - }, - "repository": { - "type": "git", - "url": "https://github.com/bitinn/node-fetch.git" - }, - "keywords": [ - "fetch", - "http", - "promise" - ], - "author": "David Frank", - "license": "MIT", - "bugs": { - "url": "https://github.com/bitinn/node-fetch/issues" - }, - "homepage": "https://github.com/bitinn/node-fetch", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - }, - "devDependencies": { - "@ungap/url-search-params": "^0.1.2", - "abort-controller": "^1.1.0", - "abortcontroller-polyfill": "^1.3.0", - "babel-core": "^6.26.3", - "babel-plugin-istanbul": "^4.1.6", - "babel-plugin-transform-async-generator-functions": "^6.24.1", - "babel-polyfill": "^6.26.0", - "babel-preset-env": "1.4.0", - "babel-register": "^6.16.3", - "chai": "^3.5.0", - "chai-as-promised": "^7.1.1", - "chai-iterator": "^1.1.1", - "chai-string": "~1.3.0", - "codecov": "3.3.0", - "cross-env": "^5.2.0", - "form-data": "^2.3.3", - "is-builtin-module": "^1.0.0", - "mocha": "^5.0.0", - "nyc": "11.9.0", - "parted": "^0.1.1", - "promise": "^8.0.3", - "resumer": "0.0.0", - "rollup": "^0.63.4", - "rollup-plugin-babel": "^3.0.7", - "string-to-arraybuffer": "^1.0.2", - "teeny-request": "3.7.0" - }, - "release": { - "branches": [ - "+([0-9]).x", - "main", - "next", - { - "name": "beta", - "prerelease": true - } - ] + "name": "node-fetch", + "version": "3.3.2", + "description": "A light-weight module that brings Fetch API to node.js", + "main": "./src/index.js", + "sideEffects": false, + "type": "module", + "files": [ + "src", + "@types/index.d.ts" + ], + "types": "./@types/index.d.ts", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "scripts": { + "test": "mocha", + "coverage": "c8 report --reporter=text-lcov | coveralls", + "test-types": "tsd", + "lint": "xo" + }, + "repository": { + "type": "git", + "url": "https://github.com/node-fetch/node-fetch.git" + }, + "keywords": [ + "fetch", + "http", + "promise", + "request", + "curl", + "wget", + "xhr", + "whatwg" + ], + "author": "David Frank", + "license": "MIT", + "bugs": { + "url": "https://github.com/node-fetch/node-fetch/issues" + }, + "homepage": "https://github.com/node-fetch/node-fetch", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + }, + "devDependencies": { + "abort-controller": "^3.0.0", + "abortcontroller-polyfill": "^1.7.1", + "busboy": "^1.4.0", + "c8": "^7.7.2", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "chai-iterator": "^3.0.2", + "chai-string": "^1.5.0", + "coveralls": "^3.1.0", + "form-data": "^4.0.0", + "formdata-node": "^4.2.4", + "mocha": "^9.1.3", + "p-timeout": "^5.0.0", + "stream-consumers": "^1.0.1", + "tsd": "^0.14.0", + "xo": "^0.39.1" + }, + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "tsd": { + "cwd": "@types", + "compilerOptions": { + "esModuleInterop": true } + }, + "xo": { + "envs": [ + "node", + "browser" + ], + "ignores": [ + "example.js" + ], + "rules": { + "complexity": 0, + "import/extensions": 0, + "import/no-useless-path-segments": 0, + "import/no-anonymous-default-export": 0, + "import/no-named-as-default": 0, + "unicorn/import-index": 0, + "unicorn/no-array-reduce": 0, + "unicorn/prefer-node-protocol": 0, + "unicorn/numeric-separators-style": 0, + "unicorn/explicit-length-check": 0, + "capitalized-comments": 0, + "node/no-unsupported-features/es-syntax": 0, + "@typescript-eslint/member-ordering": 0 + }, + "overrides": [ + { + "files": "test/**/*.js", + "envs": [ + "node", + "mocha" + ], + "rules": { + "max-nested-callbacks": 0, + "no-unused-expressions": 0, + "no-warning-comments": 0, + "new-cap": 0, + "guard-for-in": 0, + "unicorn/no-array-for-each": 0, + "unicorn/prevent-abbreviations": 0, + "promise/prefer-await-to-then": 0, + "ava/no-import-test-files": 0 + } + } + ] + }, + "runkitExampleFilename": "example.js", + "release": { + "branches": [ + "+([0-9]).x", + "main", + "next", + { + "name": "beta", + "prerelease": true + } + ] + } } diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/body.js b/node_modules/node-fetch/src/body.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/body.js rename to node_modules/node-fetch/src/body.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/abort-error.js b/node_modules/node-fetch/src/errors/abort-error.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/abort-error.js rename to node_modules/node-fetch/src/errors/abort-error.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/base.js b/node_modules/node-fetch/src/errors/base.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/base.js rename to node_modules/node-fetch/src/errors/base.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/fetch-error.js b/node_modules/node-fetch/src/errors/fetch-error.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/errors/fetch-error.js rename to node_modules/node-fetch/src/errors/fetch-error.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/headers.js b/node_modules/node-fetch/src/headers.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/headers.js rename to node_modules/node-fetch/src/headers.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/index.js b/node_modules/node-fetch/src/index.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/index.js rename to node_modules/node-fetch/src/index.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/request.js b/node_modules/node-fetch/src/request.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/request.js rename to node_modules/node-fetch/src/request.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/response.js b/node_modules/node-fetch/src/response.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/response.js rename to node_modules/node-fetch/src/response.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/get-search.js b/node_modules/node-fetch/src/utils/get-search.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/get-search.js rename to node_modules/node-fetch/src/utils/get-search.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/is-redirect.js b/node_modules/node-fetch/src/utils/is-redirect.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/is-redirect.js rename to node_modules/node-fetch/src/utils/is-redirect.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/is.js b/node_modules/node-fetch/src/utils/is.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/is.js rename to node_modules/node-fetch/src/utils/is.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/multipart-parser.js b/node_modules/node-fetch/src/utils/multipart-parser.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/multipart-parser.js rename to node_modules/node-fetch/src/utils/multipart-parser.js diff --git a/node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/referrer.js b/node_modules/node-fetch/src/utils/referrer.js similarity index 100% rename from node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch/src/utils/referrer.js rename to node_modules/node-fetch/src/utils/referrer.js diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/LICENSE b/node_modules/nostr-tools/node_modules/@noble/curves/LICENSE deleted file mode 100644 index 9297a046..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2022 Paul Miller (https://paulmillr.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/README.md b/node_modules/nostr-tools/node_modules/@noble/curves/README.md deleted file mode 100644 index a5d14f46..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/README.md +++ /dev/null @@ -1,971 +0,0 @@ -# noble-curves - -Audited & minimal JS implementation of elliptic curve cryptography. - -- 🔒 [**Audited**](#security) by an independent security firm -- 🔻 Tree-shaking-friendly: use only what's necessary, other code won't be included -- 🏎 Ultra-fast, hand-optimized for caveats of JS engines -- 🔍 Unique tests ensure correctness: property-based, cross-library and Wycheproof vectors, fuzzing -- ➰ Short Weierstrass, Edwards, Montgomery curves -- ✍️ ECDSA, EdDSA, Schnorr, BLS signature schemes, ECDH key agreement -- 🔖 SUF-CMA and SBS (non-repudiation) for ed25519, ed448 and others -- #️⃣ Hash-to-curve - for encoding or hashing an arbitrary string to an elliptic curve point -- 🧜‍♂️ Poseidon ZK-friendly hash - -Check out [Upgrading](#upgrading) if you've previously used single-feature noble -packages. See [Resources](#resources) for articles and real-world software that uses curves. - -### This library belongs to _noble_ crypto - -> **noble-crypto** — high-security, easily auditable set of contained cryptographic libraries and tools. - -- No dependencies, protection against supply chain attacks -- Auditable TypeScript / JS code -- Supported in all major browsers and stable node.js versions -- All releases are signed with PGP keys -- Check out [homepage](https://paulmillr.com/noble/) & all libraries: - [curves](https://github.com/paulmillr/noble-curves) - (4kb versions [secp256k1](https://github.com/paulmillr/noble-secp256k1), - [ed25519](https://github.com/paulmillr/noble-ed25519)), - [hashes](https://github.com/paulmillr/noble-hashes) - -## Usage - -> npm install @noble/curves - -We support all major platforms and runtimes. -For [Deno](https://deno.land), ensure to use [npm specifier](https://deno.land/manual@v1.28.0/node/npm_specifiers). -For React Native, you may need a [polyfill for crypto.getRandomValues](https://github.com/LinusU/react-native-get-random-values). -If you don't like NPM, a standalone [noble-curves.js](https://github.com/paulmillr/noble-curves/releases) is also available. - -The library is tree-shaking-friendly and does not expose root entry point as -`@noble/curves`. Instead, you need to import specific primitives. -This is done to ensure small size of your apps. - -The package consists of two parts: - -* [Implementations](#implementations), utilizing one dependency [noble-hashes](https://github.com/paulmillr/noble-hashes), - providing ready-to-use: - - NIST curves secp256r1 / p256, secp384r1 / p384, secp521r1 / p521 - - SECG curve secp256k1 - - ed25519 / curve25519 / x25519 / ristretto255, edwards448 / curve448 / x448 - - pairing-friendly curves bls12-381, bn254 - - [pasta](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) curves -2. [Abstract](#abstract-api), zero-dependency elliptic curve algorithms - -### Implementations - -#### Generic example for all curves, secp256k1 - -```ts -// Each curve has similar methods -import { secp256k1 } from '@noble/curves/secp256k1'; // ESM and Common.js -// import { secp256k1 } from 'npm:@noble/curves@1.2.0/secp256k1'; // Deno -const priv = secp256k1.utils.randomPrivateKey(); -const pub = secp256k1.getPublicKey(priv); -const msg = new Uint8Array(32).fill(1); -const sig = secp256k1.sign(msg, priv); -const isValid = secp256k1.verify(sig, msg, pub) === true; - -// hex strings are also supported besides Uint8Arrays: -const privHex = '46c930bc7bb4db7f55da20798697421b98c4175a52c630294d75a84b9c126236'; -const pub2 = secp256k1.getPublicKey(privHex); -``` - -#### All imports - -```typescript -import { secp256k1, schnorr } from '@noble/curves/secp256k1'; -import { ed25519, ed25519ph, ed25519ctx, x25519, RistrettoPoint } from '@noble/curves/ed25519'; -import { ed448, ed448ph, ed448ctx, x448 } from '@noble/curves/ed448'; -import { p256 } from '@noble/curves/p256'; -import { p384 } from '@noble/curves/p384'; -import { p521 } from '@noble/curves/p521'; -import { pallas, vesta } from '@noble/curves/pasta'; -import { bls12_381 } from '@noble/curves/bls12-381'; -import { bn254 } from '@noble/curves/bn254'; -import { jubjub } from '@noble/curves/jubjub'; -``` - -#### ECDSA public key recovery & ECDH - -```ts -// extraEntropy https://moderncrypto.org/mail-archive/curves/2017/000925.html -const sigImprovedSecurity = secp256k1.sign(msg, priv, { extraEntropy: true }); -sig.recoverPublicKey(msg) === pub; // public key recovery -const someonesPub = secp256k1.getPublicKey(secp256k1.utils.randomPrivateKey()); -const shared = secp256k1.getSharedSecret(priv, someonesPub); // ECDH -``` - -#### Schnorr signatures over secp256k1 (BIP340) - -```ts -import { schnorr } from '@noble/curves/secp256k1'; -const priv = schnorr.utils.randomPrivateKey(); -const pub = schnorr.getPublicKey(priv); -const msg = new TextEncoder().encode('hello'); -const sig = schnorr.sign(msg, priv); -const isValid = schnorr.verify(sig, msg, pub); -``` - -#### ed25519, X25519, ristretto255 - -```ts -import { ed25519 } from '@noble/curves/ed25519'; -const priv = ed25519.utils.randomPrivateKey(); -const pub = ed25519.getPublicKey(priv); -const msg = new TextEncoder().encode('hello'); -const sig = ed25519.sign(msg, priv); -ed25519.verify(sig, msg, pub); // Default mode: follows ZIP215 -ed25519.verify(sig, msg, pub, { zip215: false }); // RFC8032 / FIPS 186-5 -``` - -Default `verify` behavior follows [ZIP215](https://zips.z.cash/zip-0215) and -[can be used in consensus-critical applications](https://hdevalence.ca/blog/2020-10-04-its-25519am). -It has SUF-CMA (strong unforgeability under chosen message attacks). -`zip215: false` option switches verification criteria to strict -[RFC8032](https://www.rfc-editor.org/rfc/rfc8032) / [FIPS 186-5](https://csrc.nist.gov/publications/detail/fips/186/5/final) -and additionally provides non-repudiation with SBS [(Strongly Binding Signatures)](https://eprint.iacr.org/2020/1244). - -X25519 follows [RFC7748](https://www.rfc-editor.org/rfc/rfc7748). -ristretto255 follows [irtf draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448). - -```ts -// Variants from RFC8032: with context, prehashed -import { ed25519ctx, ed25519ph } from '@noble/curves/ed25519'; - -// ECDH using curve25519 aka x25519 -import { x25519 } from '@noble/curves/ed25519'; -const priv = 'a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4'; -const pub = 'e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c'; -x25519.getSharedSecret(priv, pub) === x25519.scalarMult(priv, pub); // aliases -x25519.getPublicKey(priv) === x25519.scalarMultBase(priv); -x25519.getPublicKey(x25519.utils.randomPrivateKey()); - -// ed25519 => x25519 conversion -import { edwardsToMontgomeryPub, edwardsToMontgomeryPriv } from '@noble/curves/ed25519'; -edwardsToMontgomeryPub(ed25519.getPublicKey(ed25519.utils.randomPrivateKey())); -edwardsToMontgomeryPriv(ed25519.utils.randomPrivateKey()); - -// hash-to-curve, ristretto255 -import { hashToCurve, encodeToCurve, RistrettoPoint } from '@noble/curves/ed25519'; -const rp = RistrettoPoint.fromHex( - '6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919' -); -RistrettoPoint.hashToCurve('Ristretto is traditionally a short shot of espresso coffee'); -// also has add(), equals(), multiply(), toRawBytes() methods -``` - -#### ed448, X448 - -```ts -import { ed448 } from '@noble/curves/ed448'; -const priv = ed448.utils.randomPrivateKey(); -const pub = ed448.getPublicKey(priv); -const msg = new TextEncoder().encode('whatsup'); -const sig = ed448.sign(msg, priv); -ed448.verify(sig, msg, pub); - -import { ed448ph, ed448ctx, x448, hashToCurve, encodeToCurve } from '@noble/curves/ed448'; -x448.getSharedSecret(priv, pub) === x448.scalarMult(priv, pub); // aliases -x448.getPublicKey(priv) === x448.scalarMultBase(priv); -``` - -Same RFC7748 / RFC8032 are followed. - -#### bls12-381 - -See [abstract/bls](#abstractbls-barreto-lynn-scott-curves). - -#### Accessing a curve's variables - -```ts -import { secp256k1 } from '@noble/curves/secp256k1'; -// Every curve has `CURVE` object that contains its parameters, field, and others -console.log(secp256k1.CURVE.p); // field modulus -console.log(secp256k1.CURVE.n); // curve order -console.log(secp256k1.CURVE.a, secp256k1.CURVE.b); // equation params -console.log(secp256k1.CURVE.Gx, secp256k1.CURVE.Gy); // base point coordinates -``` - -## Abstract API - -Abstract API allows to define custom curves. All arithmetics is done with JS -bigints over finite fields, which is defined from `modular` sub-module. For -scalar multiplication, we use -[precomputed tables with w-ary non-adjacent form (wNAF)](https://paulmillr.com/posts/noble-secp256k1-fast-ecc/). -Precomputes are enabled for weierstrass and edwards BASE points of a curve. You -could precompute any other point (e.g. for ECDH) using `utils.precompute()` -method: check out examples. - -There are following zero-dependency algorithms: - -- [abstract/weierstrass: Short Weierstrass curve](#abstractweierstrass-short-weierstrass-curve) -- [abstract/edwards: Twisted Edwards curve](#abstractedwards-twisted-edwards-curve) -- [abstract/montgomery: Montgomery curve](#abstractmontgomery-montgomery-curve) -- [abstract/bls: Barreto-Lynn-Scott curves](#abstractbls-barreto-lynn-scott-curves) -- [abstract/hash-to-curve: Hashing strings to curve points](#abstracthash-to-curve-hashing-strings-to-curve-points) -- [abstract/poseidon: Poseidon hash](#abstractposeidon-poseidon-hash) -- [abstract/modular: Modular arithmetics utilities](#abstractmodular-modular-arithmetics-utilities) -- [abstract/utils: General utilities](#abstractutils-general-utilities) - -### abstract/weierstrass: Short Weierstrass curve - -```ts -import { weierstrass } from '@noble/curves/abstract/weierstrass'; -import { Field } from '@noble/curves/abstract/modular'; // finite field for mod arithmetics -import { sha256 } from '@noble/hashes/sha256'; // 3rd-party sha256() of type utils.CHash -import { hmac } from '@noble/hashes/hmac'; // 3rd-party hmac() that will accept sha256() -import { concatBytes, randomBytes } from '@noble/hashes/utils'; // 3rd-party utilities -const secq256k1 = weierstrass({ - // secq256k1: cycle of secp256k1 with Fp/N flipped. - // https://personaelabs.org/posts/spartan-ecdsa - // https://zcash.github.io/halo2/background/curves.html#cycles-of-curves - a: 0n, - b: 7n, - Fp: Field(2n ** 256n - 432420386565659656852420866394968145599n), - n: 2n ** 256n - 2n ** 32n - 2n ** 9n - 2n ** 8n - 2n ** 7n - 2n ** 6n - 2n ** 4n - 1n, - Gx: 55066263022277343669578718895168534326250603453777594175500187360389116729240n, - Gy: 32670510020758816978083085130507043184471273380659243275938904335757337482424n, - hash: sha256, - hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => hmac(sha256, key, concatBytes(...msgs)), - randomBytes, -}); - -// Replace weierstrass with weierstrassPoints if you don't need ECDSA, hash, hmac, randomBytes -``` - -Short Weierstrass curve's formula is `y² = x³ + ax + b`. `weierstrass` -expects arguments `a`, `b`, field `Fp`, curve order `n`, cofactor `h` -and coordinates `Gx`, `Gy` of generator point. - -**`k` generation** is done deterministically, following -[RFC6979](https://www.rfc-editor.org/rfc/rfc6979). For this you will need -`hmac` & `hash`, which in our implementations is provided by noble-hashes. If -you're using different hashing library, make sure to wrap it in the following interface: - -```ts -type CHash = { - (message: Uint8Array): Uint8Array; - blockLen: number; - outputLen: number; - create(): any; -}; -``` - -**Weierstrass points:** - -1. Exported as `ProjectivePoint` -2. Represented in projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z) -3. Use complete exception-free formulas for addition and doubling -4. Can be decoded/encoded from/to Uint8Array / hex strings using - `ProjectivePoint.fromHex` and `ProjectivePoint#toRawBytes()` -5. Have `assertValidity()` which checks for being on-curve -6. Have `toAffine()` and `x` / `y` getters which convert to 2d xy affine coordinates - -```ts -// `weierstrassPoints()` returns `CURVE` and `ProjectivePoint` -// `weierstrass()` returns `CurveFn` -type SignOpts = { lowS?: boolean; prehash?: boolean; extraEntropy: boolean | Uint8Array }; -type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array; - getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean) => Uint8Array; - sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => SignatureType; - verify: ( - signature: Hex | SignatureType, - msgHash: Hex, - publicKey: Hex, - opts?: { lowS?: boolean; prehash?: boolean } - ) => boolean; - ProjectivePoint: ProjectivePointConstructor; - Signature: SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: PrivKey) => bigint; - isValidPrivateKey(key: PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number, point?: ProjPointType) => ProjPointType; - }; -}; - -// T is usually bigint, but can be something else like complex numbers in BLS curves -interface ProjPointType extends Group> { - readonly px: T; - readonly py: T; - readonly pz: T; - get x(): bigint; - get y(): bigint; - multiply(scalar: bigint): ProjPointType; - multiplyUnsafe(scalar: bigint): ProjPointType; - multiplyAndAddUnsafe(Q: ProjPointType, a: bigint, b: bigint): ProjPointType | undefined; - toAffine(iz?: T): AffinePoint; - isTorsionFree(): boolean; - clearCofactor(): ProjPointType; - assertValidity(): void; - hasEvenY(): boolean; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; -} -// Static methods for 3d XYZ points -interface ProjConstructor extends GroupConstructor> { - new (x: T, y: T, z: T): ProjPointType; - fromAffine(p: AffinePoint): ProjPointType; - fromHex(hex: Hex): ProjPointType; - fromPrivateKey(privateKey: PrivKey): ProjPointType; -} -``` - -**ECDSA signatures** are represented by `Signature` instances and can be -described by the interface: - -```ts -interface SignatureType { - readonly r: bigint; - readonly s: bigint; - readonly recovery?: number; - assertValidity(): void; - addRecoveryBit(recovery: number): SignatureType; - hasHighS(): boolean; - normalizeS(): SignatureType; - recoverPublicKey(msgHash: Hex): ProjPointType; - toCompactRawBytes(): Uint8Array; - toCompactHex(): string; - // DER-encoded - toDERRawBytes(): Uint8Array; - toDERHex(): string; -} -type SignatureConstructor = { - new (r: bigint, s: bigint): SignatureType; - fromCompact(hex: Hex): SignatureType; - fromDER(hex: Hex): SignatureType; -}; -``` - -More examples: - -```typescript -// All curves expose same generic interface. -const priv = secq256k1.utils.randomPrivateKey(); -secq256k1.getPublicKey(priv); // Convert private key to public. -const sig = secq256k1.sign(msg, priv); // Sign msg with private key. -secq256k1.verify(sig, msg, priv); // Verify if sig is correct. - -const Point = secq256k1.ProjectivePoint; -const point = Point.BASE; // Elliptic curve Point class and BASE point static var. -point.add(point).equals(point.double()); // add(), equals(), double() methods -point.subtract(point).equals(Point.ZERO); // subtract() method, ZERO static var -point.negate(); // Flips point over x/y coordinate. -point.multiply(31415n); // Multiplication of Point by scalar. - -point.assertValidity(); // Checks for being on-curve -point.toAffine(); // Converts to 2d affine xy coordinates - -secq256k1.CURVE.n; -secq256k1.CURVE.p; -secq256k1.CURVE.Fp.mod(); -secq256k1.CURVE.hash(); - -// precomputes -const fast = secq256k1.utils.precompute(8, Point.fromHex(someonesPubKey)); -fast.multiply(privKey); // much faster ECDH now -``` - -### abstract/edwards: Twisted Edwards curve - -```ts -import { twistedEdwards } from '@noble/curves/abstract/edwards'; -import { Field } from '@noble/curves/abstract/modular'; -import { sha512 } from '@noble/hashes/sha512'; -import { randomBytes } from '@noble/hashes/utils'; - -const Fp = Field(2n ** 255n - 19n); -const ed25519 = twistedEdwards({ - a: Fp.create(-1n), - d: Fp.div(-121665n, 121666n), // -121665n/121666n mod p - Fp: Fp, - n: 2n ** 252n + 27742317777372353535851937790883648493n, - h: 8n, - Gx: 15112221349535400772501151409588531511454012693041857206046113283949847762202n, - Gy: 46316835694926478169428394003475163141307993866256225615783033603165251855960n, - hash: sha512, - randomBytes, - adjustScalarBytes(bytes) { - // optional; but mandatory in ed25519 - bytes[0] &= 248; - bytes[31] &= 127; - bytes[31] |= 64; - return bytes; - }, -} as const); -``` - -Twisted Edwards curve's formula is `ax² + y² = 1 + dx²y²`. You must specify `a`, `d`, field `Fp`, order `n`, cofactor `h` -and coordinates `Gx`, `Gy` of generator point. - -For EdDSA signatures, `hash` param required. `adjustScalarBytes` which instructs how to change private scalars could be specified. - -**Edwards points:** - -1. Exported as `ExtendedPoint` -2. Represented in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z) -3. Use complete exception-free formulas for addition and doubling -4. Can be decoded/encoded from/to Uint8Array / hex strings using `ExtendedPoint.fromHex` and `ExtendedPoint#toRawBytes()` -5. Have `assertValidity()` which checks for being on-curve -6. Have `toAffine()` and `x` / `y` getters which convert to 2d xy affine coordinates -7. Have `isTorsionFree()`, `clearCofactor()` and `isSmallOrder()` utilities to handle torsions - -```ts -// `twistedEdwards()` returns `CurveFn` of following type: -type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: Hex) => Uint8Array; - sign: (message: Hex, privateKey: Hex, context?: Hex) => Uint8Array; - verify: (sig: SigType, message: Hex, publicKey: Hex, context?: Hex) => boolean; - ExtendedPoint: ExtPointConstructor; - utils: { - randomPrivateKey: () => Uint8Array; - getExtendedPublicKey: (key: PrivKey) => { - head: Uint8Array; - prefix: Uint8Array; - scalar: bigint; - point: PointType; - pointBytes: Uint8Array; - }; - }; -}; - -interface ExtPointType extends Group { - readonly ex: bigint; - readonly ey: bigint; - readonly ez: bigint; - readonly et: bigint; - get x(): bigint; - get y(): bigint; - assertValidity(): void; - multiply(scalar: bigint): ExtPointType; - multiplyUnsafe(scalar: bigint): ExtPointType; - isSmallOrder(): boolean; - isTorsionFree(): boolean; - clearCofactor(): ExtPointType; - toAffine(iz?: bigint): AffinePoint; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; -} -// Static methods of Extended Point with coordinates in X, Y, Z, T -interface ExtPointConstructor extends GroupConstructor { - new (x: bigint, y: bigint, z: bigint, t: bigint): ExtPointType; - fromAffine(p: AffinePoint): ExtPointType; - fromHex(hex: Hex): ExtPointType; - fromPrivateKey(privateKey: Hex): ExtPointType; -} -``` - -### abstract/montgomery: Montgomery curve - -```typescript -import { montgomery } from '@noble/curves/abstract/montgomery'; -import { Field } from '@noble/curves/abstract/modular'; - -const x25519 = montgomery({ - a: 486662n, - Gu: 9n, - Fp: Field(2n ** 255n - 19n), - montgomeryBits: 255, - nByteLength: 32, - // Optional param - adjustScalarBytes(bytes) { - bytes[0] &= 248; - bytes[31] &= 127; - bytes[31] |= 64; - return bytes; - }, -}); -``` - -The module contains methods for x-only ECDH on Curve25519 / Curve448 from RFC7748. -Proper Elliptic Curve Points are not implemented yet. - -You must specify curve params `Fp`, `a`, `Gu` coordinate of u, `montgomeryBits` and `nByteLength`. - -### abstract/bls: Barreto-Lynn-Scott curves - -The module abstracts BLS (Barreto-Lynn-Scott) pairing-friendly elliptic curve construction. -They allow to construct [zk-SNARKs](https://z.cash/technology/zksnarks/) and -use aggregated, batch-verifiable -[threshold signatures](https://medium.com/snigirev.stepan/bls-signatures-better-than-schnorr-5a7fe30ea716), -using Boneh-Lynn-Shacham signature scheme. - -Main methods and properties are: - -- `getPublicKey(privateKey)` -- `sign(message, privateKey)` -- `verify(signature, message, publicKey)` -- `aggregatePublicKeys(publicKeys)` -- `aggregateSignatures(signatures)` -- `G1` and `G2` curves containing `CURVE` and `ProjectivePoint` -- `Signature` property with `fromHex`, `toHex` methods -- `fields` containing `Fp`, `Fp2`, `Fp6`, `Fp12`, `Fr` - -Right now we only implement BLS12-381 (compatible with ETH and others), -but in theory defining BLS12-377, BLS24 should be straightforward. An example: - -```ts -import { bls12_381 as bls } from '@noble/curves/bls12-381'; -const privateKey = '67d53f170b908cabb9eb326c3c337762d59289a8fec79f7bc9254b584b73265c'; -const message = '64726e3da8'; -const publicKey = bls.getPublicKey(privateKey); -const signature = bls.sign(message, privateKey); -const isValid = bls.verify(signature, message, publicKey); -console.log({ publicKey, signature, isValid }); - -// Sign 1 msg with 3 keys -const privateKeys = [ - '18f020b98eb798752a50ed0563b079c125b0db5dd0b1060d1c1b47d4a193e1e4', - 'ed69a8c50cf8c9836be3b67c7eeff416612d45ba39a5c099d48fa668bf558c9c', - '16ae669f3be7a2121e17d0c68c05a8f3d6bef21ec0f2315f1d7aec12484e4cf5', -]; -const messages = ['d2', '0d98', '05caf3']; -const publicKeys = privateKeys.map(bls.getPublicKey); -const signatures2 = privateKeys.map((p) => bls.sign(message, p)); -const aggPubKey2 = bls.aggregatePublicKeys(publicKeys); -const aggSignature2 = bls.aggregateSignatures(signatures2); -const isValid2 = bls.verify(aggSignature2, message, aggPubKey2); -console.log({ signatures2, aggSignature2, isValid2 }); - -// Sign 3 msgs with 3 keys -const signatures3 = privateKeys.map((p, i) => bls.sign(messages[i], p)); -const aggSignature3 = bls.aggregateSignatures(signatures3); -const isValid3 = bls.verifyBatch(aggSignature3, messages, publicKeys); -console.log({ publicKeys, signatures3, aggSignature3, isValid3 }); - -// bls.pairing(PointG1, PointG2) // pairings -// bls.G1.ProjectivePoint.BASE, bls.G2.ProjectivePoint.BASE -// bls.fields.Fp, bls.fields.Fp2, bls.fields.Fp12, bls.fields.Fr - -// hash-to-curve examples can be seen below -``` - -Full types: - -```ts -getPublicKey: (privateKey: PrivKey) => Uint8Array; -sign: { - (message: Hex, privateKey: PrivKey): Uint8Array; - (message: ProjPointType, privateKey: PrivKey): ProjPointType; -}; -verify: ( - signature: Hex | ProjPointType, - message: Hex | ProjPointType, - publicKey: Hex | ProjPointType -) => boolean; -verifyBatch: ( - signature: Hex | ProjPointType, - messages: (Hex | ProjPointType)[], - publicKeys: (Hex | ProjPointType)[] -) => boolean; -aggregatePublicKeys: { - (publicKeys: Hex[]): Uint8Array; - (publicKeys: ProjPointType[]): ProjPointType; -}; -aggregateSignatures: { - (signatures: Hex[]): Uint8Array; - (signatures: ProjPointType[]): ProjPointType; -}; -millerLoop: (ell: [Fp2, Fp2, Fp2][], g1: [Fp, Fp]) => Fp12; -pairing: (P: ProjPointType, Q: ProjPointType, withFinalExponent?: boolean) => Fp12; -G1: CurvePointsRes & ReturnType>; -G2: CurvePointsRes & ReturnType>; -Signature: SignatureCoder; -params: { - x: bigint; - r: bigint; - G1b: bigint; - G2b: Fp2; -}; -fields: { - Fp: IField; - Fp2: IField; - Fp6: IField; - Fp12: IField; - Fr: IField; -}; -utils: { - randomPrivateKey: () => Uint8Array; - calcPairingPrecomputes: (p: AffinePoint) => [Fp2, Fp2, Fp2][]; -}; -``` - -### abstract/hash-to-curve: Hashing strings to curve points - -The module allows to hash arbitrary strings to elliptic curve points. Implements [hash-to-curve v16](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16). - -Every curve has exported `hashToCurve` and `encodeToCurve` methods. You should always prefer `hashToCurve` for security: - -```ts -import { hashToCurve, encodeToCurve } from '@noble/curves/secp256k1'; -import { randomBytes } from '@noble/hashes/utils'; -hashToCurve('0102abcd'); -console.log(hashToCurve(randomBytes())); -console.log(encodeToCurve(randomBytes())); - -import { bls12_381 } from '@noble/curves/bls12-381'; -bls12_381.G1.hashToCurve(randomBytes(), { DST: 'another' }); -bls12_381.G2.hashToCurve(randomBytes(), { DST: 'custom' }); -``` - -If you need low-level methods from spec: - -`expand_message_xmd` [(spec)](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1) produces a uniformly random byte string using a cryptographic hash function H that outputs b bits. - -Hash must conform to `CHash` interface (see [weierstrass section](#abstractweierstrass-short-weierstrass-curve)). - -```ts -function expand_message_xmd( - msg: Uint8Array, - DST: Uint8Array, - lenInBytes: number, - H: CHash -): Uint8Array; -function expand_message_xof( - msg: Uint8Array, - DST: Uint8Array, - lenInBytes: number, - k: number, - H: CHash -): Uint8Array; -``` - -`hash_to_field(msg, count, options)` -[(spec)](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3) -hashes arbitrary-length byte strings to a list of one or more elements of a finite field F. - -```ts -/** - * * `DST` is a domain separation tag, defined in section 2.2.5 - * * `p` characteristic of F, where F is a finite field of characteristic p and order q = p^m - * * `m` is extension degree (1 for prime fields) - * * `k` is the target security target in bits (e.g. 128), from section 5.1 - * * `expand` is `xmd` (SHA2, SHA3, BLAKE) or `xof` (SHAKE, BLAKE-XOF) - * * `hash` conforming to `utils.CHash` interface, with `outputLen` / `blockLen` props - */ -type UnicodeOrBytes = string | Uint8Array; -type Opts = { - DST: UnicodeOrBytes; - p: bigint; - m: number; - k: number; - expand?: 'xmd' | 'xof'; - hash: CHash; -}; - -/** - * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3 - * @param msg a byte string containing the message to hash - * @param count the number of elements of F to output - * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above - * @returns [u_0, ..., u_(count - 1)], a list of field elements. - */ -function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][]; -``` - -### abstract/poseidon: Poseidon hash - -Implements [Poseidon](https://www.poseidon-hash.info) ZK-friendly hash. - -There are many poseidon variants with different constants. -We don't provide them: you should construct them manually. -Check out [micro-starknet](https://github.com/paulmillr/micro-starknet) package for a proper example. - -```ts -import { poseidon } from '@noble/curves/abstract/poseidon'; - -type PoseidonOpts = { - Fp: Field; - t: number; - roundsFull: number; - roundsPartial: number; - sboxPower?: number; - reversePartialPowIdx?: boolean; - mds: bigint[][]; - roundConstants: bigint[][]; -}; -const instance = poseidon(opts: PoseidonOpts); -``` - -### abstract/modular: Modular arithmetics utilities - -```ts -import * as mod from '@noble/curves/abstract/modular'; -const fp = mod.Field(2n ** 255n - 19n); // Finite field over 2^255-19 -fp.mul(591n, 932n); // multiplication -fp.pow(481n, 11024858120n); // exponentiation -fp.div(5n, 17n); // division: 5/17 mod 2^255-19 == 5 * invert(17) -fp.sqrt(21n); // square root - -// Generic non-FP utils are also available -mod.mod(21n, 10n); // 21 mod 10 == 1n; fixed version of 21 % 10 -mod.invert(17n, 10n); // invert(17) mod 10; modular multiplicative inverse -mod.invertBatch([1n, 2n, 4n], 21n); // => [1n, 11n, 16n] in one inversion -``` - -#### Creating private keys from hashes - -Suppose you have `sha256(something)` (e.g. from HMAC) and you want to make a private key from it. -Even though p256 or secp256k1 may have 32-byte private keys, -and sha256 output is also 32-byte, you can't just use it and reduce it modulo `CURVE.n`. - -Doing so will make the result key [biased](https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/). - -To avoid the bias, we implement FIPS 186 B.4.1, which allows to take arbitrary -byte array and produce valid scalars / private keys with bias being neglible. - -Use [hash-to-curve](#abstracthash-to-curve-hashing-strings-to-curve-points) if you need -hashing to **public keys**; the function in the module instead operates on **private keys**. - -```ts -import { p256 } from '@noble/curves/p256'; -import { sha256 } from '@noble/hashes/sha256'; -import { hkdf } from '@noble/hashes/hkdf'; -const someKey = new Uint8Array(32).fill(2); // Needs to actually be random, not .fill(2) -const derived = hkdf(sha256, someKey, undefined, 'application', 40); // 40 bytes -const validPrivateKey = mod.hashToPrivateScalar(derived, p256.CURVE.n); -``` - -### abstract/utils: General utilities - -```ts -import * as utils from '@noble/curves/abstract/utils'; - -utils.bytesToHex(Uint8Array.from([0xde, 0xad, 0xbe, 0xef])); -utils.hexToBytes('deadbeef'); -utils.numberToHexUnpadded(123n); -utils.hexToNumber(); - -utils.bytesToNumberBE(Uint8Array.from([0xde, 0xad, 0xbe, 0xef])); -utils.bytesToNumberLE(Uint8Array.from([0xde, 0xad, 0xbe, 0xef])); -utils.numberToBytesBE(123n, 32); -utils.numberToBytesLE(123n, 64); - -utils.concatBytes(Uint8Array.from([0xde, 0xad]), Uint8Array.from([0xbe, 0xef])); -utils.nLength(255n); -utils.equalBytes(Uint8Array.from([0xde]), Uint8Array.from([0xde])); -``` - -## Security - -1. The library has been audited in Feb 2023 by an independent security firm [Trail of Bits](https://www.trailofbits.com): -[PDF](https://github.com/trailofbits/publications/blob/master/reviews/2023-01-ryanshea-noblecurveslibrary-securityreview.pdf). -The audit has been funded by [Ryan Shea](https://www.shea.io). Audit scope was abstract modules `curve`, `hash-to-curve`, `modular`, `poseidon`, `utils`, `weierstrass`, and top-level modules `_shortw_utils` and `secp256k1`. See [changes since audit](https://github.com/paulmillr/noble-curves/compare/0.7.3..main). -2. The library has been fuzzed by [Guido Vranken's cryptofuzz](https://github.com/guidovranken/cryptofuzz). You can run the fuzzer by yourself to check it. -3. [Timing attack](https://en.wikipedia.org/wiki/Timing_attack) considerations: _JIT-compiler_ and _Garbage Collector_ make "constant time" extremely hard to achieve in a scripting language. Which means _any other JS library can't have constant-timeness_. Even statically typed Rust, a language without GC, [makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security) for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones. Use low-level libraries & languages. Nonetheless we're targetting algorithmic constant time. - -We consider infrastructure attacks like rogue NPM modules very important; that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings. If your app uses 500 dependencies, any dep could get hacked and you'll be downloading malware with every `npm install`. Our goal is to minimize this attack vector. As for devDependencies used by the library: - -- `@scure` base, bip32, bip39 (used in tests), micro-bmark (benchmark), micro-should (testing) are developed by us - and follow the same practices such as: minimal library size, auditability, signed releases -- prettier (linter), fast-check (property-based testing), - typescript versions are locked and rarely updated. Every update is checked with `npm-diff`. - The packages are big, which makes it hard to audit their source code thoroughly and fully. -- They are only used if you clone the git repo and want to add some feature to it. End-users won't use them. - -As for key generation, we're deferring to built-in -[crypto.getRandomValues](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) -which is considered cryptographically secure (CSPRNG). - -## Speed - -Benchmark results on Apple M2 with node v20: - -``` -secp256k1 -init x 68 ops/sec @ 14ms/op -getPublicKey x 6,750 ops/sec @ 148μs/op -sign x 5,206 ops/sec @ 192μs/op -verify x 880 ops/sec @ 1ms/op -getSharedSecret x 536 ops/sec @ 1ms/op -recoverPublicKey x 852 ops/sec @ 1ms/op -schnorr.sign x 685 ops/sec @ 1ms/op -schnorr.verify x 908 ops/sec @ 1ms/op - -p256 -init x 38 ops/sec @ 26ms/op -getPublicKey x 6,530 ops/sec @ 153μs/op -sign x 5,074 ops/sec @ 197μs/op -verify x 626 ops/sec @ 1ms/op - -p384 -init x 17 ops/sec @ 57ms/op -getPublicKey x 2,883 ops/sec @ 346μs/op -sign x 2,358 ops/sec @ 424μs/op -verify x 245 ops/sec @ 4ms/op - -p521 -init x 9 ops/sec @ 109ms/op -getPublicKey x 1,516 ops/sec @ 659μs/op -sign x 1,271 ops/sec @ 786μs/op -verify x 123 ops/sec @ 8ms/op - -ed25519 -init x 54 ops/sec @ 18ms/op -getPublicKey x 10,269 ops/sec @ 97μs/op -sign x 5,110 ops/sec @ 195μs/op -verify x 1,049 ops/sec @ 952μs/op - -ed448 -init x 19 ops/sec @ 51ms/op -getPublicKey x 3,775 ops/sec @ 264μs/op -sign x 1,771 ops/sec @ 564μs/op -verify x 351 ops/sec @ 2ms/op - -ecdh -├─x25519 x 1,466 ops/sec @ 682μs/op -├─secp256k1 x 539 ops/sec @ 1ms/op -├─p256 x 511 ops/sec @ 1ms/op -├─p384 x 199 ops/sec @ 5ms/op -├─p521 x 103 ops/sec @ 9ms/op -└─x448 x 548 ops/sec @ 1ms/op - -bls12-381 -init x 36 ops/sec @ 27ms/op -getPublicKey 1-bit x 973 ops/sec @ 1ms/op -getPublicKey x 970 ops/sec @ 1ms/op -sign x 55 ops/sec @ 17ms/op -verify x 39 ops/sec @ 25ms/op -pairing x 106 ops/sec @ 9ms/op -aggregatePublicKeys/8 x 129 ops/sec @ 7ms/op -aggregatePublicKeys/32 x 34 ops/sec @ 28ms/op -aggregatePublicKeys/128 x 8 ops/sec @ 112ms/op -aggregatePublicKeys/512 x 2 ops/sec @ 446ms/op -aggregatePublicKeys/2048 x 0 ops/sec @ 1778ms/op -aggregateSignatures/8 x 50 ops/sec @ 19ms/op -aggregateSignatures/32 x 13 ops/sec @ 74ms/op -aggregateSignatures/128 x 3 ops/sec @ 296ms/op -aggregateSignatures/512 x 0 ops/sec @ 1180ms/op -aggregateSignatures/2048 x 0 ops/sec @ 4715ms/op - -hash-to-curve -hash_to_field x 91,600 ops/sec @ 10μs/op -secp256k1 x 2,373 ops/sec @ 421μs/op -p256 x 4,310 ops/sec @ 231μs/op -p384 x 1,664 ops/sec @ 600μs/op -p521 x 807 ops/sec @ 1ms/op -ed25519 x 3,088 ops/sec @ 323μs/op -ed448 x 1,247 ops/sec @ 801μs/op -``` - -## Contributing & testing - -1. Clone the repository -2. `npm install` to install build dependencies like TypeScript -3. `npm run build` to compile TypeScript code -4. `npm run test` will execute all main tests - -## Upgrading - -Previously, the library was split into single-feature packages -noble-secp256k1, noble-ed25519 and noble-bls12-381. - -Curves continue their original work. The single-feature packages changed their -direction towards providing minimal 4kb implementations of cryptography, -which means they have less features. - -Upgrading from @noble/secp256k1 2.0 or @noble/ed25519 2.0: no changes, libraries are compatible. - -Upgrading from [@noble/secp256k1](https://github.com/paulmillr/noble-secp256k1) 1.7: - -- `getPublicKey` - - now produce 33-byte compressed signatures by default - - to use old behavior, which produced 65-byte uncompressed keys, set - argument `isCompressed` to `false`: `getPublicKey(priv, false)` -- `sign` - - is now sync; use `signAsync` for async version - - now returns `Signature` instance with `{ r, s, recovery }` properties - - `canonical` option was renamed to `lowS` - - `recovered` option has been removed because recovery bit is always returned now - - `der` option has been removed. There are 2 options: - 1. Use compact encoding: `fromCompact`, `toCompactRawBytes`, `toCompactHex`. - Compact encoding is simply a concatenation of 32-byte r and 32-byte s. - 2. If you must use DER encoding, switch to noble-curves (see above). -- `verify` - - `strict` option was renamed to `lowS` -- `getSharedSecret` - - now produce 33-byte compressed signatures by default - - to use old behavior, which produced 65-byte uncompressed keys, set - argument `isCompressed` to `false`: `getSharedSecret(a, b, false)` -- `recoverPublicKey(msg, sig, rec)` was changed to `sig.recoverPublicKey(msg)` -- `number` type for private keys have been removed: use `bigint` instead -- `Point` (2d xy) has been changed to `ProjectivePoint` (3d xyz) -- `utils` were split into `utils` (same api as in noble-curves) and - `etc` (`hmacSha256Sync` and others) - -Upgrading from [@noble/ed25519](https://github.com/paulmillr/noble-ed25519) 1.7: - -- Methods are now sync by default -- `bigint` is no longer allowed in `getPublicKey`, `sign`, `verify`. Reason: ed25519 is LE, can lead to bugs -- `Point` (2d xy) has been changed to `ExtendedPoint` (xyzt) -- `Signature` was removed: just use raw bytes or hex now -- `utils` were split into `utils` (same api as in noble-curves) and - `etc` (`sha512Sync` and others) -- `getSharedSecret` was moved to `x25519` module -- `toX25519` has been moved to `edwardsToMontgomeryPub` and `edwardsToMontgomeryPriv` methods - -Upgrading from [@noble/bls12-381](https://github.com/paulmillr/noble-bls12-381): - -- Methods and classes were renamed: - - PointG1 -> G1.Point, PointG2 -> G2.Point - - PointG2.fromSignature -> Signature.decode, PointG2.toSignature -> Signature.encode -- Fp2 ORDER was corrected - -## Resources - -Useful documentation and articles about the library or its primitives: - -- [Learning fast elliptic-curve cryptography](https://paulmillr.com/posts/noble-secp256k1-fast-ecc/) -- [Taming the many EdDSAs](https://csrc.nist.gov/csrc/media/Presentations/2023/crclub-2023-03-08/images-media/20230308-crypto-club-slides--taming-the-many-EdDSAs.pdf) - that describes concepts of Strong UnForgeability under Chosen Message Attacks and Strongly Binding Signatures -- Pairings and BLS - - [BLS signatures for busy people](https://gist.github.com/paulmillr/18b802ad219b1aee34d773d08ec26ca2) - - [BLS12-381 for the rest of us](https://hackmd.io/@benjaminion/bls12-381) - - [Key concepts of pairings](https://medium.com/@alonmuroch_65570/bls-signatures-part-2-key-concepts-of-pairings-27a8a9533d0c) - - Pairing over bls12-381: - [part 1](https://research.nccgroup.com/2020/07/06/pairing-over-bls12-381-part-1-fields/), - [part 2](https://research.nccgroup.com/2020/07/13/pairing-over-bls12-381-part-2-curves/), - [part 3](https://research.nccgroup.com/2020/08/13/pairing-over-bls12-381-part-3-pairing/) - - [Estimating the bit security of pairing-friendly curves](https://research.nccgroup.com/2022/02/03/estimating-the-bit-security-of-pairing-friendly-curves/) - -Online demos: - -- [Elliptic Curve Calculator](https://paulmillr.com/noble): add / multiply points, sign messages -- [BLS threshold signatures](https://genthresh.com) - -Projects using noble-curves: - -- [scure-bip32](https://github.com/paulmillr/scure-bip32) and separate [bip32](https://github.com/bitcoinjs/bip32) HDkey libraries -- Ethereum libraries: - - [ethereum-cryptography](https://github.com/ethereum/js-ethereum-cryptography) - - [@ethereumjs](https://github.com/ethereumjs/ethereumjs-monorepo) - - [micro-eth-signer](https://github.com/paulmillr/micro-eth-signer) - - [ethers](https://github.com/ethers-io/ethers.js) (old noble-secp256k1 for now) - - [viem.sh](https://viem.sh) - - [metamask's eth-sig-util](https://github.com/MetaMask/eth-sig-util) - - [gridplus lattice sdk](https://github.com/GridPlus/lattice-eth2-utils) -- Bitcoin libraries: [scure-btc-signer](https://github.com/paulmillr/scure-btc-signer) -- Solana libraries: [micro-sol-signer](https://github.com/paulmillr/micro-sol-signer), [solana-web3.js](https://github.com/solana-labs/solana-web3.js) -- [polkadot.js](https://github.com/polkadot-js/common), [micro-starknet](https://github.com/paulmillr/micro-starknet) -- [protonmail](https://github.com/ProtonMail/WebClients) (old noble-ed25519 for now) -- [did-jwt](https://github.com/decentralized-identity/did-jwt), [hpke-js](https://github.com/dajiaji/hpke-js), [nostr-tools](https://github.com/nbd-wtf/nostr-tools) -- [ed25519-keygen](https://github.com/paulmillr/ed25519-keygen) SSH, PGP, TOR key generation -- [secp256k1 compatibility layer](https://github.com/ethereum/js-ethereum-cryptography/blob/2.0.0/src/secp256k1-compat.ts) -for users who want to switch from secp256k1-node or tiny-secp256k1. Allows to see which methods map to corresponding noble code. -- [BLS BBS signatures](https://github.com/Wind4Greg/BBS-Draft-Checks) following [draft-irtf-cfrg-bbs-signatures-latest](https://identity.foundation/bbs-signature/draft-irtf-cfrg-bbs-signatures.html) -- [KZG trusted setup ceremony](https://github.com/dsrvlabs/czg-keremony) - -## License - -The MIT License (MIT) - -Copyright (c) 2022 Paul Miller [(https://paulmillr.com)](https://paulmillr.com) - -See LICENSE file. diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts deleted file mode 100644 index 3eb43a81..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { randomBytes } from '@noble/hashes/utils'; -import { CurveType } from './abstract/weierstrass.js'; -import { CHash } from './abstract/utils.js'; -export declare function getHash(hash: CHash): { - hash: CHash; - hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => Uint8Array; - randomBytes: typeof randomBytes; -}; -type CurveDef = Readonly>; -export declare function createCurve(curveDef: CurveDef, defHash: CHash): Readonly<{ - create: (hash: CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export {}; -//# sourceMappingURL=_shortw_utils.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts.map deleted file mode 100644 index 974f8daf..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"_shortw_utils.d.ts","sourceRoot":"","sources":["src/_shortw_utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAe,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK;;gBAGnB,UAAU,WAAW,UAAU,EAAE;;EAGhD;AAED,KAAK,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;AAC3E,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK;mBACtC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE5B"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js b/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js deleted file mode 100644 index 555de44e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createCurve = exports.getHash = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const hmac_1 = require("@noble/hashes/hmac"); -const utils_1 = require("@noble/hashes/utils"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -// connects noble-curves to noble-hashes -function getHash(hash) { - return { - hash, - hmac: (key, ...msgs) => (0, hmac_1.hmac)(hash, key, (0, utils_1.concatBytes)(...msgs)), - randomBytes: utils_1.randomBytes, - }; -} -exports.getHash = getHash; -function createCurve(curveDef, defHash) { - const create = (hash) => (0, weierstrass_js_1.weierstrass)({ ...curveDef, ...getHash(hash) }); - return Object.freeze({ ...create(defHash), create }); -} -exports.createCurve = createCurve; -//# sourceMappingURL=_shortw_utils.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js.map deleted file mode 100644 index 318dfda2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/_shortw_utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"_shortw_utils.js","sourceRoot":"","sources":["src/_shortw_utils.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,6CAA0C;AAC1C,+CAA+D;AAC/D,8DAAmE;AAGnE,wCAAwC;AACxC,SAAgB,OAAO,CAAC,IAAW;IACjC,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,CAAC,GAAe,EAAE,GAAG,IAAkB,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,GAAG,EAAE,IAAA,mBAAW,EAAC,GAAG,IAAI,CAAC,CAAC;QACvF,WAAW,EAAX,mBAAW;KACZ,CAAC;AACJ,CAAC;AAND,0BAMC;AAGD,SAAgB,WAAW,CAAC,QAAkB,EAAE,OAAc;IAC5D,MAAM,MAAM,GAAG,CAAC,IAAW,EAAE,EAAE,CAAC,IAAA,4BAAW,EAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC;AAHD,kCAGC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts deleted file mode 100644 index f6f14ac2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -/** - * BLS (Barreto-Lynn-Scott) family of pairing-friendly curves. - * Implements BLS (Boneh-Lynn-Shacham) signatures. - * Consists of two curves: G1 and G2: - * - G1 is a subgroup of (x, y) E(Fq) over y² = x³ + 4. - * - G2 is a subgroup of ((x₁, x₂+i), (y₁, y₂+i)) E(Fq²) over y² = x³ + 4(1 + i) where i is √-1 - * - Gt, created by bilinear (ate) pairing e(G1, G2), consists of p-th roots of unity in - * Fq^k where k is embedding degree. Only degree 12 is currently supported, 24 is not. - * Pairing is used to aggregate and verify signatures. - * We are using Fp for private keys (shorter) and Fp₂ for signatures (longer). - * Some projects may prefer to swap this relation, it is not supported for now. - */ -import { AffinePoint } from './curve.js'; -import { IField } from './modular.js'; -import { Hex, PrivKey, CHash } from './utils.js'; -import * as htf from './hash-to-curve.js'; -import { CurvePointsType, ProjPointType as ProjPointType, CurvePointsRes } from './weierstrass.js'; -type Fp = bigint; -export type SignatureCoder = { - fromHex(hex: Hex): ProjPointType; - toRawBytes(point: ProjPointType): Uint8Array; - toHex(point: ProjPointType): string; -}; -export type CurveType = { - G1: Omit, 'n'> & { - mapToCurve: htf.MapToCurve; - htfDefaults: htf.Opts; - }; - G2: Omit, 'n'> & { - Signature: SignatureCoder; - mapToCurve: htf.MapToCurve; - htfDefaults: htf.Opts; - }; - fields: { - Fp: IField; - Fr: IField; - Fp2: IField & { - reim: (num: Fp2) => { - re: bigint; - im: bigint; - }; - multiplyByB: (num: Fp2) => Fp2; - frobeniusMap(num: Fp2, power: number): Fp2; - }; - Fp6: IField; - Fp12: IField & { - frobeniusMap(num: Fp12, power: number): Fp12; - multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12; - conjugate(num: Fp12): Fp12; - finalExponentiate(num: Fp12): Fp12; - }; - }; - params: { - x: bigint; - r: bigint; - }; - htfDefaults: htf.Opts; - hash: CHash; - randomBytes: (bytesLength?: number) => Uint8Array; -}; -export type CurveFn = { - getPublicKey: (privateKey: PrivKey) => Uint8Array; - sign: { - (message: Hex, privateKey: PrivKey): Uint8Array; - (message: ProjPointType, privateKey: PrivKey): ProjPointType; - }; - verify: (signature: Hex | ProjPointType, message: Hex | ProjPointType, publicKey: Hex | ProjPointType) => boolean; - verifyBatch: (signature: Hex | ProjPointType, messages: (Hex | ProjPointType)[], publicKeys: (Hex | ProjPointType)[]) => boolean; - aggregatePublicKeys: { - (publicKeys: Hex[]): Uint8Array; - (publicKeys: ProjPointType[]): ProjPointType; - }; - aggregateSignatures: { - (signatures: Hex[]): Uint8Array; - (signatures: ProjPointType[]): ProjPointType; - }; - millerLoop: (ell: [Fp2, Fp2, Fp2][], g1: [Fp, Fp]) => Fp12; - pairing: (P: ProjPointType, Q: ProjPointType, withFinalExponent?: boolean) => Fp12; - G1: CurvePointsRes & ReturnType>; - G2: CurvePointsRes & ReturnType>; - Signature: SignatureCoder; - params: { - x: bigint; - r: bigint; - G1b: bigint; - G2b: Fp2; - }; - fields: { - Fp: IField; - Fp2: IField; - Fp6: IField; - Fp12: IField; - Fr: IField; - }; - utils: { - randomPrivateKey: () => Uint8Array; - calcPairingPrecomputes: (p: AffinePoint) => [Fp2, Fp2, Fp2][]; - }; -}; -export declare function bls(CURVE: CurveType): CurveFn; -export {}; -//# sourceMappingURL=bls.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts.map deleted file mode 100644 index 75b6d262..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls.d.ts","sourceRoot":"","sources":["../src/abstract/bls.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAA+B,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,aAAa,IAAI,aAAa,EAC9B,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAE1B,KAAK,EAAE,GAAG,MAAM,CAAC;AAKjB,MAAM,MAAM,cAAc,CAAC,GAAG,IAAI;IAChC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;IAClD,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,IAAI;IAC1C,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG;QACnC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC/B,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC;KACvB,CAAC;IACF,EAAE,EAAE,IAAI,CAAC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IAAI,EAChC,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GACnC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAqR7B"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js deleted file mode 100644 index 1c0e9561..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js +++ /dev/null @@ -1,239 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.bls = void 0; -const modular_js_1 = require("./modular.js"); -const utils_js_1 = require("./utils.js"); -const htf = require("./hash-to-curve.js"); -const weierstrass_js_1 = require("./weierstrass.js"); -// prettier-ignore -const _2n = BigInt(2), _3n = BigInt(3); -function bls(CURVE) { - // Fields are specific for curve, so for now we'll need to pass them with opts - const { Fp, Fr, Fp2, Fp6, Fp12 } = CURVE.fields; - const BLS_X_LEN = (0, utils_js_1.bitLen)(CURVE.params.x); - const groupLen = 32; // TODO: calculate; hardcoded for now - // Pre-compute coefficients for sparse multiplication - // Point addition and point double calculations is reused for coefficients - function calcPairingPrecomputes(p) { - const { x, y } = p; - // prettier-ignore - const Qx = x, Qy = y, Qz = Fp2.ONE; - // prettier-ignore - let Rx = Qx, Ry = Qy, Rz = Qz; - let ell_coeff = []; - for (let i = BLS_X_LEN - 2; i >= 0; i--) { - // Double - let t0 = Fp2.sqr(Ry); // Ry² - let t1 = Fp2.sqr(Rz); // Rz² - let t2 = Fp2.multiplyByB(Fp2.mul(t1, _3n)); // 3 * T1 * B - let t3 = Fp2.mul(t2, _3n); // 3 * T2 - let t4 = Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(Ry, Rz)), t1), t0); // (Ry + Rz)² - T1 - T0 - ell_coeff.push([ - Fp2.sub(t2, t0), - Fp2.mul(Fp2.sqr(Rx), _3n), - Fp2.neg(t4), // -T4 - ]); - Rx = Fp2.div(Fp2.mul(Fp2.mul(Fp2.sub(t0, t3), Rx), Ry), _2n); // ((T0 - T3) * Rx * Ry) / 2 - Ry = Fp2.sub(Fp2.sqr(Fp2.div(Fp2.add(t0, t3), _2n)), Fp2.mul(Fp2.sqr(t2), _3n)); // ((T0 + T3) / 2)² - 3 * T2² - Rz = Fp2.mul(t0, t4); // T0 * T4 - if ((0, utils_js_1.bitGet)(CURVE.params.x, i)) { - // Addition - let t0 = Fp2.sub(Ry, Fp2.mul(Qy, Rz)); // Ry - Qy * Rz - let t1 = Fp2.sub(Rx, Fp2.mul(Qx, Rz)); // Rx - Qx * Rz - ell_coeff.push([ - Fp2.sub(Fp2.mul(t0, Qx), Fp2.mul(t1, Qy)), - Fp2.neg(t0), - t1, // T1 - ]); - let t2 = Fp2.sqr(t1); // T1² - let t3 = Fp2.mul(t2, t1); // T2 * T1 - let t4 = Fp2.mul(t2, Rx); // T2 * Rx - let t5 = Fp2.add(Fp2.sub(t3, Fp2.mul(t4, _2n)), Fp2.mul(Fp2.sqr(t0), Rz)); // T3 - 2 * T4 + T0² * Rz - Rx = Fp2.mul(t1, t5); // T1 * T5 - Ry = Fp2.sub(Fp2.mul(Fp2.sub(t4, t5), t0), Fp2.mul(t3, Ry)); // (T4 - T5) * T0 - T3 * Ry - Rz = Fp2.mul(Rz, t3); // Rz * T3 - } - } - return ell_coeff; - } - function millerLoop(ell, g1) { - const { x } = CURVE.params; - const Px = g1[0]; - const Py = g1[1]; - let f12 = Fp12.ONE; - for (let j = 0, i = BLS_X_LEN - 2; i >= 0; i--, j++) { - const E = ell[j]; - f12 = Fp12.multiplyBy014(f12, E[0], Fp2.mul(E[1], Px), Fp2.mul(E[2], Py)); - if ((0, utils_js_1.bitGet)(x, i)) { - j += 1; - const F = ell[j]; - f12 = Fp12.multiplyBy014(f12, F[0], Fp2.mul(F[1], Px), Fp2.mul(F[2], Py)); - } - if (i !== 0) - f12 = Fp12.sqr(f12); - } - return Fp12.conjugate(f12); - } - const utils = { - randomPrivateKey: () => { - return Fr.toBytes((0, modular_js_1.hashToPrivateScalar)(CURVE.randomBytes(groupLen + 8), CURVE.params.r)); - }, - calcPairingPrecomputes, - }; - // Point on G1 curve: (x, y) - const G1_ = (0, weierstrass_js_1.weierstrassPoints)({ n: Fr.ORDER, ...CURVE.G1 }); - const G1 = Object.assign(G1_, htf.createHasher(G1_.ProjectivePoint, CURVE.G1.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G1.htfDefaults, - })); - function pairingPrecomputes(point) { - const p = point; - if (p._PPRECOMPUTES) - return p._PPRECOMPUTES; - p._PPRECOMPUTES = calcPairingPrecomputes(point.toAffine()); - return p._PPRECOMPUTES; - } - // TODO: export - // function clearPairingPrecomputes(point: G2) { - // const p = point as G2 & withPairingPrecomputes; - // p._PPRECOMPUTES = undefined; - // } - // Point on G2 curve (complex numbers): (x₁, x₂+i), (y₁, y₂+i) - const G2_ = (0, weierstrass_js_1.weierstrassPoints)({ n: Fr.ORDER, ...CURVE.G2 }); - const G2 = Object.assign(G2_, htf.createHasher(G2_.ProjectivePoint, CURVE.G2.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G2.htfDefaults, - })); - const { Signature } = CURVE.G2; - // Calculates bilinear pairing - function pairing(Q, P, withFinalExponent = true) { - if (Q.equals(G1.ProjectivePoint.ZERO) || P.equals(G2.ProjectivePoint.ZERO)) - throw new Error('pairing is not available for ZERO point'); - Q.assertValidity(); - P.assertValidity(); - // Performance: 9ms for millerLoop and ~14ms for exp. - const Qa = Q.toAffine(); - const looped = millerLoop(pairingPrecomputes(P), [Qa.x, Qa.y]); - return withFinalExponent ? Fp12.finalExponentiate(looped) : looped; - } - function normP1(point) { - return point instanceof G1.ProjectivePoint ? point : G1.ProjectivePoint.fromHex(point); - } - function normP2(point) { - return point instanceof G2.ProjectivePoint ? point : Signature.fromHex(point); - } - function normP2Hash(point, htfOpts) { - return point instanceof G2.ProjectivePoint - ? point - : G2.hashToCurve((0, utils_js_1.ensureBytes)('point', point), htfOpts); - } - // Multiplies generator by private key. - // P = pk x G - function getPublicKey(privateKey) { - return G1.ProjectivePoint.fromPrivateKey(privateKey).toRawBytes(true); - } - function sign(message, privateKey, htfOpts) { - const msgPoint = normP2Hash(message, htfOpts); - msgPoint.assertValidity(); - const sigPoint = msgPoint.multiply(G1.normPrivateKeyToScalar(privateKey)); - if (message instanceof G2.ProjectivePoint) - return sigPoint; - return Signature.toRawBytes(sigPoint); - } - // Checks if pairing of public key & hash is equal to pairing of generator & signature. - // e(P, H(m)) == e(G, S) - function verify(signature, message, publicKey, htfOpts) { - const P = normP1(publicKey); - const Hm = normP2Hash(message, htfOpts); - const G = G1.ProjectivePoint.BASE; - const S = normP2(signature); - // Instead of doing 2 exponentiations, we use property of billinear maps - // and do one exp after multiplying 2 points. - const ePHm = pairing(P.negate(), Hm, false); - const eGS = pairing(G, S, false); - const exp = Fp12.finalExponentiate(Fp12.mul(eGS, ePHm)); - return Fp12.eql(exp, Fp12.ONE); - } - function aggregatePublicKeys(publicKeys) { - if (!publicKeys.length) - throw new Error('Expected non-empty array'); - const agg = publicKeys.map(normP1).reduce((sum, p) => sum.add(p), G1.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (publicKeys[0] instanceof G1.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - // toRawBytes ensures point validity - return aggAffine.toRawBytes(true); - } - function aggregateSignatures(signatures) { - if (!signatures.length) - throw new Error('Expected non-empty array'); - const agg = signatures.map(normP2).reduce((sum, s) => sum.add(s), G2.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (signatures[0] instanceof G2.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - return Signature.toRawBytes(aggAffine); - } - // https://ethresear.ch/t/fast-verification-of-multiple-bls-signatures/5407 - // e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si)) - function verifyBatch(signature, messages, publicKeys, htfOpts) { - // @ts-ignore - // console.log('verifyBatch', bytesToHex(signature as any), messages, publicKeys.map(bytesToHex)); - if (!messages.length) - throw new Error('Expected non-empty messages array'); - if (publicKeys.length !== messages.length) - throw new Error('Pubkey count should equal msg count'); - const sig = normP2(signature); - const nMessages = messages.map((i) => normP2Hash(i, htfOpts)); - const nPublicKeys = publicKeys.map(normP1); - try { - const paired = []; - for (const message of new Set(nMessages)) { - const groupPublicKey = nMessages.reduce((groupPublicKey, subMessage, i) => subMessage === message ? groupPublicKey.add(nPublicKeys[i]) : groupPublicKey, G1.ProjectivePoint.ZERO); - // const msg = message instanceof PointG2 ? message : await PointG2.hashToCurve(message); - // Possible to batch pairing for same msg with different groupPublicKey here - paired.push(pairing(groupPublicKey, message, false)); - } - paired.push(pairing(G1.ProjectivePoint.BASE.negate(), sig, false)); - const product = paired.reduce((a, b) => Fp12.mul(a, b), Fp12.ONE); - const exp = Fp12.finalExponentiate(product); - return Fp12.eql(exp, Fp12.ONE); - } - catch { - return false; - } - } - G1.ProjectivePoint.BASE._setWindowSize(4); - return { - getPublicKey, - sign, - verify, - verifyBatch, - aggregatePublicKeys, - aggregateSignatures, - millerLoop, - pairing, - G1, - G2, - Signature, - fields: { - Fr, - Fp, - Fp2, - Fp6, - Fp12, - }, - params: { - x: CURVE.params.x, - r: CURVE.params.r, - G1b: CURVE.G1.b, - G2b: CURVE.G2.b, - }, - utils, - }; -} -exports.bls = bls; -//# sourceMappingURL=bls.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js.map deleted file mode 100644 index 1ce9b316..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/bls.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls.js","sourceRoot":"","sources":["../src/abstract/bls.ts"],"names":[],"mappings":";;;AAcA,6CAA2D;AAC3D,yCAA8E;AAC9E,0CAA0C;AAC1C,qDAK0B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D,KAAK;KACN,CAAC;AACJ,CAAC;AAvRD,kBAuRC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts deleted file mode 100644 index 9caf29cc..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { IField } from './modular.js'; -export type AffinePoint = { - x: T; - y: T; -} & { - z?: never; - t?: never; -}; -export interface Group> { - double(): T; - negate(): T; - add(other: T): T; - subtract(other: T): T; - equals(other: T): boolean; - multiply(scalar: bigint): T; -} -export type GroupConstructor = { - BASE: T; - ZERO: T; -}; -export type Mapper = (i: T[]) => T[]; -export declare function wNAF>(c: GroupConstructor, bits: number): { - constTimeNegate: (condition: boolean, item: T) => T; - unsafeLadder(elm: T, n: bigint): T; - /** - * Creates a wNAF precomputation window. Used for caching. - * Default window size is set by `utils.precompute()` and is equal to 8. - * Number of precomputed points depends on the curve size: - * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: - * - 𝑊 is the window size - * - 𝑛 is the bitlength of the curve order. - * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. - * @returns precomputed point tables flattened to a single array - */ - precomputeWindow(elm: T, W: number): Group[]; - /** - * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. - * @param W window size - * @param precomputes precomputed tables - * @param n scalar (we don't check here, but should be less than curve order) - * @returns real and fake (for const-time) points - */ - wNAF(W: number, precomputes: T[], n: bigint): { - p: T; - f: T; - }; - wNAFCached(P: T, precomputesMap: Map, n: bigint, transform: Mapper): { - p: T; - f: T; - }; -}; -export type BasicCurve = { - Fp: IField; - n: bigint; - nBitLength?: number; - nByteLength?: number; - h: bigint; - hEff?: bigint; - Gx: T; - Gy: T; - allowInfinityPoint?: boolean; -}; -export declare function validateBasic(curve: BasicCurve & T): Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; -} & BasicCurve & T & { - p: bigint; -}>; -//# sourceMappingURL=curve.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts.map deleted file mode 100644 index fc52e87b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../src/abstract/curve.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,MAAM,EAA0B,MAAM,cAAc,CAAC;AAK9D,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,CAAC,EAAE,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,CAAC;CACN,GAAG;IAAE,CAAC,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7B,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC;IACvC,MAAM,IAAI,CAAC,CAAC;IACZ,MAAM,IAAI,CAAC,CAAC;IACZ,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AACF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;AAaxC,wBAAgB,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM;iCACvC,OAAO,QAAQ,CAAC,KAAG,CAAC;sBAYpC,CAAC,KAAK,MAAM;IAW9B;;;;;;;;;OASG;0BACmB,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE;IAkB/C;;;;;;OAMG;YACK,MAAM,eAAe,CAAC,EAAE,KAAK,MAAM;WAAQ,CAAC;WAAK,CAAC;;kBAsD5C,CAAC,kBAAkB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,aAAa,OAAO,CAAC,CAAC,GAAG;QAAE,CAAC,EAAE,CAAC,CAAC;QAAC,CAAC,EAAE,CAAC,CAAA;KAAE;EAcjG;AAID,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,CAAC,CAAC;IACN,EAAE,EAAE,CAAC,CAAC;IACN,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC;;;;;GAqB7D"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js deleted file mode 100644 index 5a005bcd..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js +++ /dev/null @@ -1,161 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validateBasic = exports.wNAF = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Abelian group utilities -const modular_js_1 = require("./modular.js"); -const utils_js_1 = require("./utils.js"); -const _0n = BigInt(0); -const _1n = BigInt(1); -// Elliptic curve multiplication of Point by scalar. Fragile. -// Scalars should always be less than curve order: this should be checked inside of a curve itself. -// Creates precomputation tables for fast multiplication: -// - private scalar is split by fixed size windows of W bits -// - every window point is collected from window's table & added to accumulator -// - since windows are different, same point inside tables won't be accessed more than once per calc -// - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar) -// - +1 window is neccessary for wNAF -// - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication -// TODO: Research returning 2d JS array of windows, instead of a single window. This would allow -// windows to be in different memory locations -function wNAF(c, bits) { - const constTimeNegate = (condition, item) => { - const neg = item.negate(); - return condition ? neg : item; - }; - const opts = (W) => { - const windows = Math.ceil(bits / W) + 1; // +1, because - const windowSize = 2 ** (W - 1); // -1 because we skip zero - return { windows, windowSize }; - }; - return { - constTimeNegate, - // non-const time multiplication ladder - unsafeLadder(elm, n) { - let p = c.ZERO; - let d = elm; - while (n > _0n) { - if (n & _1n) - p = p.add(d); - d = d.double(); - n >>= _1n; - } - return p; - }, - /** - * Creates a wNAF precomputation window. Used for caching. - * Default window size is set by `utils.precompute()` and is equal to 8. - * Number of precomputed points depends on the curve size: - * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: - * - 𝑊 is the window size - * - 𝑛 is the bitlength of the curve order. - * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. - * @returns precomputed point tables flattened to a single array - */ - precomputeWindow(elm, W) { - const { windows, windowSize } = opts(W); - const points = []; - let p = elm; - let base = p; - for (let window = 0; window < windows; window++) { - base = p; - points.push(base); - // =1, because we skip zero - for (let i = 1; i < windowSize; i++) { - base = base.add(p); - points.push(base); - } - p = base.double(); - } - return points; - }, - /** - * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. - * @param W window size - * @param precomputes precomputed tables - * @param n scalar (we don't check here, but should be less than curve order) - * @returns real and fake (for const-time) points - */ - wNAF(W, precomputes, n) { - // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise - // But need to carefully remove other checks before wNAF. ORDER == bits here - const { windows, windowSize } = opts(W); - let p = c.ZERO; - let f = c.BASE; - const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc. - const maxNumber = 2 ** W; - const shiftBy = BigInt(W); - for (let window = 0; window < windows; window++) { - const offset = window * windowSize; - // Extract W bits. - let wbits = Number(n & mask); - // Shift number by W bits. - n >>= shiftBy; - // If the bits are bigger than max size, we'll split those. - // +224 => 256 - 32 - if (wbits > windowSize) { - wbits -= maxNumber; - n += _1n; - } - // This code was first written with assumption that 'f' and 'p' will never be infinity point: - // since each addition is multiplied by 2 ** W, it cannot cancel each other. However, - // there is negate now: it is possible that negated element from low value - // would be the same as high element, which will create carry into next window. - // It's not obvious how this can fail, but still worth investigating later. - // Check if we're onto Zero point. - // Add random point inside current window to f. - const offset1 = offset; - const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero - const cond1 = window % 2 !== 0; - const cond2 = wbits < 0; - if (wbits === 0) { - // The most important part for const-time getPublicKey - f = f.add(constTimeNegate(cond1, precomputes[offset1])); - } - else { - p = p.add(constTimeNegate(cond2, precomputes[offset2])); - } - } - // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ() - // Even if the variable is still unused, there are some checks which will - // throw an exception, so compiler needs to prove they won't happen, which is hard. - // At this point there is a way to F be infinity-point even if p is not, - // which makes it less const-time: around 1 bigint multiply. - return { p, f }; - }, - wNAFCached(P, precomputesMap, n, transform) { - // @ts-ignore - const W = P._WINDOW_SIZE || 1; - // Calculate precomputes on a first run, reuse them after - let comp = precomputesMap.get(P); - if (!comp) { - comp = this.precomputeWindow(P, W); - if (W !== 1) { - precomputesMap.set(P, transform(comp)); - } - } - return this.wNAF(W, comp, n); - }, - }; -} -exports.wNAF = wNAF; -function validateBasic(curve) { - (0, modular_js_1.validateField)(curve.Fp); - (0, utils_js_1.validateObject)(curve, { - n: 'bigint', - h: 'bigint', - Gx: 'field', - Gy: 'field', - }, { - nBitLength: 'isSafeInteger', - nByteLength: 'isSafeInteger', - }); - // Set defaults - return Object.freeze({ - ...(0, modular_js_1.nLength)(curve.n, curve.nBitLength), - ...curve, - ...{ p: curve.Fp.ORDER }, - }); -} -exports.validateBasic = validateBasic; -//# sourceMappingURL=curve.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js.map deleted file mode 100644 index dd6ca4b3..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/curve.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"curve.js","sourceRoot":"","sources":["../src/abstract/curve.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,0BAA0B;AAC1B,6CAA8D;AAC9D,yCAA4C;AAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAsBtB,6DAA6D;AAC7D,mGAAmG;AACnG,yDAAyD;AACzD,4DAA4D;AAC5D,+EAA+E;AAC/E,oGAAoG;AACpG,oGAAoG;AACpG,qCAAqC;AACrC,kGAAkG;AAClG,gGAAgG;AAChG,8CAA8C;AAC9C,SAAgB,IAAI,CAAqB,CAAsB,EAAE,IAAY;IAC3E,MAAM,eAAe,GAAG,CAAC,SAAkB,EAAE,IAAO,EAAK,EAAE;QACzD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,CAAC,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,CAA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AK,CAAC,EAAE,CAAC,CAAC;IACxB,IAAA,yBAAc,EACZ,KAAK,EACL;QACE,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,QAAQ;QACX,EAAE,EAAE,OAAO;QACX,EAAE,EAAE,OAAO;KACZ,EACD;QACE,UAAU,EAAE,eAAe;QAC3B,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IACF,eAAe;IACf,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,IAAA,oBAAO,EAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;QACrC,GAAG,KAAK;QACR,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;KAChB,CAAC,CAAC;AACd,CAAC;AArBD,sCAqBC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts deleted file mode 100644 index 9c43c661..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -import * as ut from './utils.js'; -import { FHash, Hex } from './utils.js'; -import { Group, GroupConstructor, BasicCurve, AffinePoint } from './curve.js'; -export type CurveType = BasicCurve & { - a: bigint; - d: bigint; - hash: FHash; - randomBytes: (bytesLength?: number) => Uint8Array; - adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array; - domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array; - uvRatio?: (u: bigint, v: bigint) => { - isValid: boolean; - value: bigint; - }; - prehash?: FHash; - mapToCurve?: (scalar: bigint[]) => AffinePoint; -}; -declare function validateOpts(curve: CurveType): Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly d: bigint; - readonly hash: ut.FHash; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - readonly adjustScalarBytes?: ((bytes: Uint8Array) => Uint8Array) | undefined; - readonly domain?: ((data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array) | undefined; - readonly uvRatio?: ((u: bigint, v: bigint) => { - isValid: boolean; - value: bigint; - }) | undefined; - readonly prehash?: ut.FHash | undefined; - readonly mapToCurve?: ((scalar: bigint[]) => AffinePoint) | undefined; - readonly p: bigint; -}>; -export interface ExtPointType extends Group { - readonly ex: bigint; - readonly ey: bigint; - readonly ez: bigint; - readonly et: bigint; - get x(): bigint; - get y(): bigint; - assertValidity(): void; - multiply(scalar: bigint): ExtPointType; - multiplyUnsafe(scalar: bigint): ExtPointType; - isSmallOrder(): boolean; - isTorsionFree(): boolean; - clearCofactor(): ExtPointType; - toAffine(iz?: bigint): AffinePoint; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; -} -export interface ExtPointConstructor extends GroupConstructor { - new (x: bigint, y: bigint, z: bigint, t: bigint): ExtPointType; - fromAffine(p: AffinePoint): ExtPointType; - fromHex(hex: Hex): ExtPointType; - fromPrivateKey(privateKey: Hex): ExtPointType; -} -export type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: Hex) => Uint8Array; - sign: (message: Hex, privateKey: Hex, options?: { - context?: Hex; - }) => Uint8Array; - verify: (sig: Hex, message: Hex, publicKey: Hex, options?: { - context?: Hex; - zip215: boolean; - }) => boolean; - ExtendedPoint: ExtPointConstructor; - utils: { - randomPrivateKey: () => Uint8Array; - getExtendedPublicKey: (key: Hex) => { - head: Uint8Array; - prefix: Uint8Array; - scalar: bigint; - point: ExtPointType; - pointBytes: Uint8Array; - }; - }; -}; -export declare function twistedEdwards(curveDef: CurveType): CurveFn; -export {}; -//# sourceMappingURL=edwards.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts.map deleted file mode 100644 index a32123f7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"edwards.d.ts","sourceRoot":"","sources":["../src/abstract/edwards.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAe,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAQ,UAAU,EAAiB,WAAW,EAAE,MAAM,YAAY,CAAC;AAOnG,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG;IAC3C,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;IAClD,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,UAAU,CAAC;IACtD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;IAC5E,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;CACxD,CAAC;AAKF,iBAAS,YAAY,CAAC,KAAK,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;GAmBrC;AAGD,MAAM,WAAW,YAAa,SAAQ,KAAK,CAA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AAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,KAAK,UAAU,CAAC;IACjF,MAAM,EAAE,CACN,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,GAAG,EACd,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KACzC,OAAO,CAAC;IACb,aAAa,EAAE,mBAAmB,CAAC;IACnC,KAAK,EAAE;QACL,gBAAgB,EAAE,MAAM,UAAU,CAAC;QACnC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK;YAClC,IAAI,EAAE,UAAU,CAAC;YACjB,MAAM,EAAE,UAAU,CAAC;YACnB,MAAM,EAAE,MAAM,CAAC;YACf,KAAK,EAAE,YAAY,CAAC;YACpB,UAAU,EAAE,UAAU,CAAC;SACxB,CAAC;KACH,CAAC;CACH,CAAC;AAGF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CA8Z3D"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js deleted file mode 100644 index 6dd4151a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js +++ /dev/null @@ -1,429 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.twistedEdwards = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y² -const modular_js_1 = require("./modular.js"); -const ut = require("./utils.js"); -const utils_js_1 = require("./utils.js"); -const curve_js_1 = require("./curve.js"); -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _8n = BigInt(8); -// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex: -const VERIFY_DEFAULT = { zip215: true }; -function validateOpts(curve) { - const opts = (0, curve_js_1.validateBasic)(curve); - ut.validateObject(curve, { - hash: 'function', - a: 'bigint', - d: 'bigint', - randomBytes: 'function', - }, { - adjustScalarBytes: 'function', - domain: 'function', - uvRatio: 'function', - mapToCurve: 'function', - }); - // Set defaults - return Object.freeze({ ...opts }); -} -// It is not generic twisted curve for now, but ed25519/ed448 generic implementation -function twistedEdwards(curveDef) { - const CURVE = validateOpts(curveDef); - const { Fp, n: CURVE_ORDER, prehash: prehash, hash: cHash, randomBytes, nByteLength, h: cofactor, } = CURVE; - const MASK = _2n << (BigInt(nByteLength * 8) - _1n); - const modP = Fp.create; // Function overrides - // sqrt(u/v) - const uvRatio = CURVE.uvRatio || - ((u, v) => { - try { - return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) }; - } - catch (e) { - return { isValid: false, value: _0n }; - } - }); - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); // NOOP - const domain = CURVE.domain || - ((data, ctx, phflag) => { - if (ctx.length || phflag) - throw new Error('Contexts/pre-hash are not supported'); - return data; - }); // NOOP - const inBig = (n) => typeof n === 'bigint' && _0n < n; // n in [1..] - const inRange = (n, max) => inBig(n) && inBig(max) && n < max; // n in [1..max-1] - const in0MaskRange = (n) => n === _0n || inRange(n, MASK); // n in [0..MASK-1] - function assertInRange(n, max) { - // n in [1..max-1] - if (inRange(n, max)) - return n; - throw new Error(`Expected valid scalar < ${max}, got ${typeof n} ${n}`); - } - function assertGE0(n) { - // n in [0..CURVE_ORDER-1] - return n === _0n ? n : assertInRange(n, CURVE_ORDER); // GE = prime subgroup, not full group - } - const pointPrecomputes = new Map(); - function isPoint(other) { - if (!(other instanceof Point)) - throw new Error('ExtendedPoint expected'); - } - // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy). - // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates - class Point { - constructor(ex, ey, ez, et) { - this.ex = ex; - this.ey = ey; - this.ez = ez; - this.et = et; - if (!in0MaskRange(ex)) - throw new Error('x required'); - if (!in0MaskRange(ey)) - throw new Error('y required'); - if (!in0MaskRange(ez)) - throw new Error('z required'); - if (!in0MaskRange(et)) - throw new Error('t required'); - } - get x() { - return this.toAffine().x; - } - get y() { - return this.toAffine().y; - } - static fromAffine(p) { - if (p instanceof Point) - throw new Error('extended point not allowed'); - const { x, y } = p || {}; - if (!in0MaskRange(x) || !in0MaskRange(y)) - throw new Error('invalid affine point'); - return new Point(x, y, _1n, modP(x * y)); - } - static normalizeZ(points) { - const toInv = Fp.invertBatch(points.map((p) => p.ez)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - // "Private method", don't use it directly - _setWindowSize(windowSize) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - // Not required for fromHex(), which always creates valid points. - // Could be useful for fromAffine(). - assertValidity() { - const { a, d } = CURVE; - if (this.is0()) - throw new Error('bad point: ZERO'); // TODO: optimize, with vars below? - // Equation in affine coordinates: ax² + y² = 1 + dx²y² - // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y² - const { ex: X, ey: Y, ez: Z, et: T } = this; - const X2 = modP(X * X); // X² - const Y2 = modP(Y * Y); // Y² - const Z2 = modP(Z * Z); // Z² - const Z4 = modP(Z2 * Z2); // Z⁴ - const aX2 = modP(X2 * a); // aX² - const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z² - const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y² - if (left !== right) - throw new Error('bad point: equation left != right (1)'); - // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T - const XY = modP(X * Y); - const ZT = modP(Z * T); - if (XY !== ZT) - throw new Error('bad point: equation left != right (2)'); - } - // Compare one point to another. - equals(other) { - isPoint(other); - const { ex: X1, ey: Y1, ez: Z1 } = this; - const { ex: X2, ey: Y2, ez: Z2 } = other; - const X1Z2 = modP(X1 * Z2); - const X2Z1 = modP(X2 * Z1); - const Y1Z2 = modP(Y1 * Z2); - const Y2Z1 = modP(Y2 * Z1); - return X1Z2 === X2Z1 && Y1Z2 === Y2Z1; - } - is0() { - return this.equals(Point.ZERO); - } - negate() { - // Flips point sign to a negative one (-x, y in affine coords) - return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et)); - } - // Fast algo for doubling Extended Point. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd - // Cost: 4M + 4S + 1*a + 6add + 1*2. - double() { - const { a } = CURVE; - const { ex: X1, ey: Y1, ez: Z1 } = this; - const A = modP(X1 * X1); // A = X12 - const B = modP(Y1 * Y1); // B = Y12 - const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12 - const D = modP(a * A); // D = a*A - const x1y1 = X1 + Y1; - const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B - const G = D + B; // G = D+B - const F = G - C; // F = G-C - const H = D - B; // H = D-B - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - return new Point(X3, Y3, Z3, T3); - } - // Fast algo for adding 2 Extended Points. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd - // Cost: 9M + 1*a + 1*d + 7add. - add(other) { - isPoint(other); - const { a, d } = CURVE; - const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this; - const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other; - // Faster algo for adding 2 Extended Points when curve's a=-1. - // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4 - // Cost: 8M + 8add + 2*2. - // Note: It does not check whether the `other` point is valid. - if (a === BigInt(-1)) { - const A = modP((Y1 - X1) * (Y2 + X2)); - const B = modP((Y1 + X1) * (Y2 - X2)); - const F = modP(B - A); - if (F === _0n) - return this.double(); // Same point. Tests say it doesn't affect timing - const C = modP(Z1 * _2n * T2); - const D = modP(T1 * _2n * Z2); - const E = D + C; - const G = B + A; - const H = D - C; - const X3 = modP(E * F); - const Y3 = modP(G * H); - const T3 = modP(E * H); - const Z3 = modP(F * G); - return new Point(X3, Y3, Z3, T3); - } - const A = modP(X1 * X2); // A = X1*X2 - const B = modP(Y1 * Y2); // B = Y1*Y2 - const C = modP(T1 * d * T2); // C = T1*d*T2 - const D = modP(Z1 * Z2); // D = Z1*Z2 - const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B - const F = D - C; // F = D-C - const G = D + C; // G = D+C - const H = modP(B - a * A); // H = B-a*A - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - return new Point(X3, Y3, Z3, T3); - } - subtract(other) { - return this.add(other.negate()); - } - wNAF(n) { - return wnaf.wNAFCached(this, pointPrecomputes, n, Point.normalizeZ); - } - // Constant-time multiplication. - multiply(scalar) { - const { p, f } = this.wNAF(assertInRange(scalar, CURVE_ORDER)); - return Point.normalizeZ([p, f])[0]; - } - // Non-constant-time multiplication. Uses double-and-add algorithm. - // It's faster, but should only be used when you don't care about - // an exposed private key e.g. sig verification. - // Does NOT allow scalars higher than CURVE.n. - multiplyUnsafe(scalar) { - let n = assertGE0(scalar); // 0 <= scalar < CURVE.n - if (n === _0n) - return I; - if (this.equals(I) || n === _1n) - return this; - if (this.equals(G)) - return this.wNAF(n).p; - return wnaf.unsafeLadder(this, n); - } - // Checks if point is of small order. - // If you add something to small order point, you will have "dirty" - // point with torsion component. - // Multiplies point by cofactor and checks if the result is 0. - isSmallOrder() { - return this.multiplyUnsafe(cofactor).is0(); - } - // Multiplies point by curve order and checks if the result is 0. - // Returns `false` is the point is dirty. - isTorsionFree() { - return wnaf.unsafeLadder(this, CURVE_ORDER).is0(); - } - // Converts Extended point to default (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - toAffine(iz) { - const { ex: x, ey: y, ez: z } = this; - const is0 = this.is0(); - if (iz == null) - iz = is0 ? _8n : Fp.inv(z); // 8 was chosen arbitrarily - const ax = modP(x * iz); - const ay = modP(y * iz); - const zz = modP(z * iz); - if (is0) - return { x: _0n, y: _1n }; - if (zz !== _1n) - throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - clearCofactor() { - const { h: cofactor } = CURVE; - if (cofactor === _1n) - return this; - return this.multiplyUnsafe(cofactor); - } - // Converts hash string or Uint8Array to Point. - // Uses algo from RFC8032 5.1.3. - static fromHex(hex, zip215 = false) { - const { d, a } = CURVE; - const len = Fp.BYTES; - hex = (0, utils_js_1.ensureBytes)('pointHex', hex, len); // copy hex to a new array - const normed = hex.slice(); // copy again, we'll manipulate it - const lastByte = hex[len - 1]; // select last byte - normed[len - 1] = lastByte & ~0x80; // clear last bit - const y = ut.bytesToNumberLE(normed); - if (y === _0n) { - // y=0 is allowed - } - else { - // RFC8032 prohibits >= p, but ZIP215 doesn't - if (zip215) - assertInRange(y, MASK); // zip215=true [1..P-1] (2^255-19-1 for ed25519) - else - assertInRange(y, Fp.ORDER); // zip215=false [1..MASK-1] (2^256-1 for ed25519) - } - // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case: - // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a) - const y2 = modP(y * y); // denominator is always non-0 mod p. - const u = modP(y2 - _1n); // u = y² - 1 - const v = modP(d * y2 - a); // v = d y² + 1. - let { isValid, value: x } = uvRatio(u, v); // √(u/v) - if (!isValid) - throw new Error('Point.fromHex: invalid y coordinate'); - const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper - const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit - if (!zip215 && x === _0n && isLastByteOdd) - // if x=0 and x_0 = 1, fail - throw new Error('Point.fromHex: x=0 and x_0=1'); - if (isLastByteOdd !== isXOdd) - x = modP(-x); // if x_0 != x mod 2, set x = p-x - return Point.fromAffine({ x, y }); - } - static fromPrivateKey(privKey) { - return getExtendedPublicKey(privKey).point; - } - toRawBytes() { - const { x, y } = this.toAffine(); - const bytes = ut.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y) - bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y - return bytes; // and use the last byte to encode sign of x - } - toHex() { - return ut.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string. - } - } - Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy)); - Point.ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0 - const { BASE: G, ZERO: I } = Point; - const wnaf = (0, curve_js_1.wNAF)(Point, nByteLength * 8); - function modN(a) { - return (0, modular_js_1.mod)(a, CURVE_ORDER); - } - // Little-endian SHA512 with modulo n - function modN_LE(hash) { - return modN(ut.bytesToNumberLE(hash)); - } - /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */ - function getExtendedPublicKey(key) { - const len = nByteLength; - key = (0, utils_js_1.ensureBytes)('private key', key, len); - // Hash private key with curve's hash function to produce uniformingly random input - // Check byte lengths: ensure(64, h(ensure(32, key))) - const hashed = (0, utils_js_1.ensureBytes)('hashed private key', cHash(key), 2 * len); - const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE - const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6) - const scalar = modN_LE(head); // The actual private scalar - const point = G.multiply(scalar); // Point on Edwards curve aka public key - const pointBytes = point.toRawBytes(); // Uint8Array representation - return { head, prefix, scalar, point, pointBytes }; - } - // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared - function getPublicKey(privKey) { - return getExtendedPublicKey(privKey).pointBytes; - } - // int('LE', SHA512(dom2(F, C) || msgs)) mod N - function hashDomainToScalar(context = new Uint8Array(), ...msgs) { - const msg = ut.concatBytes(...msgs); - return modN_LE(cHash(domain(msg, (0, utils_js_1.ensureBytes)('context', context), !!prehash))); - } - /** Signs message with privateKey. RFC8032 5.1.6 */ - function sign(msg, privKey, options = {}) { - msg = (0, utils_js_1.ensureBytes)('message', msg); - if (prehash) - msg = prehash(msg); // for ed25519ph etc. - const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey); - const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M) - const R = G.multiply(r).toRawBytes(); // R = rG - const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M) - const s = modN(r + k * scalar); // S = (r + k * s) mod L - assertGE0(s); // 0 <= s < l - const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES)); - return (0, utils_js_1.ensureBytes)('result', res, nByteLength * 2); // 64-byte signature - } - const verifyOpts = VERIFY_DEFAULT; - function verify(sig, msg, publicKey, options = verifyOpts) { - const { context, zip215 } = options; - const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7. - sig = (0, utils_js_1.ensureBytes)('signature', sig, 2 * len); // An extended group equation is checked. - msg = (0, utils_js_1.ensureBytes)('message', msg); - if (prehash) - msg = prehash(msg); // for ed25519ph, etc - const s = ut.bytesToNumberLE(sig.slice(len, 2 * len)); - // zip215: true is good for consensus-critical apps and allows points < 2^256 - // zip215: false follows RFC8032 / NIST186-5 and restricts points to CURVE.p - let A, R, SB; - try { - A = Point.fromHex(publicKey, zip215); - R = Point.fromHex(sig.slice(0, len), zip215); - SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside - } - catch (error) { - return false; - } - if (!zip215 && A.isSmallOrder()) - return false; - const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg); - const RkA = R.add(A.multiplyUnsafe(k)); - // [8][S]B = [8]R + [8][k]A' - return RkA.subtract(SB).clearCofactor().equals(Point.ZERO); - } - G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms. - const utils = { - getExtendedPublicKey, - // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1. - randomPrivateKey: () => randomBytes(Fp.BYTES), - /** - * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT - * values. This slows down first getPublicKey() by milliseconds (see Speed section), - * but allows to speed-up subsequent getPublicKey() calls up to 20x. - * @param windowSize 2, 4, 8, 16 - */ - precompute(windowSize = 8, point = Point.BASE) { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); - return point; - }, - }; - return { - CURVE, - getPublicKey, - sign, - verify, - ExtendedPoint: Point, - utils, - }; -} -exports.twistedEdwards = twistedEdwards; -//# sourceMappingURL=edwards.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js.map deleted file mode 100644 index 73ac6d5a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/edwards.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"edwards.js","sourceRoot":"","sources":["../src/abstract/edwards.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,8DAA8D;AAC9D,6CAAmC;AACnC,iCAAiC;AACjC,yCAAqD;AACrD,yCAAmG;AAEnG,qEAAqE;AACrE,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAezE,8EAA8E;AAC9E,MAAM,cAAc,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAExC,SAAS,YAAY,C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AC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,4BAA4B;QAC5B,OAAO,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,sEAAsE;IAE3F,MAAM,KAAK,GAAG;QACZ,oBAAoB;QACpB,6FAA6F;QAC7F,gBAAgB,EAAE,GAAe,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;QAEzD;;;;;WAKG;QACH,UAAU,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,IAAI;YAC3C,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YACjC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,OAAO;QACL,KAAK;QACL,YAAY;QACZ,IAAI;QACJ,MAAM;QACN,aAAa,EAAE,KAAK;QACpB,KAAK;KACN,CAAC;AACJ,CAAC;AA9ZD,wCA8ZC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts deleted file mode 100644 index 7f099503..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import type { Group, GroupConstructor, AffinePoint } from './curve.js'; -import { IField } from './modular.js'; -import { CHash } from './utils.js'; -/** - * * `DST` is a domain separation tag, defined in section 2.2.5 - * * `p` characteristic of F, where F is a finite field of characteristic p and order q = p^m - * * `m` is extension degree (1 for prime fields) - * * `k` is the target security target in bits (e.g. 128), from section 5.1 - * * `expand` is `xmd` (SHA2, SHA3, BLAKE) or `xof` (SHAKE, BLAKE-XOF) - * * `hash` conforming to `utils.CHash` interface, with `outputLen` / `blockLen` props - */ -type UnicodeOrBytes = string | Uint8Array; -export type Opts = { - DST: UnicodeOrBytes; - p: bigint; - m: number; - k: number; - expand: 'xmd' | 'xof'; - hash: CHash; -}; -export declare function expand_message_xmd(msg: Uint8Array, DST: Uint8Array, lenInBytes: number, H: CHash): Uint8Array; -export declare function expand_message_xof(msg: Uint8Array, DST: Uint8Array, lenInBytes: number, k: number, H: CHash): Uint8Array; -/** - * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3 - * @param msg a byte string containing the message to hash - * @param count the number of elements of F to output - * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above - * @returns [u_0, ..., u_(count - 1)], a list of field elements. - */ -export declare function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][]; -export declare function isogenyMap>(field: F, map: [T[], T[], T[], T[]]): (x: T, y: T) => { - x: T; - y: T; -}; -export interface H2CPoint extends Group> { - add(rhs: H2CPoint): H2CPoint; - toAffine(iz?: bigint): AffinePoint; - clearCofactor(): H2CPoint; - assertValidity(): void; -} -export interface H2CPointConstructor extends GroupConstructor> { - fromAffine(ap: AffinePoint): H2CPoint; -} -export type MapToCurve = (scalar: bigint[]) => AffinePoint; -export type htfBasicOpts = { - DST: UnicodeOrBytes; -}; -export declare function createHasher(Point: H2CPointConstructor, mapToCurve: MapToCurve, def: Opts & { - encodeDST?: UnicodeOrBytes; -}): { - hashToCurve(msg: Uint8Array, options?: htfBasicOpts): H2CPoint; - encodeToCurve(msg: Uint8Array, options?: htfBasicOpts): H2CPoint; -}; -export {}; -//# sourceMappingURL=hash-to-curve.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map deleted file mode 100644 index e89ad844..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-to-curve.d.ts","sourceRoot":"","sources":["../src/abstract/hash-to-curve.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAO,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAmB,KAAK,EAA4C,MAAM,YAAY,CAAC;AAE9F;;;;;;;GAOG;AACH,KAAK,cAAc,GAAG,MAAM,GAAG,UAAU,CAAC;AAC1C,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,cAAc,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAyCF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,MAAM,EAClB,CAAC,EAAE,KAAK,GACP,UAAU,CAqBZ;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,MAAM,EAClB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,KAAK,GACP,UAAU,CAqBZ;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,EAAE,EAAE,CAqCvF;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,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-curve.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.js deleted file mode 100644 index 418a80c4..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.js +++ /dev/null @@ -1,175 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createHasher = exports.isogenyMap = exports.hash_to_field = exports.expand_message_xof = exports.expand_message_xmd = void 0; -const modular_js_1 = require("./modular.js"); -const utils_js_1 = require("./utils.js"); -function validateDST(dst) { - if (dst instanceof Uint8Array) - return dst; - if (typeof dst === 'string') - return (0, utils_js_1.utf8ToBytes)(dst); - throw new Error('DST must be Uint8Array or string'); -} -// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE. -const os2ip = utils_js_1.bytesToNumberBE; -// Integer to Octet Stream (numberToBytesBE) -function i2osp(value, length) { - if (value < 0 || value >= 1 << (8 * length)) { - throw new Error(`bad I2OSP call: value=${value} length=${length}`); - } - const res = Array.from({ length }).fill(0); - for (let i = length - 1; i >= 0; i--) { - res[i] = value & 0xff; - value >>>= 8; - } - return new Uint8Array(res); -} -function strxor(a, b) { - const arr = new Uint8Array(a.length); - for (let i = 0; i < a.length; i++) { - arr[i] = a[i] ^ b[i]; - } - return arr; -} -function isBytes(item) { - if (!(item instanceof Uint8Array)) - throw new Error('Uint8Array expected'); -} -function isNum(item) { - if (!Number.isSafeInteger(item)) - throw new Error('number expected'); -} -// Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1 -function expand_message_xmd(msg, DST, lenInBytes, H) { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - if (DST.length > 255) - DST = H((0, utils_js_1.concatBytes)((0, utils_js_1.utf8ToBytes)('H2C-OVERSIZE-DST-'), DST)); - const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H; - const ell = Math.ceil(lenInBytes / b_in_bytes); - if (ell > 255) - throw new Error('Invalid xmd length'); - const DST_prime = (0, utils_js_1.concatBytes)(DST, i2osp(DST.length, 1)); - const Z_pad = i2osp(0, r_in_bytes); - const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str - const b = new Array(ell); - const b_0 = H((0, utils_js_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime)); - b[0] = H((0, utils_js_1.concatBytes)(b_0, i2osp(1, 1), DST_prime)); - for (let i = 1; i <= ell; i++) { - const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime]; - b[i] = H((0, utils_js_1.concatBytes)(...args)); - } - const pseudo_random_bytes = (0, utils_js_1.concatBytes)(...b); - return pseudo_random_bytes.slice(0, lenInBytes); -} -exports.expand_message_xmd = expand_message_xmd; -function expand_message_xof(msg, DST, lenInBytes, k, H) { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8)); - if (DST.length > 255) { - const dkLen = Math.ceil((2 * k) / 8); - DST = H.create({ dkLen }).update((0, utils_js_1.utf8ToBytes)('H2C-OVERSIZE-DST-')).update(DST).digest(); - } - if (lenInBytes > 65535 || DST.length > 255) - throw new Error('expand_message_xof: invalid lenInBytes'); - return (H.create({ dkLen: lenInBytes }) - .update(msg) - .update(i2osp(lenInBytes, 2)) - // 2. DST_prime = DST || I2OSP(len(DST), 1) - .update(DST) - .update(i2osp(DST.length, 1)) - .digest()); -} -exports.expand_message_xof = expand_message_xof; -/** - * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3 - * @param msg a byte string containing the message to hash - * @param count the number of elements of F to output - * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above - * @returns [u_0, ..., u_(count - 1)], a list of field elements. - */ -function hash_to_field(msg, count, options) { - (0, utils_js_1.validateObject)(options, { - DST: 'string', - p: 'bigint', - m: 'isSafeInteger', - k: 'isSafeInteger', - hash: 'hash', - }); - const { p, k, m, hash, expand, DST: _DST } = options; - isBytes(msg); - isNum(count); - const DST = validateDST(_DST); - const log2p = p.toString(2).length; - const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above - const len_in_bytes = count * m * L; - let prb; // pseudo_random_bytes - if (expand === 'xmd') { - prb = expand_message_xmd(msg, DST, len_in_bytes, hash); - } - else if (expand === 'xof') { - prb = expand_message_xof(msg, DST, len_in_bytes, k, hash); - } - else if (expand === '_internal_pass') { - // for internal tests only - prb = msg; - } - else { - throw new Error('expand must be "xmd" or "xof"'); - } - const u = new Array(count); - for (let i = 0; i < count; i++) { - const e = new Array(m); - for (let j = 0; j < m; j++) { - const elm_offset = L * (j + i * m); - const tv = prb.subarray(elm_offset, elm_offset + L); - e[j] = (0, modular_js_1.mod)(os2ip(tv), p); - } - u[i] = e; - } - return u; -} -exports.hash_to_field = hash_to_field; -function isogenyMap(field, map) { - // Make same order as in spec - const COEFF = map.map((i) => Array.from(i).reverse()); - return (x, y) => { - const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i))); - x = field.div(xNum, xDen); // xNum / xDen - y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev) - return { x, y }; - }; -} -exports.isogenyMap = isogenyMap; -function createHasher(Point, mapToCurve, def) { - if (typeof mapToCurve !== 'function') - throw new Error('mapToCurve() must be defined'); - return { - // Encodes byte string to elliptic curve - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - hashToCurve(msg, options) { - const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options }); - const u0 = Point.fromAffine(mapToCurve(u[0])); - const u1 = Point.fromAffine(mapToCurve(u[1])); - const P = u0.add(u1).clearCofactor(); - P.assertValidity(); - return P; - }, - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - encodeToCurve(msg, options) { - const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options }); - const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor(); - P.assertValidity(); - return P; - }, - }; -} -exports.createHasher = createHasher; -//# sourceMappingURL=hash-to-curve.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.js.map deleted file mode 100644 index c2fa8bd2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/hash-to-curve.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-to-curve.js","sourceRoot":"","sources":["../src/abstract/hash-to-curve.ts"],"names":[],"mappings":";;;AAEA,6CAA2C;AAC3C,yCAA8F;AAoB9F,SAAS,WAAW,CAAC,GAAmB;IACtC,IAAI,GAAG,YAAY,UAAU;QAAE,OAAO,GAAG,CAAC;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAA,sBAAW,EAAC,GAAG,CAAC,CAAC;IACrD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,CAAC;AAED,6FAA6F;AAC7F,MAAM,KAAK,GAAG,0BAAe,CAAC;AAE9B,4CAA4C;AAC5C,SAAS,KAAK,CAAC,KAAa,EAAE,MAAc;IAC1C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE;QAC3C,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,WAAW,MAAM,EAAE,CAAC,CAAC;KACpE;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,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AC;YACpF,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;YAC7D,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,CAAC;QACX,CAAC;KACF,CAAC;AACJ,CAAC;AA1BD,oCA0BC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts deleted file mode 100644 index 3acaa1ef..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts +++ /dev/null @@ -1,83 +0,0 @@ -export declare function mod(a: bigint, b: bigint): bigint; -/** - * Efficiently raise num to power and do modular division. - * Unsafe in some contexts: uses ladder, so can expose bigint bits. - * @example - * pow(2n, 6n, 11n) // 64n % 11n == 9n - */ -export declare function pow(num: bigint, power: bigint, modulo: bigint): bigint; -export declare function pow2(x: bigint, power: bigint, modulo: bigint): bigint; -export declare function invert(number: bigint, modulo: bigint): bigint; -export declare function tonelliShanks(P: bigint): (Fp: IField, n: T) => T; -export declare function FpSqrt(P: bigint): (Fp: IField, n: T) => T; -export declare const isNegativeLE: (num: bigint, modulo: bigint) => boolean; -export interface IField { - ORDER: bigint; - BYTES: number; - BITS: number; - MASK: bigint; - ZERO: T; - ONE: T; - create: (num: T) => T; - isValid: (num: T) => boolean; - is0: (num: T) => boolean; - neg(num: T): T; - inv(num: T): T; - sqrt(num: T): T; - sqr(num: T): T; - eql(lhs: T, rhs: T): boolean; - add(lhs: T, rhs: T): T; - sub(lhs: T, rhs: T): T; - mul(lhs: T, rhs: T | bigint): T; - pow(lhs: T, power: bigint): T; - div(lhs: T, rhs: T | bigint): T; - addN(lhs: T, rhs: T): T; - subN(lhs: T, rhs: T): T; - mulN(lhs: T, rhs: T | bigint): T; - sqrN(num: T): T; - isOdd?(num: T): boolean; - pow(lhs: T, power: bigint): T; - invertBatch: (lst: T[]) => T[]; - toBytes(num: T): Uint8Array; - fromBytes(bytes: Uint8Array): T; - cmov(a: T, b: T, c: boolean): T; -} -export declare function validateField(field: IField): IField; -export declare function FpPow(f: IField, num: T, power: bigint): T; -export declare function FpInvertBatch(f: IField, nums: T[]): T[]; -export declare function FpDiv(f: IField, lhs: T, rhs: T | bigint): T; -export declare function FpIsSquare(f: IField): (x: T) => boolean; -export declare function nLength(n: bigint, nBitLength?: number): { - nBitLength: number; - nByteLength: number; -}; -type FpField = IField & Required, 'isOdd'>>; -/** - * Initializes a galois field over prime. Non-primes are not supported for now. - * Do not init in loop: slow. Very fragile: always run a benchmark on change. - * Major performance gains: - * a) non-normalized operations like mulN instead of mul - * b) `Object.freeze` - * c) Same object shape: never add or remove keys - * @param ORDER prime positive bigint - * @param bitLen how many bits the field consumes - * @param isLE (def: false) if encoding / decoding should be in little-endian - * @param redef optional faster redefinitions of sqrt and other methods - */ -export declare function Field(ORDER: bigint, bitLen?: number, isLE?: boolean, redef?: Partial>): Readonly; -export declare function FpSqrtOdd(Fp: IField, elm: T): T; -export declare function FpSqrtEven(Fp: IField, elm: T): T; -/** - * FIPS 186 B.4.1-compliant "constant-time" private key generation utility. - * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF - * and convert them into private scalar, with the modulo bias being negligible. - * Needs at least 40 bytes of input for 32-byte private key. - * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ - * @param hash hash output from SHA3 or a similar function - * @param groupOrder size of subgroup - (e.g. curveFn.CURVE.n) - * @param isLE interpret hash bytes as LE num - * @returns valid private scalar - */ -export declare function hashToPrivateScalar(hash: string | Uint8Array, groupOrder: bigint, isLE?: boolean): bigint; -export {}; -//# sourceMappingURL=modular.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts.map deleted file mode 100644 index 49b9d759..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"modular.d.ts","sourceRoot":"","sources":["../src/abstract/modular.ts"],"names":[],"mappings":"AAmBA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AACD;;;;;GAKG;AAEH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUtE;AAGD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOrE;AAGD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsB7D;AAKD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,iCAsDtC;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,iCA2D/B;AAGD,eAAO,MAAM,YAAY,QAAS,MAAM,UAAU,MAAM,YAAqC,CAAC;AAG9F,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,CAAC,CAAC;IAEP,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;IACzB,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACf,GAAG,CAAC,GAAG,EAAE,C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AC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAIjD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAIlD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,UAAU,EAAE,MAAM,EAClB,IAAI,UAAQ,GACX,MAAM,CAQR"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js deleted file mode 100644 index 2f338e57..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js +++ /dev/null @@ -1,381 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hashToPrivateScalar = exports.FpSqrtEven = exports.FpSqrtOdd = exports.Field = exports.nLength = exports.FpIsSquare = exports.FpDiv = exports.FpInvertBatch = exports.FpPow = exports.validateField = exports.isNegativeLE = exports.FpSqrt = exports.tonelliShanks = exports.invert = exports.pow2 = exports.pow = exports.mod = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Utilities for modular arithmetics and finite fields -const utils_js_1 = require("./utils.js"); -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3); -// prettier-ignore -const _4n = BigInt(4), _5n = BigInt(5), _8n = BigInt(8); -// prettier-ignore -const _9n = BigInt(9), _16n = BigInt(16); -// Calculates a modulo b -function mod(a, b) { - const result = a % b; - return result >= _0n ? result : b + result; -} -exports.mod = mod; -/** - * Efficiently raise num to power and do modular division. - * Unsafe in some contexts: uses ladder, so can expose bigint bits. - * @example - * pow(2n, 6n, 11n) // 64n % 11n == 9n - */ -// TODO: use field version && remove -function pow(num, power, modulo) { - if (modulo <= _0n || power < _0n) - throw new Error('Expected power/modulo > 0'); - if (modulo === _1n) - return _0n; - let res = _1n; - while (power > _0n) { - if (power & _1n) - res = (res * num) % modulo; - num = (num * num) % modulo; - power >>= _1n; - } - return res; -} -exports.pow = pow; -// Does x ^ (2 ^ power) mod p. pow2(30, 4) == 30 ^ (2 ^ 4) -function pow2(x, power, modulo) { - let res = x; - while (power-- > _0n) { - res *= res; - res %= modulo; - } - return res; -} -exports.pow2 = pow2; -// Inverses number over modulo -function invert(number, modulo) { - if (number === _0n || modulo <= _0n) { - throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`); - } - // Euclidean GCD https://brilliant.org/wiki/extended-euclidean-algorithm/ - // Fermat's little theorem "CT-like" version inv(n) = n^(m-2) mod m is 30x slower. - let a = mod(number, modulo); - let b = modulo; - // prettier-ignore - let x = _0n, y = _1n, u = _1n, v = _0n; - while (a !== _0n) { - // JIT applies optimization if those two lines follow each other - const q = b / a; - const r = b % a; - const m = x - u * q; - const n = y - v * q; - // prettier-ignore - b = a, a = r, x = u, y = v, u = m, v = n; - } - const gcd = b; - if (gcd !== _1n) - throw new Error('invert: does not exist'); - return mod(x, modulo); -} -exports.invert = invert; -// Tonelli-Shanks algorithm -// Paper 1: https://eprint.iacr.org/2012/685.pdf (page 12) -// Paper 2: Square Roots from 1; 24, 51, 10 to Dan Shanks -function tonelliShanks(P) { - // Legendre constant: used to calculate Legendre symbol (a | p), - // which denotes the value of a^((p-1)/2) (mod p). - // (a | p) ≡ 1 if a is a square (mod p) - // (a | p) ≡ -1 if a is not a square (mod p) - // (a | p) ≡ 0 if a ≡ 0 (mod p) - const legendreC = (P - _1n) / _2n; - let Q, S, Z; - // Step 1: By factoring out powers of 2 from p - 1, - // find q and s such that p - 1 = q*(2^s) with q odd - for (Q = P - _1n, S = 0; Q % _2n === _0n; Q /= _2n, S++) - ; - // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq - for (Z = _2n; Z < P && pow(Z, legendreC, P) !== P - _1n; Z++) - ; - // Fast-path - if (S === 1) { - const p1div4 = (P + _1n) / _4n; - return function tonelliFast(Fp, n) { - const root = Fp.pow(n, p1div4); - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // Slow-path - const Q1div2 = (Q + _1n) / _2n; - return function tonelliSlow(Fp, n) { - // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1 - if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) - throw new Error('Cannot find square root'); - let r = S; - // TODO: will fail at Fp2/etc - let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b - let x = Fp.pow(n, Q1div2); // first guess at the square root - let b = Fp.pow(n, Q); // first guess at the fudge factor - while (!Fp.eql(b, Fp.ONE)) { - if (Fp.eql(b, Fp.ZERO)) - return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0) - // Find m such b^(2^m)==1 - let m = 1; - for (let t2 = Fp.sqr(b); m < r; m++) { - if (Fp.eql(t2, Fp.ONE)) - break; - t2 = Fp.sqr(t2); // t2 *= t2 - } - // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow - const ge = Fp.pow(g, _1n << BigInt(r - m - 1)); // ge = 2^(r-m-1) - g = Fp.sqr(ge); // g = ge * ge - x = Fp.mul(x, ge); // x *= ge - b = Fp.mul(b, g); // b *= g - r = m; - } - return x; - }; -} -exports.tonelliShanks = tonelliShanks; -function FpSqrt(P) { - // NOTE: different algorithms can give different roots, it is up to user to decide which one they want. - // For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve). - // P ≡ 3 (mod 4) - // √n = n^((P+1)/4) - if (P % _4n === _3n) { - // Not all roots possible! - // const ORDER = - // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn; - // const NUM = 72057594037927816n; - const p1div4 = (P + _1n) / _4n; - return function sqrt3mod4(Fp, n) { - const root = Fp.pow(n, p1div4); - // Throw if root**2 != n - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10) - if (P % _8n === _5n) { - const c1 = (P - _5n) / _8n; - return function sqrt5mod8(Fp, n) { - const n2 = Fp.mul(n, _2n); - const v = Fp.pow(n2, c1); - const nv = Fp.mul(n, v); - const i = Fp.mul(Fp.mul(nv, _2n), v); - const root = Fp.mul(nv, Fp.sub(i, Fp.ONE)); - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // P ≡ 9 (mod 16) - if (P % _16n === _9n) { - // NOTE: tonelli is too slow for bls-Fp2 calculations even on start - // Means we cannot use sqrt for constants at all! - // - // const c1 = Fp.sqrt(Fp.negate(Fp.ONE)); // 1. c1 = sqrt(-1) in F, i.e., (c1^2) == -1 in F - // const c2 = Fp.sqrt(c1); // 2. c2 = sqrt(c1) in F, i.e., (c2^2) == c1 in F - // const c3 = Fp.sqrt(Fp.negate(c1)); // 3. c3 = sqrt(-c1) in F, i.e., (c3^2) == -c1 in F - // const c4 = (P + _7n) / _16n; // 4. c4 = (q + 7) / 16 # Integer arithmetic - // sqrt = (x) => { - // let tv1 = Fp.pow(x, c4); // 1. tv1 = x^c4 - // let tv2 = Fp.mul(c1, tv1); // 2. tv2 = c1 * tv1 - // const tv3 = Fp.mul(c2, tv1); // 3. tv3 = c2 * tv1 - // let tv4 = Fp.mul(c3, tv1); // 4. tv4 = c3 * tv1 - // const e1 = Fp.equals(Fp.square(tv2), x); // 5. e1 = (tv2^2) == x - // const e2 = Fp.equals(Fp.square(tv3), x); // 6. e2 = (tv3^2) == x - // tv1 = Fp.cmov(tv1, tv2, e1); // 7. tv1 = CMOV(tv1, tv2, e1) # Select tv2 if (tv2^2) == x - // tv2 = Fp.cmov(tv4, tv3, e2); // 8. tv2 = CMOV(tv4, tv3, e2) # Select tv3 if (tv3^2) == x - // const e3 = Fp.equals(Fp.square(tv2), x); // 9. e3 = (tv2^2) == x - // return Fp.cmov(tv1, tv2, e3); // 10. z = CMOV(tv1, tv2, e3) # Select the sqrt from tv1 and tv2 - // } - } - // Other cases: Tonelli-Shanks algorithm - return tonelliShanks(P); -} -exports.FpSqrt = FpSqrt; -// Little-endian check for first LE bit (last BE bit); -const isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n) === _1n; -exports.isNegativeLE = isNegativeLE; -// prettier-ignore -const FIELD_FIELDS = [ - 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr', - 'eql', 'add', 'sub', 'mul', 'pow', 'div', - 'addN', 'subN', 'mulN', 'sqrN' -]; -function validateField(field) { - const initial = { - ORDER: 'bigint', - MASK: 'bigint', - BYTES: 'isSafeInteger', - BITS: 'isSafeInteger', - }; - const opts = FIELD_FIELDS.reduce((map, val) => { - map[val] = 'function'; - return map; - }, initial); - return (0, utils_js_1.validateObject)(field, opts); -} -exports.validateField = validateField; -// Generic field functions -function FpPow(f, num, power) { - // Should have same speed as pow for bigints - // TODO: benchmark! - if (power < _0n) - throw new Error('Expected power > 0'); - if (power === _0n) - return f.ONE; - if (power === _1n) - return num; - let p = f.ONE; - let d = num; - while (power > _0n) { - if (power & _1n) - p = f.mul(p, d); - d = f.sqr(d); - power >>= _1n; - } - return p; -} -exports.FpPow = FpPow; -// 0 is non-invertible: non-batched version will throw on 0 -function FpInvertBatch(f, nums) { - const tmp = new Array(nums.length); - // Walk from first to last, multiply them by each other MOD p - const lastMultiplied = nums.reduce((acc, num, i) => { - if (f.is0(num)) - return acc; - tmp[i] = acc; - return f.mul(acc, num); - }, f.ONE); - // Invert last element - const inverted = f.inv(lastMultiplied); - // Walk from last to first, multiply them by inverted each other MOD p - nums.reduceRight((acc, num, i) => { - if (f.is0(num)) - return acc; - tmp[i] = f.mul(acc, tmp[i]); - return f.mul(acc, num); - }, inverted); - return tmp; -} -exports.FpInvertBatch = FpInvertBatch; -function FpDiv(f, lhs, rhs) { - return f.mul(lhs, typeof rhs === 'bigint' ? invert(rhs, f.ORDER) : f.inv(rhs)); -} -exports.FpDiv = FpDiv; -// This function returns True whenever the value x is a square in the field F. -function FpIsSquare(f) { - const legendreConst = (f.ORDER - _1n) / _2n; // Integer arithmetic - return (x) => { - const p = f.pow(x, legendreConst); - return f.eql(p, f.ZERO) || f.eql(p, f.ONE); - }; -} -exports.FpIsSquare = FpIsSquare; -// CURVE.n lengths -function nLength(n, nBitLength) { - // Bit size, byte size of CURVE.n - const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length; - const nByteLength = Math.ceil(_nBitLength / 8); - return { nBitLength: _nBitLength, nByteLength }; -} -exports.nLength = nLength; -/** - * Initializes a galois field over prime. Non-primes are not supported for now. - * Do not init in loop: slow. Very fragile: always run a benchmark on change. - * Major performance gains: - * a) non-normalized operations like mulN instead of mul - * b) `Object.freeze` - * c) Same object shape: never add or remove keys - * @param ORDER prime positive bigint - * @param bitLen how many bits the field consumes - * @param isLE (def: false) if encoding / decoding should be in little-endian - * @param redef optional faster redefinitions of sqrt and other methods - */ -function Field(ORDER, bitLen, isLE = false, redef = {}) { - if (ORDER <= _0n) - throw new Error(`Expected Fp ORDER > 0, got ${ORDER}`); - const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen); - if (BYTES > 2048) - throw new Error('Field lengths over 2048 bytes are not supported'); - const sqrtP = FpSqrt(ORDER); - const f = Object.freeze({ - ORDER, - BITS, - BYTES, - MASK: (0, utils_js_1.bitMask)(BITS), - ZERO: _0n, - ONE: _1n, - create: (num) => mod(num, ORDER), - isValid: (num) => { - if (typeof num !== 'bigint') - throw new Error(`Invalid field element: expected bigint, got ${typeof num}`); - return _0n <= num && num < ORDER; // 0 is valid element, but it's not invertible - }, - is0: (num) => num === _0n, - isOdd: (num) => (num & _1n) === _1n, - neg: (num) => mod(-num, ORDER), - eql: (lhs, rhs) => lhs === rhs, - sqr: (num) => mod(num * num, ORDER), - add: (lhs, rhs) => mod(lhs + rhs, ORDER), - sub: (lhs, rhs) => mod(lhs - rhs, ORDER), - mul: (lhs, rhs) => mod(lhs * rhs, ORDER), - pow: (num, power) => FpPow(f, num, power), - div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER), - // Same as above, but doesn't normalize - sqrN: (num) => num * num, - addN: (lhs, rhs) => lhs + rhs, - subN: (lhs, rhs) => lhs - rhs, - mulN: (lhs, rhs) => lhs * rhs, - inv: (num) => invert(num, ORDER), - sqrt: redef.sqrt || ((n) => sqrtP(f, n)), - invertBatch: (lst) => FpInvertBatch(f, lst), - // TODO: do we really need constant cmov? - // We don't have const-time bigints anyway, so probably will be not very useful - cmov: (a, b, c) => (c ? b : a), - toBytes: (num) => (isLE ? (0, utils_js_1.numberToBytesLE)(num, BYTES) : (0, utils_js_1.numberToBytesBE)(num, BYTES)), - fromBytes: (bytes) => { - if (bytes.length !== BYTES) - throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes.length}`); - return isLE ? (0, utils_js_1.bytesToNumberLE)(bytes) : (0, utils_js_1.bytesToNumberBE)(bytes); - }, - }); - return Object.freeze(f); -} -exports.Field = Field; -function FpSqrtOdd(Fp, elm) { - if (!Fp.isOdd) - throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? root : Fp.neg(root); -} -exports.FpSqrtOdd = FpSqrtOdd; -function FpSqrtEven(Fp, elm) { - if (!Fp.isOdd) - throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? Fp.neg(root) : root; -} -exports.FpSqrtEven = FpSqrtEven; -/** - * FIPS 186 B.4.1-compliant "constant-time" private key generation utility. - * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF - * and convert them into private scalar, with the modulo bias being negligible. - * Needs at least 40 bytes of input for 32-byte private key. - * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ - * @param hash hash output from SHA3 or a similar function - * @param groupOrder size of subgroup - (e.g. curveFn.CURVE.n) - * @param isLE interpret hash bytes as LE num - * @returns valid private scalar - */ -function hashToPrivateScalar(hash, groupOrder, isLE = false) { - hash = (0, utils_js_1.ensureBytes)('privateHash', hash); - const hashLen = hash.length; - const minLen = nLength(groupOrder).nByteLength + 8; - if (minLen < 24 || hashLen < minLen || hashLen > 1024) - throw new Error(`hashToPrivateScalar: expected ${minLen}-1024 bytes of input, got ${hashLen}`); - const num = isLE ? (0, utils_js_1.bytesToNumberLE)(hash) : (0, utils_js_1.bytesToNumberBE)(hash); - return mod(num, groupOrder - _1n) + _1n; -} -exports.hashToPrivateScalar = hashToPrivateScalar; -//# sourceMappingURL=modular.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js.map deleted file mode 100644 index 9938a175..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/modular.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"modular.js","sourceRoot":"","sources":["../src/abstract/modular.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,sDAAsD;AACtD,yCAQoB;AACpB,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACxD,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzC,wB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AAU,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;IACnD,IAAI,MAAM,GAAG,EAAE,IAAI,OAAO,GAAG,MAAM,IAAI,OAAO,GAAG,IAAI;QACnD,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACjG,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC;IACjE,OAAO,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC1C,CAAC;AAZD,kDAYC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts deleted file mode 100644 index 69e2bc45..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -type Hex = string | Uint8Array; -export type CurveType = { - P: bigint; - nByteLength: number; - adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array; - domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array; - a: bigint; - montgomeryBits: number; - powPminus2?: (x: bigint) => bigint; - xyToU?: (x: bigint, y: bigint) => bigint; - Gu: bigint; - randomBytes?: (bytesLength?: number) => Uint8Array; -}; -export type CurveFn = { - scalarMult: (scalar: Hex, u: Hex) => Uint8Array; - scalarMultBase: (scalar: Hex) => Uint8Array; - getSharedSecret: (privateKeyA: Hex, publicKeyB: Hex) => Uint8Array; - getPublicKey: (privateKey: Hex) => Uint8Array; - utils: { - randomPrivateKey: () => Uint8Array; - }; - GuBytes: Uint8Array; -}; -export declare function montgomery(curveDef: CurveType): CurveFn; -export {}; -//# sourceMappingURL=montgomery.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts.map deleted file mode 100644 index a0d1c0b9..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"montgomery.d.ts","sourceRoot":"","sources":["../src/abstract/montgomery.ts"],"names":[],"mappings":"AAMA,KAAK,GAAG,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/B,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,UAAU,CAAC;IACtD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;IAC5E,CAAC,EAAE,MAAM,CAAC;IACV,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;CACpD,CAAC;AACF,MAAM,MAAM,OAAO,GAAG;IACpB,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,UAAU,CAAC;IAChD,cAAc,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,UAAU,CAAC;IAC5C,eAAe,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,KAAK,UAAU,CAAC;IACnE,YAAY,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,UAAU,CAAC;IAC9C,KAAK,EAAE;QAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;KAAE,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAuBF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CA0IvD"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js deleted file mode 100644 index b43e43b5..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js +++ /dev/null @@ -1,161 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.montgomery = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const modular_js_1 = require("./modular.js"); -const utils_js_1 = require("./utils.js"); -const _0n = BigInt(0); -const _1n = BigInt(1); -function validateOpts(curve) { - (0, utils_js_1.validateObject)(curve, { - a: 'bigint', - }, { - montgomeryBits: 'isSafeInteger', - nByteLength: 'isSafeInteger', - adjustScalarBytes: 'function', - domain: 'function', - powPminus2: 'function', - Gu: 'bigint', - }); - // Set defaults - return Object.freeze({ ...curve }); -} -// NOTE: not really montgomery curve, just bunch of very specific methods for X25519/X448 (RFC 7748, https://www.rfc-editor.org/rfc/rfc7748) -// Uses only one coordinate instead of two -function montgomery(curveDef) { - const CURVE = validateOpts(curveDef); - const { P } = CURVE; - const modP = (n) => (0, modular_js_1.mod)(n, P); - const montgomeryBits = CURVE.montgomeryBits; - const montgomeryBytes = Math.ceil(montgomeryBits / 8); - const fieldLen = CURVE.nByteLength; - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); - const powPminus2 = CURVE.powPminus2 || ((x) => (0, modular_js_1.pow)(x, P - BigInt(2), P)); - // cswap from RFC7748. But it is not from RFC7748! - /* - cswap(swap, x_2, x_3): - dummy = mask(swap) AND (x_2 XOR x_3) - x_2 = x_2 XOR dummy - x_3 = x_3 XOR dummy - Return (x_2, x_3) - Where mask(swap) is the all-1 or all-0 word of the same length as x_2 - and x_3, computed, e.g., as mask(swap) = 0 - swap. - */ - function cswap(swap, x_2, x_3) { - const dummy = modP(swap * (x_2 - x_3)); - x_2 = modP(x_2 - dummy); - x_3 = modP(x_3 + dummy); - return [x_2, x_3]; - } - // Accepts 0 as well - function assertFieldElement(n) { - if (typeof n === 'bigint' && _0n <= n && n < P) - return n; - throw new Error('Expected valid scalar 0 < scalar < CURVE.P'); - } - // x25519 from 4 - // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519 - const a24 = (CURVE.a - BigInt(2)) / BigInt(4); - /** - * - * @param pointU u coordinate (x) on Montgomery Curve 25519 - * @param scalar by which the point would be multiplied - * @returns new Point on Montgomery curve - */ - function montgomeryLadder(pointU, scalar) { - const u = assertFieldElement(pointU); - // Section 5: Implementations MUST accept non-canonical values and process them as - // if they had been reduced modulo the field prime. - const k = assertFieldElement(scalar); - const x_1 = u; - let x_2 = _1n; - let z_2 = _0n; - let x_3 = u; - let z_3 = _1n; - let swap = _0n; - let sw; - for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) { - const k_t = (k >> t) & _1n; - swap ^= k_t; - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - swap = k_t; - const A = x_2 + z_2; - const AA = modP(A * A); - const B = x_2 - z_2; - const BB = modP(B * B); - const E = AA - BB; - const C = x_3 + z_3; - const D = x_3 - z_3; - const DA = modP(D * A); - const CB = modP(C * B); - const dacb = DA + CB; - const da_cb = DA - CB; - x_3 = modP(dacb * dacb); - z_3 = modP(x_1 * modP(da_cb * da_cb)); - x_2 = modP(AA * BB); - z_2 = modP(E * (AA + modP(a24 * E))); - } - // (x_2, x_3) = cswap(swap, x_2, x_3) - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - // (z_2, z_3) = cswap(swap, z_2, z_3) - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - // z_2^(p - 2) - const z2 = powPminus2(z_2); - // Return x_2 * (z_2^(p - 2)) - return modP(x_2 * z2); - } - function encodeUCoordinate(u) { - return (0, utils_js_1.numberToBytesLE)(modP(u), montgomeryBytes); - } - function decodeUCoordinate(uEnc) { - // Section 5: When receiving such an array, implementations of X25519 - // MUST mask the most significant bit in the final byte. - // This is very ugly way, but it works because fieldLen-1 is outside of bounds for X448, so this becomes NOOP - // fieldLen - scalaryBytes = 1 for X448 and = 0 for X25519 - const u = (0, utils_js_1.ensureBytes)('u coordinate', uEnc, montgomeryBytes); - // u[fieldLen-1] crashes QuickJS (TypeError: out-of-bound numeric index) - if (fieldLen === montgomeryBytes) - u[fieldLen - 1] &= 127; // 0b0111_1111 - return (0, utils_js_1.bytesToNumberLE)(u); - } - function decodeScalar(n) { - const bytes = (0, utils_js_1.ensureBytes)('scalar', n); - if (bytes.length !== montgomeryBytes && bytes.length !== fieldLen) - throw new Error(`Expected ${montgomeryBytes} or ${fieldLen} bytes, got ${bytes.length}`); - return (0, utils_js_1.bytesToNumberLE)(adjustScalarBytes(bytes)); - } - function scalarMult(scalar, u) { - const pointU = decodeUCoordinate(u); - const _scalar = decodeScalar(scalar); - const pu = montgomeryLadder(pointU, _scalar); - // The result was not contributory - // https://cr.yp.to/ecdh.html#validate - if (pu === _0n) - throw new Error('Invalid private or public key received'); - return encodeUCoordinate(pu); - } - // Computes public key from private. By doing scalar multiplication of base point. - const GuBytes = encodeUCoordinate(CURVE.Gu); - function scalarMultBase(scalar) { - return scalarMult(scalar, GuBytes); - } - return { - scalarMult, - scalarMultBase, - getSharedSecret: (privateKey, publicKey) => scalarMult(privateKey, publicKey), - getPublicKey: (privateKey) => scalarMultBase(privateKey), - utils: { randomPrivateKey: () => CURVE.randomBytes(CURVE.nByteLength) }, - GuBytes: GuBytes, - }; -} -exports.montgomery = montgomery; -//# sourceMappingURL=montgomery.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js.map deleted file mode 100644 index 1aa0c9eb..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/montgomery.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"montgomery.js","sourceRoot":"","sources":["../src/abstract/montgomery.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,6CAAwC;AACxC,yCAA2F;AAE3F,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAwBtB,SAAS,YAAY,CAAC,KAAgB;IACpC,IAAA,yBAAc,EACZ,KAAK,EACL;QACE,CAAC,EAAE,QAAQ;KACZ,EACD;QACE,cAAc,EAAE,eAAe;QAC/B,WAAW,EAAE,eAAe;QAC5B,iBAAiB,EAAE,UAAU;QAC7B,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,UAAU;QACtB,EAAE,EAAE,QAAQ;KACb,CACF,CAAC;IACF,eAAe;IACf,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAW,CAAC,CAAC;AAC9C,CAAC;AAED,4IAA4I;AAC5I,0CAA0C;AAC1C,SAAgB,UAAU,CAAC,QAAmB;IAC5C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAA,gBAAG,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,KAAK,CAA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AO;QACL,UAAU;QACV,cAAc;QACd,eAAe,EAAE,CAAC,UAAe,EAAE,SAAc,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC;QACvF,YAAY,EAAE,CAAC,UAAe,EAAc,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC;QACzE,KAAK,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;QACxE,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC;AA1ID,gCA0IC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts deleted file mode 100644 index 2f9ab819..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { IField } from './modular.js'; -export type PoseidonOpts = { - Fp: IField; - t: number; - roundsFull: number; - roundsPartial: number; - sboxPower?: number; - reversePartialPowIdx?: boolean; - mds: bigint[][]; - roundConstants: bigint[][]; -}; -export declare function validateOpts(opts: PoseidonOpts): Readonly<{ - rounds: number; - sboxFn: (n: bigint) => bigint; - roundConstants: bigint[][]; - mds: bigint[][]; - Fp: IField; - t: number; - roundsFull: number; - roundsPartial: number; - sboxPower?: number | undefined; - reversePartialPowIdx?: boolean | undefined; -}>; -export declare function splitConstants(rc: bigint[], t: number): bigint[][]; -export declare function poseidon(opts: PoseidonOpts): { - (values: bigint[]): bigint[]; - roundConstants: bigint[][]; -}; -//# sourceMappingURL=poseidon.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts.map deleted file mode 100644 index 7107b83f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"poseidon.d.ts","sourceRoot":"","sources":["../src/abstract/poseidon.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,MAAM,EAAwB,MAAM,cAAc,CAAC;AAG5D,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY;;gBAgB5B,MAAM;;;;;;;;;GAgCxB;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,cAarD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY;aAeU,MAAM,EAAE;;EAsB5D"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js deleted file mode 100644 index fc66916f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js +++ /dev/null @@ -1,116 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.poseidon = exports.splitConstants = exports.validateOpts = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Poseidon Hash: https://eprint.iacr.org/2019/458.pdf, https://www.poseidon-hash.info -const modular_js_1 = require("./modular.js"); -function validateOpts(opts) { - const { Fp } = opts; - (0, modular_js_1.validateField)(Fp); - for (const i of ['t', 'roundsFull', 'roundsPartial']) { - if (typeof opts[i] !== 'number' || !Number.isSafeInteger(opts[i])) - throw new Error(`Poseidon: invalid param ${i}=${opts[i]} (${typeof opts[i]})`); - } - if (opts.reversePartialPowIdx !== undefined && typeof opts.reversePartialPowIdx !== 'boolean') - throw new Error(`Poseidon: invalid param reversePartialPowIdx=${opts.reversePartialPowIdx}`); - // Default is 5, but by some reasons stark uses 3 - let sboxPower = opts.sboxPower; - if (sboxPower === undefined) - sboxPower = 5; - if (typeof sboxPower !== 'number' || !Number.isSafeInteger(sboxPower)) - throw new Error(`Poseidon wrong sboxPower=${sboxPower}`); - const _sboxPower = BigInt(sboxPower); - let sboxFn = (n) => (0, modular_js_1.FpPow)(Fp, n, _sboxPower); - // Unwrapped sbox power for common cases (195->142μs) - if (sboxPower === 3) - sboxFn = (n) => Fp.mul(Fp.sqrN(n), n); - else if (sboxPower === 5) - sboxFn = (n) => Fp.mul(Fp.sqrN(Fp.sqrN(n)), n); - if (opts.roundsFull % 2 !== 0) - throw new Error(`Poseidon roundsFull is not even: ${opts.roundsFull}`); - const rounds = opts.roundsFull + opts.roundsPartial; - if (!Array.isArray(opts.roundConstants) || opts.roundConstants.length !== rounds) - throw new Error('Poseidon: wrong round constants'); - const roundConstants = opts.roundConstants.map((rc) => { - if (!Array.isArray(rc) || rc.length !== opts.t) - throw new Error(`Poseidon wrong round constants: ${rc}`); - return rc.map((i) => { - if (typeof i !== 'bigint' || !Fp.isValid(i)) - throw new Error(`Poseidon wrong round constant=${i}`); - return Fp.create(i); - }); - }); - // MDS is TxT matrix - if (!Array.isArray(opts.mds) || opts.mds.length !== opts.t) - throw new Error('Poseidon: wrong MDS matrix'); - const mds = opts.mds.map((mdsRow) => { - if (!Array.isArray(mdsRow) || mdsRow.length !== opts.t) - throw new Error(`Poseidon MDS matrix row: ${mdsRow}`); - return mdsRow.map((i) => { - if (typeof i !== 'bigint') - throw new Error(`Poseidon MDS matrix value=${i}`); - return Fp.create(i); - }); - }); - return Object.freeze({ ...opts, rounds, sboxFn, roundConstants, mds }); -} -exports.validateOpts = validateOpts; -function splitConstants(rc, t) { - if (typeof t !== 'number') - throw new Error('poseidonSplitConstants: wrong t'); - if (!Array.isArray(rc) || rc.length % t) - throw new Error('poseidonSplitConstants: wrong rc'); - const res = []; - let tmp = []; - for (let i = 0; i < rc.length; i++) { - tmp.push(rc[i]); - if (tmp.length === t) { - res.push(tmp); - tmp = []; - } - } - return res; -} -exports.splitConstants = splitConstants; -function poseidon(opts) { - const { t, Fp, rounds, sboxFn, reversePartialPowIdx } = validateOpts(opts); - const halfRoundsFull = Math.floor(opts.roundsFull / 2); - const partialIdx = reversePartialPowIdx ? t - 1 : 0; - const poseidonRound = (values, isFull, idx) => { - values = values.map((i, j) => Fp.add(i, opts.roundConstants[idx][j])); - if (isFull) - values = values.map((i) => sboxFn(i)); - else - values[partialIdx] = sboxFn(values[partialIdx]); - // Matrix multiplication - values = opts.mds.map((i) => i.reduce((acc, i, j) => Fp.add(acc, Fp.mulN(i, values[j])), Fp.ZERO)); - return values; - }; - const poseidonHash = function poseidonHash(values) { - if (!Array.isArray(values) || values.length !== t) - throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`); - values = values.map((i) => { - if (typeof i !== 'bigint') - throw new Error(`Poseidon: wrong value=${i} (${typeof i})`); - return Fp.create(i); - }); - let round = 0; - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) - values = poseidonRound(values, true, round++); - // Apply r_p partial rounds. - for (let i = 0; i < opts.roundsPartial; i++) - values = poseidonRound(values, false, round++); - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) - values = poseidonRound(values, true, round++); - if (round !== rounds) - throw new Error(`Poseidon: wrong number of rounds: last round=${round}, total=${rounds}`); - return values; - }; - // For verification in tests - poseidonHash.roundConstants = opts.roundConstants; - return poseidonHash; -} -exports.poseidon = poseidon; -//# sourceMappingURL=poseidon.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js.map deleted file mode 100644 index 422866db..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/poseidon.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"poseidon.js","sourceRoot":"","sources":["../src/abstract/poseidon.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,sFAAsF;AACtF,6CAA4D;AAc5D,SAAgB,YAAY,CAAC,IAAkB;IAC7C,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IACpB,IAAA,0BAAa,EAAC,EAAE,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,eAAe,CAAU,EAAE;QAC7D,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC/D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KAClF;IACD,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,oBAAoB,KAAK,SAAS;QAC3F,MAAM,IAAI,KAAK,CAAC,gDAAgD,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC/F,iDAAiD;IACjD,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAC/B,IAAI,SAAS,KAAK,SAAS;QAAE,SAAS,GAAG,CAAC,CAAC;IAC3C,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAE3D,MAAM,UAAU,GAAG,MAA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,EAAE,CAAC,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5F,2BAA2B;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAEvF,IAAI,KAAK,KAAK,MAAM;YAClB,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,WAAW,MAAM,EAAE,CAAC,CAAC;QAC5F,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,4BAA4B;IAC5B,YAAY,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAClD,OAAO,YAAY,CAAC;AACtB,CAAC;AArCD,4BAqCC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts deleted file mode 100644 index 2842612e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -export type Hex = Uint8Array | string; -export type PrivKey = Hex | bigint; -export type CHash = { - (message: Uint8Array | string): Uint8Array; - blockLen: number; - outputLen: number; - create(opts?: { - dkLen?: number; - }): any; -}; -export type FHash = (message: Uint8Array | string) => Uint8Array; -/** - * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' - */ -export declare function bytesToHex(bytes: Uint8Array): string; -export declare function numberToHexUnpadded(num: number | bigint): string; -export declare function hexToNumber(hex: string): bigint; -/** - * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) - */ -export declare function hexToBytes(hex: string): Uint8Array; -export declare function bytesToNumberBE(bytes: Uint8Array): bigint; -export declare function bytesToNumberLE(bytes: Uint8Array): bigint; -export declare function numberToBytesBE(n: number | bigint, len: number): Uint8Array; -export declare function numberToBytesLE(n: number | bigint, len: number): Uint8Array; -export declare function numberToVarBytesBE(n: number | bigint): Uint8Array; -/** - * Takes hex string or Uint8Array, converts to Uint8Array. - * Validates output length. - * Will throw error for other types. - * @param title descriptive title for an error e.g. 'private key' - * @param hex hex string or Uint8Array - * @param expectedLength optional, will compare to result array's length - * @returns - */ -export declare function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array; -/** - * Copies several Uint8Arrays into one. - */ -export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; -export declare function equalBytes(b1: Uint8Array, b2: Uint8Array): boolean; -/** - * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) - */ -export declare function utf8ToBytes(str: string): Uint8Array; -/** - * Calculates amount of bits in a bigint. - * Same as `n.toString(2).length` - */ -export declare function bitLen(n: bigint): number; -/** - * Gets single bit at position. - * NOTE: first bit position is 0 (same as arrays) - * Same as `!!+Array.from(n.toString(2)).reverse()[pos]` - */ -export declare function bitGet(n: bigint, pos: number): bigint; -/** - * Sets single bit at position. - */ -export declare const bitSet: (n: bigint, pos: number, value: boolean) => bigint; -/** - * Calculate mask for N bits. Not using ** operator with bigints because of old engines. - * Same as BigInt(`0b${Array(i).fill('1').join('')}`) - */ -export declare const bitMask: (n: number) => bigint; -type Pred = (v: Uint8Array) => T | undefined; -/** - * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - * @returns function that will call DRBG until 2nd arg returns something meaningful - * @example - * const drbg = createHmacDRBG(32, 32, hmac); - * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined - */ -export declare function createHmacDrbg(hashLen: number, qByteLen: number, hmacFn: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array): (seed: Uint8Array, predicate: Pred) => T; -declare const validatorFns: { - readonly bigint: (val: any) => boolean; - readonly function: (val: any) => boolean; - readonly boolean: (val: any) => boolean; - readonly string: (val: any) => boolean; - readonly isSafeInteger: (val: any) => boolean; - readonly array: (val: any) => boolean; - readonly field: (val: any, object: any) => any; - readonly hash: (val: any) => boolean; -}; -type Validator = keyof typeof validatorFns; -type ValMap> = { - [K in keyof T]?: Validator; -}; -export declare function validateObject>(object: T, validators: ValMap, optValidators?: ValMap): T; -export {}; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts.map deleted file mode 100644 index 706d6513..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/abstract/utils.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC;CACxC,CAAC;AACF,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC;AAGjE;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQpD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAalD;AAGD,wBAAgB,eAA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,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,KAAK,UAAU,GACjE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CA4C7C;AAID,QAAA,MAAM,YAAY;2BACF,GAAG;6BACD,GAAG;4BACJ,GAAG;2BACJ,GAAG;kCACI,GAAG;0BACX,GAAG;0BACH,GAAG,UAAU,GAAG;yBACjB,GAAG;CACP,CAAC;AACX,KAAK,SAAS,GAAG,MAAM,OAAO,YAAY,CAAC;AAC3C,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS;CAAE,CAAC;AAG5E,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EACrB,aAAa,GAAE,MAAM,CAAC,CAAC,CAAM,KAkB9B"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js deleted file mode 100644 index 60774c4b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js +++ /dev/null @@ -1,287 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validateObject = exports.createHmacDrbg = exports.bitMask = exports.bitSet = exports.bitGet = exports.bitLen = exports.utf8ToBytes = exports.equalBytes = exports.concatBytes = exports.ensureBytes = exports.numberToVarBytesBE = exports.numberToBytesLE = exports.numberToBytesBE = exports.bytesToNumberLE = exports.bytesToNumberBE = exports.hexToBytes = exports.hexToNumber = exports.numberToHexUnpadded = exports.bytesToHex = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// 100 lines of code in the file are duplicated from noble-hashes (utils). -// This is OK: `abstract` directory does not use noble-hashes. -// User may opt-in into using different hashing library. This way, noble-hashes -// won't be included into their bundle. -const _0n = BigInt(0); -const _1n = BigInt(1); -const _2n = BigInt(2); -const u8a = (a) => a instanceof Uint8Array; -const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0')); -/** - * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' - */ -function bytesToHex(bytes) { - if (!u8a(bytes)) - throw new Error('Uint8Array expected'); - // pre-caching improves the speed 6x - let hex = ''; - for (let i = 0; i < bytes.length; i++) { - hex += hexes[bytes[i]]; - } - return hex; -} -exports.bytesToHex = bytesToHex; -function numberToHexUnpadded(num) { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; -} -exports.numberToHexUnpadded = numberToHexUnpadded; -function hexToNumber(hex) { - if (typeof hex !== 'string') - throw new Error('hex string expected, got ' + typeof hex); - // Big Endian - return BigInt(hex === '' ? '0' : `0x${hex}`); -} -exports.hexToNumber = hexToNumber; -/** - * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) - */ -function hexToBytes(hex) { - if (typeof hex !== 'string') - throw new Error('hex string expected, got ' + typeof hex); - const len = hex.length; - if (len % 2) - throw new Error('padded hex string expected, got unpadded hex of length ' + len); - const array = new Uint8Array(len / 2); - for (let i = 0; i < array.length; i++) { - const j = i * 2; - const hexByte = hex.slice(j, j + 2); - const byte = Number.parseInt(hexByte, 16); - if (Number.isNaN(byte) || byte < 0) - throw new Error('Invalid byte sequence'); - array[i] = byte; - } - return array; -} -exports.hexToBytes = hexToBytes; -// BE: Big Endian, LE: Little Endian -function bytesToNumberBE(bytes) { - return hexToNumber(bytesToHex(bytes)); -} -exports.bytesToNumberBE = bytesToNumberBE; -function bytesToNumberLE(bytes) { - if (!u8a(bytes)) - throw new Error('Uint8Array expected'); - return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); -} -exports.bytesToNumberLE = bytesToNumberLE; -function numberToBytesBE(n, len) { - return hexToBytes(n.toString(16).padStart(len * 2, '0')); -} -exports.numberToBytesBE = numberToBytesBE; -function numberToBytesLE(n, len) { - return numberToBytesBE(n, len).reverse(); -} -exports.numberToBytesLE = numberToBytesLE; -// Unpadded, rarely used -function numberToVarBytesBE(n) { - return hexToBytes(numberToHexUnpadded(n)); -} -exports.numberToVarBytesBE = numberToVarBytesBE; -/** - * Takes hex string or Uint8Array, converts to Uint8Array. - * Validates output length. - * Will throw error for other types. - * @param title descriptive title for an error e.g. 'private key' - * @param hex hex string or Uint8Array - * @param expectedLength optional, will compare to result array's length - * @returns - */ -function ensureBytes(title, hex, expectedLength) { - let res; - if (typeof hex === 'string') { - try { - res = hexToBytes(hex); - } - catch (e) { - throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`); - } - } - else if (u8a(hex)) { - // Uint8Array.from() instead of hash.slice() because node.js Buffer - // is instance of Uint8Array, and its slice() creates **mutable** copy - res = Uint8Array.from(hex); - } - else { - throw new Error(`${title} must be hex string or Uint8Array`); - } - const len = res.length; - if (typeof expectedLength === 'number' && len !== expectedLength) - throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`); - return res; -} -exports.ensureBytes = ensureBytes; -/** - * Copies several Uint8Arrays into one. - */ -function concatBytes(...arrays) { - const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0)); - let pad = 0; // walk through each item, ensure they have proper type - arrays.forEach((a) => { - if (!u8a(a)) - throw new Error('Uint8Array expected'); - r.set(a, pad); - pad += a.length; - }); - return r; -} -exports.concatBytes = concatBytes; -function equalBytes(b1, b2) { - // We don't care about timing attacks here - if (b1.length !== b2.length) - return false; - for (let i = 0; i < b1.length; i++) - if (b1[i] !== b2[i]) - return false; - return true; -} -exports.equalBytes = equalBytes; -/** - * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) - */ -function utf8ToBytes(str) { - if (typeof str !== 'string') - throw new Error(`utf8ToBytes expected string, got ${typeof str}`); - return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 -} -exports.utf8ToBytes = utf8ToBytes; -// Bit operations -/** - * Calculates amount of bits in a bigint. - * Same as `n.toString(2).length` - */ -function bitLen(n) { - let len; - for (len = 0; n > _0n; n >>= _1n, len += 1) - ; - return len; -} -exports.bitLen = bitLen; -/** - * Gets single bit at position. - * NOTE: first bit position is 0 (same as arrays) - * Same as `!!+Array.from(n.toString(2)).reverse()[pos]` - */ -function bitGet(n, pos) { - return (n >> BigInt(pos)) & _1n; -} -exports.bitGet = bitGet; -/** - * Sets single bit at position. - */ -const bitSet = (n, pos, value) => { - return n | ((value ? _1n : _0n) << BigInt(pos)); -}; -exports.bitSet = bitSet; -/** - * Calculate mask for N bits. Not using ** operator with bigints because of old engines. - * Same as BigInt(`0b${Array(i).fill('1').join('')}`) - */ -const bitMask = (n) => (_2n << BigInt(n - 1)) - _1n; -exports.bitMask = bitMask; -// DRBG -const u8n = (data) => new Uint8Array(data); // creates Uint8Array -const u8fr = (arr) => Uint8Array.from(arr); // another shortcut -/** - * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - * @returns function that will call DRBG until 2nd arg returns something meaningful - * @example - * const drbg = createHmacDRBG(32, 32, hmac); - * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined - */ -function createHmacDrbg(hashLen, qByteLen, hmacFn) { - if (typeof hashLen !== 'number' || hashLen < 2) - throw new Error('hashLen must be a number'); - if (typeof qByteLen !== 'number' || qByteLen < 2) - throw new Error('qByteLen must be a number'); - if (typeof hmacFn !== 'function') - throw new Error('hmacFn must be a function'); - // Step B, Step C: set hashLen to 8*ceil(hlen/8) - let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same - let i = 0; // Iterations counter, will throw when over 1000 - const reset = () => { - v.fill(1); - k.fill(0); - i = 0; - }; - const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values) - const reseed = (seed = u8n()) => { - // HMAC-DRBG reseed() function. Steps D-G - k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed) - v = h(); // v = hmac(k || v) - if (seed.length === 0) - return; - k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed) - v = h(); // v = hmac(k || v) - }; - const gen = () => { - // HMAC-DRBG generate() function - if (i++ >= 1000) - throw new Error('drbg: tried 1000 values'); - let len = 0; - const out = []; - while (len < qByteLen) { - v = h(); - const sl = v.slice(); - out.push(sl); - len += v.length; - } - return concatBytes(...out); - }; - const genUntil = (seed, pred) => { - reset(); - reseed(seed); // Steps D-G - let res = undefined; // Step H: grind until k is in [1..n-1] - while (!(res = pred(gen()))) - reseed(); - reset(); - return res; - }; - return genUntil; -} -exports.createHmacDrbg = createHmacDrbg; -// Validating curves and fields -const validatorFns = { - bigint: (val) => typeof val === 'bigint', - function: (val) => typeof val === 'function', - boolean: (val) => typeof val === 'boolean', - string: (val) => typeof val === 'string', - isSafeInteger: (val) => Number.isSafeInteger(val), - array: (val) => Array.isArray(val), - field: (val, object) => object.Fp.isValid(val), - hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen), -}; -// type Record = { [P in K]: T; } -function validateObject(object, validators, optValidators = {}) { - const checkField = (fieldName, type, isOptional) => { - const checkVal = validatorFns[type]; - if (typeof checkVal !== 'function') - throw new Error(`Invalid validator "${type}", expected function`); - const val = object[fieldName]; - if (isOptional && val === undefined) - return; - if (!checkVal(val, object)) { - throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`); - } - }; - for (const [fieldName, type] of Object.entries(validators)) - checkField(fieldName, type, false); - for (const [fieldName, type] of Object.entries(optValidators)) - checkField(fieldName, type, true); - return object; -} -exports.validateObject = validateObject; -// validate type tests -// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 }; -// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok! -// // Should fail type-check -// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' }); -// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' }); -// const z3 = validateObject(o, { test: 'boolean', z: 'bug' }); -// const z4 = validateObject(o, { a: 'boolean', z: 'bug' }); -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js.map deleted file mode 100644 index c60d8a83..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/abstract/utils.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,0EAA0E;AAC1E,8DAA8D;AAC9D,+EAA+E;AAC/E,uCAAuC;AACvC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,CAAC,CAAM,EAAmB,EAAE,CAAC,CAAC,YAAY,UAAU,CAAC;AAWjE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACrF;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAiB;IAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxD,oCAAoC;IACpC,IAAI,G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AC,GAAG,CAAC,SAAS,CAAC;CAC5E,CAAC;AAGX,wEAAwE;AAExE,SAAgB,cAAc,CAC5B,MAAS,EACT,UAAqB,EACrB,gBAA2B,EAAE;IAE7B,MAAM,UAAU,GAAG,CAAC,SAAkB,EAAE,IAAe,EAAE,UAAmB,EAAE,EAAE;QAC9E,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,QAAQ,KAAK,UAAU;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,sBAAsB,CAAC,CAAC;QAEpE,MAAM,GAAG,GAAG,MAAM,CAAC,SAAgC,CAAC,CAAC;QACrD,IAAI,UAAU,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO;QAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,OAAO,GAAG,eAAe,IAAI,EAAE,CAC9E,CAAC;SACH;IACH,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,UAAU,CAAC,SAAS,EAAE,IAAK,EAAE,KAAK,CAAC,CAAC;IAChG,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;QAAE,UAAU,CAAC,SAAS,EAAE,IAAK,EAAE,IAAI,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,wCAqBC;AACD,sBAAsB;AACtB,uEAAuE;AACvE,gFAAgF;AAChF,4BAA4B;AAC5B,2DAA2D;AAC3D,qEAAqE;AACrE,+DAA+D;AAC/D,4DAA4D"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts deleted file mode 100644 index 53449c53..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts +++ /dev/null @@ -1,240 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import * as mod from './modular.js'; -import * as ut from './utils.js'; -import { CHash, Hex, PrivKey } from './utils.js'; -import { Group, GroupConstructor, BasicCurve, AffinePoint } from './curve.js'; -export type { AffinePoint }; -type HmacFnSync = (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; -type EndomorphismOpts = { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; -}; -export type BasicWCurve = BasicCurve & { - a: T; - b: T; - allowedPrivateKeyLengths?: readonly number[]; - wrapPrivateKey?: boolean; - endo?: EndomorphismOpts; - isTorsionFree?: (c: ProjConstructor, point: ProjPointType) => boolean; - clearCofactor?: (c: ProjConstructor, point: ProjPointType) => ProjPointType; -}; -type Entropy = Hex | true; -export type SignOpts = { - lowS?: boolean; - extraEntropy?: Entropy; - prehash?: boolean; -}; -export type VerOpts = { - lowS?: boolean; - prehash?: boolean; -}; -/** - * ### Design rationale for types - * - * * Interaction between classes from different curves should fail: - * `k256.Point.BASE.add(p256.Point.BASE)` - * * For this purpose we want to use `instanceof` operator, which is fast and works during runtime - * * Different calls of `curve()` would return different classes - - * `curve(params) !== curve(params)`: if somebody decided to monkey-patch their curve, - * it won't affect others - * - * TypeScript can't infer types for classes created inside a function. Classes is one instance of nominative types in TypeScript and interfaces only check for shape, so it's hard to create unique type for every function call. - * - * We can use generic types via some param, like curve opts, but that would: - * 1. Enable interaction between `curve(params)` and `curve(params)` (curves of same params) - * which is hard to debug. - * 2. Params can be generic and we can't enforce them to be constant value: - * if somebody creates curve from non-constant params, - * it would be allowed to interact with other curves with non-constant params - * - * TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol - */ -export interface ProjPointType extends Group> { - readonly px: T; - readonly py: T; - readonly pz: T; - get x(): T; - get y(): T; - multiply(scalar: bigint): ProjPointType; - toAffine(iz?: T): AffinePoint; - isTorsionFree(): boolean; - clearCofactor(): ProjPointType; - assertValidity(): void; - hasEvenY(): boolean; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; - multiplyUnsafe(scalar: bigint): ProjPointType; - multiplyAndAddUnsafe(Q: ProjPointType, a: bigint, b: bigint): ProjPointType | undefined; - _setWindowSize(windowSize: number): void; -} -export interface ProjConstructor extends GroupConstructor> { - new (x: T, y: T, z: T): ProjPointType; - fromAffine(p: AffinePoint): ProjPointType; - fromHex(hex: Hex): ProjPointType; - fromPrivateKey(privateKey: PrivKey): ProjPointType; - normalizeZ(points: ProjPointType[]): ProjPointType[]; -} -export type CurvePointsType = BasicWCurve & { - fromBytes?: (bytes: Uint8Array) => AffinePoint; - toBytes?: (c: ProjConstructor, point: ProjPointType, isCompressed: boolean) => Uint8Array; -}; -export type CurvePointsRes = { - ProjectivePoint: ProjConstructor; - normPrivateKeyToScalar: (key: PrivKey) => bigint; - weierstrassEquation: (x: T) => T; - isWithinCurveOrder: (num: bigint) => boolean; -}; -export declare const DER: { - Err: { - new (m?: string): { - name: string; - message: string; - stack?: string | undefined; - }; - }; - _parseInt(data: Uint8Array): { - d: bigint; - l: Uint8Array; - }; - toSig(hex: string | Uint8Array): { - r: bigint; - s: bigint; - }; - hexFromSig(sig: { - r: bigint; - s: bigint; - }): string; -}; -export declare function weierstrassPoints(opts: CurvePointsType): { - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: mod.IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: T; - readonly Gy: T; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: T; - readonly b: T; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: EndomorphismOpts | undefined; - readonly isTorsionFree?: ((c: ProjConstructor, point: ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: ProjConstructor, point: ProjPointType) => ProjPointType) | undefined; - readonly fromBytes?: ((bytes: Uint8Array) => AffinePoint) | undefined; - readonly toBytes?: ((c: ProjConstructor, point: ProjPointType, isCompressed: boolean) => Uint8Array) | undefined; - readonly p: bigint; - }>; - ProjectivePoint: ProjConstructor; - normPrivateKeyToScalar: (key: PrivKey) => bigint; - weierstrassEquation: (x: T) => T; - isWithinCurveOrder: (num: bigint) => boolean; -}; -export interface SignatureType { - readonly r: bigint; - readonly s: bigint; - readonly recovery?: number; - assertValidity(): void; - addRecoveryBit(recovery: number): RecoveredSignatureType; - hasHighS(): boolean; - normalizeS(): SignatureType; - recoverPublicKey(msgHash: Hex): ProjPointType; - toCompactRawBytes(): Uint8Array; - toCompactHex(): string; - toDERRawBytes(isCompressed?: boolean): Uint8Array; - toDERHex(isCompressed?: boolean): string; -} -export type RecoveredSignatureType = SignatureType & { - readonly recovery: number; -}; -export type SignatureConstructor = { - new (r: bigint, s: bigint): SignatureType; - fromCompact(hex: Hex): SignatureType; - fromDER(hex: Hex): SignatureType; -}; -type SignatureLike = { - r: bigint; - s: bigint; -}; -export type PubKey = Hex | ProjPointType; -export type CurveType = BasicWCurve & { - hash: CHash; - hmac: HmacFnSync; - randomBytes: (bytesLength?: number) => Uint8Array; - lowS?: boolean; - bits2int?: (bytes: Uint8Array) => bigint; - bits2int_modN?: (bytes: Uint8Array) => bigint; -}; -declare function validateOpts(curve: CurveType): Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: mod.IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: EndomorphismOpts | undefined; - readonly isTorsionFree?: ((c: ProjConstructor, point: ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: ProjConstructor, point: ProjPointType) => ProjPointType) | undefined; - readonly hash: ut.CHash; - readonly hmac: HmacFnSync; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; -}>; -export type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array; - getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean) => Uint8Array; - sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => RecoveredSignatureType; - verify: (signature: Hex | SignatureLike, msgHash: Hex, publicKey: Hex, opts?: VerOpts) => boolean; - ProjectivePoint: ProjConstructor; - Signature: SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: PrivKey) => bigint; - isValidPrivateKey(privateKey: PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number, point?: ProjPointType) => ProjPointType; - }; -}; -export declare function weierstrass(curveDef: CurveType): CurveFn; -/** - * Implementation of the Shallue and van de Woestijne method for any weierstrass curve. - * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular. - * b = True and y = sqrt(u / v) if (u / v) is square in F, and - * b = False and y = sqrt(Z * (u / v)) otherwise. - * @param Fp - * @param Z - * @returns - */ -export declare function SWUFpSqrtRatio(Fp: mod.IField, Z: T): (u: T, v: T) => { - isValid: boolean; - value: T; -}; -/** - * From draft-irtf-cfrg-hash-to-curve-16 - */ -export declare function mapToCurveSimpleSWU(Fp: mod.IField, opts: { - A: T; - B: T; - Z: T; -}): (u: T) => { - x: T; - y: T; -}; -//# sourceMappingURL=weierstrass.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts.map deleted file mode 100644 index ef268906..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weierstrass.d.ts","sourceRoot":"","sources":["../src/abstract/weierstrass.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAQ,UAAU,EAAiB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnG,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,KAAK,UAAU,CAAC;AAC7E,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACxF,CAAC;AACF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;IAE3C,CAAC,EAAE,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,CAAC;IAGL,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAGxB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,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,OASU,CAAC;OAAQ,CAAC;OAAK,CAAC;EA8B5B"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js deleted file mode 100644 index b24bfbfd..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js +++ /dev/null @@ -1,1061 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.mapToCurveSimpleSWU = exports.SWUFpSqrtRatio = exports.weierstrass = exports.weierstrassPoints = exports.DER = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Short Weierstrass curve. The formula is: y² = x³ + ax + b -const mod = require("./modular.js"); -const ut = require("./utils.js"); -const utils_js_1 = require("./utils.js"); -const curve_js_1 = require("./curve.js"); -function validatePointOpts(curve) { - const opts = (0, curve_js_1.validateBasic)(curve); - ut.validateObject(opts, { - a: 'field', - b: 'field', - }, { - allowedPrivateKeyLengths: 'array', - wrapPrivateKey: 'boolean', - isTorsionFree: 'function', - clearCofactor: 'function', - allowInfinityPoint: 'boolean', - fromBytes: 'function', - toBytes: 'function', - }); - const { endo, Fp, a } = opts; - if (endo) { - if (!Fp.eql(a, Fp.ZERO)) { - throw new Error('Endomorphism can only be defined for Koblitz curves that have a=0'); - } - if (typeof endo !== 'object' || - typeof endo.beta !== 'bigint' || - typeof endo.splitScalar !== 'function') { - throw new Error('Expected endomorphism with beta: bigint and splitScalar: function'); - } - } - return Object.freeze({ ...opts }); -} -// ASN.1 DER encoding utilities -const { bytesToNumberBE: b2n, hexToBytes: h2b } = ut; -exports.DER = { - // asn.1 DER encoding utils - Err: class DERErr extends Error { - constructor(m = '') { - super(m); - } - }, - _parseInt(data) { - const { Err: E } = exports.DER; - if (data.length < 2 || data[0] !== 0x02) - throw new E('Invalid signature integer tag'); - const len = data[1]; - const res = data.subarray(2, len + 2); - if (!len || res.length !== len) - throw new E('Invalid signature integer: wrong length'); - // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, - // since we always use positive integers here. It must always be empty: - // - add zero byte if exists - // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) - if (res[0] & 0b10000000) - throw new E('Invalid signature integer: negative'); - if (res[0] === 0x00 && !(res[1] & 0b10000000)) - throw new E('Invalid signature integer: unnecessary leading zero'); - return { d: b2n(res), l: data.subarray(len + 2) }; // d is data, l is left - }, - toSig(hex) { - // parse DER signature - const { Err: E } = exports.DER; - const data = typeof hex === 'string' ? h2b(hex) : hex; - if (!(data instanceof Uint8Array)) - throw new Error('ui8a expected'); - let l = data.length; - if (l < 2 || data[0] != 0x30) - throw new E('Invalid signature tag'); - if (data[1] !== l - 2) - throw new E('Invalid signature: incorrect length'); - const { d: r, l: sBytes } = exports.DER._parseInt(data.subarray(2)); - const { d: s, l: rBytesLeft } = exports.DER._parseInt(sBytes); - if (rBytesLeft.length) - throw new E('Invalid signature: left bytes after parsing'); - return { r, s }; - }, - hexFromSig(sig) { - // Add leading zero if first byte has negative bit enabled. More details in '_parseInt' - const slice = (s) => (Number.parseInt(s[0], 16) & 0b1000 ? '00' + s : s); - const h = (num) => { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; - }; - const s = slice(h(sig.s)); - const r = slice(h(sig.r)); - const shl = s.length / 2; - const rhl = r.length / 2; - const sl = h(shl); - const rl = h(rhl); - return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`; - }, -}; -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); -function weierstrassPoints(opts) { - const CURVE = validatePointOpts(opts); - const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ - const toBytes = CURVE.toBytes || - ((c, point, isCompressed) => { - const a = point.toAffine(); - return ut.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y)); - }); - const fromBytes = CURVE.fromBytes || - ((bytes) => { - // const head = bytes[0]; - const tail = bytes.subarray(1); - // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported'); - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - }); - /** - * y² = x³ + ax + b: Short weierstrass curve formula - * @returns y² - */ - function weierstrassEquation(x) { - const { a, b } = CURVE; - const x2 = Fp.sqr(x); // x * x - const x3 = Fp.mul(x2, x); // x2 * x - return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b - } - // Validate whether the passed curve params are valid. - // We check if curve equation works for generator point. - // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381. - // ProjectivePoint class has not been initialized yet. - if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx))) - throw new Error('bad generator point: equation left != right'); - // Valid group elements reside in range 1..n-1 - function isWithinCurveOrder(num) { - return typeof num === 'bigint' && _0n < num && num < CURVE.n; - } - function assertGE(num) { - if (!isWithinCurveOrder(num)) - throw new Error('Expected valid bigint: 0 < bigint < curve.n'); - } - // Validates if priv key is valid and converts it to bigint. - // Supports options allowedPrivateKeyLengths and wrapPrivateKey. - function normPrivateKeyToScalar(key) { - const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE; - if (lengths && typeof key !== 'bigint') { - if (key instanceof Uint8Array) - key = ut.bytesToHex(key); - // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes - if (typeof key !== 'string' || !lengths.includes(key.length)) - throw new Error('Invalid key'); - key = key.padStart(nByteLength * 2, '0'); - } - let num; - try { - num = - typeof key === 'bigint' - ? key - : ut.bytesToNumberBE((0, utils_js_1.ensureBytes)('private key', key, nByteLength)); - } - catch (error) { - throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`); - } - if (wrapPrivateKey) - num = mod.mod(num, n); // disabled by default, enabled for BLS - assertGE(num); // num in range [1..N-1] - return num; - } - const pointPrecomputes = new Map(); - function assertPrjPoint(other) { - if (!(other instanceof Point)) - throw new Error('ProjectivePoint expected'); - } - /** - * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z) - * Default Point works in 2d / affine coordinates: (x, y) - * We're doing calculations in projective, because its operations don't require costly inversion. - */ - class Point { - constructor(px, py, pz) { - this.px = px; - this.py = py; - this.pz = pz; - if (px == null || !Fp.isValid(px)) - throw new Error('x required'); - if (py == null || !Fp.isValid(py)) - throw new Error('y required'); - if (pz == null || !Fp.isValid(pz)) - throw new Error('z required'); - } - // Does not validate if the point is on-curve. - // Use fromHex instead, or call assertValidity() later. - static fromAffine(p) { - const { x, y } = p || {}; - if (!p || !Fp.isValid(x) || !Fp.isValid(y)) - throw new Error('invalid affine point'); - if (p instanceof Point) - throw new Error('projective point not allowed'); - const is0 = (i) => Fp.eql(i, Fp.ZERO); - // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0) - if (is0(x) && is0(y)) - return Point.ZERO; - return new Point(x, y, Fp.ONE); - } - get x() { - return this.toAffine().x; - } - get y() { - return this.toAffine().y; - } - /** - * Takes a bunch of Projective Points but executes only one - * inversion on all of them. Inversion is very slow operation, - * so this improves performance massively. - * Optimization: converts a list of projective points to a list of identical points with Z=1. - */ - static normalizeZ(points) { - const toInv = Fp.invertBatch(points.map((p) => p.pz)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - /** - * Converts hash string or Uint8Array to Point. - * @param hex short/long ECDSA hex - */ - static fromHex(hex) { - const P = Point.fromAffine(fromBytes((0, utils_js_1.ensureBytes)('pointHex', hex))); - P.assertValidity(); - return P; - } - // Multiplies generator point by privateKey. - static fromPrivateKey(privateKey) { - return Point.BASE.multiply(normPrivateKeyToScalar(privateKey)); - } - // "Private method", don't use it directly - _setWindowSize(windowSize) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - // A point on curve is valid if it conforms to equation. - assertValidity() { - // Zero is valid point too! - if (this.is0()) { - if (CURVE.allowInfinityPoint) - return; - throw new Error('bad point: ZERO'); - } - // Some 3rd-party test vectors require different wording between here & `fromCompressedHex` - const { x, y } = this.toAffine(); - // Check if x, y are valid field elements - if (!Fp.isValid(x) || !Fp.isValid(y)) - throw new Error('bad point: x or y not FE'); - const left = Fp.sqr(y); // y² - const right = weierstrassEquation(x); // x³ + ax + b - if (!Fp.eql(left, right)) - throw new Error('bad point: equation left != right'); - if (!this.isTorsionFree()) - throw new Error('bad point: not in prime-order subgroup'); - } - hasEvenY() { - const { y } = this.toAffine(); - if (Fp.isOdd) - return !Fp.isOdd(y); - throw new Error("Field doesn't support isOdd"); - } - /** - * Compare one point to another. - */ - equals(other) { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1)); - const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1)); - return U1 && U2; - } - /** - * Flips point to one corresponding to (x, -y) in Affine coordinates. - */ - negate() { - return new Point(this.px, Fp.neg(this.py), this.pz); - } - // Renes-Costello-Batina exception-free doubling formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 3 - // Cost: 8M + 3S + 3*a + 2*b3 + 15add. - double() { - const { a, b } = CURVE; - const b3 = Fp.mul(b, _3n); - const { px: X1, py: Y1, pz: Z1 } = this; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - let t0 = Fp.mul(X1, X1); // step 1 - let t1 = Fp.mul(Y1, Y1); - let t2 = Fp.mul(Z1, Z1); - let t3 = Fp.mul(X1, Y1); - t3 = Fp.add(t3, t3); // step 5 - Z3 = Fp.mul(X1, Z1); - Z3 = Fp.add(Z3, Z3); - X3 = Fp.mul(a, Z3); - Y3 = Fp.mul(b3, t2); - Y3 = Fp.add(X3, Y3); // step 10 - X3 = Fp.sub(t1, Y3); - Y3 = Fp.add(t1, Y3); - Y3 = Fp.mul(X3, Y3); - X3 = Fp.mul(t3, X3); - Z3 = Fp.mul(b3, Z3); // step 15 - t2 = Fp.mul(a, t2); - t3 = Fp.sub(t0, t2); - t3 = Fp.mul(a, t3); - t3 = Fp.add(t3, Z3); - Z3 = Fp.add(t0, t0); // step 20 - t0 = Fp.add(Z3, t0); - t0 = Fp.add(t0, t2); - t0 = Fp.mul(t0, t3); - Y3 = Fp.add(Y3, t0); - t2 = Fp.mul(Y1, Z1); // step 25 - t2 = Fp.add(t2, t2); - t0 = Fp.mul(t2, t3); - X3 = Fp.sub(X3, t0); - Z3 = Fp.mul(t2, t1); - Z3 = Fp.add(Z3, Z3); // step 30 - Z3 = Fp.add(Z3, Z3); - return new Point(X3, Y3, Z3); - } - // Renes-Costello-Batina exception-free addition formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 1 - // Cost: 12M + 0S + 3*a + 3*b3 + 23add. - add(other) { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - const a = CURVE.a; - const b3 = Fp.mul(CURVE.b, _3n); - let t0 = Fp.mul(X1, X2); // step 1 - let t1 = Fp.mul(Y1, Y2); - let t2 = Fp.mul(Z1, Z2); - let t3 = Fp.add(X1, Y1); - let t4 = Fp.add(X2, Y2); // step 5 - t3 = Fp.mul(t3, t4); - t4 = Fp.add(t0, t1); - t3 = Fp.sub(t3, t4); - t4 = Fp.add(X1, Z1); - let t5 = Fp.add(X2, Z2); // step 10 - t4 = Fp.mul(t4, t5); - t5 = Fp.add(t0, t2); - t4 = Fp.sub(t4, t5); - t5 = Fp.add(Y1, Z1); - X3 = Fp.add(Y2, Z2); // step 15 - t5 = Fp.mul(t5, X3); - X3 = Fp.add(t1, t2); - t5 = Fp.sub(t5, X3); - Z3 = Fp.mul(a, t4); - X3 = Fp.mul(b3, t2); // step 20 - Z3 = Fp.add(X3, Z3); - X3 = Fp.sub(t1, Z3); - Z3 = Fp.add(t1, Z3); - Y3 = Fp.mul(X3, Z3); - t1 = Fp.add(t0, t0); // step 25 - t1 = Fp.add(t1, t0); - t2 = Fp.mul(a, t2); - t4 = Fp.mul(b3, t4); - t1 = Fp.add(t1, t2); - t2 = Fp.sub(t0, t2); // step 30 - t2 = Fp.mul(a, t2); - t4 = Fp.add(t4, t2); - t0 = Fp.mul(t1, t4); - Y3 = Fp.add(Y3, t0); - t0 = Fp.mul(t5, t4); // step 35 - X3 = Fp.mul(t3, X3); - X3 = Fp.sub(X3, t0); - t0 = Fp.mul(t3, t1); - Z3 = Fp.mul(t5, Z3); - Z3 = Fp.add(Z3, t0); // step 40 - return new Point(X3, Y3, Z3); - } - subtract(other) { - return this.add(other.negate()); - } - is0() { - return this.equals(Point.ZERO); - } - wNAF(n) { - return wnaf.wNAFCached(this, pointPrecomputes, n, (comp) => { - const toInv = Fp.invertBatch(comp.map((p) => p.pz)); - return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - }); - } - /** - * Non-constant-time multiplication. Uses double-and-add algorithm. - * It's faster, but should only be used when you don't care about - * an exposed private key e.g. sig verification, which works over *public* keys. - */ - multiplyUnsafe(n) { - const I = Point.ZERO; - if (n === _0n) - return I; - assertGE(n); // Will throw on 0 - if (n === _1n) - return this; - const { endo } = CURVE; - if (!endo) - return wnaf.unsafeLadder(this, n); - // Apply endomorphism - let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let k1p = I; - let k2p = I; - let d = this; - while (k1 > _0n || k2 > _0n) { - if (k1 & _1n) - k1p = k1p.add(d); - if (k2 & _1n) - k2p = k2p.add(d); - d = d.double(); - k1 >>= _1n; - k2 >>= _1n; - } - if (k1neg) - k1p = k1p.negate(); - if (k2neg) - k2p = k2p.negate(); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - return k1p.add(k2p); - } - /** - * Constant time multiplication. - * Uses wNAF method. Windowed method may be 10% faster, - * but takes 2x longer to generate and consumes 2x memory. - * Uses precomputes when available. - * Uses endomorphism for Koblitz curves. - * @param scalar by which the point would be multiplied - * @returns New point - */ - multiply(scalar) { - assertGE(scalar); - let n = scalar; - let point, fake; // Fake point is used to const-time mult - const { endo } = CURVE; - if (endo) { - const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let { p: k1p, f: f1p } = this.wNAF(k1); - let { p: k2p, f: f2p } = this.wNAF(k2); - k1p = wnaf.constTimeNegate(k1neg, k1p); - k2p = wnaf.constTimeNegate(k2neg, k2p); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - point = k1p.add(k2p); - fake = f1p.add(f2p); - } - else { - const { p, f } = this.wNAF(n); - point = p; - fake = f; - } - // Normalize `z` for both points, but return only real one - return Point.normalizeZ([point, fake])[0]; - } - /** - * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. - * Not using Strauss-Shamir trick: precomputation tables are faster. - * The trick could be useful if both P and Q are not G (not in our case). - * @returns non-zero affine point - */ - multiplyAndAddUnsafe(Q, a, b) { - const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes - const mul = (P, a // Select faster multiply() method - ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a)); - const sum = mul(this, a).add(mul(Q, b)); - return sum.is0() ? undefined : sum; - } - // Converts Projective point to affine (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - // (x, y, z) ∋ (x=x/z, y=y/z) - toAffine(iz) { - const { px: x, py: y, pz: z } = this; - const is0 = this.is0(); - // If invZ was 0, we return zero point. However we still want to execute - // all operations, so we replace invZ with a random number, 1. - if (iz == null) - iz = is0 ? Fp.ONE : Fp.inv(z); - const ax = Fp.mul(x, iz); - const ay = Fp.mul(y, iz); - const zz = Fp.mul(z, iz); - if (is0) - return { x: Fp.ZERO, y: Fp.ZERO }; - if (!Fp.eql(zz, Fp.ONE)) - throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - isTorsionFree() { - const { h: cofactor, isTorsionFree } = CURVE; - if (cofactor === _1n) - return true; // No subgroups, always torsion-free - if (isTorsionFree) - return isTorsionFree(Point, this); - throw new Error('isTorsionFree() has not been declared for the elliptic curve'); - } - clearCofactor() { - const { h: cofactor, clearCofactor } = CURVE; - if (cofactor === _1n) - return this; // Fast-path - if (clearCofactor) - return clearCofactor(Point, this); - return this.multiplyUnsafe(CURVE.h); - } - toRawBytes(isCompressed = true) { - this.assertValidity(); - return toBytes(Point, this, isCompressed); - } - toHex(isCompressed = true) { - return ut.bytesToHex(this.toRawBytes(isCompressed)); - } - } - Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE); - Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO); - const _bits = CURVE.nBitLength; - const wnaf = (0, curve_js_1.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits); - // Validate if generator point is on curve - return { - CURVE, - ProjectivePoint: Point, - normPrivateKeyToScalar, - weierstrassEquation, - isWithinCurveOrder, - }; -} -exports.weierstrassPoints = weierstrassPoints; -function validateOpts(curve) { - const opts = (0, curve_js_1.validateBasic)(curve); - ut.validateObject(opts, { - hash: 'hash', - hmac: 'function', - randomBytes: 'function', - }, { - bits2int: 'function', - bits2int_modN: 'function', - lowS: 'boolean', - }); - return Object.freeze({ lowS: true, ...opts }); -} -function weierstrass(curveDef) { - const CURVE = validateOpts(curveDef); - const { Fp, n: CURVE_ORDER } = CURVE; - const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32 - const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32 - function isValidFieldElement(num) { - return _0n < num && num < Fp.ORDER; // 0 is banned since it's not invertible FE - } - function modN(a) { - return mod.mod(a, CURVE_ORDER); - } - function invN(a) { - return mod.invert(a, CURVE_ORDER); - } - const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder, } = weierstrassPoints({ - ...CURVE, - toBytes(c, point, isCompressed) { - const a = point.toAffine(); - const x = Fp.toBytes(a.x); - const cat = ut.concatBytes; - if (isCompressed) { - return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x); - } - else { - return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y)); - } - }, - fromBytes(bytes) { - const len = bytes.length; - const head = bytes[0]; - const tail = bytes.subarray(1); - // this.assertValidity() is done inside of fromHex - if (len === compressedLen && (head === 0x02 || head === 0x03)) { - const x = ut.bytesToNumberBE(tail); - if (!isValidFieldElement(x)) - throw new Error('Point is not on curve'); - const y2 = weierstrassEquation(x); // y² = x³ + ax + b - let y = Fp.sqrt(y2); // y = y² ^ (p+1)/4 - const isYOdd = (y & _1n) === _1n; - // ECDSA - const isHeadOdd = (head & 1) === 1; - if (isHeadOdd !== isYOdd) - y = Fp.neg(y); - return { x, y }; - } - else if (len === uncompressedLen && head === 0x04) { - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - } - else { - throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`); - } - }, - }); - const numToNByteStr = (num) => ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength)); - function isBiggerThanHalfOrder(number) { - const HALF = CURVE_ORDER >> _1n; - return number > HALF; - } - function normalizeS(s) { - return isBiggerThanHalfOrder(s) ? modN(-s) : s; - } - // slice bytes num - const slcNum = (b, from, to) => ut.bytesToNumberBE(b.slice(from, to)); - /** - * ECDSA signature with its (r, s) properties. Supports DER & compact representations. - */ - class Signature { - constructor(r, s, recovery) { - this.r = r; - this.s = s; - this.recovery = recovery; - this.assertValidity(); - } - // pair (bytes of r, bytes of s) - static fromCompact(hex) { - const l = CURVE.nByteLength; - hex = (0, utils_js_1.ensureBytes)('compactSignature', hex, l * 2); - return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l)); - } - // DER encoded ECDSA signature - // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script - static fromDER(hex) { - const { r, s } = exports.DER.toSig((0, utils_js_1.ensureBytes)('DER', hex)); - return new Signature(r, s); - } - assertValidity() { - // can use assertGE here - if (!isWithinCurveOrder(this.r)) - throw new Error('r must be 0 < r < CURVE.n'); - if (!isWithinCurveOrder(this.s)) - throw new Error('s must be 0 < s < CURVE.n'); - } - addRecoveryBit(recovery) { - return new Signature(this.r, this.s, recovery); - } - recoverPublicKey(msgHash) { - const { r, s, recovery: rec } = this; - const h = bits2int_modN((0, utils_js_1.ensureBytes)('msgHash', msgHash)); // Truncate hash - if (rec == null || ![0, 1, 2, 3].includes(rec)) - throw new Error('recovery id invalid'); - const radj = rec === 2 || rec === 3 ? r + CURVE.n : r; - if (radj >= Fp.ORDER) - throw new Error('recovery id 2 or 3 invalid'); - const prefix = (rec & 1) === 0 ? '02' : '03'; - const R = Point.fromHex(prefix + numToNByteStr(radj)); - const ir = invN(radj); // r^-1 - const u1 = modN(-h * ir); // -hr^-1 - const u2 = modN(s * ir); // sr^-1 - const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1) - if (!Q) - throw new Error('point at infinify'); // unsafe is fine: no priv data leaked - Q.assertValidity(); - return Q; - } - // Signatures should be low-s, to prevent malleability. - hasHighS() { - return isBiggerThanHalfOrder(this.s); - } - normalizeS() { - return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this; - } - // DER-encoded - toDERRawBytes() { - return ut.hexToBytes(this.toDERHex()); - } - toDERHex() { - return exports.DER.hexFromSig({ r: this.r, s: this.s }); - } - // padded bytes of r, then padded bytes of s - toCompactRawBytes() { - return ut.hexToBytes(this.toCompactHex()); - } - toCompactHex() { - return numToNByteStr(this.r) + numToNByteStr(this.s); - } - } - const utils = { - isValidPrivateKey(privateKey) { - try { - normPrivateKeyToScalar(privateKey); - return true; - } - catch (error) { - return false; - } - }, - normPrivateKeyToScalar: normPrivateKeyToScalar, - /** - * Produces cryptographically secure private key from random of size (nBitLength+64) - * as per FIPS 186 B.4.1 with modulo bias being neglible. - */ - randomPrivateKey: () => { - const rand = CURVE.randomBytes(Fp.BYTES + 8); - const num = mod.hashToPrivateScalar(rand, CURVE_ORDER); - return ut.numberToBytesBE(num, CURVE.nByteLength); - }, - /** - * Creates precompute table for an arbitrary EC point. Makes point "cached". - * Allows to massively speed-up `point.multiply(scalar)`. - * @returns cached point - * @example - * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); - * fast.multiply(privKey); // much faster ECDH now - */ - precompute(windowSize = 8, point = Point.BASE) { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here - return point; - }, - }; - /** - * Computes public key for a private key. Checks for validity of the private key. - * @param privateKey private key - * @param isCompressed whether to return compact (default), or full key - * @returns Public key, full when isCompressed=false; short when isCompressed=true - */ - function getPublicKey(privateKey, isCompressed = true) { - return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed); - } - /** - * Quick and dirty check for item being public key. Does not validate hex, or being on-curve. - */ - function isProbPub(item) { - const arr = item instanceof Uint8Array; - const str = typeof item === 'string'; - const len = (arr || str) && item.length; - if (arr) - return len === compressedLen || len === uncompressedLen; - if (str) - return len === 2 * compressedLen || len === 2 * uncompressedLen; - if (item instanceof Point) - return true; - return false; - } - /** - * ECDH (Elliptic Curve Diffie Hellman). - * Computes shared public key from private key and public key. - * Checks: 1) private key validity 2) shared key is on-curve. - * Does NOT hash the result. - * @param privateA private key - * @param publicB different public key - * @param isCompressed whether to return compact (default), or full key - * @returns shared public key - */ - function getSharedSecret(privateA, publicB, isCompressed = true) { - if (isProbPub(privateA)) - throw new Error('first arg must be private key'); - if (!isProbPub(publicB)) - throw new Error('second arg must be public key'); - const b = Point.fromHex(publicB); // check for being on-curve - return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed); - } - // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets. - // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int. - // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same. - // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors - const bits2int = CURVE.bits2int || - function (bytes) { - // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m) - // for some cases, since bytes.length * 8 is not actual bitLength. - const num = ut.bytesToNumberBE(bytes); // check for == u8 done here - const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits - return delta > 0 ? num >> BigInt(delta) : num; - }; - const bits2int_modN = CURVE.bits2int_modN || - function (bytes) { - return modN(bits2int(bytes)); // can't use bytesToNumberBE here - }; - // NOTE: pads output with zero as per spec - const ORDER_MASK = ut.bitMask(CURVE.nBitLength); - /** - * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`. - */ - function int2octets(num) { - if (typeof num !== 'bigint') - throw new Error('bigint expected'); - if (!(_0n <= num && num < ORDER_MASK)) - throw new Error(`bigint expected < 2^${CURVE.nBitLength}`); - // works with order, can have different size than numToField! - return ut.numberToBytesBE(num, CURVE.nByteLength); - } - // Steps A, D of RFC6979 3.2 - // Creates RFC6979 seed; converts msg/privKey to numbers. - // Used only in sign, not in verify. - // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order, this will be wrong at least for P521. - // Also it can be bigger for P224 + SHA256 - function prepSig(msgHash, privateKey, opts = defaultSigOpts) { - if (['recovered', 'canonical'].some((k) => k in opts)) - throw new Error('sign() legacy options not supported'); - const { hash, randomBytes } = CURVE; - let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default - if (lowS == null) - lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash - msgHash = (0, utils_js_1.ensureBytes)('msgHash', msgHash); - if (prehash) - msgHash = (0, utils_js_1.ensureBytes)('prehashed msgHash', hash(msgHash)); - // We can't later call bits2octets, since nested bits2int is broken for curves - // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call. - // const bits2octets = (bits) => int2octets(bits2int_modN(bits)) - const h1int = bits2int_modN(msgHash); - const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint - const seedArgs = [int2octets(d), int2octets(h1int)]; - // extraEntropy. RFC6979 3.6: additional k' (optional). - if (ent != null) { - // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k') - const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is - seedArgs.push((0, utils_js_1.ensureBytes)('extraEntropy', e, Fp.BYTES)); // check for being of size BYTES - } - const seed = ut.concatBytes(...seedArgs); // Step D of RFC6979 3.2 - const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash! - // Converts signature params into point w r/s, checks result for validity. - function k2sig(kBytes) { - // RFC 6979 Section 3.2, step 3: k = bits2int(T) - const k = bits2int(kBytes); // Cannot use fields methods, since it is group element - if (!isWithinCurveOrder(k)) - return; // Important: all mod() calls here must be done over N - const ik = invN(k); // k^-1 mod n - const q = Point.BASE.multiply(k).toAffine(); // q = Gk - const r = modN(q.x); // r = q.x mod n - if (r === _0n) - return; - // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to - // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it: - // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT - const s = modN(ik * modN(m + r * d)); // Not using blinding here - if (s === _0n) - return; - let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n) - let normS = s; - if (lowS && isBiggerThanHalfOrder(s)) { - normS = normalizeS(s); // if lowS was passed, ensure s is always - recovery ^= 1; // // in the bottom half of N - } - return new Signature(r, normS, recovery); // use normS, not s - } - return { seed, k2sig }; - } - const defaultSigOpts = { lowS: CURVE.lowS, prehash: false }; - const defaultVerOpts = { lowS: CURVE.lowS, prehash: false }; - /** - * Signs message hash with a private key. - * ``` - * sign(m, d, k) where - * (x, y) = G × k - * r = x mod n - * s = (m + dr)/k mod n - * ``` - * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`. - * @param privKey private key - * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg. - * @returns signature with recovery param - */ - function sign(msgHash, privKey, opts = defaultSigOpts) { - const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2. - const C = CURVE; - const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac); - return drbg(seed, k2sig); // Steps B, C, D, E, F, G - } - // Enable precomputes. Slows down first publicKey computation by 20ms. - Point.BASE._setWindowSize(8); - // utils.precompute(8, ProjectivePoint.BASE) - /** - * Verifies a signature against message hash and public key. - * Rejects lowS signatures by default: to override, - * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf: - * - * ``` - * verify(r, s, h, P) where - * U1 = hs^-1 mod n - * U2 = rs^-1 mod n - * R = U1⋅G - U2⋅P - * mod(R.x, n) == r - * ``` - */ - function verify(signature, msgHash, publicKey, opts = defaultVerOpts) { - const sg = signature; - msgHash = (0, utils_js_1.ensureBytes)('msgHash', msgHash); - publicKey = (0, utils_js_1.ensureBytes)('publicKey', publicKey); - if ('strict' in opts) - throw new Error('options.strict was renamed to lowS'); - const { lowS, prehash } = opts; - let _sig = undefined; - let P; - try { - if (typeof sg === 'string' || sg instanceof Uint8Array) { - // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length). - // Since DER can also be 2*nByteLength bytes, we check for it first. - try { - _sig = Signature.fromDER(sg); - } - catch (derError) { - if (!(derError instanceof exports.DER.Err)) - throw derError; - _sig = Signature.fromCompact(sg); - } - } - else if (typeof sg === 'object' && typeof sg.r === 'bigint' && typeof sg.s === 'bigint') { - const { r, s } = sg; - _sig = new Signature(r, s); - } - else { - throw new Error('PARSE'); - } - P = Point.fromHex(publicKey); - } - catch (error) { - if (error.message === 'PARSE') - throw new Error(`signature must be Signature instance, Uint8Array or hex string`); - return false; - } - if (lowS && _sig.hasHighS()) - return false; - if (prehash) - msgHash = CURVE.hash(msgHash); - const { r, s } = _sig; - const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element - const is = invN(s); // s^-1 - const u1 = modN(h * is); // u1 = hs^-1 mod n - const u2 = modN(r * is); // u2 = rs^-1 mod n - const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P - if (!R) - return false; - const v = modN(R.x); - return v === r; - } - return { - CURVE, - getPublicKey, - getSharedSecret, - sign, - verify, - ProjectivePoint: Point, - Signature, - utils, - }; -} -exports.weierstrass = weierstrass; -/** - * Implementation of the Shallue and van de Woestijne method for any weierstrass curve. - * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular. - * b = True and y = sqrt(u / v) if (u / v) is square in F, and - * b = False and y = sqrt(Z * (u / v)) otherwise. - * @param Fp - * @param Z - * @returns - */ -function SWUFpSqrtRatio(Fp, Z) { - // Generic implementation - const q = Fp.ORDER; - let l = _0n; - for (let o = q - _1n; o % _2n === _0n; o /= _2n) - l += _1n; - const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1. - // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<. - // 2n ** c1 == 2n << (c1-1) - const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n); - const _2n_pow_c1 = _2n_pow_c1_1 * _2n; - const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic - const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic - const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic - const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic - const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2 - const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2) - let sqrtRatio = (u, v) => { - let tv1 = c6; // 1. tv1 = c6 - let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4 - let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2 - tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v - let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3 - tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3 - tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2 - tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v - tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u - let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2 - tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5 - let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1 - tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7 - tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR) - tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR) - // 17. for i in (c1, c1 - 1, ..., 2): - for (let i = c1; i > _1n; i--) { - let tv5 = i - _2n; // 18. tv5 = i - 2 - tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5 - let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5 - const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1 - tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1 - tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1 - tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1) - tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1) - } - return { isValid: isQR, value: tv3 }; - }; - if (Fp.ORDER % _4n === _3n) { - // sqrt_ratio_3mod4(u, v) - const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic - const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z) - sqrtRatio = (u, v) => { - let tv1 = Fp.sqr(v); // 1. tv1 = v^2 - const tv2 = Fp.mul(u, v); // 2. tv2 = u * v - tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2 - let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1 - y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2 - const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2 - const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v - const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u - let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR) - return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2 - }; - } - // No curves uses that - // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8 - return sqrtRatio; -} -exports.SWUFpSqrtRatio = SWUFpSqrtRatio; -/** - * From draft-irtf-cfrg-hash-to-curve-16 - */ -function mapToCurveSimpleSWU(Fp, opts) { - mod.validateField(Fp); - if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z)) - throw new Error('mapToCurveSimpleSWU: invalid opts'); - const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z); - if (!Fp.isOdd) - throw new Error('Fp.isOdd is not implemented!'); - // Input: u, an element of F. - // Output: (x, y), a point on E. - return (u) => { - // prettier-ignore - let tv1, tv2, tv3, tv4, tv5, tv6, x, y; - tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1 - tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2 - tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1 - tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1 - tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3 - tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0) - tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4 - tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2 - tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2 - tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6 - tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5 - tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3 - tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4 - tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6 - tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5 - x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3 - const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6) - y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1 - y = Fp.mul(y, value); // 20. y = y * y1 - x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square) - y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square) - const e1 = Fp.isOdd(u) === Fp.isOdd(y); // 23. e1 = sgn0(u) == sgn0(y) - y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1) - x = Fp.div(x, tv4); // 25. x = x / tv4 - return { x, y }; - }; -} -exports.mapToCurveSimpleSWU = mapToCurveSimpleSWU; -//# sourceMappingURL=weierstrass.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js.map deleted file mode 100644 index 56663a3e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/abstract/weierstrass.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weierstrass.js","sourceRoot":"","sources":["../src/abstract/weierstrass.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,4DAA4D;AAC5D,oCAAoC;AACpC,iCAAiC;AACjC,yCAA8D;AAC9D,yCAAmG;AAqFnG,SAAS,iBAAiB,CAAI,KAAyB;IACrD,MAAM,IAAI,GAAG,IAAA,wBAAa,EAAC,KAAK,CAAC,CAAC;IAClC,EAAE,CAAC,cAAc,CACf,IAAI,EACJ;QACE,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,OAAO;KACX,EACD;QACE,wBAAwB,EAAE,OAAO;QACjC,cAAc,EAAE,SAAS;QACzB,aAAa,EAAE,UAAU;QACzB,aAAa,EAAE,UAAU;QACzB,kBAAkB,EAAE,SAAS;QAC7B,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,UAAU;KACpB,CACF,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;SACtF;QACD,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,OAAO,IAAI,CAAC,IAAI,KAAK,Q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,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,mBAAmB;QACzC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,wCAAwC;QACtE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,uCAAuC;QACvE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;QACzE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,4BAA4B;QAC3D,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,oBAAoB;QACxC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AA7CD,kDA6CC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts deleted file mode 100644 index 0e711140..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { CurveFn } from './abstract/bls.js'; -import * as mod from './abstract/modular.js'; -declare const Fp: Readonly & Required, "isOdd">>>; -type Fp = bigint; -type BigintTuple = [bigint, bigint]; -type Fp2 = { - c0: bigint; - c1: bigint; -}; -type Fp2Utils = { - fromBigTuple: (tuple: BigintTuple | bigint[]) => Fp2; - reim: (num: Fp2) => { - re: bigint; - im: bigint; - }; - mulByNonresidue: (num: Fp2) => Fp2; - multiplyByB: (num: Fp2) => Fp2; - frobeniusMap(num: Fp2, power: number): Fp2; -}; -declare const Fp2: mod.IField & Fp2Utils; -type BigintSix = [bigint, bigint, bigint, bigint, bigint, bigint]; -type Fp6 = { - c0: Fp2; - c1: Fp2; - c2: Fp2; -}; -type Fp6Utils = { - fromBigSix: (tuple: BigintSix) => Fp6; - mulByNonresidue: (num: Fp6) => Fp6; - frobeniusMap(num: Fp6, power: number): Fp6; - multiplyBy1(num: Fp6, b1: Fp2): Fp6; - multiplyBy01(num: Fp6, b0: Fp2, b1: Fp2): Fp6; - multiplyByFp2(lhs: Fp6, rhs: Fp2): Fp6; -}; -declare const Fp6: mod.IField & Fp6Utils; -type Fp12 = { - c0: Fp6; - c1: Fp6; -}; -type BigintTwelve = [ - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint, - bigint -]; -type Fp12Utils = { - fromBigTwelve: (t: BigintTwelve) => Fp12; - frobeniusMap(num: Fp12, power: number): Fp12; - multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12; - multiplyByFp2(lhs: Fp12, rhs: Fp2): Fp12; - conjugate(num: Fp12): Fp12; - finalExponentiate(num: Fp12): Fp12; - _cyclotomicSquare(num: Fp12): Fp12; - _cyclotomicExp(num: Fp12, n: bigint): Fp12; -}; -declare const Fp12: mod.IField & Fp12Utils; -export declare const bls12_381: CurveFn; -export {}; -//# sourceMappingURL=bls12-381.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts.map deleted file mode 100644 index b724df15..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls12-381.d.ts","sourceRoot":"","sources":["src/bls12-381.ts"],"names":[],"mappings":"AAAA,sEAAsE;AA+BtE,OAAO,EAAO,OAAO,EAAE,MAAM,mBAAmB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c,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,SA6I9B,CAAC;AAmWF,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CA2ShD,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js b/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js deleted file mode 100644 index c825e0e9..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js +++ /dev/null @@ -1,1176 +0,0 @@ -"use strict"; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.bls12_381 = void 0; -// bls12-381 pairing-friendly Barreto-Lynn-Scott elliptic curve construction allows to: -// - Construct zk-SNARKs at the 128-bit security -// - Use threshold signatures, which allows a user to sign lots of messages with one signature and -// verify them swiftly in a batch, using Boneh-Lynn-Shacham signature scheme. -// -// The library uses G1 for public keys and G2 for signatures. Support for G1 signatures is planned. -// Compatible with Algorand, Chia, Dfinity, Ethereum, FIL, Zcash. Matches specs -// [pairing-curves-11](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-11), -// [bls-sigs-04](https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04), -// [hash-to-curve-12](https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-12). -// -// ### Summary -// 1. BLS Relies on Bilinear Pairing (expensive) -// 2. Private Keys: 32 bytes -// 3. Public Keys: 48 bytes: 381 bit affine x coordinate, encoded into 48 big-endian bytes. -// 4. Signatures: 96 bytes: two 381 bit integers (affine x coordinate), encoded into two 48 big-endian byte arrays. -// - The signature is a point on the G2 subgroup, which is defined over a finite field -// with elements twice as big as the G1 curve (G2 is over Fp2 rather than Fp. Fp2 is analogous to the complex numbers). -// 5. The 12 stands for the Embedding degree. -// -// ### Formulas -// - `P = pk x G` - public keys -// - `S = pk x H(m)` - signing -// - `e(P, H(m)) == e(G, S)` - verification using pairings -// - `e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si))` - signature aggregation -// Filecoin uses little endian byte arrays for private keys - -// so ensure to reverse byte order if you'll use it with FIL. -const sha256_1 = require("@noble/hashes/sha256"); -const utils_1 = require("@noble/hashes/utils"); -const bls_js_1 = require("./abstract/bls.js"); -const mod = require("./abstract/modular.js"); -const utils_js_1 = require("./abstract/utils.js"); -// Types -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); -// prettier-ignore -const _8n = BigInt(8), _16n = BigInt(16); -// CURVE FIELDS -// Finite field over p. -const Fp_raw = BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab'); -const Fp = mod.Field(Fp_raw); -// Finite field over r. -// This particular field is not used anywhere in bls12-381, but it is still useful. -const Fr = mod.Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')); -const Fp2Add = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp.add(c0, r0), - c1: Fp.add(c1, r1), -}); -const Fp2Subtract = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp.sub(c0, r0), - c1: Fp.sub(c1, r1), -}); -const Fp2Multiply = ({ c0, c1 }, rhs) => { - if (typeof rhs === 'bigint') - return { c0: Fp.mul(c0, rhs), c1: Fp.mul(c1, rhs) }; - // (a+bi)(c+di) = (ac−bd) + (ad+bc)i - const { c0: r0, c1: r1 } = rhs; - let t1 = Fp.mul(c0, r0); // c0 * o0 - let t2 = Fp.mul(c1, r1); // c1 * o1 - // (T1 - T2) + ((c0 + c1) * (r0 + r1) - (T1 + T2))*i - const o0 = Fp.sub(t1, t2); - const o1 = Fp.sub(Fp.mul(Fp.add(c0, c1), Fp.add(r0, r1)), Fp.add(t1, t2)); - return { c0: o0, c1: o1 }; -}; -const Fp2Square = ({ c0, c1 }) => { - const a = Fp.add(c0, c1); - const b = Fp.sub(c0, c1); - const c = Fp.add(c0, c0); - return { c0: Fp.mul(a, b), c1: Fp.mul(c, c1) }; -}; -// G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), -// where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where -// G² - 1 -// h2q -// NOTE: ORDER was wrong! -const FP2_ORDER = Fp_raw * Fp_raw; -const Fp2 = { - ORDER: FP2_ORDER, - BITS: (0, utils_js_1.bitLen)(FP2_ORDER), - BYTES: Math.ceil((0, utils_js_1.bitLen)(FP2_ORDER) / 8), - MASK: (0, utils_js_1.bitMask)((0, utils_js_1.bitLen)(FP2_ORDER)), - ZERO: { c0: Fp.ZERO, c1: Fp.ZERO }, - ONE: { c0: Fp.ONE, c1: Fp.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => typeof c0 === 'bigint' && typeof c1 === 'bigint', - is0: ({ c0, c1 }) => Fp.is0(c0) && Fp.is0(c1), - eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp.eql(c0, r0) && Fp.eql(c1, r1), - neg: ({ c0, c1 }) => ({ c0: Fp.neg(c0), c1: Fp.neg(c1) }), - pow: (num, power) => mod.FpPow(Fp2, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp2, nums), - // Normalized - add: Fp2Add, - sub: Fp2Subtract, - mul: Fp2Multiply, - sqr: Fp2Square, - // NonNormalized stuff - addN: Fp2Add, - subN: Fp2Subtract, - mulN: Fp2Multiply, - sqrN: Fp2Square, - // Why inversion for bigint inside Fp instead of Fp2? it is even used in that context? - div: (lhs, rhs) => Fp2.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp2.inv(rhs)), - inv: ({ c0: a, c1: b }) => { - // We wish to find the multiplicative inverse of a nonzero - // element a + bu in Fp2. We leverage an identity - // - // (a + bu)(a - bu) = a² + b² - // - // which holds because u² = -1. This can be rewritten as - // - // (a + bu)(a - bu)/(a² + b²) = 1 - // - // because a² + b² = 0 has no nonzero solutions for (a, b). - // This gives that (a - bu)/(a² + b²) is the inverse - // of (a + bu). Importantly, this can be computing using - // only a single inversion in Fp. - const factor = Fp.inv(Fp.create(a * a + b * b)); - return { c0: Fp.mul(factor, Fp.create(a)), c1: Fp.mul(factor, Fp.create(-b)) }; - }, - sqrt: (num) => { - if (Fp2.eql(num, Fp2.ZERO)) - return Fp2.ZERO; // Algo doesn't handles this case - // TODO: Optimize this line. It's extremely slow. - // Speeding this up would boost aggregateSignatures. - // https://eprint.iacr.org/2012/685.pdf applicable? - // https://github.com/zkcrypto/bls12_381/blob/080eaa74ec0e394377caa1ba302c8c121df08b07/src/fp2.rs#L250 - // https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/src/exp2.c#L1 - // Inspired by https://github.com/dalek-cryptography/curve25519-dalek/blob/17698df9d4c834204f83a3574143abacb4fc81a5/src/field.rs#L99 - const candidateSqrt = Fp2.pow(num, (Fp2.ORDER + _8n) / _16n); - const check = Fp2.div(Fp2.sqr(candidateSqrt), num); // candidateSqrt.square().div(this); - const R = FP2_ROOTS_OF_UNITY; - const divisor = [R[0], R[2], R[4], R[6]].find((r) => Fp2.eql(r, check)); - if (!divisor) - throw new Error('No root'); - const index = R.indexOf(divisor); - const root = R[index / 2]; - if (!root) - throw new Error('Invalid root'); - const x1 = Fp2.div(candidateSqrt, root); - const x2 = Fp2.neg(x1); - const { re: re1, im: im1 } = Fp2.reim(x1); - const { re: re2, im: im2 } = Fp2.reim(x2); - if (im1 > im2 || (im1 === im2 && re1 > re2)) - return x1; - return x2; - }, - // Same as sgn0_fp2 in draft-irtf-cfrg-hash-to-curve-16 - isOdd: (x) => { - const { re: x0, im: x1 } = Fp2.reim(x); - const sign_0 = x0 % _2n; - const zero_0 = x0 === _0n; - const sign_1 = x1 % _2n; - return BigInt(sign_0 || (zero_0 && sign_1)) == _1n; - }, - // Bytes util - fromBytes(b) { - if (b.length !== Fp2.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { c0: Fp.fromBytes(b.subarray(0, Fp.BYTES)), c1: Fp.fromBytes(b.subarray(Fp.BYTES)) }; - }, - toBytes: ({ c0, c1 }) => (0, utils_js_1.concatBytes)(Fp.toBytes(c0), Fp.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp.cmov(c0, r0, c), - c1: Fp.cmov(c1, r1, c), - }), - // Specific utils - // toString() { - // return `Fp2(${this.c0} + ${this.c1}×i)`; - // } - reim: ({ c0, c1 }) => ({ re: c0, im: c1 }), - // multiply by u + 1 - mulByNonresidue: ({ c0, c1 }) => ({ c0: Fp.sub(c0, c1), c1: Fp.add(c0, c1) }), - multiplyByB: ({ c0, c1 }) => { - let t0 = Fp.mul(c0, _4n); // 4 * c0 - let t1 = Fp.mul(c1, _4n); // 4 * c1 - // (T0-T1) + (T0+T1)*i - return { c0: Fp.sub(t0, t1), c1: Fp.add(t0, t1) }; - }, - fromBigTuple: (tuple) => { - if (tuple.length !== 2) - throw new Error('Invalid tuple'); - const fps = tuple.map((n) => Fp.create(n)); - return { c0: fps[0], c1: fps[1] }; - }, - frobeniusMap: ({ c0, c1 }, power) => ({ - c0, - c1: Fp.mul(c1, FP2_FROBENIUS_COEFFICIENTS[power % 2]), - }), -}; -// Finite extension field over irreducible polynominal. -// Fp(u) / (u² - β) where β = -1 -const FP2_FROBENIUS_COEFFICIENTS = [ - BigInt('0x1'), - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), -].map((item) => Fp.create(item)); -// For Fp2 roots of unity. -const rv1 = BigInt('0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'); -// const ev1 = -// BigInt('0x699be3b8c6870965e5bf892ad5d2cc7b0e85a117402dfd83b7f4a947e02d978498255a2aaec0ac627b5afbdf1bf1c90'); -// const ev2 = -// BigInt('0x8157cd83046453f5dd0972b6e3949e4288020b5b8a9cc99ca07e27089a2ce2436d965026adad3ef7baba37f2183e9b5'); -// const ev3 = -// BigInt('0xab1c2ffdd6c253ca155231eb3e71ba044fd562f6f72bc5bad5ec46a0b7a3b0247cf08ce6c6317f40edbc653a72dee17'); -// const ev4 = -// BigInt('0xaa404866706722864480885d68ad0ccac1967c7544b447873cc37e0181271e006df72162a3d3e0287bf597fbf7f8fc1'); -// Eighth roots of unity, used for computing square roots in Fp2. -// To verify or re-calculate: -// Array(8).fill(new Fp2([1n, 1n])).map((fp2, k) => fp2.pow(Fp2.ORDER * BigInt(k) / 8n)) -const FP2_ROOTS_OF_UNITY = [ - [_1n, _0n], - [rv1, -rv1], - [_0n, _1n], - [rv1, rv1], - [-_1n, _0n], - [-rv1, rv1], - [_0n, -_1n], - [-rv1, -rv1], -].map((pair) => Fp2.fromBigTuple(pair)); -const Fp6Add = ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => ({ - c0: Fp2.add(c0, r0), - c1: Fp2.add(c1, r1), - c2: Fp2.add(c2, r2), -}); -const Fp6Subtract = ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => ({ - c0: Fp2.sub(c0, r0), - c1: Fp2.sub(c1, r1), - c2: Fp2.sub(c2, r2), -}); -const Fp6Multiply = ({ c0, c1, c2 }, rhs) => { - if (typeof rhs === 'bigint') { - return { - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }; - } - const { c0: r0, c1: r1, c2: r2 } = rhs; - const t0 = Fp2.mul(c0, r0); // c0 * o0 - const t1 = Fp2.mul(c1, r1); // c1 * o1 - const t2 = Fp2.mul(c2, r2); // c2 * o2 - return { - // t0 + (c1 + c2) * (r1 * r2) - (T1 + T2) * (u + 1) - c0: Fp2.add(t0, Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), Fp2.add(r1, r2)), Fp2.add(t1, t2)))), - // (c0 + c1) * (r0 + r1) - (T0 + T1) + T2 * (u + 1) - c1: Fp2.add(Fp2.sub(Fp2.mul(Fp2.add(c0, c1), Fp2.add(r0, r1)), Fp2.add(t0, t1)), Fp2.mulByNonresidue(t2)), - // T1 + (c0 + c2) * (r0 + r2) - T0 + T2 - c2: Fp2.sub(Fp2.add(t1, Fp2.mul(Fp2.add(c0, c2), Fp2.add(r0, r2))), Fp2.add(t0, t2)), - }; -}; -const Fp6Square = ({ c0, c1, c2 }) => { - let t0 = Fp2.sqr(c0); // c0² - let t1 = Fp2.mul(Fp2.mul(c0, c1), _2n); // 2 * c0 * c1 - let t3 = Fp2.mul(Fp2.mul(c1, c2), _2n); // 2 * c1 * c2 - let t4 = Fp2.sqr(c2); // c2² - return { - c0: Fp2.add(Fp2.mulByNonresidue(t3), t0), - c1: Fp2.add(Fp2.mulByNonresidue(t4), t1), - // T1 + (c0 - c1 + c2)² + T3 - T0 - T4 - c2: Fp2.sub(Fp2.sub(Fp2.add(Fp2.add(t1, Fp2.sqr(Fp2.add(Fp2.sub(c0, c1), c2))), t3), t0), t4), - }; -}; -const Fp6 = { - ORDER: Fp2.ORDER, - BITS: 3 * Fp2.BITS, - BYTES: 3 * Fp2.BYTES, - MASK: (0, utils_js_1.bitMask)(3 * Fp2.BITS), - ZERO: { c0: Fp2.ZERO, c1: Fp2.ZERO, c2: Fp2.ZERO }, - ONE: { c0: Fp2.ONE, c1: Fp2.ZERO, c2: Fp2.ZERO }, - create: (num) => num, - isValid: ({ c0, c1, c2 }) => Fp2.isValid(c0) && Fp2.isValid(c1) && Fp2.isValid(c2), - is0: ({ c0, c1, c2 }) => Fp2.is0(c0) && Fp2.is0(c1) && Fp2.is0(c2), - neg: ({ c0, c1, c2 }) => ({ c0: Fp2.neg(c0), c1: Fp2.neg(c1), c2: Fp2.neg(c2) }), - eql: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => Fp2.eql(c0, r0) && Fp2.eql(c1, r1) && Fp2.eql(c2, r2), - sqrt: () => { - throw new Error('Not implemented'); - }, - // Do we need division by bigint at all? Should be done via order: - div: (lhs, rhs) => Fp6.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp6.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp6, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp6, nums), - // Normalized - add: Fp6Add, - sub: Fp6Subtract, - mul: Fp6Multiply, - sqr: Fp6Square, - // NonNormalized stuff - addN: Fp6Add, - subN: Fp6Subtract, - mulN: Fp6Multiply, - sqrN: Fp6Square, - inv: ({ c0, c1, c2 }) => { - let t0 = Fp2.sub(Fp2.sqr(c0), Fp2.mulByNonresidue(Fp2.mul(c2, c1))); // c0² - c2 * c1 * (u + 1) - let t1 = Fp2.sub(Fp2.mulByNonresidue(Fp2.sqr(c2)), Fp2.mul(c0, c1)); // c2² * (u + 1) - c0 * c1 - let t2 = Fp2.sub(Fp2.sqr(c1), Fp2.mul(c0, c2)); // c1² - c0 * c2 - // 1/(((c2 * T1 + c1 * T2) * v) + c0 * T0) - let t4 = Fp2.inv(Fp2.add(Fp2.mulByNonresidue(Fp2.add(Fp2.mul(c2, t1), Fp2.mul(c1, t2))), Fp2.mul(c0, t0))); - return { c0: Fp2.mul(t4, t0), c1: Fp2.mul(t4, t1), c2: Fp2.mul(t4, t2) }; - }, - // Bytes utils - fromBytes: (b) => { - if (b.length !== Fp6.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp2.fromBytes(b.subarray(0, Fp2.BYTES)), - c1: Fp2.fromBytes(b.subarray(Fp2.BYTES, 2 * Fp2.BYTES)), - c2: Fp2.fromBytes(b.subarray(2 * Fp2.BYTES)), - }; - }, - toBytes: ({ c0, c1, c2 }) => (0, utils_js_1.concatBytes)(Fp2.toBytes(c0), Fp2.toBytes(c1), Fp2.toBytes(c2)), - cmov: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }, c) => ({ - c0: Fp2.cmov(c0, r0, c), - c1: Fp2.cmov(c1, r1, c), - c2: Fp2.cmov(c2, r2, c), - }), - // Utils - // fromTriple(triple: [Fp2, Fp2, Fp2]) { - // return new Fp6(...triple); - // } - // toString() { - // return `Fp6(${this.c0} + ${this.c1} * v, ${this.c2} * v^2)`; - // } - fromBigSix: (t) => { - if (!Array.isArray(t) || t.length !== 6) - throw new Error('Invalid Fp6 usage'); - return { - c0: Fp2.fromBigTuple(t.slice(0, 2)), - c1: Fp2.fromBigTuple(t.slice(2, 4)), - c2: Fp2.fromBigTuple(t.slice(4, 6)), - }; - }, - frobeniusMap: ({ c0, c1, c2 }, power) => ({ - c0: Fp2.frobeniusMap(c0, power), - c1: Fp2.mul(Fp2.frobeniusMap(c1, power), FP6_FROBENIUS_COEFFICIENTS_1[power % 6]), - c2: Fp2.mul(Fp2.frobeniusMap(c2, power), FP6_FROBENIUS_COEFFICIENTS_2[power % 6]), - }), - mulByNonresidue: ({ c0, c1, c2 }) => ({ c0: Fp2.mulByNonresidue(c2), c1: c0, c2: c1 }), - // Sparse multiplication - multiplyBy1: ({ c0, c1, c2 }, b1) => ({ - c0: Fp2.mulByNonresidue(Fp2.mul(c2, b1)), - c1: Fp2.mul(c0, b1), - c2: Fp2.mul(c1, b1), - }), - // Sparse multiplication - multiplyBy01({ c0, c1, c2 }, b0, b1) { - let t0 = Fp2.mul(c0, b0); // c0 * b0 - let t1 = Fp2.mul(c1, b1); // c1 * b1 - return { - // ((c1 + c2) * b1 - T1) * (u + 1) + T0 - c0: Fp2.add(Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), b1), t1)), t0), - // (b0 + b1) * (c0 + c1) - T0 - T1 - c1: Fp2.sub(Fp2.sub(Fp2.mul(Fp2.add(b0, b1), Fp2.add(c0, c1)), t0), t1), - // (c0 + c2) * b0 - T0 + T1 - c2: Fp2.add(Fp2.sub(Fp2.mul(Fp2.add(c0, c2), b0), t0), t1), - }; - }, - multiplyByFp2: ({ c0, c1, c2 }, rhs) => ({ - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }), -}; -const FP6_FROBENIUS_COEFFICIENTS_1 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x0'), - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [BigInt('0x0'), BigInt('0x1')], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x0'), - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - ], -].map((pair) => Fp2.fromBigTuple(pair)); -const FP6_FROBENIUS_COEFFICIENTS_2 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - BigInt('0x0'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - BigInt('0x0'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - BigInt('0x0'), - ], -].map((pair) => Fp2.fromBigTuple(pair)); -// The BLS parameter x for BLS12-381 -const BLS_X = BigInt('0xd201000000010000'); -const BLS_X_LEN = (0, utils_js_1.bitLen)(BLS_X); -const Fp12Add = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp6.add(c0, r0), - c1: Fp6.add(c1, r1), -}); -const Fp12Subtract = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp6.sub(c0, r0), - c1: Fp6.sub(c1, r1), -}); -const Fp12Multiply = ({ c0, c1 }, rhs) => { - if (typeof rhs === 'bigint') - return { c0: Fp6.mul(c0, rhs), c1: Fp6.mul(c1, rhs) }; - let { c0: r0, c1: r1 } = rhs; - let t1 = Fp6.mul(c0, r0); // c0 * r0 - let t2 = Fp6.mul(c1, r1); // c1 * r1 - return { - c0: Fp6.add(t1, Fp6.mulByNonresidue(t2)), - // (c0 + c1) * (r0 + r1) - (T1 + T2) - c1: Fp6.sub(Fp6.mul(Fp6.add(c0, c1), Fp6.add(r0, r1)), Fp6.add(t1, t2)), - }; -}; -const Fp12Square = ({ c0, c1 }) => { - let ab = Fp6.mul(c0, c1); // c0 * c1 - return { - // (c1 * v + c0) * (c0 + c1) - AB - AB * v - c0: Fp6.sub(Fp6.sub(Fp6.mul(Fp6.add(Fp6.mulByNonresidue(c1), c0), Fp6.add(c0, c1)), ab), Fp6.mulByNonresidue(ab)), - c1: Fp6.add(ab, ab), - }; // AB + AB -}; -function Fp4Square(a, b) { - const a2 = Fp2.sqr(a); - const b2 = Fp2.sqr(b); - return { - first: Fp2.add(Fp2.mulByNonresidue(b2), a2), - second: Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(a, b)), a2), b2), // (a + b)² - a² - b² - }; -} -const Fp12 = { - ORDER: Fp2.ORDER, - BITS: 2 * Fp2.BITS, - BYTES: 2 * Fp2.BYTES, - MASK: (0, utils_js_1.bitMask)(2 * Fp2.BITS), - ZERO: { c0: Fp6.ZERO, c1: Fp6.ZERO }, - ONE: { c0: Fp6.ONE, c1: Fp6.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => Fp6.isValid(c0) && Fp6.isValid(c1), - is0: ({ c0, c1 }) => Fp6.is0(c0) && Fp6.is0(c1), - neg: ({ c0, c1 }) => ({ c0: Fp6.neg(c0), c1: Fp6.neg(c1) }), - eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp6.eql(c0, r0) && Fp6.eql(c1, r1), - sqrt: () => { - throw new Error('Not implemented'); - }, - inv: ({ c0, c1 }) => { - let t = Fp6.inv(Fp6.sub(Fp6.sqr(c0), Fp6.mulByNonresidue(Fp6.sqr(c1)))); // 1 / (c0² - c1² * v) - return { c0: Fp6.mul(c0, t), c1: Fp6.neg(Fp6.mul(c1, t)) }; // ((C0 * T) * T) + (-C1 * T) * w - }, - div: (lhs, rhs) => Fp12.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp12.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp12, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp12, nums), - // Normalized - add: Fp12Add, - sub: Fp12Subtract, - mul: Fp12Multiply, - sqr: Fp12Square, - // NonNormalized stuff - addN: Fp12Add, - subN: Fp12Subtract, - mulN: Fp12Multiply, - sqrN: Fp12Square, - // Bytes utils - fromBytes: (b) => { - if (b.length !== Fp12.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp6.fromBytes(b.subarray(0, Fp6.BYTES)), - c1: Fp6.fromBytes(b.subarray(Fp6.BYTES)), - }; - }, - toBytes: ({ c0, c1 }) => (0, utils_js_1.concatBytes)(Fp6.toBytes(c0), Fp6.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp6.cmov(c0, r0, c), - c1: Fp6.cmov(c1, r1, c), - }), - // Utils - // toString() { - // return `Fp12(${this.c0} + ${this.c1} * w)`; - // }, - // fromTuple(c: [Fp6, Fp6]) { - // return new Fp12(...c); - // } - fromBigTwelve: (t) => ({ - c0: Fp6.fromBigSix(t.slice(0, 6)), - c1: Fp6.fromBigSix(t.slice(6, 12)), - }), - // Raises to q**i -th power - frobeniusMap(lhs, power) { - const r0 = Fp6.frobeniusMap(lhs.c0, power); - const { c0, c1, c2 } = Fp6.frobeniusMap(lhs.c1, power); - const coeff = FP12_FROBENIUS_COEFFICIENTS[power % 12]; - return { - c0: r0, - c1: Fp6.create({ - c0: Fp2.mul(c0, coeff), - c1: Fp2.mul(c1, coeff), - c2: Fp2.mul(c2, coeff), - }), - }; - }, - // Sparse multiplication - multiplyBy014: ({ c0, c1 }, o0, o1, o4) => { - let t0 = Fp6.multiplyBy01(c0, o0, o1); - let t1 = Fp6.multiplyBy1(c1, o4); - return { - c0: Fp6.add(Fp6.mulByNonresidue(t1), t0), - // (c1 + c0) * [o0, o1+o4] - T0 - T1 - c1: Fp6.sub(Fp6.sub(Fp6.multiplyBy01(Fp6.add(c1, c0), o0, Fp2.add(o1, o4)), t0), t1), - }; - }, - multiplyByFp2: ({ c0, c1 }, rhs) => ({ - c0: Fp6.multiplyByFp2(c0, rhs), - c1: Fp6.multiplyByFp2(c1, rhs), - }), - conjugate: ({ c0, c1 }) => ({ c0, c1: Fp6.neg(c1) }), - // A cyclotomic group is a subgroup of Fp^n defined by - // GΦₙ(p) = {α ∈ Fpⁿ : α^Φₙ(p) = 1} - // The result of any pairing is in a cyclotomic subgroup - // https://eprint.iacr.org/2009/565.pdf - _cyclotomicSquare: ({ c0, c1 }) => { - const { c0: c0c0, c1: c0c1, c2: c0c2 } = c0; - const { c0: c1c0, c1: c1c1, c2: c1c2 } = c1; - const { first: t3, second: t4 } = Fp4Square(c0c0, c1c1); - const { first: t5, second: t6 } = Fp4Square(c1c0, c0c2); - const { first: t7, second: t8 } = Fp4Square(c0c1, c1c2); - let t9 = Fp2.mulByNonresidue(t8); // T8 * (u + 1) - return { - c0: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.sub(t3, c0c0), _2n), t3), - c1: Fp2.add(Fp2.mul(Fp2.sub(t5, c0c1), _2n), t5), - c2: Fp2.add(Fp2.mul(Fp2.sub(t7, c0c2), _2n), t7), - }), - c1: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.add(t9, c1c0), _2n), t9), - c1: Fp2.add(Fp2.mul(Fp2.add(t4, c1c1), _2n), t4), - c2: Fp2.add(Fp2.mul(Fp2.add(t6, c1c2), _2n), t6), - }), - }; // 2 * (T6 + c1c2) + T6 - }, - _cyclotomicExp(num, n) { - let z = Fp12.ONE; - for (let i = BLS_X_LEN - 1; i >= 0; i--) { - z = Fp12._cyclotomicSquare(z); - if ((0, utils_js_1.bitGet)(n, i)) - z = Fp12.mul(z, num); - } - return z; - }, - // https://eprint.iacr.org/2010/354.pdf - // https://eprint.iacr.org/2009/565.pdf - finalExponentiate: (num) => { - const x = BLS_X; - // this^(q⁶) / this - const t0 = Fp12.div(Fp12.frobeniusMap(num, 6), num); - // t0^(q²) * t0 - const t1 = Fp12.mul(Fp12.frobeniusMap(t0, 2), t0); - const t2 = Fp12.conjugate(Fp12._cyclotomicExp(t1, x)); - const t3 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicSquare(t1)), t2); - const t4 = Fp12.conjugate(Fp12._cyclotomicExp(t3, x)); - const t5 = Fp12.conjugate(Fp12._cyclotomicExp(t4, x)); - const t6 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicExp(t5, x)), Fp12._cyclotomicSquare(t2)); - const t7 = Fp12.conjugate(Fp12._cyclotomicExp(t6, x)); - const t2_t5_pow_q2 = Fp12.frobeniusMap(Fp12.mul(t2, t5), 2); - const t4_t1_pow_q3 = Fp12.frobeniusMap(Fp12.mul(t4, t1), 3); - const t6_t1c_pow_q1 = Fp12.frobeniusMap(Fp12.mul(t6, Fp12.conjugate(t1)), 1); - const t7_t3c_t1 = Fp12.mul(Fp12.mul(t7, Fp12.conjugate(t3)), t1); - // (t2 * t5)^(q²) * (t4 * t1)^(q³) * (t6 * t1.conj)^(q^1) * t7 * t3.conj * t1 - return Fp12.mul(Fp12.mul(Fp12.mul(t2_t5_pow_q2, t4_t1_pow_q3), t6_t1c_pow_q1), t7_t3c_t1); - }, -}; -const FP12_FROBENIUS_COEFFICIENTS = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8'), - BigInt('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - BigInt('0x0'), - ], - [ - BigInt('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2'), - BigInt('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [ - BigInt('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995'), - BigInt('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116'), - ], - [ - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - BigInt('0x0'), - ], - [ - BigInt('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3'), - BigInt('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'), - BigInt('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - BigInt('0x0'), - ], - [ - BigInt('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116'), - BigInt('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995'), - ], -].map((n) => Fp2.fromBigTuple(n)); -// END OF CURVE FIELDS -// HashToCurve -// 3-isogeny map from E' to E -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#appendix-E.3 -const isogenyMapG2 = (0, hash_to_curve_js_1.isogenyMap)(Fp2, [ - // xNum - [ - [ - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - ], - [ - '0x0', - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d', - ], - [ - '0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1', - '0x0', - ], - ], - // xDen - [ - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63', - ], - [ - '0xc', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f', - ], - ['0x1', '0x0'], // LAST 1 - ], - // yNum - [ - [ - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - ], - [ - '0x0', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f', - ], - [ - '0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10', - '0x0', - ], - ], - // yDen - [ - [ - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - ], - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3', - ], - [ - '0x12', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99', - ], - ['0x1', '0x0'], // LAST 1 - ], -].map((i) => i.map((pair) => Fp2.fromBigTuple(pair.map(BigInt))))); -// 11-isogeny map from E' to E -const isogenyMapG1 = (0, hash_to_curve_js_1.isogenyMap)(Fp, [ - // xNum - [ - '0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7', - '0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb', - '0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0', - '0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861', - '0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9', - '0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983', - '0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84', - '0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e', - '0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317', - '0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e', - '0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b', - '0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229', - ], - // xDen - [ - '0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c', - '0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff', - '0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19', - '0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8', - '0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e', - '0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5', - '0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a', - '0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e', - '0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641', - '0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33', - '0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696', - '0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6', - '0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb', - '0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb', - '0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0', - '0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2', - '0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29', - '0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587', - '0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30', - '0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132', - '0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e', - '0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8', - '0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133', - '0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b', - '0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604', - ], - // yDen - [ - '0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1', - '0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d', - '0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2', - '0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416', - '0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d', - '0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac', - '0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c', - '0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9', - '0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a', - '0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55', - '0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8', - '0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092', - '0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc', - '0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7', - '0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], -].map((i) => i.map((j) => BigInt(j)))); -// SWU Map - Fp2 to G2': y² = x³ + 240i * x + 1012 + 1012i -const G2_SWU = (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp2, { - A: Fp2.create({ c0: Fp.create(_0n), c1: Fp.create(BigInt(240)) }), - B: Fp2.create({ c0: Fp.create(BigInt(1012)), c1: Fp.create(BigInt(1012)) }), - Z: Fp2.create({ c0: Fp.create(BigInt(-2)), c1: Fp.create(BigInt(-1)) }), // Z: -(2 + I) -}); -// Optimized SWU Map - Fp to G1 -const G1_SWU = (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp, { - A: Fp.create(BigInt('0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d')), - B: Fp.create(BigInt('0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0')), - Z: Fp.create(BigInt(11)), -}); -// Endomorphisms (for fast cofactor clearing) -// Ψ(P) endomorphism -const ut_root = Fp6.create({ c0: Fp2.ZERO, c1: Fp2.ONE, c2: Fp2.ZERO }); -const wsq = Fp12.create({ c0: ut_root, c1: Fp6.ZERO }); -const wcu = Fp12.create({ c0: Fp6.ZERO, c1: ut_root }); -const [wsq_inv, wcu_inv] = Fp12.invertBatch([wsq, wcu]); -function psi(x, y) { - // Untwist Fp2->Fp12 && frobenius(1) && twist back - const x2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wsq_inv, x), 1), wsq).c0.c0; - const y2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wcu_inv, y), 1), wcu).c0.c0; - return [x2, y2]; -} -// Ψ endomorphism -function G2psi(c, P) { - const affine = P.toAffine(); - const p = psi(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} -// Ψ²(P) endomorphism -// 1 / F2(2)^((p-1)/3) in GF(p²) -const PSI2_C1 = BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'); -function psi2(x, y) { - return [Fp2.mul(x, PSI2_C1), Fp2.neg(y)]; -} -function G2psi2(c, P) { - const affine = P.toAffine(); - const p = psi2(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} -// Default hash_to_field options are for hash to G2. -// -// Parameter definitions are in section 5.3 of the spec unless otherwise noted. -// Parameter values come from section 8.8.2 of the spec. -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-8.8.2 -// -// Base field F is GF(p^m) -// p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab -// m = 2 (or 1 for G1 see section 8.8.1) -// k = 128 -const htfDefaults = Object.freeze({ - // DST: a domain separation tag - // defined in section 2.2.5 - // Use utils.getDSTLabel(), utils.setDSTLabel(value) - DST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - encodeDST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - // p: the characteristic of F - // where F is a finite field of characteristic p and order q = p^m - p: Fp.ORDER, - // m: the extension degree of F, m >= 1 - // where F is a finite field of characteristic p and order q = p^m - m: 2, - // k: the target security level for the suite in bits - // defined in section 5.1 - k: 128, - // option to use a message that has already been processed by - // expand_message_xmd - expand: 'xmd', - // Hash functions for: expand_message_xmd is appropriate for use with a - // wide range of hash functions, including SHA-2, SHA-3, BLAKE2, and others. - // BBS+ uses blake2: https://github.com/hyperledger/aries-framework-go/issues/2247 - hash: sha256_1.sha256, -}); -// Encoding utils -// Point on G1 curve: (x, y) -const C_BIT_POS = Fp.BITS; // C_bit, compression bit for serialization flag -const I_BIT_POS = Fp.BITS + 1; // I_bit, point-at-infinity bit for serialization flag -const S_BIT_POS = Fp.BITS + 2; // S_bit, sign bit for serialization flag -// Compressed point of infinity -const COMPRESSED_ZERO = Fp.toBytes((0, utils_js_1.bitSet)((0, utils_js_1.bitSet)(_0n, I_BIT_POS, true), S_BIT_POS, true)); // set compressed & point-at-infinity bits -function signatureG2ToRawBytes(point) { - // NOTE: by some reasons it was missed in bls12-381, looks like bug - point.assertValidity(); - const len = Fp.BYTES; - if (point.equals(exports.bls12_381.G2.ProjectivePoint.ZERO)) - return (0, utils_js_1.concatBytes)(COMPRESSED_ZERO, (0, utils_js_1.numberToBytesBE)(_0n, len)); - const { x, y } = point.toAffine(); - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - const tmp = y1 > _0n ? y1 * _2n : y0 * _2n; - const aflag1 = Boolean((tmp / Fp.ORDER) & _1n); - const z1 = (0, utils_js_1.bitSet)((0, utils_js_1.bitSet)(x1, 381, aflag1), S_BIT_POS, true); - const z2 = x0; - return (0, utils_js_1.concatBytes)((0, utils_js_1.numberToBytesBE)(z1, len), (0, utils_js_1.numberToBytesBE)(z2, len)); -} -// To verify curve parameters, see pairing-friendly-curves spec: -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-pairing-friendly-curves-09 -// Basic math is done over finite fields over p. -// More complicated math is done over polynominal extension fields. -// To simplify calculations in Fp12, we construct extension tower: -// Fp₁₂ = Fp₆² => Fp₂³ -// Fp(u) / (u² - β) where β = -1 -// Fp₂(v) / (v³ - ξ) where ξ = u + 1 -// Fp₆(w) / (w² - γ) where γ = v -// Here goes constants && point encoding format -exports.bls12_381 = (0, bls_js_1.bls)({ - // Fields - fields: { - Fp, - Fp2, - Fp6, - Fp12, - Fr, - }, - // G1 is the order-q subgroup of E1(Fp) : y² = x³ + 4, #E1(Fp) = h1q, where - // characteristic; z + (z⁴ - z² + 1)(z - 1)²/3 - G1: { - Fp, - // cofactor; (z - 1)²/3 - h: BigInt('0x396c8c005555e1568c00aaab0000aaab'), - // generator's coordinates - // x = 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507 - // y = 1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569 - Gx: BigInt('0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb'), - Gy: BigInt('0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1'), - a: Fp.ZERO, - b: _4n, - htfDefaults: { ...htfDefaults, m: 1 }, - wrapPrivateKey: true, - allowInfinityPoint: true, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, point) => { - // φ endomorphism - const cubicRootOfUnityModP = BigInt('0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'); - const phi = new c(Fp.mul(point.px, cubicRootOfUnityModP), point.py, point.pz); - // todo: unroll - const xP = point.multiplyUnsafe(exports.bls12_381.params.x).negate(); // [x]P - const u2P = xP.multiplyUnsafe(exports.bls12_381.params.x); // [u2]P - return u2P.equals(phi); - // https://eprint.iacr.org/2019/814.pdf - // (z² − 1)/3 - // const c1 = BigInt('0x396c8c005555e1560000000055555555'); - // const P = this; - // const S = P.sigma(); - // const Q = S.double(); - // const S2 = S.sigma(); - // // [(z² − 1)/3](2σ(P) − P − σ²(P)) − σ²(P) = O - // const left = Q.subtract(P).subtract(S2).multiplyUnsafe(c1); - // const C = left.subtract(S2); - // return C.isZero(); - }, - // Clear cofactor of G1 - // https://eprint.iacr.org/2019/403 - clearCofactor: (c, point) => { - // return this.multiplyUnsafe(CURVE.h); - return point.multiplyUnsafe(exports.bls12_381.params.x).add(point); // x*P + P - }, - mapToCurve: (scalars) => { - const { x, y } = G1_SWU(Fp.create(scalars[0])); - return isogenyMapG1(x, y); - }, - fromBytes: (bytes) => { - bytes = bytes.slice(); - if (bytes.length === 48) { - // TODO: Fp.bytes - const P = Fp.ORDER; - const compressedValue = (0, utils_js_1.bytesToNumberBE)(bytes); - const bflag = (0, utils_js_1.bitGet)(compressedValue, I_BIT_POS); - // Zero - if (bflag === _1n) - return { x: _0n, y: _0n }; - const x = Fp.create(compressedValue & Fp.MASK); - const right = Fp.add(Fp.pow(x, _3n), Fp.create(exports.bls12_381.params.G1b)); // y² = x³ + b - let y = Fp.sqrt(right); - if (!y) - throw new Error('Invalid compressed G1 point'); - const aflag = (0, utils_js_1.bitGet)(compressedValue, C_BIT_POS); - if ((y * _2n) / P !== aflag) - y = Fp.neg(y); - return { x: Fp.create(x), y: Fp.create(y) }; - } - else if (bytes.length === 96) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) - return exports.bls12_381.G1.ProjectivePoint.ZERO.toAffine(); - const x = (0, utils_js_1.bytesToNumberBE)(bytes.subarray(0, Fp.BYTES)); - const y = (0, utils_js_1.bytesToNumberBE)(bytes.subarray(Fp.BYTES)); - return { x: Fp.create(x), y: Fp.create(y) }; - } - else { - throw new Error('Invalid point G1, expected 48/96 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) - return COMPRESSED_ZERO.slice(); - const P = Fp.ORDER; - let num; - num = (0, utils_js_1.bitSet)(x, C_BIT_POS, Boolean((y * _2n) / P)); // set aflag - num = (0, utils_js_1.bitSet)(num, S_BIT_POS, true); - return (0, utils_js_1.numberToBytesBE)(num, Fp.BYTES); - } - else { - if (isZero) { - // 2x PUBLIC_KEY_LENGTH - const x = (0, utils_js_1.concatBytes)(new Uint8Array([0x40]), new Uint8Array(2 * Fp.BYTES - 1)); - return x; - } - else { - return (0, utils_js_1.concatBytes)((0, utils_js_1.numberToBytesBE)(x, Fp.BYTES), (0, utils_js_1.numberToBytesBE)(y, Fp.BYTES)); - } - } - }, - }, - // G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), - // where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where - // G² - 1 - // h2q - G2: { - Fp: Fp2, - // cofactor - h: BigInt('0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5'), - Gx: Fp2.fromBigTuple([ - BigInt('0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8'), - BigInt('0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e'), - ]), - // y = - // 927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582, - // 1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905 - Gy: Fp2.fromBigTuple([ - BigInt('0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801'), - BigInt('0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be'), - ]), - a: Fp2.ZERO, - b: Fp2.fromBigTuple([_4n, _4n]), - hEff: BigInt('0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551'), - htfDefaults: { ...htfDefaults }, - wrapPrivateKey: true, - allowInfinityPoint: true, - mapToCurve: (scalars) => { - const { x, y } = G2_SWU(Fp2.fromBigTuple(scalars)); - return isogenyMapG2(x, y); - }, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, P) => { - return P.multiplyUnsafe(exports.bls12_381.params.x).negate().equals(G2psi(c, P)); // ψ(P) == [u](P) - // Older version: https://eprint.iacr.org/2019/814.pdf - // Ψ²(P) => Ψ³(P) => [z]Ψ³(P) where z = -x => [z]Ψ³(P) - Ψ²(P) + P == O - // return P.psi2().psi().mulNegX().subtract(psi2).add(P).isZero(); - }, - // Maps the point into the prime-order subgroup G2. - // clear_cofactor_bls12381_g2 from cfrg-hash-to-curve-11 - // https://eprint.iacr.org/2017/419.pdf - // prettier-ignore - clearCofactor: (c, P) => { - const x = exports.bls12_381.params.x; - let t1 = P.multiplyUnsafe(x).negate(); // [-x]P - let t2 = G2psi(c, P); // Ψ(P) - let t3 = P.double(); // 2P - t3 = G2psi2(c, t3); // Ψ²(2P) - t3 = t3.subtract(t2); // Ψ²(2P) - Ψ(P) - t2 = t1.add(t2); // [-x]P + Ψ(P) - t2 = t2.multiplyUnsafe(x).negate(); // [x²]P - [x]Ψ(P) - t3 = t3.add(t2); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) - t3 = t3.subtract(t1); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - const Q = t3.subtract(P); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - 1P - return Q; // [x²-x-1]P + [x-1]Ψ(P) + Ψ²(2P) - }, - fromBytes: (bytes) => { - bytes = bytes.slice(); - const m_byte = bytes[0] & 0xe0; - if (m_byte === 0x20 || m_byte === 0x60 || m_byte === 0xe0) { - throw new Error('Invalid encoding flag: ' + m_byte); - } - const bitC = m_byte & 0x80; // compression bit - const bitI = m_byte & 0x40; // point at infinity bit - const bitS = m_byte & 0x20; // sign bit - const L = Fp.BYTES; - const slc = (b, from, to) => (0, utils_js_1.bytesToNumberBE)(b.slice(from, to)); - if (bytes.length === 96 && bitC) { - const b = exports.bls12_381.params.G2b; - const P = Fp.ORDER; - bytes[0] = bytes[0] & 0x1f; // clear flags - if (bitI) { - // check that all bytes are 0 - if (bytes.reduce((p, c) => (p !== 0 ? c + 1 : c), 0) > 0) { - throw new Error('Invalid compressed G2 point'); - } - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x_1 = slc(bytes, 0, L); - const x_0 = slc(bytes, L, 2 * L); - const x = Fp2.create({ c0: Fp.create(x_0), c1: Fp.create(x_1) }); - const right = Fp2.add(Fp2.pow(x, _3n), b); // y² = x³ + 4 * (u+1) = x³ + b - let y = Fp2.sqrt(right); - const Y_bit = y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P ? _1n : _0n; - y = bitS > 0 && Y_bit > 0 ? y : Fp2.neg(y); - return { x, y }; - } - else if (bytes.length === 192 && !bitC) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) { - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x1 = slc(bytes, 0, L); - const x0 = slc(bytes, L, 2 * L); - const y1 = slc(bytes, 2 * L, 3 * L); - const y0 = slc(bytes, 3 * L, 4 * L); - return { x: Fp2.fromBigTuple([x0, x1]), y: Fp2.fromBigTuple([y0, y1]) }; - } - else { - throw new Error('Invalid point G2, expected 96/192 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const { BYTES: len, ORDER: P } = Fp; - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) - return (0, utils_js_1.concatBytes)(COMPRESSED_ZERO, (0, utils_js_1.numberToBytesBE)(_0n, len)); - const flag = Boolean(y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P); - // set compressed & sign bits (looks like different offsets than for G1/Fp?) - let x_1 = (0, utils_js_1.bitSet)(x.c1, C_BIT_POS, flag); - x_1 = (0, utils_js_1.bitSet)(x_1, S_BIT_POS, true); - return (0, utils_js_1.concatBytes)((0, utils_js_1.numberToBytesBE)(x_1, len), (0, utils_js_1.numberToBytesBE)(x.c0, len)); - } - else { - if (isZero) - return (0, utils_js_1.concatBytes)(new Uint8Array([0x40]), new Uint8Array(4 * len - 1)); // bytes[0] |= 1 << 6; - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - return (0, utils_js_1.concatBytes)((0, utils_js_1.numberToBytesBE)(x1, len), (0, utils_js_1.numberToBytesBE)(x0, len), (0, utils_js_1.numberToBytesBE)(y1, len), (0, utils_js_1.numberToBytesBE)(y0, len)); - } - }, - Signature: { - // TODO: Optimize, it's very slow because of sqrt. - fromHex(hex) { - hex = (0, utils_js_1.ensureBytes)('signatureHex', hex); - const P = Fp.ORDER; - const half = hex.length / 2; - if (half !== 48 && half !== 96) - throw new Error('Invalid compressed signature length, must be 96 or 192'); - const z1 = (0, utils_js_1.bytesToNumberBE)(hex.slice(0, half)); - const z2 = (0, utils_js_1.bytesToNumberBE)(hex.slice(half)); - // Indicates the infinity point - const bflag1 = (0, utils_js_1.bitGet)(z1, I_BIT_POS); - if (bflag1 === _1n) - return exports.bls12_381.G2.ProjectivePoint.ZERO; - const x1 = Fp.create(z1 & Fp.MASK); - const x2 = Fp.create(z2); - const x = Fp2.create({ c0: x2, c1: x1 }); - const y2 = Fp2.add(Fp2.pow(x, _3n), exports.bls12_381.params.G2b); // y² = x³ + 4 - // The slow part - let y = Fp2.sqrt(y2); - if (!y) - throw new Error('Failed to find a square root'); - // Choose the y whose leftmost bit of the imaginary part is equal to the a_flag1 - // If y1 happens to be zero, then use the bit of y0 - const { re: y0, im: y1 } = Fp2.reim(y); - const aflag1 = (0, utils_js_1.bitGet)(z1, 381); - const isGreater = y1 > _0n && (y1 * _2n) / P !== aflag1; - const isZero = y1 === _0n && (y0 * _2n) / P !== aflag1; - if (isGreater || isZero) - y = Fp2.neg(y); - const point = exports.bls12_381.G2.ProjectivePoint.fromAffine({ x, y }); - point.assertValidity(); - return point; - }, - toRawBytes(point) { - return signatureG2ToRawBytes(point); - }, - toHex(point) { - return (0, utils_js_1.bytesToHex)(signatureG2ToRawBytes(point)); - }, - }, - }, - params: { - x: BLS_X, - r: Fr.ORDER, // order; z⁴ − z² + 1; CURVE.n from other curves - }, - htfDefaults, - hash: sha256_1.sha256, - randomBytes: utils_1.randomBytes, -}); -//# sourceMappingURL=bls12-381.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js.map deleted file mode 100644 index 55ecfb5b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bls12-381.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls12-381.js","sourceRoot":"","sources":["src/bls12-381.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,uFAAuF;AACvF,gDAAgD;AAChD,kGAAkG;AAClG,+EAA+E;AAC/E,EAAE;AACF,mGAAmG;AACnG,+EAA+E;AAC/E,+FAA+F;AAC/F,+EAA+E;AAC/E,oFAAoF;AACpF,EAAE;AACF,cAAc;AACd,gDAAgD;AAChD,4BAA4B;AAC5B,2FAA2F;AAC3F,mHAAmH;AACnH,0FAA0F;AAC1F,2HAA2H;AAC3H,6CAA6C;AAC7C,EAAE;AACF,eAAe;AACf,+BAA+B;AAC/B,8BAA8B;AAC9B,0DAA0D;AAC1D,4EAA4E;AAC5E,6DAA6D;AAC7D,6DAA6D;AAC7D,iDAA8C;AAC9C,+CAAkD;AAClD,8CAAiD;AACjD,6CAA6C;AAC7C,kDAW6B;AAC7B,QAAQ;AACR,8DAKmC;AACnC,kEAAyD;AAEzD,qEAAqE;AACrE,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1F,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzC,eAAe;AACf,uBAAuB;AACvB,MAAM,MAAM,GAAG,MAAM,CACnB,oGAAoG,CACrG,CAAC;AACF,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAE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nostr-tools/node_modules/@noble/curves/bn254.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/bn254.d.ts deleted file mode 100644 index fd7064ad..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * bn254 pairing-friendly curve. - * Previously known as alt_bn_128, when it had 128-bit security. - * Recent research shown it's weaker, the naming has been adjusted to its prime bit count. - * https://github.com/zcash/zcash/issues/2502 - */ -export declare const bn254: import("./abstract/weierstrass.js").CurveFn; -//# sourceMappingURL=bn254.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/bn254.d.ts.map deleted file mode 100644 index 572db18a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bn254.d.ts","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,6CAShB,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js b/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js deleted file mode 100644 index 8b1c4b74..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.bn254 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha256_1 = require("@noble/hashes/sha256"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const modular_js_1 = require("./abstract/modular.js"); -/** - * bn254 pairing-friendly curve. - * Previously known as alt_bn_128, when it had 128-bit security. - * Recent research shown it's weaker, the naming has been adjusted to its prime bit count. - * https://github.com/zcash/zcash/issues/2502 - */ -exports.bn254 = (0, weierstrass_js_1.weierstrass)({ - a: BigInt(0), - b: BigInt(3), - Fp: (0, modular_js_1.Field)(BigInt('0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47')), - n: BigInt('0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001'), - Gx: BigInt(1), - Gy: BigInt(2), - h: BigInt(1), - ...(0, _shortw_utils_js_1.getHash)(sha256_1.sha256), -}); -//# sourceMappingURL=bn254.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js.map deleted file mode 100644 index a54fb586..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/bn254.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bn254.js","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,8DAAwD;AACxD,yDAA6C;AAC7C,sDAA8C;AAC9C;;;;;GAKG;AACU,QAAA,KAAK,GAAG,IAAA,4BAAW,EAAC;IAC/B,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,IAAA,kBAAK,EAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC;IACvF,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,IAAA,0BAAO,EAAC,eAAM,CAAC;CACnB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts deleted file mode 100644 index b996bf4f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { ExtPointType } from './abstract/edwards.js'; -import { Hex } from './abstract/utils.js'; -import { htfBasicOpts } from './abstract/hash-to-curve.js'; -import { AffinePoint } from './abstract/curve.js'; -export declare const ED25519_TORSION_SUBGROUP: string[]; -export declare const ed25519: import("./abstract/edwards.js").CurveFn; -export declare const ed25519ctx: import("./abstract/edwards.js").CurveFn; -export declare const ed25519ph: import("./abstract/edwards.js").CurveFn; -export declare const x25519: import("./abstract/montgomery.js").CurveFn; -/** - * Converts ed25519 public key to x25519 public key. Uses formula: - * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)` - * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))` - * @example - * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey()); - * const aPriv = x25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub)) - */ -export declare function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array; -export declare const edwardsToMontgomery: typeof edwardsToMontgomeryPub; -/** - * Converts ed25519 secret key to x25519 secret key. - * @example - * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey()); - * const aPriv = ed25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub) - */ -export declare function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array; -export declare const hashToCurve: (msg: Uint8Array, options?: htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -type ExtendedPoint = ExtPointType; -/** - * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be - * a source of bugs for protocols like ring signatures. Ristretto was created to solve this. - * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint, - * but it should work in its own namespace: do not combine those two. - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448 - */ -declare class RistPoint { - private readonly ep; - static BASE: RistPoint; - static ZERO: RistPoint; - constructor(ep: ExtendedPoint); - static fromAffine(ap: AffinePoint): RistPoint; - /** - * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`. - * The hash-to-group operation applies Elligator twice and adds the results. - * **Note:** this is one-way map, there is no conversion from point to hash. - * https://ristretto.group/formulas/elligator.html - * @param hex 64-byte output of a hash function - */ - static hashToCurve(hex: Hex): RistPoint; - /** - * Converts ristretto-encoded string to ristretto point. - * https://ristretto.group/formulas/decoding.html - * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding - */ - static fromHex(hex: Hex): RistPoint; - /** - * Encodes ristretto point to Uint8Array. - * https://ristretto.group/formulas/encoding.html - */ - toRawBytes(): Uint8Array; - toHex(): string; - toString(): string; - equals(other: RistPoint): boolean; - add(other: RistPoint): RistPoint; - subtract(other: RistPoint): RistPoint; - multiply(scalar: bigint): RistPoint; - multiplyUnsafe(scalar: bigint): RistPoint; -} -export declare const RistrettoPoint: typeof RistPoint; -export declare const hash_to_ristretto255: (msg: Uint8Array, options: htfBasicOpts) => RistPoint; -export {}; -//# sourceMappingURL=ed25519.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts.map deleted file mode 100644 index 13be7bcb..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["src/ed25519.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAkB,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAKL,GAAG,EAEJ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAgB,YAAY,EAAsB,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC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CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;CAG1C;AACD,eAAO,MAAM,cAAc,kBAIvB,CAAC;AAIL,eAAO,MAAM,oBAAoB,QAAS,UAAU,WAAW,YAAY,cAM1E,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js b/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js deleted file mode 100644 index c750251a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js +++ /dev/null @@ -1,436 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hash_to_ristretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.edwardsToMontgomeryPriv = exports.edwardsToMontgomery = exports.edwardsToMontgomeryPub = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha512_1 = require("@noble/hashes/sha512"); -const utils_1 = require("@noble/hashes/utils"); -const edwards_js_1 = require("./abstract/edwards.js"); -const montgomery_js_1 = require("./abstract/montgomery.js"); -const modular_js_1 = require("./abstract/modular.js"); -const utils_js_1 = require("./abstract/utils.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -/** - * ed25519 Twisted Edwards curve with following addons: - * - X25519 ECDH - * - Ristretto cofactor elimination - * - Elligator hash-to-group / point indistinguishability - */ -const ED25519_P = BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'); -// √(-1) aka √(a) aka 2^((p-1)/4) -const ED25519_SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752'); -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _5n = BigInt(5); -// prettier-ignore -const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80); -function ed25519_pow_2_252_3(x) { - const P = ED25519_P; - const x2 = (x * x) % P; - const b2 = (x2 * x) % P; // x^3, 11 - const b4 = ((0, modular_js_1.pow2)(b2, _2n, P) * b2) % P; // x^15, 1111 - const b5 = ((0, modular_js_1.pow2)(b4, _1n, P) * x) % P; // x^31 - const b10 = ((0, modular_js_1.pow2)(b5, _5n, P) * b5) % P; - const b20 = ((0, modular_js_1.pow2)(b10, _10n, P) * b10) % P; - const b40 = ((0, modular_js_1.pow2)(b20, _20n, P) * b20) % P; - const b80 = ((0, modular_js_1.pow2)(b40, _40n, P) * b40) % P; - const b160 = ((0, modular_js_1.pow2)(b80, _80n, P) * b80) % P; - const b240 = ((0, modular_js_1.pow2)(b160, _80n, P) * b80) % P; - const b250 = ((0, modular_js_1.pow2)(b240, _10n, P) * b10) % P; - const pow_p_5_8 = ((0, modular_js_1.pow2)(b250, _2n, P) * x) % P; - // ^ To pow to (p+3)/8, multiply it by x. - return { pow_p_5_8, b2 }; -} -function adjustScalarBytes(bytes) { - // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar, - // set the three least significant bits of the first byte - bytes[0] &= 248; // 0b1111_1000 - // and the most significant bit of the last to zero, - bytes[31] &= 127; // 0b0111_1111 - // set the second most significant bit of the last byte to 1 - bytes[31] |= 64; // 0b0100_0000 - return bytes; -} -// sqrt(u/v) -function uvRatio(u, v) { - const P = ED25519_P; - const v3 = (0, modular_js_1.mod)(v * v * v, P); // v³ - const v7 = (0, modular_js_1.mod)(v3 * v3 * v, P); // v⁷ - // (p+3)/8 and (p-5)/8 - const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8; - let x = (0, modular_js_1.mod)(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8 - const vx2 = (0, modular_js_1.mod)(v * x * x, P); // vx² - const root1 = x; // First root candidate - const root2 = (0, modular_js_1.mod)(x * ED25519_SQRT_M1, P); // Second root candidate - const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root - const useRoot2 = vx2 === (0, modular_js_1.mod)(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4) - const noRoot = vx2 === (0, modular_js_1.mod)(-u * ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1) - if (useRoot1) - x = root1; - if (useRoot2 || noRoot) - x = root2; // We return root2 anyway, for const-time - if ((0, modular_js_1.isNegativeLE)(x, P)) - x = (0, modular_js_1.mod)(-x, P); - return { isValid: useRoot1 || useRoot2, value: x }; -} -// Just in case -exports.ED25519_TORSION_SUBGROUP = [ - '0100000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a', - '0000000000000000000000000000000000000000000000000000000000000080', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05', - 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85', - '0000000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa', -]; -const Fp = (0, modular_js_1.Field)(ED25519_P, undefined, true); -const ed25519Defaults = { - // Param: a - a: BigInt(-1), - // d is equal to -121665/121666 over finite field. - // Negative number is P - number, and division is invert(number, P) - d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'), - // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n - Fp, - // Subgroup order: how many points curve has - // 2n**252n + 27742317777372353535851937790883648493n; - n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'), - Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'), - hash: sha512_1.sha512, - randomBytes: utils_1.randomBytes, - adjustScalarBytes, - // dom2 - // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3. - // Constant-time, u/√v - uvRatio, -}; -exports.ed25519 = (0, edwards_js_1.twistedEdwards)(ed25519Defaults); -function ed25519_domain(data, ctx, phflag) { - if (ctx.length > 255) - throw new Error('Context is too big'); - return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data); -} -exports.ed25519ctx = (0, edwards_js_1.twistedEdwards)({ ...ed25519Defaults, domain: ed25519_domain }); -exports.ed25519ph = (0, edwards_js_1.twistedEdwards)({ - ...ed25519Defaults, - domain: ed25519_domain, - prehash: sha512_1.sha512, -}); -exports.x25519 = (() => (0, montgomery_js_1.montgomery)({ - P: ED25519_P, - a: BigInt(486662), - montgomeryBits: 255, - nByteLength: 32, - Gu: BigInt(9), - powPminus2: (x) => { - const P = ED25519_P; - // x^(p-2) aka x^(2^255-21) - const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x); - return (0, modular_js_1.mod)((0, modular_js_1.pow2)(pow_p_5_8, BigInt(3), P) * b2, P); - }, - adjustScalarBytes, - randomBytes: utils_1.randomBytes, -}))(); -/** - * Converts ed25519 public key to x25519 public key. Uses formula: - * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)` - * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))` - * @example - * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey()); - * const aPriv = x25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub)) - */ -function edwardsToMontgomeryPub(edwardsPub) { - const { y } = exports.ed25519.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((_1n + y) * Fp.inv(_1n - y))); -} -exports.edwardsToMontgomeryPub = edwardsToMontgomeryPub; -exports.edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated -/** - * Converts ed25519 secret key to x25519 secret key. - * @example - * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey()); - * const aPriv = ed25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub) - */ -function edwardsToMontgomeryPriv(edwardsPriv) { - const hashed = ed25519Defaults.hash(edwardsPriv.subarray(0, 32)); - return ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32); -} -exports.edwardsToMontgomeryPriv = edwardsToMontgomeryPriv; -// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator) -// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since -// SageMath returns different root first and everything falls apart -const ELL2_C1 = (Fp.ORDER + BigInt(3)) / BigInt(8); // 1. c1 = (q + 3) / 8 # Integer arithmetic -const ELL2_C2 = Fp.pow(_2n, ELL2_C1); // 2. c2 = 2^c1 -const ELL2_C3 = Fp.sqrt(Fp.neg(Fp.ONE)); // 3. c3 = sqrt(-1) -const ELL2_C4 = (Fp.ORDER - BigInt(5)) / BigInt(8); // 4. c4 = (q - 5) / 8 # Integer arithmetic -const ELL2_J = BigInt(486662); -// prettier-ignore -function map_to_curve_elligator2_curve25519(u) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1 - let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not - let x1n = Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2) - let tv2 = Fp.sqr(xd); // 5. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 11. tv3 = gxd^2 - tv2 = Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4 - tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3 - tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3 - tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7 - let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8) - y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8) - let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3 - tv2 = Fp.sqr(y11); // 19. tv2 = y11^2 - tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd - let e1 = Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1 - let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt - let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd - let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u - y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2 - let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3 - let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1) - tv2 = Fp.sqr(y21); // 28. tv2 = y21^2 - tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2 - let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt - tv2 = Fp.sqr(y1); // 32. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd - let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2 - let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4) - return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1) -} -const ELL2_C1_EDWARDS = (0, modular_js_1.FpSqrtEven)(Fp, Fp.neg(BigInt(486664))); // sgn0(c1) MUST equal 0 -function map_to_curve_elligator2_edwards25519(u) { - const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) = - // map_to_curve_elligator2_curve25519(u) - let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd - xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1 - let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM - let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd - let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d) - let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd - let e = Fp.eql(tv1, Fp.ZERO); // 8. e = tv1 == 0 - xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e) - xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e) - yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e) - yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e) - const inv = Fp.invertBatch([xd, yd]); // batch division - return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd) -} -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), { - DST: 'edwards25519_XMD:SHA-512_ELL2_RO_', - encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha512_1.sha512, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -function assertRstPoint(other) { - if (!(other instanceof RistPoint)) - throw new Error('RistrettoPoint expected'); -} -// √(-1) aka √(a) aka 2^((p-1)/4) -const SQRT_M1 = ED25519_SQRT_M1; -// √(ad - 1) -const SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235'); -// 1 / √(a-d) -const INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578'); -// 1-d² -const ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838'); -// (d-1)² -const D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952'); -// Calculates 1/√(number) -const invertSqrt = (number) => uvRatio(_1n, number); -const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0, utils_js_1.bytesToNumberLE)(bytes) & MAX_255B); -// Computes Elligator map for Ristretto -// https://ristretto.group/formulas/elligator.html -function calcElligatorRistrettoMap(r0) { - const { d } = exports.ed25519.CURVE; - const P = exports.ed25519.CURVE.Fp.ORDER; - const mod = exports.ed25519.CURVE.Fp.create; - const r = mod(SQRT_M1 * r0 * r0); // 1 - const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2 - let c = BigInt(-1); // 3 - const D = mod((c - d * r) * mod(r + d)); // 4 - let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D); // 5 - let s_ = mod(s * r0); // 6 - if (!(0, modular_js_1.isNegativeLE)(s_, P)) - s_ = mod(-s_); - if (!Ns_D_is_sq) - s = s_; // 7 - if (!Ns_D_is_sq) - c = r; // 8 - const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D); // 9 - const s2 = s * s; - const W0 = mod((s + s) * D); // 10 - const W1 = mod(Nt * SQRT_AD_MINUS_ONE); // 11 - const W2 = mod(_1n - s2); // 12 - const W3 = mod(_1n + s2); // 13 - return new exports.ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2)); -} -/** - * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be - * a source of bugs for protocols like ring signatures. Ristretto was created to solve this. - * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint, - * but it should work in its own namespace: do not combine those two. - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448 - */ -class RistPoint { - // Private property to discourage combining ExtendedPoint + RistrettoPoint - // Always use Ristretto encoding/decoding instead. - constructor(ep) { - this.ep = ep; - } - static fromAffine(ap) { - return new RistPoint(exports.ed25519.ExtendedPoint.fromAffine(ap)); - } - /** - * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`. - * The hash-to-group operation applies Elligator twice and adds the results. - * **Note:** this is one-way map, there is no conversion from point to hash. - * https://ristretto.group/formulas/elligator.html - * @param hex 64-byte output of a hash function - */ - static hashToCurve(hex) { - hex = (0, utils_js_1.ensureBytes)('ristrettoHash', hex, 64); - const r1 = bytes255ToNumberLE(hex.slice(0, 32)); - const R1 = calcElligatorRistrettoMap(r1); - const r2 = bytes255ToNumberLE(hex.slice(32, 64)); - const R2 = calcElligatorRistrettoMap(r2); - return new RistPoint(R1.add(R2)); - } - /** - * Converts ristretto-encoded string to ristretto point. - * https://ristretto.group/formulas/decoding.html - * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding - */ - static fromHex(hex) { - hex = (0, utils_js_1.ensureBytes)('ristrettoHex', hex, 32); - const { a, d } = exports.ed25519.CURVE; - const P = exports.ed25519.CURVE.Fp.ORDER; - const mod = exports.ed25519.CURVE.Fp.create; - const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint'; - const s = bytes255ToNumberLE(hex); - // 1. Check that s_bytes is the canonical encoding of a field element, or else abort. - // 3. Check that s is non-negative, or else abort - if (!(0, utils_js_1.equalBytes)((0, utils_js_1.numberToBytesLE)(s, 32), hex) || (0, modular_js_1.isNegativeLE)(s, P)) - throw new Error(emsg); - const s2 = mod(s * s); - const u1 = mod(_1n + a * s2); // 4 (a is -1) - const u2 = mod(_1n - a * s2); // 5 - const u1_2 = mod(u1 * u1); - const u2_2 = mod(u2 * u2); - const v = mod(a * d * u1_2 - u2_2); // 6 - const { isValid, value: I } = invertSqrt(mod(v * u2_2)); // 7 - const Dx = mod(I * u2); // 8 - const Dy = mod(I * Dx * v); // 9 - let x = mod((s + s) * Dx); // 10 - if ((0, modular_js_1.isNegativeLE)(x, P)) - x = mod(-x); // 10 - const y = mod(u1 * Dy); // 11 - const t = mod(x * y); // 12 - if (!isValid || (0, modular_js_1.isNegativeLE)(t, P) || y === _0n) - throw new Error(emsg); - return new RistPoint(new exports.ed25519.ExtendedPoint(x, y, _1n, t)); - } - /** - * Encodes ristretto point to Uint8Array. - * https://ristretto.group/formulas/encoding.html - */ - toRawBytes() { - let { ex: x, ey: y, ez: z, et: t } = this.ep; - const P = exports.ed25519.CURVE.Fp.ORDER; - const mod = exports.ed25519.CURVE.Fp.create; - const u1 = mod(mod(z + y) * mod(z - y)); // 1 - const u2 = mod(x * y); // 2 - // Square root always exists - const u2sq = mod(u2 * u2); - const { value: invsqrt } = invertSqrt(mod(u1 * u2sq)); // 3 - const D1 = mod(invsqrt * u1); // 4 - const D2 = mod(invsqrt * u2); // 5 - const zInv = mod(D1 * D2 * t); // 6 - let D; // 7 - if ((0, modular_js_1.isNegativeLE)(t * zInv, P)) { - let _x = mod(y * SQRT_M1); - let _y = mod(x * SQRT_M1); - x = _x; - y = _y; - D = mod(D1 * INVSQRT_A_MINUS_D); - } - else { - D = D2; // 8 - } - if ((0, modular_js_1.isNegativeLE)(x * zInv, P)) - y = mod(-y); // 9 - let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a)) - if ((0, modular_js_1.isNegativeLE)(s, P)) - s = mod(-s); - return (0, utils_js_1.numberToBytesLE)(s, 32); // 11 - } - toHex() { - return (0, utils_js_1.bytesToHex)(this.toRawBytes()); - } - toString() { - return this.toHex(); - } - // Compare one point to another. - equals(other) { - assertRstPoint(other); - const { ex: X1, ey: Y1 } = this.ep; - const { ex: X2, ey: Y2 } = other.ep; - const mod = exports.ed25519.CURVE.Fp.create; - // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2) - const one = mod(X1 * Y2) === mod(Y1 * X2); - const two = mod(Y1 * Y2) === mod(X1 * X2); - return one || two; - } - add(other) { - assertRstPoint(other); - return new RistPoint(this.ep.add(other.ep)); - } - subtract(other) { - assertRstPoint(other); - return new RistPoint(this.ep.subtract(other.ep)); - } - multiply(scalar) { - return new RistPoint(this.ep.multiply(scalar)); - } - multiplyUnsafe(scalar) { - return new RistPoint(this.ep.multiplyUnsafe(scalar)); - } -} -exports.RistrettoPoint = (() => { - if (!RistPoint.BASE) - RistPoint.BASE = new RistPoint(exports.ed25519.ExtendedPoint.BASE); - if (!RistPoint.ZERO) - RistPoint.ZERO = new RistPoint(exports.ed25519.ExtendedPoint.ZERO); - return RistPoint; -})(); -// https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/14/ -// Appendix B. Hashing to ristretto255 -const hash_to_ristretto255 = (msg, options) => { - const d = options.DST; - const DST = typeof d === 'string' ? (0, utils_1.utf8ToBytes)(d) : d; - const uniform_bytes = (0, hash_to_curve_js_1.expand_message_xmd)(msg, DST, 64, sha512_1.sha512); - const P = RistPoint.hashToCurve(uniform_bytes); - return P; -}; -exports.hash_to_ristretto255 = hash_to_ristretto255; -//# sourceMappingURL=ed25519.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js.map deleted file mode 100644 index fb5b5232..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed25519.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["src/ed25519.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,+CAA4E;AAC5E,sDAAqE;AACrE,4DAAsD;AACtD,sDAAmF;AACnF,kDAO6B;AAC7B,kEAA6F;AAG7F;;;;;GAKG;AAEH,MAAM,SAAS,GAAG,MAAM,CACtB,+EAA+E,CAChF,CAAC;AACF,iCAAiC;AACjC,MAAM,eAAe,GAAG,MAAM,CAC5B,+EAA+E,CAChF,CAAC;AAEF,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,kBAAkB;AAClB,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEjF,SAAS,mBAAmB,CAAC,CAAS;IACpC,MAAM,CAAC,GAAG,SAAS,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CA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,CAAC;IACnD,CAAC;IAED,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,cAAc,CAAC,MAAc;QAC3B,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AACY,QAAA,cAAc,GAAmB,CAAC,GAAG,EAAE;IAClD,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,eAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,eAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC,EAAE,CAAC;AAEL,qEAAqE;AACrE,uCAAuC;AAChC,MAAM,oBAAoB,GAAG,CAAC,GAAe,EAAE,OAAqB,EAAE,EAAE;IAC7E,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IACtB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,IAAA,qCAAkB,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,eAAM,CAAC,CAAC;IAC/D,MAAM,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts deleted file mode 100644 index c6e8068e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export declare const ed448: import("./abstract/edwards.js").CurveFn; -export declare const ed448ph: import("./abstract/edwards.js").CurveFn; -export declare const x448: import("./abstract/montgomery.js").CurveFn; -/** - * Converts edwards448 public key to x448 public key. Uses formula: - * * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)` - * * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))` - * @example - * const aPub = ed448.getPublicKey(utils.randomPrivateKey()); - * x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub)) - */ -export declare function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array; -export declare const edwardsToMontgomery: typeof edwardsToMontgomeryPub; -export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -//# sourceMappingURL=ed448.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts.map deleted file mode 100644 index 93b9d92a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed448.d.ts","sourceRoot":"","sources":["src/ed448.ts"],"names":[],"mappings":"AAwHA,eAAO,MAAM,KAAK,yCAA4B,CAAC;AAE/C,eAAO,MAAM,OAAO,yCAAyD,CAAC;AAE9E,eAAO,MAAM,IAAI,4CAeV,CAAC;AAER;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAIlF;AACD,eAAO,MAAM,mBAAmB,+BAAyB,CAAC;AA2F1D,eAAO,MAAM,WAAW,uJAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,uJAA8C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js b/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js deleted file mode 100644 index 5d08fc37..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js +++ /dev/null @@ -1,219 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodeToCurve = exports.hashToCurve = exports.edwardsToMontgomery = exports.edwardsToMontgomeryPub = exports.x448 = exports.ed448ph = exports.ed448 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha3_1 = require("@noble/hashes/sha3"); -const utils_1 = require("@noble/hashes/utils"); -const edwards_js_1 = require("./abstract/edwards.js"); -const modular_js_1 = require("./abstract/modular.js"); -const montgomery_js_1 = require("./abstract/montgomery.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -/** - * Edwards448 (not Ed448-Goldilocks) curve with following addons: - * * X448 ECDH - * Conforms to RFC 8032 https://www.rfc-editor.org/rfc/rfc8032.html#section-5.2 - */ -const shake256_114 = (0, utils_1.wrapConstructor)(() => sha3_1.shake256.create({ dkLen: 114 })); -const shake256_64 = (0, utils_1.wrapConstructor)(() => sha3_1.shake256.create({ dkLen: 64 })); -const ed448P = BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439'); -// powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4. -// Used for efficient square root calculation. -// ((P-3)/4).toString(2) would produce bits [223x 1, 0, 222x 1] -function ed448_pow_Pminus3div4(x) { - const P = ed448P; - // prettier-ignore - const _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _11n = BigInt(11); - // prettier-ignore - const _22n = BigInt(22), _44n = BigInt(44), _88n = BigInt(88), _223n = BigInt(223); - const b2 = (x * x * x) % P; - const b3 = (b2 * b2 * x) % P; - const b6 = ((0, modular_js_1.pow2)(b3, _3n, P) * b3) % P; - const b9 = ((0, modular_js_1.pow2)(b6, _3n, P) * b3) % P; - const b11 = ((0, modular_js_1.pow2)(b9, _2n, P) * b2) % P; - const b22 = ((0, modular_js_1.pow2)(b11, _11n, P) * b11) % P; - const b44 = ((0, modular_js_1.pow2)(b22, _22n, P) * b22) % P; - const b88 = ((0, modular_js_1.pow2)(b44, _44n, P) * b44) % P; - const b176 = ((0, modular_js_1.pow2)(b88, _88n, P) * b88) % P; - const b220 = ((0, modular_js_1.pow2)(b176, _44n, P) * b44) % P; - const b222 = ((0, modular_js_1.pow2)(b220, _2n, P) * b2) % P; - const b223 = ((0, modular_js_1.pow2)(b222, _1n, P) * x) % P; - return ((0, modular_js_1.pow2)(b223, _223n, P) * b222) % P; -} -function adjustScalarBytes(bytes) { - // Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0, and the most - // significant bit of the last byte to 1. - bytes[0] &= 252; // 0b11111100 - // and the most significant bit of the last byte to 1. - bytes[55] |= 128; // 0b10000000 - // NOTE: is is NOOP for 56 bytes scalars (X25519/X448) - bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits) - return bytes; -} -const Fp = (0, modular_js_1.Field)(ed448P, 456, true); -const _4n = BigInt(4); -const ED448_DEF = { - // Param: a - a: BigInt(1), - // -39081. Negative number is P - number - d: BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358'), - // Finite field 𝔽p over which we'll do calculations; 2n**448n - 2n**224n - 1n - Fp, - // Subgroup order: how many points curve has; - // 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n - n: BigInt('181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779'), - nBitLength: 456, - // Cofactor - h: BigInt(4), - // Base point (x, y) aka generator point - Gx: BigInt('224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710'), - Gy: BigInt('298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660'), - // SHAKE256(dom4(phflag,context)||x, 114) - hash: shake256_114, - randomBytes: utils_1.randomBytes, - adjustScalarBytes, - // dom4 - domain: (data, ctx, phflag) => { - if (ctx.length > 255) - throw new Error(`Context is too big: ${ctx.length}`); - return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)('SigEd448'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data); - }, - // Constant-time ratio of u to v. Allows to combine inversion and square root u/√v. - // Uses algo from RFC8032 5.1.3. - uvRatio: (u, v) => { - const P = ed448P; - // https://datatracker.ietf.org/doc/html/rfc8032#section-5.2.3 - // To compute the square root of (u/v), the first step is to compute the - // candidate root x = (u/v)^((p+1)/4). This can be done using the - // following trick, to use a single modular powering for both the - // inversion of v and the square root: - // x = (u/v)^((p+1)/4) = u³v(u⁵v³)^((p-3)/4) (mod p) - const u2v = (0, modular_js_1.mod)(u * u * v, P); // u²v - const u3v = (0, modular_js_1.mod)(u2v * u, P); // u³v - const u5v3 = (0, modular_js_1.mod)(u3v * u2v * v, P); // u⁵v³ - const root = ed448_pow_Pminus3div4(u5v3); - const x = (0, modular_js_1.mod)(u3v * root, P); - // Verify that root is exists - const x2 = (0, modular_js_1.mod)(x * x, P); // x² - // If vx² = u, the recovered x-coordinate is x. Otherwise, no - // square root exists, and the decoding fails. - return { isValid: (0, modular_js_1.mod)(x2 * v, P) === u, value: x }; - }, -}; -exports.ed448 = (0, edwards_js_1.twistedEdwards)(ED448_DEF); -// NOTE: there is no ed448ctx, since ed448 supports ctx by default -exports.ed448ph = (0, edwards_js_1.twistedEdwards)({ ...ED448_DEF, prehash: shake256_64 }); -exports.x448 = (() => (0, montgomery_js_1.montgomery)({ - a: BigInt(156326), - montgomeryBits: 448, - nByteLength: 57, - P: ed448P, - Gu: BigInt(5), - powPminus2: (x) => { - const P = ed448P; - const Pminus3div4 = ed448_pow_Pminus3div4(x); - const Pminus3 = (0, modular_js_1.pow2)(Pminus3div4, BigInt(2), P); - return (0, modular_js_1.mod)(Pminus3 * x, P); // Pminus3 * x = Pminus2 - }, - adjustScalarBytes, - randomBytes: utils_1.randomBytes, -}))(); -/** - * Converts edwards448 public key to x448 public key. Uses formula: - * * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)` - * * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))` - * @example - * const aPub = ed448.getPublicKey(utils.randomPrivateKey()); - * x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub)) - */ -function edwardsToMontgomeryPub(edwardsPub) { - const { y } = exports.ed448.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((y - _1n) * Fp.inv(y + _1n))); -} -exports.edwardsToMontgomeryPub = edwardsToMontgomeryPub; -exports.edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated -// Hash To Curve Elligator2 Map -const ELL2_C1 = (Fp.ORDER - BigInt(3)) / BigInt(4); // 1. c1 = (q - 3) / 4 # Integer arithmetic -const ELL2_J = BigInt(156326); -function map_to_curve_elligator2_curve448(u) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - let e1 = Fp.eql(tv1, Fp.ONE); // 2. e1 = tv1 == 1 - tv1 = Fp.cmov(tv1, Fp.ZERO, e1); // 3. tv1 = CMOV(tv1, 0, e1) # If Z * u^2 == -1, set tv1 = 0 - let xd = Fp.sub(Fp.ONE, tv1); // 4. xd = 1 - tv1 - let x1n = Fp.neg(ELL2_J); // 5. x1n = -J - let tv2 = Fp.sqr(xd); // 6. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 7. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, Fp.neg(ELL2_J)); // 8. gx1 = -J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 9. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 10. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 11. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 12. tv3 = gxd^2 - tv2 = Fp.mul(gx1, gxd); // 13. tv2 = gx1 * gxd # gx1 * gxd - tv3 = Fp.mul(tv3, tv2); // 14. tv3 = tv3 * tv2 # gx1 * gxd^3 - let y1 = Fp.pow(tv3, ELL2_C1); // 15. y1 = tv3^c1 # (gx1 * gxd^3)^((p - 3) / 4) - y1 = Fp.mul(y1, tv2); // 16. y1 = y1 * tv2 # gx1 * gxd * (gx1 * gxd^3)^((p - 3) / 4) - let x2n = Fp.mul(x1n, Fp.neg(tv1)); // 17. x2n = -tv1 * x1n # x2 = x2n / xd = -1 * u^2 * x1n / xd - let y2 = Fp.mul(y1, u); // 18. y2 = y1 * u - y2 = Fp.cmov(y2, Fp.ZERO, e1); // 19. y2 = CMOV(y2, 0, e1) - tv2 = Fp.sqr(y1); // 20. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 21. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx1); // 22. e2 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e2); // 23. xn = CMOV(x2n, x1n, e2) # If e2, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e2); // 24. y = CMOV(y2, y1, e2) # If e2, y = y1, else y = y2 - let e3 = Fp.isOdd(y); // 25. e3 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e2 !== e3); // 26. y = CMOV(y, -y, e2 XOR e3) - return { xn, xd, yn: y, yd: Fp.ONE }; // 27. return (xn, xd, y, 1) -} -function map_to_curve_elligator2_edwards448(u) { - let { xn, xd, yn, yd } = map_to_curve_elligator2_curve448(u); // 1. (xn, xd, yn, yd) = map_to_curve_elligator2_curve448(u) - let xn2 = Fp.sqr(xn); // 2. xn2 = xn^2 - let xd2 = Fp.sqr(xd); // 3. xd2 = xd^2 - let xd4 = Fp.sqr(xd2); // 4. xd4 = xd2^2 - let yn2 = Fp.sqr(yn); // 5. yn2 = yn^2 - let yd2 = Fp.sqr(yd); // 6. yd2 = yd^2 - let xEn = Fp.sub(xn2, xd2); // 7. xEn = xn2 - xd2 - let tv2 = Fp.sub(xEn, xd2); // 8. tv2 = xEn - xd2 - xEn = Fp.mul(xEn, xd2); // 9. xEn = xEn * xd2 - xEn = Fp.mul(xEn, yd); // 10. xEn = xEn * yd - xEn = Fp.mul(xEn, yn); // 11. xEn = xEn * yn - xEn = Fp.mul(xEn, _4n); // 12. xEn = xEn * 4 - tv2 = Fp.mul(tv2, xn2); // 13. tv2 = tv2 * xn2 - tv2 = Fp.mul(tv2, yd2); // 14. tv2 = tv2 * yd2 - let tv3 = Fp.mul(yn2, _4n); // 15. tv3 = 4 * yn2 - let tv1 = Fp.add(tv3, yd2); // 16. tv1 = tv3 + yd2 - tv1 = Fp.mul(tv1, xd4); // 17. tv1 = tv1 * xd4 - let xEd = Fp.add(tv1, tv2); // 18. xEd = tv1 + tv2 - tv2 = Fp.mul(tv2, xn); // 19. tv2 = tv2 * xn - let tv4 = Fp.mul(xn, xd4); // 20. tv4 = xn * xd4 - let yEn = Fp.sub(tv3, yd2); // 21. yEn = tv3 - yd2 - yEn = Fp.mul(yEn, tv4); // 22. yEn = yEn * tv4 - yEn = Fp.sub(yEn, tv2); // 23. yEn = yEn - tv2 - tv1 = Fp.add(xn2, xd2); // 24. tv1 = xn2 + xd2 - tv1 = Fp.mul(tv1, xd2); // 25. tv1 = tv1 * xd2 - tv1 = Fp.mul(tv1, xd); // 26. tv1 = tv1 * xd - tv1 = Fp.mul(tv1, yn2); // 27. tv1 = tv1 * yn2 - tv1 = Fp.mul(tv1, BigInt(-2)); // 28. tv1 = -2 * tv1 - let yEd = Fp.add(tv2, tv1); // 29. yEd = tv2 + tv1 - tv4 = Fp.mul(tv4, yd2); // 30. tv4 = tv4 * yd2 - yEd = Fp.add(yEd, tv4); // 31. yEd = yEd + tv4 - tv1 = Fp.mul(xEd, yEd); // 32. tv1 = xEd * yEd - let e = Fp.eql(tv1, Fp.ZERO); // 33. e = tv1 == 0 - xEn = Fp.cmov(xEn, Fp.ZERO, e); // 34. xEn = CMOV(xEn, 0, e) - xEd = Fp.cmov(xEd, Fp.ONE, e); // 35. xEd = CMOV(xEd, 1, e) - yEn = Fp.cmov(yEn, Fp.ONE, e); // 36. yEn = CMOV(yEn, 1, e) - yEd = Fp.cmov(yEd, Fp.ONE, e); // 37. yEd = CMOV(yEd, 1, e) - const inv = Fp.invertBatch([xEd, yEd]); // batch division - return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd) -} -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.ed448.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), { - DST: 'edwards448_XOF:SHAKE256_ELL2_RO_', - encodeDST: 'edwards448_XOF:SHAKE256_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 224, - expand: 'xof', - hash: sha3_1.shake256, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -//# sourceMappingURL=ed448.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js.map deleted file mode 100644 index b3956e28..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/ed448.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed448.js","sourceRoot":"","sources":["src/ed448.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,6CAA8C;AAC9C,+CAA6F;AAC7F,sDAAuD;AACvD,sDAAyD;AACzD,4DAAsD;AACtD,kEAA2D;AAE3D;;;;GAIG;AAEH,MAAM,YAAY,GAAG,IAAA,u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AAiB;IACzD,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,kCAAkC;AAC/F,CAAC;AAED,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,IAAA,+BAAY,EACV,aAAK,CAAC,aAAa,EACnB,CAAC,OAAiB,EAAE,EAAE,CAAC,kCAAkC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EACrE;IACE,GAAG,EAAE,kCAAkC;IACvC,SAAS,EAAE,kCAAkC;IAC7C,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAQ;CACf,CACF,CAAC,EAAE,CAAC;AACM,QAAA,WAAW,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxD,QAAA,aAAa,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js deleted file mode 100644 index cc93e458..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js +++ /dev/null @@ -1,17 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { hmac } from '@noble/hashes/hmac'; -import { concatBytes, randomBytes } from '@noble/hashes/utils'; -import { weierstrass } from './abstract/weierstrass.js'; -// connects noble-curves to noble-hashes -export function getHash(hash) { - return { - hash, - hmac: (key, ...msgs) => hmac(hash, key, concatBytes(...msgs)), - randomBytes, - }; -} -export function createCurve(curveDef, defHash) { - const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) }); - return Object.freeze({ ...create(defHash), create }); -} -//# sourceMappingURL=_shortw_utils.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js.map deleted file mode 100644 index 656ee45f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"_shortw_utils.js","sourceRoot":"","sources":["../src/_shortw_utils.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAa,MAAM,2BAA2B,CAAC;AAGnE,wCAAwC;AACxC,MAAM,UAAU,OAAO,CAAC,IAAW;IACjC,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,CAAC,GAAe,EAAE,GAAG,IAAkB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;QACvF,WAAW;KACZ,CAAC;AACJ,CAAC;AAGD,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,OAAc;IAC5D,MAAM,MAAM,GAAG,CAAC,IAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js deleted file mode 100644 index cbb3721e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js +++ /dev/null @@ -1,235 +0,0 @@ -import { hashToPrivateScalar } from './modular.js'; -import { bitLen, bitGet, ensureBytes } from './utils.js'; -import * as htf from './hash-to-curve.js'; -import { weierstrassPoints, } from './weierstrass.js'; -// prettier-ignore -const _2n = BigInt(2), _3n = BigInt(3); -export function bls(CURVE) { - // Fields are specific for curve, so for now we'll need to pass them with opts - const { Fp, Fr, Fp2, Fp6, Fp12 } = CURVE.fields; - const BLS_X_LEN = bitLen(CURVE.params.x); - const groupLen = 32; // TODO: calculate; hardcoded for now - // Pre-compute coefficients for sparse multiplication - // Point addition and point double calculations is reused for coefficients - function calcPairingPrecomputes(p) { - const { x, y } = p; - // prettier-ignore - const Qx = x, Qy = y, Qz = Fp2.ONE; - // prettier-ignore - let Rx = Qx, Ry = Qy, Rz = Qz; - let ell_coeff = []; - for (let i = BLS_X_LEN - 2; i >= 0; i--) { - // Double - let t0 = Fp2.sqr(Ry); // Ry² - let t1 = Fp2.sqr(Rz); // Rz² - let t2 = Fp2.multiplyByB(Fp2.mul(t1, _3n)); // 3 * T1 * B - let t3 = Fp2.mul(t2, _3n); // 3 * T2 - let t4 = Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(Ry, Rz)), t1), t0); // (Ry + Rz)² - T1 - T0 - ell_coeff.push([ - Fp2.sub(t2, t0), - Fp2.mul(Fp2.sqr(Rx), _3n), - Fp2.neg(t4), // -T4 - ]); - Rx = Fp2.div(Fp2.mul(Fp2.mul(Fp2.sub(t0, t3), Rx), Ry), _2n); // ((T0 - T3) * Rx * Ry) / 2 - Ry = Fp2.sub(Fp2.sqr(Fp2.div(Fp2.add(t0, t3), _2n)), Fp2.mul(Fp2.sqr(t2), _3n)); // ((T0 + T3) / 2)² - 3 * T2² - Rz = Fp2.mul(t0, t4); // T0 * T4 - if (bitGet(CURVE.params.x, i)) { - // Addition - let t0 = Fp2.sub(Ry, Fp2.mul(Qy, Rz)); // Ry - Qy * Rz - let t1 = Fp2.sub(Rx, Fp2.mul(Qx, Rz)); // Rx - Qx * Rz - ell_coeff.push([ - Fp2.sub(Fp2.mul(t0, Qx), Fp2.mul(t1, Qy)), - Fp2.neg(t0), - t1, // T1 - ]); - let t2 = Fp2.sqr(t1); // T1² - let t3 = Fp2.mul(t2, t1); // T2 * T1 - let t4 = Fp2.mul(t2, Rx); // T2 * Rx - let t5 = Fp2.add(Fp2.sub(t3, Fp2.mul(t4, _2n)), Fp2.mul(Fp2.sqr(t0), Rz)); // T3 - 2 * T4 + T0² * Rz - Rx = Fp2.mul(t1, t5); // T1 * T5 - Ry = Fp2.sub(Fp2.mul(Fp2.sub(t4, t5), t0), Fp2.mul(t3, Ry)); // (T4 - T5) * T0 - T3 * Ry - Rz = Fp2.mul(Rz, t3); // Rz * T3 - } - } - return ell_coeff; - } - function millerLoop(ell, g1) { - const { x } = CURVE.params; - const Px = g1[0]; - const Py = g1[1]; - let f12 = Fp12.ONE; - for (let j = 0, i = BLS_X_LEN - 2; i >= 0; i--, j++) { - const E = ell[j]; - f12 = Fp12.multiplyBy014(f12, E[0], Fp2.mul(E[1], Px), Fp2.mul(E[2], Py)); - if (bitGet(x, i)) { - j += 1; - const F = ell[j]; - f12 = Fp12.multiplyBy014(f12, F[0], Fp2.mul(F[1], Px), Fp2.mul(F[2], Py)); - } - if (i !== 0) - f12 = Fp12.sqr(f12); - } - return Fp12.conjugate(f12); - } - const utils = { - randomPrivateKey: () => { - return Fr.toBytes(hashToPrivateScalar(CURVE.randomBytes(groupLen + 8), CURVE.params.r)); - }, - calcPairingPrecomputes, - }; - // Point on G1 curve: (x, y) - const G1_ = weierstrassPoints({ n: Fr.ORDER, ...CURVE.G1 }); - const G1 = Object.assign(G1_, htf.createHasher(G1_.ProjectivePoint, CURVE.G1.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G1.htfDefaults, - })); - function pairingPrecomputes(point) { - const p = point; - if (p._PPRECOMPUTES) - return p._PPRECOMPUTES; - p._PPRECOMPUTES = calcPairingPrecomputes(point.toAffine()); - return p._PPRECOMPUTES; - } - // TODO: export - // function clearPairingPrecomputes(point: G2) { - // const p = point as G2 & withPairingPrecomputes; - // p._PPRECOMPUTES = undefined; - // } - // Point on G2 curve (complex numbers): (x₁, x₂+i), (y₁, y₂+i) - const G2_ = weierstrassPoints({ n: Fr.ORDER, ...CURVE.G2 }); - const G2 = Object.assign(G2_, htf.createHasher(G2_.ProjectivePoint, CURVE.G2.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G2.htfDefaults, - })); - const { Signature } = CURVE.G2; - // Calculates bilinear pairing - function pairing(Q, P, withFinalExponent = true) { - if (Q.equals(G1.ProjectivePoint.ZERO) || P.equals(G2.ProjectivePoint.ZERO)) - throw new Error('pairing is not available for ZERO point'); - Q.assertValidity(); - P.assertValidity(); - // Performance: 9ms for millerLoop and ~14ms for exp. - const Qa = Q.toAffine(); - const looped = millerLoop(pairingPrecomputes(P), [Qa.x, Qa.y]); - return withFinalExponent ? Fp12.finalExponentiate(looped) : looped; - } - function normP1(point) { - return point instanceof G1.ProjectivePoint ? point : G1.ProjectivePoint.fromHex(point); - } - function normP2(point) { - return point instanceof G2.ProjectivePoint ? point : Signature.fromHex(point); - } - function normP2Hash(point, htfOpts) { - return point instanceof G2.ProjectivePoint - ? point - : G2.hashToCurve(ensureBytes('point', point), htfOpts); - } - // Multiplies generator by private key. - // P = pk x G - function getPublicKey(privateKey) { - return G1.ProjectivePoint.fromPrivateKey(privateKey).toRawBytes(true); - } - function sign(message, privateKey, htfOpts) { - const msgPoint = normP2Hash(message, htfOpts); - msgPoint.assertValidity(); - const sigPoint = msgPoint.multiply(G1.normPrivateKeyToScalar(privateKey)); - if (message instanceof G2.ProjectivePoint) - return sigPoint; - return Signature.toRawBytes(sigPoint); - } - // Checks if pairing of public key & hash is equal to pairing of generator & signature. - // e(P, H(m)) == e(G, S) - function verify(signature, message, publicKey, htfOpts) { - const P = normP1(publicKey); - const Hm = normP2Hash(message, htfOpts); - const G = G1.ProjectivePoint.BASE; - const S = normP2(signature); - // Instead of doing 2 exponentiations, we use property of billinear maps - // and do one exp after multiplying 2 points. - const ePHm = pairing(P.negate(), Hm, false); - const eGS = pairing(G, S, false); - const exp = Fp12.finalExponentiate(Fp12.mul(eGS, ePHm)); - return Fp12.eql(exp, Fp12.ONE); - } - function aggregatePublicKeys(publicKeys) { - if (!publicKeys.length) - throw new Error('Expected non-empty array'); - const agg = publicKeys.map(normP1).reduce((sum, p) => sum.add(p), G1.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (publicKeys[0] instanceof G1.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - // toRawBytes ensures point validity - return aggAffine.toRawBytes(true); - } - function aggregateSignatures(signatures) { - if (!signatures.length) - throw new Error('Expected non-empty array'); - const agg = signatures.map(normP2).reduce((sum, s) => sum.add(s), G2.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (signatures[0] instanceof G2.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - return Signature.toRawBytes(aggAffine); - } - // https://ethresear.ch/t/fast-verification-of-multiple-bls-signatures/5407 - // e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si)) - function verifyBatch(signature, messages, publicKeys, htfOpts) { - // @ts-ignore - // console.log('verifyBatch', bytesToHex(signature as any), messages, publicKeys.map(bytesToHex)); - if (!messages.length) - throw new Error('Expected non-empty messages array'); - if (publicKeys.length !== messages.length) - throw new Error('Pubkey count should equal msg count'); - const sig = normP2(signature); - const nMessages = messages.map((i) => normP2Hash(i, htfOpts)); - const nPublicKeys = publicKeys.map(normP1); - try { - const paired = []; - for (const message of new Set(nMessages)) { - const groupPublicKey = nMessages.reduce((groupPublicKey, subMessage, i) => subMessage === message ? groupPublicKey.add(nPublicKeys[i]) : groupPublicKey, G1.ProjectivePoint.ZERO); - // const msg = message instanceof PointG2 ? message : await PointG2.hashToCurve(message); - // Possible to batch pairing for same msg with different groupPublicKey here - paired.push(pairing(groupPublicKey, message, false)); - } - paired.push(pairing(G1.ProjectivePoint.BASE.negate(), sig, false)); - const product = paired.reduce((a, b) => Fp12.mul(a, b), Fp12.ONE); - const exp = Fp12.finalExponentiate(product); - return Fp12.eql(exp, Fp12.ONE); - } - catch { - return false; - } - } - G1.ProjectivePoint.BASE._setWindowSize(4); - return { - getPublicKey, - sign, - verify, - verifyBatch, - aggregatePublicKeys, - aggregateSignatures, - millerLoop, - pairing, - G1, - G2, - Signature, - fields: { - Fr, - Fp, - Fp2, - Fp6, - Fp12, - }, - params: { - x: CURVE.params.x, - r: CURVE.params.r, - G1b: CURVE.G1.b, - G2b: CURVE.G2.b, - }, - utils, - }; -} -//# sourceMappingURL=bls.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js.map deleted file mode 100644 index 84a65d7f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/bls.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls.js","sourceRoot":"","sources":["../../src/abstract/bls.ts"],"names":[],"mappings":"AAcA,OAAO,EAAU,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAuB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAIL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAI1B,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AA2FvC,MAAM,UAAU,GAAG,CACjB,KAAoC;IAEpC,8EAA8E;IAC9E,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE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CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACnE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YAClE,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;SAChC;QAAC,MAAM;YACN,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAED,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAE1C,OAAO;QACL,YAAY;QACZ,IAAI;QACJ,MAAM;QACN,WAAW;QACX,mBAAmB;QACnB,mBAAmB;QACnB,UAAU;QACV,OAAO;QACP,EAAE;QACF,EAAE;QACF,SAAS;QACT,MAAM,EAAE;YACN,EAAE;YACF,EAAE;YACF,GAAG;YACH,GAAG;YACH,IAAI;SACL;QACD,MAAM,EAAE;YACN,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACjB,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACf,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;SAChB;QACD,KAAK;KACN,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js deleted file mode 100644 index 3454763e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js +++ /dev/null @@ -1,156 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Abelian group utilities -import { validateField, nLength } from './modular.js'; -import { validateObject } from './utils.js'; -const _0n = BigInt(0); -const _1n = BigInt(1); -// Elliptic curve multiplication of Point by scalar. Fragile. -// Scalars should always be less than curve order: this should be checked inside of a curve itself. -// Creates precomputation tables for fast multiplication: -// - private scalar is split by fixed size windows of W bits -// - every window point is collected from window's table & added to accumulator -// - since windows are different, same point inside tables won't be accessed more than once per calc -// - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar) -// - +1 window is neccessary for wNAF -// - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication -// TODO: Research returning 2d JS array of windows, instead of a single window. This would allow -// windows to be in different memory locations -export function wNAF(c, bits) { - const constTimeNegate = (condition, item) => { - const neg = item.negate(); - return condition ? neg : item; - }; - const opts = (W) => { - const windows = Math.ceil(bits / W) + 1; // +1, because - const windowSize = 2 ** (W - 1); // -1 because we skip zero - return { windows, windowSize }; - }; - return { - constTimeNegate, - // non-const time multiplication ladder - unsafeLadder(elm, n) { - let p = c.ZERO; - let d = elm; - while (n > _0n) { - if (n & _1n) - p = p.add(d); - d = d.double(); - n >>= _1n; - } - return p; - }, - /** - * Creates a wNAF precomputation window. Used for caching. - * Default window size is set by `utils.precompute()` and is equal to 8. - * Number of precomputed points depends on the curve size: - * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: - * - 𝑊 is the window size - * - 𝑛 is the bitlength of the curve order. - * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. - * @returns precomputed point tables flattened to a single array - */ - precomputeWindow(elm, W) { - const { windows, windowSize } = opts(W); - const points = []; - let p = elm; - let base = p; - for (let window = 0; window < windows; window++) { - base = p; - points.push(base); - // =1, because we skip zero - for (let i = 1; i < windowSize; i++) { - base = base.add(p); - points.push(base); - } - p = base.double(); - } - return points; - }, - /** - * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. - * @param W window size - * @param precomputes precomputed tables - * @param n scalar (we don't check here, but should be less than curve order) - * @returns real and fake (for const-time) points - */ - wNAF(W, precomputes, n) { - // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise - // But need to carefully remove other checks before wNAF. ORDER == bits here - const { windows, windowSize } = opts(W); - let p = c.ZERO; - let f = c.BASE; - const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc. - const maxNumber = 2 ** W; - const shiftBy = BigInt(W); - for (let window = 0; window < windows; window++) { - const offset = window * windowSize; - // Extract W bits. - let wbits = Number(n & mask); - // Shift number by W bits. - n >>= shiftBy; - // If the bits are bigger than max size, we'll split those. - // +224 => 256 - 32 - if (wbits > windowSize) { - wbits -= maxNumber; - n += _1n; - } - // This code was first written with assumption that 'f' and 'p' will never be infinity point: - // since each addition is multiplied by 2 ** W, it cannot cancel each other. However, - // there is negate now: it is possible that negated element from low value - // would be the same as high element, which will create carry into next window. - // It's not obvious how this can fail, but still worth investigating later. - // Check if we're onto Zero point. - // Add random point inside current window to f. - const offset1 = offset; - const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero - const cond1 = window % 2 !== 0; - const cond2 = wbits < 0; - if (wbits === 0) { - // The most important part for const-time getPublicKey - f = f.add(constTimeNegate(cond1, precomputes[offset1])); - } - else { - p = p.add(constTimeNegate(cond2, precomputes[offset2])); - } - } - // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ() - // Even if the variable is still unused, there are some checks which will - // throw an exception, so compiler needs to prove they won't happen, which is hard. - // At this point there is a way to F be infinity-point even if p is not, - // which makes it less const-time: around 1 bigint multiply. - return { p, f }; - }, - wNAFCached(P, precomputesMap, n, transform) { - // @ts-ignore - const W = P._WINDOW_SIZE || 1; - // Calculate precomputes on a first run, reuse them after - let comp = precomputesMap.get(P); - if (!comp) { - comp = this.precomputeWindow(P, W); - if (W !== 1) { - precomputesMap.set(P, transform(comp)); - } - } - return this.wNAF(W, comp, n); - }, - }; -} -export function validateBasic(curve) { - validateField(curve.Fp); - validateObject(curve, { - n: 'bigint', - h: 'bigint', - Gx: 'field', - Gy: 'field', - }, { - nBitLength: 'isSafeInteger', - nByteLength: 'isSafeInteger', - }); - // Set defaults - return Object.freeze({ - ...nLength(curve.n, curve.nBitLength), - ...curve, - ...{ p: curve.Fp.ORDER }, - }); -} -//# sourceMappingURL=curve.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js.map deleted file mode 100644 index f0fbc7d3..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"curve.js","sourceRoot":"","sources":["../../src/abstract/curve.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,0BAA0B;AAC1B,OAAO,EAAU,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAsBtB,6DAA6D;AAC7D,mGAAmG;AACnG,yDAAyD;AACzD,4DAA4D;AAC5D,+EAA+E;AAC/E,oGAAoG;AACpG,oGAAoG;AACpG,qCAAqC;AACrC,kGAAkG;AAClG,gGAAgG;AAChG,8CAA8C;AAC9C,MAAM,UAAU,IAAI,CAAqB,CAAsB,EAAE,IAAY;IAC3E,MAAM,eAAe,GAAG,CAAC,SAAkB,EAAE,IAAO,EAAK,EAAE;QACzD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,CAAC,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE;QACz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Ac,CACZ,KAAK,EACL;QACE,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,QAAQ;QACX,EAAE,EAAE,OAAO;QACX,EAAE,EAAE,OAAO;KACZ,EACD;QACE,UAAU,EAAE,eAAe;QAC3B,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IACF,eAAe;IACf,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;QACrC,GAAG,KAAK;QACR,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;KAChB,CAAC,CAAC;AACd,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js deleted file mode 100644 index de5123ae..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js +++ /dev/null @@ -1,425 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y² -import { mod } from './modular.js'; -import * as ut from './utils.js'; -import { ensureBytes } from './utils.js'; -import { wNAF, validateBasic } from './curve.js'; -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _8n = BigInt(8); -// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex: -const VERIFY_DEFAULT = { zip215: true }; -function validateOpts(curve) { - const opts = validateBasic(curve); - ut.validateObject(curve, { - hash: 'function', - a: 'bigint', - d: 'bigint', - randomBytes: 'function', - }, { - adjustScalarBytes: 'function', - domain: 'function', - uvRatio: 'function', - mapToCurve: 'function', - }); - // Set defaults - return Object.freeze({ ...opts }); -} -// It is not generic twisted curve for now, but ed25519/ed448 generic implementation -export function twistedEdwards(curveDef) { - const CURVE = validateOpts(curveDef); - const { Fp, n: CURVE_ORDER, prehash: prehash, hash: cHash, randomBytes, nByteLength, h: cofactor, } = CURVE; - const MASK = _2n << (BigInt(nByteLength * 8) - _1n); - const modP = Fp.create; // Function overrides - // sqrt(u/v) - const uvRatio = CURVE.uvRatio || - ((u, v) => { - try { - return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) }; - } - catch (e) { - return { isValid: false, value: _0n }; - } - }); - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); // NOOP - const domain = CURVE.domain || - ((data, ctx, phflag) => { - if (ctx.length || phflag) - throw new Error('Contexts/pre-hash are not supported'); - return data; - }); // NOOP - const inBig = (n) => typeof n === 'bigint' && _0n < n; // n in [1..] - const inRange = (n, max) => inBig(n) && inBig(max) && n < max; // n in [1..max-1] - const in0MaskRange = (n) => n === _0n || inRange(n, MASK); // n in [0..MASK-1] - function assertInRange(n, max) { - // n in [1..max-1] - if (inRange(n, max)) - return n; - throw new Error(`Expected valid scalar < ${max}, got ${typeof n} ${n}`); - } - function assertGE0(n) { - // n in [0..CURVE_ORDER-1] - return n === _0n ? n : assertInRange(n, CURVE_ORDER); // GE = prime subgroup, not full group - } - const pointPrecomputes = new Map(); - function isPoint(other) { - if (!(other instanceof Point)) - throw new Error('ExtendedPoint expected'); - } - // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy). - // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates - class Point { - constructor(ex, ey, ez, et) { - this.ex = ex; - this.ey = ey; - this.ez = ez; - this.et = et; - if (!in0MaskRange(ex)) - throw new Error('x required'); - if (!in0MaskRange(ey)) - throw new Error('y required'); - if (!in0MaskRange(ez)) - throw new Error('z required'); - if (!in0MaskRange(et)) - throw new Error('t required'); - } - get x() { - return this.toAffine().x; - } - get y() { - return this.toAffine().y; - } - static fromAffine(p) { - if (p instanceof Point) - throw new Error('extended point not allowed'); - const { x, y } = p || {}; - if (!in0MaskRange(x) || !in0MaskRange(y)) - throw new Error('invalid affine point'); - return new Point(x, y, _1n, modP(x * y)); - } - static normalizeZ(points) { - const toInv = Fp.invertBatch(points.map((p) => p.ez)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - // "Private method", don't use it directly - _setWindowSize(windowSize) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - // Not required for fromHex(), which always creates valid points. - // Could be useful for fromAffine(). - assertValidity() { - const { a, d } = CURVE; - if (this.is0()) - throw new Error('bad point: ZERO'); // TODO: optimize, with vars below? - // Equation in affine coordinates: ax² + y² = 1 + dx²y² - // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y² - const { ex: X, ey: Y, ez: Z, et: T } = this; - const X2 = modP(X * X); // X² - const Y2 = modP(Y * Y); // Y² - const Z2 = modP(Z * Z); // Z² - const Z4 = modP(Z2 * Z2); // Z⁴ - const aX2 = modP(X2 * a); // aX² - const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z² - const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y² - if (left !== right) - throw new Error('bad point: equation left != right (1)'); - // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T - const XY = modP(X * Y); - const ZT = modP(Z * T); - if (XY !== ZT) - throw new Error('bad point: equation left != right (2)'); - } - // Compare one point to another. - equals(other) { - isPoint(other); - const { ex: X1, ey: Y1, ez: Z1 } = this; - const { ex: X2, ey: Y2, ez: Z2 } = other; - const X1Z2 = modP(X1 * Z2); - const X2Z1 = modP(X2 * Z1); - const Y1Z2 = modP(Y1 * Z2); - const Y2Z1 = modP(Y2 * Z1); - return X1Z2 === X2Z1 && Y1Z2 === Y2Z1; - } - is0() { - return this.equals(Point.ZERO); - } - negate() { - // Flips point sign to a negative one (-x, y in affine coords) - return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et)); - } - // Fast algo for doubling Extended Point. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd - // Cost: 4M + 4S + 1*a + 6add + 1*2. - double() { - const { a } = CURVE; - const { ex: X1, ey: Y1, ez: Z1 } = this; - const A = modP(X1 * X1); // A = X12 - const B = modP(Y1 * Y1); // B = Y12 - const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12 - const D = modP(a * A); // D = a*A - const x1y1 = X1 + Y1; - const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B - const G = D + B; // G = D+B - const F = G - C; // F = G-C - const H = D - B; // H = D-B - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - return new Point(X3, Y3, Z3, T3); - } - // Fast algo for adding 2 Extended Points. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd - // Cost: 9M + 1*a + 1*d + 7add. - add(other) { - isPoint(other); - const { a, d } = CURVE; - const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this; - const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other; - // Faster algo for adding 2 Extended Points when curve's a=-1. - // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4 - // Cost: 8M + 8add + 2*2. - // Note: It does not check whether the `other` point is valid. - if (a === BigInt(-1)) { - const A = modP((Y1 - X1) * (Y2 + X2)); - const B = modP((Y1 + X1) * (Y2 - X2)); - const F = modP(B - A); - if (F === _0n) - return this.double(); // Same point. Tests say it doesn't affect timing - const C = modP(Z1 * _2n * T2); - const D = modP(T1 * _2n * Z2); - const E = D + C; - const G = B + A; - const H = D - C; - const X3 = modP(E * F); - const Y3 = modP(G * H); - const T3 = modP(E * H); - const Z3 = modP(F * G); - return new Point(X3, Y3, Z3, T3); - } - const A = modP(X1 * X2); // A = X1*X2 - const B = modP(Y1 * Y2); // B = Y1*Y2 - const C = modP(T1 * d * T2); // C = T1*d*T2 - const D = modP(Z1 * Z2); // D = Z1*Z2 - const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B - const F = D - C; // F = D-C - const G = D + C; // G = D+C - const H = modP(B - a * A); // H = B-a*A - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - return new Point(X3, Y3, Z3, T3); - } - subtract(other) { - return this.add(other.negate()); - } - wNAF(n) { - return wnaf.wNAFCached(this, pointPrecomputes, n, Point.normalizeZ); - } - // Constant-time multiplication. - multiply(scalar) { - const { p, f } = this.wNAF(assertInRange(scalar, CURVE_ORDER)); - return Point.normalizeZ([p, f])[0]; - } - // Non-constant-time multiplication. Uses double-and-add algorithm. - // It's faster, but should only be used when you don't care about - // an exposed private key e.g. sig verification. - // Does NOT allow scalars higher than CURVE.n. - multiplyUnsafe(scalar) { - let n = assertGE0(scalar); // 0 <= scalar < CURVE.n - if (n === _0n) - return I; - if (this.equals(I) || n === _1n) - return this; - if (this.equals(G)) - return this.wNAF(n).p; - return wnaf.unsafeLadder(this, n); - } - // Checks if point is of small order. - // If you add something to small order point, you will have "dirty" - // point with torsion component. - // Multiplies point by cofactor and checks if the result is 0. - isSmallOrder() { - return this.multiplyUnsafe(cofactor).is0(); - } - // Multiplies point by curve order and checks if the result is 0. - // Returns `false` is the point is dirty. - isTorsionFree() { - return wnaf.unsafeLadder(this, CURVE_ORDER).is0(); - } - // Converts Extended point to default (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - toAffine(iz) { - const { ex: x, ey: y, ez: z } = this; - const is0 = this.is0(); - if (iz == null) - iz = is0 ? _8n : Fp.inv(z); // 8 was chosen arbitrarily - const ax = modP(x * iz); - const ay = modP(y * iz); - const zz = modP(z * iz); - if (is0) - return { x: _0n, y: _1n }; - if (zz !== _1n) - throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - clearCofactor() { - const { h: cofactor } = CURVE; - if (cofactor === _1n) - return this; - return this.multiplyUnsafe(cofactor); - } - // Converts hash string or Uint8Array to Point. - // Uses algo from RFC8032 5.1.3. - static fromHex(hex, zip215 = false) { - const { d, a } = CURVE; - const len = Fp.BYTES; - hex = ensureBytes('pointHex', hex, len); // copy hex to a new array - const normed = hex.slice(); // copy again, we'll manipulate it - const lastByte = hex[len - 1]; // select last byte - normed[len - 1] = lastByte & ~0x80; // clear last bit - const y = ut.bytesToNumberLE(normed); - if (y === _0n) { - // y=0 is allowed - } - else { - // RFC8032 prohibits >= p, but ZIP215 doesn't - if (zip215) - assertInRange(y, MASK); // zip215=true [1..P-1] (2^255-19-1 for ed25519) - else - assertInRange(y, Fp.ORDER); // zip215=false [1..MASK-1] (2^256-1 for ed25519) - } - // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case: - // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a) - const y2 = modP(y * y); // denominator is always non-0 mod p. - const u = modP(y2 - _1n); // u = y² - 1 - const v = modP(d * y2 - a); // v = d y² + 1. - let { isValid, value: x } = uvRatio(u, v); // √(u/v) - if (!isValid) - throw new Error('Point.fromHex: invalid y coordinate'); - const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper - const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit - if (!zip215 && x === _0n && isLastByteOdd) - // if x=0 and x_0 = 1, fail - throw new Error('Point.fromHex: x=0 and x_0=1'); - if (isLastByteOdd !== isXOdd) - x = modP(-x); // if x_0 != x mod 2, set x = p-x - return Point.fromAffine({ x, y }); - } - static fromPrivateKey(privKey) { - return getExtendedPublicKey(privKey).point; - } - toRawBytes() { - const { x, y } = this.toAffine(); - const bytes = ut.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y) - bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y - return bytes; // and use the last byte to encode sign of x - } - toHex() { - return ut.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string. - } - } - Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy)); - Point.ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0 - const { BASE: G, ZERO: I } = Point; - const wnaf = wNAF(Point, nByteLength * 8); - function modN(a) { - return mod(a, CURVE_ORDER); - } - // Little-endian SHA512 with modulo n - function modN_LE(hash) { - return modN(ut.bytesToNumberLE(hash)); - } - /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */ - function getExtendedPublicKey(key) { - const len = nByteLength; - key = ensureBytes('private key', key, len); - // Hash private key with curve's hash function to produce uniformingly random input - // Check byte lengths: ensure(64, h(ensure(32, key))) - const hashed = ensureBytes('hashed private key', cHash(key), 2 * len); - const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE - const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6) - const scalar = modN_LE(head); // The actual private scalar - const point = G.multiply(scalar); // Point on Edwards curve aka public key - const pointBytes = point.toRawBytes(); // Uint8Array representation - return { head, prefix, scalar, point, pointBytes }; - } - // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared - function getPublicKey(privKey) { - return getExtendedPublicKey(privKey).pointBytes; - } - // int('LE', SHA512(dom2(F, C) || msgs)) mod N - function hashDomainToScalar(context = new Uint8Array(), ...msgs) { - const msg = ut.concatBytes(...msgs); - return modN_LE(cHash(domain(msg, ensureBytes('context', context), !!prehash))); - } - /** Signs message with privateKey. RFC8032 5.1.6 */ - function sign(msg, privKey, options = {}) { - msg = ensureBytes('message', msg); - if (prehash) - msg = prehash(msg); // for ed25519ph etc. - const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey); - const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M) - const R = G.multiply(r).toRawBytes(); // R = rG - const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M) - const s = modN(r + k * scalar); // S = (r + k * s) mod L - assertGE0(s); // 0 <= s < l - const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES)); - return ensureBytes('result', res, nByteLength * 2); // 64-byte signature - } - const verifyOpts = VERIFY_DEFAULT; - function verify(sig, msg, publicKey, options = verifyOpts) { - const { context, zip215 } = options; - const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7. - sig = ensureBytes('signature', sig, 2 * len); // An extended group equation is checked. - msg = ensureBytes('message', msg); - if (prehash) - msg = prehash(msg); // for ed25519ph, etc - const s = ut.bytesToNumberLE(sig.slice(len, 2 * len)); - // zip215: true is good for consensus-critical apps and allows points < 2^256 - // zip215: false follows RFC8032 / NIST186-5 and restricts points to CURVE.p - let A, R, SB; - try { - A = Point.fromHex(publicKey, zip215); - R = Point.fromHex(sig.slice(0, len), zip215); - SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside - } - catch (error) { - return false; - } - if (!zip215 && A.isSmallOrder()) - return false; - const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg); - const RkA = R.add(A.multiplyUnsafe(k)); - // [8][S]B = [8]R + [8][k]A' - return RkA.subtract(SB).clearCofactor().equals(Point.ZERO); - } - G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms. - const utils = { - getExtendedPublicKey, - // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1. - randomPrivateKey: () => randomBytes(Fp.BYTES), - /** - * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT - * values. This slows down first getPublicKey() by milliseconds (see Speed section), - * but allows to speed-up subsequent getPublicKey() calls up to 20x. - * @param windowSize 2, 4, 8, 16 - */ - precompute(windowSize = 8, point = Point.BASE) { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); - return point; - }, - }; - return { - CURVE, - getPublicKey, - sign, - verify, - ExtendedPoint: Point, - utils, - }; -} -//# sourceMappingURL=edwards.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js.map deleted file mode 100644 index dda68a80..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/edwards.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"edwards.js","sourceRoot":"","sources":["../../src/abstract/edwards.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,8DAA8D;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AACrD,OAAO,EAA2B,IAAI,EAAc,aAAa,EAAe,MAAM,YAAY,CAAC;AAEnG,qEAAqE;AACrE,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAezE,8EAA8E;AAC9E,MAAM,cAAc,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAExC,SAAS,YAAY,CAAC,KAAgB;IACpC,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,EAAE,CAAC,cAAc,CACf,KAAK,EACL;QACE,IAAI,EAAE,UAAU;QAChB,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,QAAQ;QACX,WAAW,EAAE,UAAU;KACxB,EACD;QACE,iBAAiB,EAAE,UAAU;QAC7B,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,UAAU;QACnB,UAAU,EAAE,UAAU;KACvB,CACF,CAAC;IACF,eAAe;IACf,OAAO,MAAM,CAAC,MAAM,CAAC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,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,IAAI;YAC3C,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YACjC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,OAAO;QACL,KAAK;QACL,YAAY;QACZ,IAAI;QACJ,MAAM;QACN,aAAa,EAAE,KAAK;QACpB,KAAK;KACN,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js deleted file mode 100644 index a6419f97..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js +++ /dev/null @@ -1,167 +0,0 @@ -import { mod } from './modular.js'; -import { bytesToNumberBE, concatBytes, utf8ToBytes, validateObject } from './utils.js'; -function validateDST(dst) { - if (dst instanceof Uint8Array) - return dst; - if (typeof dst === 'string') - return utf8ToBytes(dst); - throw new Error('DST must be Uint8Array or string'); -} -// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE. -const os2ip = bytesToNumberBE; -// Integer to Octet Stream (numberToBytesBE) -function i2osp(value, length) { - if (value < 0 || value >= 1 << (8 * length)) { - throw new Error(`bad I2OSP call: value=${value} length=${length}`); - } - const res = Array.from({ length }).fill(0); - for (let i = length - 1; i >= 0; i--) { - res[i] = value & 0xff; - value >>>= 8; - } - return new Uint8Array(res); -} -function strxor(a, b) { - const arr = new Uint8Array(a.length); - for (let i = 0; i < a.length; i++) { - arr[i] = a[i] ^ b[i]; - } - return arr; -} -function isBytes(item) { - if (!(item instanceof Uint8Array)) - throw new Error('Uint8Array expected'); -} -function isNum(item) { - if (!Number.isSafeInteger(item)) - throw new Error('number expected'); -} -// Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1 -export function expand_message_xmd(msg, DST, lenInBytes, H) { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - if (DST.length > 255) - DST = H(concatBytes(utf8ToBytes('H2C-OVERSIZE-DST-'), DST)); - const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H; - const ell = Math.ceil(lenInBytes / b_in_bytes); - if (ell > 255) - throw new Error('Invalid xmd length'); - const DST_prime = concatBytes(DST, i2osp(DST.length, 1)); - const Z_pad = i2osp(0, r_in_bytes); - const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str - const b = new Array(ell); - const b_0 = H(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime)); - b[0] = H(concatBytes(b_0, i2osp(1, 1), DST_prime)); - for (let i = 1; i <= ell; i++) { - const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime]; - b[i] = H(concatBytes(...args)); - } - const pseudo_random_bytes = concatBytes(...b); - return pseudo_random_bytes.slice(0, lenInBytes); -} -export function expand_message_xof(msg, DST, lenInBytes, k, H) { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8)); - if (DST.length > 255) { - const dkLen = Math.ceil((2 * k) / 8); - DST = H.create({ dkLen }).update(utf8ToBytes('H2C-OVERSIZE-DST-')).update(DST).digest(); - } - if (lenInBytes > 65535 || DST.length > 255) - throw new Error('expand_message_xof: invalid lenInBytes'); - return (H.create({ dkLen: lenInBytes }) - .update(msg) - .update(i2osp(lenInBytes, 2)) - // 2. DST_prime = DST || I2OSP(len(DST), 1) - .update(DST) - .update(i2osp(DST.length, 1)) - .digest()); -} -/** - * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3 - * @param msg a byte string containing the message to hash - * @param count the number of elements of F to output - * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above - * @returns [u_0, ..., u_(count - 1)], a list of field elements. - */ -export function hash_to_field(msg, count, options) { - validateObject(options, { - DST: 'string', - p: 'bigint', - m: 'isSafeInteger', - k: 'isSafeInteger', - hash: 'hash', - }); - const { p, k, m, hash, expand, DST: _DST } = options; - isBytes(msg); - isNum(count); - const DST = validateDST(_DST); - const log2p = p.toString(2).length; - const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above - const len_in_bytes = count * m * L; - let prb; // pseudo_random_bytes - if (expand === 'xmd') { - prb = expand_message_xmd(msg, DST, len_in_bytes, hash); - } - else if (expand === 'xof') { - prb = expand_message_xof(msg, DST, len_in_bytes, k, hash); - } - else if (expand === '_internal_pass') { - // for internal tests only - prb = msg; - } - else { - throw new Error('expand must be "xmd" or "xof"'); - } - const u = new Array(count); - for (let i = 0; i < count; i++) { - const e = new Array(m); - for (let j = 0; j < m; j++) { - const elm_offset = L * (j + i * m); - const tv = prb.subarray(elm_offset, elm_offset + L); - e[j] = mod(os2ip(tv), p); - } - u[i] = e; - } - return u; -} -export function isogenyMap(field, map) { - // Make same order as in spec - const COEFF = map.map((i) => Array.from(i).reverse()); - return (x, y) => { - const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i))); - x = field.div(xNum, xDen); // xNum / xDen - y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev) - return { x, y }; - }; -} -export function createHasher(Point, mapToCurve, def) { - if (typeof mapToCurve !== 'function') - throw new Error('mapToCurve() must be defined'); - return { - // Encodes byte string to elliptic curve - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - hashToCurve(msg, options) { - const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options }); - const u0 = Point.fromAffine(mapToCurve(u[0])); - const u1 = Point.fromAffine(mapToCurve(u[1])); - const P = u0.add(u1).clearCofactor(); - P.assertValidity(); - return P; - }, - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - encodeToCurve(msg, options) { - const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options }); - const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor(); - P.assertValidity(); - return P; - }, - }; -} -//# sourceMappingURL=hash-to-curve.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map deleted file mode 100644 index 02c9e79c..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/hash-to-curve.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-to-curve.js","sourceRoot":"","sources":["../../src/abstract/hash-to-curve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAS,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAoB9F,SAAS,WAAW,CAAC,GAAmB;IACtC,IAAI,GAAG,YAAY,UAAU;QAAE,OAAO,GAAG,CAAC;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,CAAC;AAED,6FAA6F;AAC7F,MAAM,KAAK,GAAG,eAAe,CAAC;AAE9B,4CAA4C;AAC5C,SAAS,KAAK,CAAC,KAAa,EAAE,MAAc;IAC1C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,EA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AAG,CAAC,SAAS,EAAE,GAAG,OAAO,EAAU,CAAC,CAAC;YACpF,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;YAC7D,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,CAAC;QACX,CAAC;KACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js deleted file mode 100644 index e26772af..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js +++ /dev/null @@ -1,361 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Utilities for modular arithmetics and finite fields -import { bitMask, numberToBytesBE, numberToBytesLE, bytesToNumberBE, bytesToNumberLE, ensureBytes, validateObject, } from './utils.js'; -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3); -// prettier-ignore -const _4n = BigInt(4), _5n = BigInt(5), _8n = BigInt(8); -// prettier-ignore -const _9n = BigInt(9), _16n = BigInt(16); -// Calculates a modulo b -export function mod(a, b) { - const result = a % b; - return result >= _0n ? result : b + result; -} -/** - * Efficiently raise num to power and do modular division. - * Unsafe in some contexts: uses ladder, so can expose bigint bits. - * @example - * pow(2n, 6n, 11n) // 64n % 11n == 9n - */ -// TODO: use field version && remove -export function pow(num, power, modulo) { - if (modulo <= _0n || power < _0n) - throw new Error('Expected power/modulo > 0'); - if (modulo === _1n) - return _0n; - let res = _1n; - while (power > _0n) { - if (power & _1n) - res = (res * num) % modulo; - num = (num * num) % modulo; - power >>= _1n; - } - return res; -} -// Does x ^ (2 ^ power) mod p. pow2(30, 4) == 30 ^ (2 ^ 4) -export function pow2(x, power, modulo) { - let res = x; - while (power-- > _0n) { - res *= res; - res %= modulo; - } - return res; -} -// Inverses number over modulo -export function invert(number, modulo) { - if (number === _0n || modulo <= _0n) { - throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`); - } - // Euclidean GCD https://brilliant.org/wiki/extended-euclidean-algorithm/ - // Fermat's little theorem "CT-like" version inv(n) = n^(m-2) mod m is 30x slower. - let a = mod(number, modulo); - let b = modulo; - // prettier-ignore - let x = _0n, y = _1n, u = _1n, v = _0n; - while (a !== _0n) { - // JIT applies optimization if those two lines follow each other - const q = b / a; - const r = b % a; - const m = x - u * q; - const n = y - v * q; - // prettier-ignore - b = a, a = r, x = u, y = v, u = m, v = n; - } - const gcd = b; - if (gcd !== _1n) - throw new Error('invert: does not exist'); - return mod(x, modulo); -} -// Tonelli-Shanks algorithm -// Paper 1: https://eprint.iacr.org/2012/685.pdf (page 12) -// Paper 2: Square Roots from 1; 24, 51, 10 to Dan Shanks -export function tonelliShanks(P) { - // Legendre constant: used to calculate Legendre symbol (a | p), - // which denotes the value of a^((p-1)/2) (mod p). - // (a | p) ≡ 1 if a is a square (mod p) - // (a | p) ≡ -1 if a is not a square (mod p) - // (a | p) ≡ 0 if a ≡ 0 (mod p) - const legendreC = (P - _1n) / _2n; - let Q, S, Z; - // Step 1: By factoring out powers of 2 from p - 1, - // find q and s such that p - 1 = q*(2^s) with q odd - for (Q = P - _1n, S = 0; Q % _2n === _0n; Q /= _2n, S++) - ; - // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq - for (Z = _2n; Z < P && pow(Z, legendreC, P) !== P - _1n; Z++) - ; - // Fast-path - if (S === 1) { - const p1div4 = (P + _1n) / _4n; - return function tonelliFast(Fp, n) { - const root = Fp.pow(n, p1div4); - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // Slow-path - const Q1div2 = (Q + _1n) / _2n; - return function tonelliSlow(Fp, n) { - // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1 - if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) - throw new Error('Cannot find square root'); - let r = S; - // TODO: will fail at Fp2/etc - let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b - let x = Fp.pow(n, Q1div2); // first guess at the square root - let b = Fp.pow(n, Q); // first guess at the fudge factor - while (!Fp.eql(b, Fp.ONE)) { - if (Fp.eql(b, Fp.ZERO)) - return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0) - // Find m such b^(2^m)==1 - let m = 1; - for (let t2 = Fp.sqr(b); m < r; m++) { - if (Fp.eql(t2, Fp.ONE)) - break; - t2 = Fp.sqr(t2); // t2 *= t2 - } - // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow - const ge = Fp.pow(g, _1n << BigInt(r - m - 1)); // ge = 2^(r-m-1) - g = Fp.sqr(ge); // g = ge * ge - x = Fp.mul(x, ge); // x *= ge - b = Fp.mul(b, g); // b *= g - r = m; - } - return x; - }; -} -export function FpSqrt(P) { - // NOTE: different algorithms can give different roots, it is up to user to decide which one they want. - // For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve). - // P ≡ 3 (mod 4) - // √n = n^((P+1)/4) - if (P % _4n === _3n) { - // Not all roots possible! - // const ORDER = - // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn; - // const NUM = 72057594037927816n; - const p1div4 = (P + _1n) / _4n; - return function sqrt3mod4(Fp, n) { - const root = Fp.pow(n, p1div4); - // Throw if root**2 != n - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10) - if (P % _8n === _5n) { - const c1 = (P - _5n) / _8n; - return function sqrt5mod8(Fp, n) { - const n2 = Fp.mul(n, _2n); - const v = Fp.pow(n2, c1); - const nv = Fp.mul(n, v); - const i = Fp.mul(Fp.mul(nv, _2n), v); - const root = Fp.mul(nv, Fp.sub(i, Fp.ONE)); - if (!Fp.eql(Fp.sqr(root), n)) - throw new Error('Cannot find square root'); - return root; - }; - } - // P ≡ 9 (mod 16) - if (P % _16n === _9n) { - // NOTE: tonelli is too slow for bls-Fp2 calculations even on start - // Means we cannot use sqrt for constants at all! - // - // const c1 = Fp.sqrt(Fp.negate(Fp.ONE)); // 1. c1 = sqrt(-1) in F, i.e., (c1^2) == -1 in F - // const c2 = Fp.sqrt(c1); // 2. c2 = sqrt(c1) in F, i.e., (c2^2) == c1 in F - // const c3 = Fp.sqrt(Fp.negate(c1)); // 3. c3 = sqrt(-c1) in F, i.e., (c3^2) == -c1 in F - // const c4 = (P + _7n) / _16n; // 4. c4 = (q + 7) / 16 # Integer arithmetic - // sqrt = (x) => { - // let tv1 = Fp.pow(x, c4); // 1. tv1 = x^c4 - // let tv2 = Fp.mul(c1, tv1); // 2. tv2 = c1 * tv1 - // const tv3 = Fp.mul(c2, tv1); // 3. tv3 = c2 * tv1 - // let tv4 = Fp.mul(c3, tv1); // 4. tv4 = c3 * tv1 - // const e1 = Fp.equals(Fp.square(tv2), x); // 5. e1 = (tv2^2) == x - // const e2 = Fp.equals(Fp.square(tv3), x); // 6. e2 = (tv3^2) == x - // tv1 = Fp.cmov(tv1, tv2, e1); // 7. tv1 = CMOV(tv1, tv2, e1) # Select tv2 if (tv2^2) == x - // tv2 = Fp.cmov(tv4, tv3, e2); // 8. tv2 = CMOV(tv4, tv3, e2) # Select tv3 if (tv3^2) == x - // const e3 = Fp.equals(Fp.square(tv2), x); // 9. e3 = (tv2^2) == x - // return Fp.cmov(tv1, tv2, e3); // 10. z = CMOV(tv1, tv2, e3) # Select the sqrt from tv1 and tv2 - // } - } - // Other cases: Tonelli-Shanks algorithm - return tonelliShanks(P); -} -// Little-endian check for first LE bit (last BE bit); -export const isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n) === _1n; -// prettier-ignore -const FIELD_FIELDS = [ - 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr', - 'eql', 'add', 'sub', 'mul', 'pow', 'div', - 'addN', 'subN', 'mulN', 'sqrN' -]; -export function validateField(field) { - const initial = { - ORDER: 'bigint', - MASK: 'bigint', - BYTES: 'isSafeInteger', - BITS: 'isSafeInteger', - }; - const opts = FIELD_FIELDS.reduce((map, val) => { - map[val] = 'function'; - return map; - }, initial); - return validateObject(field, opts); -} -// Generic field functions -export function FpPow(f, num, power) { - // Should have same speed as pow for bigints - // TODO: benchmark! - if (power < _0n) - throw new Error('Expected power > 0'); - if (power === _0n) - return f.ONE; - if (power === _1n) - return num; - let p = f.ONE; - let d = num; - while (power > _0n) { - if (power & _1n) - p = f.mul(p, d); - d = f.sqr(d); - power >>= _1n; - } - return p; -} -// 0 is non-invertible: non-batched version will throw on 0 -export function FpInvertBatch(f, nums) { - const tmp = new Array(nums.length); - // Walk from first to last, multiply them by each other MOD p - const lastMultiplied = nums.reduce((acc, num, i) => { - if (f.is0(num)) - return acc; - tmp[i] = acc; - return f.mul(acc, num); - }, f.ONE); - // Invert last element - const inverted = f.inv(lastMultiplied); - // Walk from last to first, multiply them by inverted each other MOD p - nums.reduceRight((acc, num, i) => { - if (f.is0(num)) - return acc; - tmp[i] = f.mul(acc, tmp[i]); - return f.mul(acc, num); - }, inverted); - return tmp; -} -export function FpDiv(f, lhs, rhs) { - return f.mul(lhs, typeof rhs === 'bigint' ? invert(rhs, f.ORDER) : f.inv(rhs)); -} -// This function returns True whenever the value x is a square in the field F. -export function FpIsSquare(f) { - const legendreConst = (f.ORDER - _1n) / _2n; // Integer arithmetic - return (x) => { - const p = f.pow(x, legendreConst); - return f.eql(p, f.ZERO) || f.eql(p, f.ONE); - }; -} -// CURVE.n lengths -export function nLength(n, nBitLength) { - // Bit size, byte size of CURVE.n - const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length; - const nByteLength = Math.ceil(_nBitLength / 8); - return { nBitLength: _nBitLength, nByteLength }; -} -/** - * Initializes a galois field over prime. Non-primes are not supported for now. - * Do not init in loop: slow. Very fragile: always run a benchmark on change. - * Major performance gains: - * a) non-normalized operations like mulN instead of mul - * b) `Object.freeze` - * c) Same object shape: never add or remove keys - * @param ORDER prime positive bigint - * @param bitLen how many bits the field consumes - * @param isLE (def: false) if encoding / decoding should be in little-endian - * @param redef optional faster redefinitions of sqrt and other methods - */ -export function Field(ORDER, bitLen, isLE = false, redef = {}) { - if (ORDER <= _0n) - throw new Error(`Expected Fp ORDER > 0, got ${ORDER}`); - const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen); - if (BYTES > 2048) - throw new Error('Field lengths over 2048 bytes are not supported'); - const sqrtP = FpSqrt(ORDER); - const f = Object.freeze({ - ORDER, - BITS, - BYTES, - MASK: bitMask(BITS), - ZERO: _0n, - ONE: _1n, - create: (num) => mod(num, ORDER), - isValid: (num) => { - if (typeof num !== 'bigint') - throw new Error(`Invalid field element: expected bigint, got ${typeof num}`); - return _0n <= num && num < ORDER; // 0 is valid element, but it's not invertible - }, - is0: (num) => num === _0n, - isOdd: (num) => (num & _1n) === _1n, - neg: (num) => mod(-num, ORDER), - eql: (lhs, rhs) => lhs === rhs, - sqr: (num) => mod(num * num, ORDER), - add: (lhs, rhs) => mod(lhs + rhs, ORDER), - sub: (lhs, rhs) => mod(lhs - rhs, ORDER), - mul: (lhs, rhs) => mod(lhs * rhs, ORDER), - pow: (num, power) => FpPow(f, num, power), - div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER), - // Same as above, but doesn't normalize - sqrN: (num) => num * num, - addN: (lhs, rhs) => lhs + rhs, - subN: (lhs, rhs) => lhs - rhs, - mulN: (lhs, rhs) => lhs * rhs, - inv: (num) => invert(num, ORDER), - sqrt: redef.sqrt || ((n) => sqrtP(f, n)), - invertBatch: (lst) => FpInvertBatch(f, lst), - // TODO: do we really need constant cmov? - // We don't have const-time bigints anyway, so probably will be not very useful - cmov: (a, b, c) => (c ? b : a), - toBytes: (num) => (isLE ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES)), - fromBytes: (bytes) => { - if (bytes.length !== BYTES) - throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes.length}`); - return isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes); - }, - }); - return Object.freeze(f); -} -export function FpSqrtOdd(Fp, elm) { - if (!Fp.isOdd) - throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? root : Fp.neg(root); -} -export function FpSqrtEven(Fp, elm) { - if (!Fp.isOdd) - throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? Fp.neg(root) : root; -} -/** - * FIPS 186 B.4.1-compliant "constant-time" private key generation utility. - * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF - * and convert them into private scalar, with the modulo bias being negligible. - * Needs at least 40 bytes of input for 32-byte private key. - * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ - * @param hash hash output from SHA3 or a similar function - * @param groupOrder size of subgroup - (e.g. curveFn.CURVE.n) - * @param isLE interpret hash bytes as LE num - * @returns valid private scalar - */ -export function hashToPrivateScalar(hash, groupOrder, isLE = false) { - hash = ensureBytes('privateHash', hash); - const hashLen = hash.length; - const minLen = nLength(groupOrder).nByteLength + 8; - if (minLen < 24 || hashLen < minLen || hashLen > 1024) - throw new Error(`hashToPrivateScalar: expected ${minLen}-1024 bytes of input, got ${hashLen}`); - const num = isLE ? bytesToNumberLE(hash) : bytesToNumberBE(hash); - return mod(num, groupOrder - _1n) + _1n; -} -//# sourceMappingURL=modular.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js.map deleted file mode 100644 index 607c1f28..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"modular.js","sourceRoot":"","sources":["../../src/abstract/modular.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,EACL,OAAO,EACP,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACxD,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzC,wBAAwB;AACxB,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAC7C,CAAC;AACD;;;;;GAKG;AACH,oCAAoC;AACpC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,MAAc;IAC5D,IAAI,MAAM,IAAI,GAAG,IAAI,KAAK,GAAG,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/E,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,GAAG,CAAC;IAC/B,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,OAAO,KAAK,G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KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAyB,EACzB,UAAkB,EAClB,IAAI,GAAG,KAAK;IAEZ,IAAI,GAAG,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;IACnD,IAAI,MAAM,GAAG,EAAE,IAAI,OAAO,GAAG,MAAM,IAAI,OAAO,GAAG,IAAI;QACnD,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACjG,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC1C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js deleted file mode 100644 index 19a8b6eb..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js +++ /dev/null @@ -1,157 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { mod, pow } from './modular.js'; -import { bytesToNumberLE, ensureBytes, numberToBytesLE, validateObject } from './utils.js'; -const _0n = BigInt(0); -const _1n = BigInt(1); -function validateOpts(curve) { - validateObject(curve, { - a: 'bigint', - }, { - montgomeryBits: 'isSafeInteger', - nByteLength: 'isSafeInteger', - adjustScalarBytes: 'function', - domain: 'function', - powPminus2: 'function', - Gu: 'bigint', - }); - // Set defaults - return Object.freeze({ ...curve }); -} -// NOTE: not really montgomery curve, just bunch of very specific methods for X25519/X448 (RFC 7748, https://www.rfc-editor.org/rfc/rfc7748) -// Uses only one coordinate instead of two -export function montgomery(curveDef) { - const CURVE = validateOpts(curveDef); - const { P } = CURVE; - const modP = (n) => mod(n, P); - const montgomeryBits = CURVE.montgomeryBits; - const montgomeryBytes = Math.ceil(montgomeryBits / 8); - const fieldLen = CURVE.nByteLength; - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); - const powPminus2 = CURVE.powPminus2 || ((x) => pow(x, P - BigInt(2), P)); - // cswap from RFC7748. But it is not from RFC7748! - /* - cswap(swap, x_2, x_3): - dummy = mask(swap) AND (x_2 XOR x_3) - x_2 = x_2 XOR dummy - x_3 = x_3 XOR dummy - Return (x_2, x_3) - Where mask(swap) is the all-1 or all-0 word of the same length as x_2 - and x_3, computed, e.g., as mask(swap) = 0 - swap. - */ - function cswap(swap, x_2, x_3) { - const dummy = modP(swap * (x_2 - x_3)); - x_2 = modP(x_2 - dummy); - x_3 = modP(x_3 + dummy); - return [x_2, x_3]; - } - // Accepts 0 as well - function assertFieldElement(n) { - if (typeof n === 'bigint' && _0n <= n && n < P) - return n; - throw new Error('Expected valid scalar 0 < scalar < CURVE.P'); - } - // x25519 from 4 - // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519 - const a24 = (CURVE.a - BigInt(2)) / BigInt(4); - /** - * - * @param pointU u coordinate (x) on Montgomery Curve 25519 - * @param scalar by which the point would be multiplied - * @returns new Point on Montgomery curve - */ - function montgomeryLadder(pointU, scalar) { - const u = assertFieldElement(pointU); - // Section 5: Implementations MUST accept non-canonical values and process them as - // if they had been reduced modulo the field prime. - const k = assertFieldElement(scalar); - const x_1 = u; - let x_2 = _1n; - let z_2 = _0n; - let x_3 = u; - let z_3 = _1n; - let swap = _0n; - let sw; - for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) { - const k_t = (k >> t) & _1n; - swap ^= k_t; - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - swap = k_t; - const A = x_2 + z_2; - const AA = modP(A * A); - const B = x_2 - z_2; - const BB = modP(B * B); - const E = AA - BB; - const C = x_3 + z_3; - const D = x_3 - z_3; - const DA = modP(D * A); - const CB = modP(C * B); - const dacb = DA + CB; - const da_cb = DA - CB; - x_3 = modP(dacb * dacb); - z_3 = modP(x_1 * modP(da_cb * da_cb)); - x_2 = modP(AA * BB); - z_2 = modP(E * (AA + modP(a24 * E))); - } - // (x_2, x_3) = cswap(swap, x_2, x_3) - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - // (z_2, z_3) = cswap(swap, z_2, z_3) - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - // z_2^(p - 2) - const z2 = powPminus2(z_2); - // Return x_2 * (z_2^(p - 2)) - return modP(x_2 * z2); - } - function encodeUCoordinate(u) { - return numberToBytesLE(modP(u), montgomeryBytes); - } - function decodeUCoordinate(uEnc) { - // Section 5: When receiving such an array, implementations of X25519 - // MUST mask the most significant bit in the final byte. - // This is very ugly way, but it works because fieldLen-1 is outside of bounds for X448, so this becomes NOOP - // fieldLen - scalaryBytes = 1 for X448 and = 0 for X25519 - const u = ensureBytes('u coordinate', uEnc, montgomeryBytes); - // u[fieldLen-1] crashes QuickJS (TypeError: out-of-bound numeric index) - if (fieldLen === montgomeryBytes) - u[fieldLen - 1] &= 127; // 0b0111_1111 - return bytesToNumberLE(u); - } - function decodeScalar(n) { - const bytes = ensureBytes('scalar', n); - if (bytes.length !== montgomeryBytes && bytes.length !== fieldLen) - throw new Error(`Expected ${montgomeryBytes} or ${fieldLen} bytes, got ${bytes.length}`); - return bytesToNumberLE(adjustScalarBytes(bytes)); - } - function scalarMult(scalar, u) { - const pointU = decodeUCoordinate(u); - const _scalar = decodeScalar(scalar); - const pu = montgomeryLadder(pointU, _scalar); - // The result was not contributory - // https://cr.yp.to/ecdh.html#validate - if (pu === _0n) - throw new Error('Invalid private or public key received'); - return encodeUCoordinate(pu); - } - // Computes public key from private. By doing scalar multiplication of base point. - const GuBytes = encodeUCoordinate(CURVE.Gu); - function scalarMultBase(scalar) { - return scalarMult(scalar, GuBytes); - } - return { - scalarMult, - scalarMultBase, - getSharedSecret: (privateKey, publicKey) => scalarMult(privateKey, publicKey), - getPublicKey: (privateKey) => scalarMultBase(privateKey), - utils: { randomPrivateKey: () => CURVE.randomBytes(CURVE.nByteLength) }, - GuBytes: GuBytes, - }; -} -//# sourceMappingURL=montgomery.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js.map deleted file mode 100644 index 6bc1a061..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/montgomery.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"montgomery.js","sourceRoot":"","sources":["../../src/abstract/montgomery.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3F,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAwBtB,SAAS,YAAY,CAAC,KAAgB;IACpC,cAAc,CACZ,KAAK,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KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3F,OAAO,eAAe,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,SAAS,UAAU,CAAC,MAAW,EAAE,CAAM;QACrC,MAAM,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7C,kCAAkC;QAClC,sCAAsC;QACtC,IAAI,EAAE,KAAK,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC1E,OAAO,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,kFAAkF;IAClF,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,SAAS,cAAc,CAAC,MAAW;QACjC,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,UAAU;QACV,cAAc;QACd,eAAe,EAAE,CAAC,UAAe,EAAE,SAAc,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC;QACvF,YAAY,EAAE,CAAC,UAAe,EAAc,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC;QACzE,KAAK,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;QACxE,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js deleted file mode 100644 index 7ea744bc..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js +++ /dev/null @@ -1,110 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Poseidon Hash: https://eprint.iacr.org/2019/458.pdf, https://www.poseidon-hash.info -import { FpPow, validateField } from './modular.js'; -export function validateOpts(opts) { - const { Fp } = opts; - validateField(Fp); - for (const i of ['t', 'roundsFull', 'roundsPartial']) { - if (typeof opts[i] !== 'number' || !Number.isSafeInteger(opts[i])) - throw new Error(`Poseidon: invalid param ${i}=${opts[i]} (${typeof opts[i]})`); - } - if (opts.reversePartialPowIdx !== undefined && typeof opts.reversePartialPowIdx !== 'boolean') - throw new Error(`Poseidon: invalid param reversePartialPowIdx=${opts.reversePartialPowIdx}`); - // Default is 5, but by some reasons stark uses 3 - let sboxPower = opts.sboxPower; - if (sboxPower === undefined) - sboxPower = 5; - if (typeof sboxPower !== 'number' || !Number.isSafeInteger(sboxPower)) - throw new Error(`Poseidon wrong sboxPower=${sboxPower}`); - const _sboxPower = BigInt(sboxPower); - let sboxFn = (n) => FpPow(Fp, n, _sboxPower); - // Unwrapped sbox power for common cases (195->142μs) - if (sboxPower === 3) - sboxFn = (n) => Fp.mul(Fp.sqrN(n), n); - else if (sboxPower === 5) - sboxFn = (n) => Fp.mul(Fp.sqrN(Fp.sqrN(n)), n); - if (opts.roundsFull % 2 !== 0) - throw new Error(`Poseidon roundsFull is not even: ${opts.roundsFull}`); - const rounds = opts.roundsFull + opts.roundsPartial; - if (!Array.isArray(opts.roundConstants) || opts.roundConstants.length !== rounds) - throw new Error('Poseidon: wrong round constants'); - const roundConstants = opts.roundConstants.map((rc) => { - if (!Array.isArray(rc) || rc.length !== opts.t) - throw new Error(`Poseidon wrong round constants: ${rc}`); - return rc.map((i) => { - if (typeof i !== 'bigint' || !Fp.isValid(i)) - throw new Error(`Poseidon wrong round constant=${i}`); - return Fp.create(i); - }); - }); - // MDS is TxT matrix - if (!Array.isArray(opts.mds) || opts.mds.length !== opts.t) - throw new Error('Poseidon: wrong MDS matrix'); - const mds = opts.mds.map((mdsRow) => { - if (!Array.isArray(mdsRow) || mdsRow.length !== opts.t) - throw new Error(`Poseidon MDS matrix row: ${mdsRow}`); - return mdsRow.map((i) => { - if (typeof i !== 'bigint') - throw new Error(`Poseidon MDS matrix value=${i}`); - return Fp.create(i); - }); - }); - return Object.freeze({ ...opts, rounds, sboxFn, roundConstants, mds }); -} -export function splitConstants(rc, t) { - if (typeof t !== 'number') - throw new Error('poseidonSplitConstants: wrong t'); - if (!Array.isArray(rc) || rc.length % t) - throw new Error('poseidonSplitConstants: wrong rc'); - const res = []; - let tmp = []; - for (let i = 0; i < rc.length; i++) { - tmp.push(rc[i]); - if (tmp.length === t) { - res.push(tmp); - tmp = []; - } - } - return res; -} -export function poseidon(opts) { - const { t, Fp, rounds, sboxFn, reversePartialPowIdx } = validateOpts(opts); - const halfRoundsFull = Math.floor(opts.roundsFull / 2); - const partialIdx = reversePartialPowIdx ? t - 1 : 0; - const poseidonRound = (values, isFull, idx) => { - values = values.map((i, j) => Fp.add(i, opts.roundConstants[idx][j])); - if (isFull) - values = values.map((i) => sboxFn(i)); - else - values[partialIdx] = sboxFn(values[partialIdx]); - // Matrix multiplication - values = opts.mds.map((i) => i.reduce((acc, i, j) => Fp.add(acc, Fp.mulN(i, values[j])), Fp.ZERO)); - return values; - }; - const poseidonHash = function poseidonHash(values) { - if (!Array.isArray(values) || values.length !== t) - throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`); - values = values.map((i) => { - if (typeof i !== 'bigint') - throw new Error(`Poseidon: wrong value=${i} (${typeof i})`); - return Fp.create(i); - }); - let round = 0; - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) - values = poseidonRound(values, true, round++); - // Apply r_p partial rounds. - for (let i = 0; i < opts.roundsPartial; i++) - values = poseidonRound(values, false, round++); - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) - values = poseidonRound(values, true, round++); - if (round !== rounds) - throw new Error(`Poseidon: wrong number of rounds: last round=${round}, total=${rounds}`); - return values; - }; - // For verification in tests - poseidonHash.roundConstants = opts.roundConstants; - return poseidonHash; -} -//# sourceMappingURL=poseidon.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js.map deleted file mode 100644 index 8863ad28..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/poseidon.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"poseidon.js","sourceRoot":"","sources":["../../src/abstract/poseidon.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sFAAsF;AACtF,OAAO,EAAU,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAc5D,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC7C,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,eAAe,CAAU,EAAE;QAC7D,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC/D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KAClF;IACD,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,oBAAoB,KAAK,SAAS;QAC3F,MAAM,IAAI,KAAK,CAAC,gDAAgD,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC/F,iDAAiD;IACjD,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAC/B,IAAI,SAAS,KAAK,SAAS;QAAE,SAAS,GAAG,CAAC,CAAC;I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AG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvF,4BAA4B;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5F,2BAA2B;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAEvF,IAAI,KAAK,KAAK,MAAM;YAClB,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,WAAW,MAAM,EAAE,CAAC,CAAC;QAC5F,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,4BAA4B;IAC5B,YAAY,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAClD,OAAO,YAAY,CAAC;AACtB,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js deleted file mode 100644 index 7839e259..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js +++ /dev/null @@ -1,265 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// 100 lines of code in the file are duplicated from noble-hashes (utils). -// This is OK: `abstract` directory does not use noble-hashes. -// User may opt-in into using different hashing library. This way, noble-hashes -// won't be included into their bundle. -const _0n = BigInt(0); -const _1n = BigInt(1); -const _2n = BigInt(2); -const u8a = (a) => a instanceof Uint8Array; -const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0')); -/** - * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' - */ -export function bytesToHex(bytes) { - if (!u8a(bytes)) - throw new Error('Uint8Array expected'); - // pre-caching improves the speed 6x - let hex = ''; - for (let i = 0; i < bytes.length; i++) { - hex += hexes[bytes[i]]; - } - return hex; -} -export function numberToHexUnpadded(num) { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; -} -export function hexToNumber(hex) { - if (typeof hex !== 'string') - throw new Error('hex string expected, got ' + typeof hex); - // Big Endian - return BigInt(hex === '' ? '0' : `0x${hex}`); -} -/** - * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) - */ -export function hexToBytes(hex) { - if (typeof hex !== 'string') - throw new Error('hex string expected, got ' + typeof hex); - const len = hex.length; - if (len % 2) - throw new Error('padded hex string expected, got unpadded hex of length ' + len); - const array = new Uint8Array(len / 2); - for (let i = 0; i < array.length; i++) { - const j = i * 2; - const hexByte = hex.slice(j, j + 2); - const byte = Number.parseInt(hexByte, 16); - if (Number.isNaN(byte) || byte < 0) - throw new Error('Invalid byte sequence'); - array[i] = byte; - } - return array; -} -// BE: Big Endian, LE: Little Endian -export function bytesToNumberBE(bytes) { - return hexToNumber(bytesToHex(bytes)); -} -export function bytesToNumberLE(bytes) { - if (!u8a(bytes)) - throw new Error('Uint8Array expected'); - return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); -} -export function numberToBytesBE(n, len) { - return hexToBytes(n.toString(16).padStart(len * 2, '0')); -} -export function numberToBytesLE(n, len) { - return numberToBytesBE(n, len).reverse(); -} -// Unpadded, rarely used -export function numberToVarBytesBE(n) { - return hexToBytes(numberToHexUnpadded(n)); -} -/** - * Takes hex string or Uint8Array, converts to Uint8Array. - * Validates output length. - * Will throw error for other types. - * @param title descriptive title for an error e.g. 'private key' - * @param hex hex string or Uint8Array - * @param expectedLength optional, will compare to result array's length - * @returns - */ -export function ensureBytes(title, hex, expectedLength) { - let res; - if (typeof hex === 'string') { - try { - res = hexToBytes(hex); - } - catch (e) { - throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`); - } - } - else if (u8a(hex)) { - // Uint8Array.from() instead of hash.slice() because node.js Buffer - // is instance of Uint8Array, and its slice() creates **mutable** copy - res = Uint8Array.from(hex); - } - else { - throw new Error(`${title} must be hex string or Uint8Array`); - } - const len = res.length; - if (typeof expectedLength === 'number' && len !== expectedLength) - throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`); - return res; -} -/** - * Copies several Uint8Arrays into one. - */ -export function concatBytes(...arrays) { - const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0)); - let pad = 0; // walk through each item, ensure they have proper type - arrays.forEach((a) => { - if (!u8a(a)) - throw new Error('Uint8Array expected'); - r.set(a, pad); - pad += a.length; - }); - return r; -} -export function equalBytes(b1, b2) { - // We don't care about timing attacks here - if (b1.length !== b2.length) - return false; - for (let i = 0; i < b1.length; i++) - if (b1[i] !== b2[i]) - return false; - return true; -} -/** - * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) - */ -export function utf8ToBytes(str) { - if (typeof str !== 'string') - throw new Error(`utf8ToBytes expected string, got ${typeof str}`); - return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 -} -// Bit operations -/** - * Calculates amount of bits in a bigint. - * Same as `n.toString(2).length` - */ -export function bitLen(n) { - let len; - for (len = 0; n > _0n; n >>= _1n, len += 1) - ; - return len; -} -/** - * Gets single bit at position. - * NOTE: first bit position is 0 (same as arrays) - * Same as `!!+Array.from(n.toString(2)).reverse()[pos]` - */ -export function bitGet(n, pos) { - return (n >> BigInt(pos)) & _1n; -} -/** - * Sets single bit at position. - */ -export const bitSet = (n, pos, value) => { - return n | ((value ? _1n : _0n) << BigInt(pos)); -}; -/** - * Calculate mask for N bits. Not using ** operator with bigints because of old engines. - * Same as BigInt(`0b${Array(i).fill('1').join('')}`) - */ -export const bitMask = (n) => (_2n << BigInt(n - 1)) - _1n; -// DRBG -const u8n = (data) => new Uint8Array(data); // creates Uint8Array -const u8fr = (arr) => Uint8Array.from(arr); // another shortcut -/** - * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - * @returns function that will call DRBG until 2nd arg returns something meaningful - * @example - * const drbg = createHmacDRBG(32, 32, hmac); - * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined - */ -export function createHmacDrbg(hashLen, qByteLen, hmacFn) { - if (typeof hashLen !== 'number' || hashLen < 2) - throw new Error('hashLen must be a number'); - if (typeof qByteLen !== 'number' || qByteLen < 2) - throw new Error('qByteLen must be a number'); - if (typeof hmacFn !== 'function') - throw new Error('hmacFn must be a function'); - // Step B, Step C: set hashLen to 8*ceil(hlen/8) - let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same - let i = 0; // Iterations counter, will throw when over 1000 - const reset = () => { - v.fill(1); - k.fill(0); - i = 0; - }; - const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values) - const reseed = (seed = u8n()) => { - // HMAC-DRBG reseed() function. Steps D-G - k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed) - v = h(); // v = hmac(k || v) - if (seed.length === 0) - return; - k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed) - v = h(); // v = hmac(k || v) - }; - const gen = () => { - // HMAC-DRBG generate() function - if (i++ >= 1000) - throw new Error('drbg: tried 1000 values'); - let len = 0; - const out = []; - while (len < qByteLen) { - v = h(); - const sl = v.slice(); - out.push(sl); - len += v.length; - } - return concatBytes(...out); - }; - const genUntil = (seed, pred) => { - reset(); - reseed(seed); // Steps D-G - let res = undefined; // Step H: grind until k is in [1..n-1] - while (!(res = pred(gen()))) - reseed(); - reset(); - return res; - }; - return genUntil; -} -// Validating curves and fields -const validatorFns = { - bigint: (val) => typeof val === 'bigint', - function: (val) => typeof val === 'function', - boolean: (val) => typeof val === 'boolean', - string: (val) => typeof val === 'string', - isSafeInteger: (val) => Number.isSafeInteger(val), - array: (val) => Array.isArray(val), - field: (val, object) => object.Fp.isValid(val), - hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen), -}; -// type Record = { [P in K]: T; } -export function validateObject(object, validators, optValidators = {}) { - const checkField = (fieldName, type, isOptional) => { - const checkVal = validatorFns[type]; - if (typeof checkVal !== 'function') - throw new Error(`Invalid validator "${type}", expected function`); - const val = object[fieldName]; - if (isOptional && val === undefined) - return; - if (!checkVal(val, object)) { - throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`); - } - }; - for (const [fieldName, type] of Object.entries(validators)) - checkField(fieldName, type, false); - for (const [fieldName, type] of Object.entries(optValidators)) - checkField(fieldName, type, true); - return object; -} -// validate type tests -// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 }; -// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok! -// // Should fail type-check -// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' }); -// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' }); -// const z3 = validateObject(o, { test: 'boolean', z: 'bug' }); -// const z4 = validateObject(o, { a: 'boolean', z: 'bug' }); -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js.map deleted file mode 100644 index 289afb8e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/abstract/utils.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,0EAA0E;AAC1E,8DAA8D;AAC9D,+EAA+E;AAC/E,uCAAuC;AACvC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GA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AAO,CAAC,aAAa,CAAC;QAAE,UAAU,CAAC,SAAS,EAAE,IAAK,EAAE,IAAI,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC;AAChB,CAAC;AACD,sBAAsB;AACtB,uEAAuE;AACvE,gFAAgF;AAChF,4BAA4B;AAC5B,2DAA2D;AAC3D,qEAAqE;AACrE,+DAA+D;AAC/D,4DAA4D"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js deleted file mode 100644 index 3d79ba0e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js +++ /dev/null @@ -1,1054 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Short Weierstrass curve. The formula is: y² = x³ + ax + b -import * as mod from './modular.js'; -import * as ut from './utils.js'; -import { ensureBytes } from './utils.js'; -import { wNAF, validateBasic } from './curve.js'; -function validatePointOpts(curve) { - const opts = validateBasic(curve); - ut.validateObject(opts, { - a: 'field', - b: 'field', - }, { - allowedPrivateKeyLengths: 'array', - wrapPrivateKey: 'boolean', - isTorsionFree: 'function', - clearCofactor: 'function', - allowInfinityPoint: 'boolean', - fromBytes: 'function', - toBytes: 'function', - }); - const { endo, Fp, a } = opts; - if (endo) { - if (!Fp.eql(a, Fp.ZERO)) { - throw new Error('Endomorphism can only be defined for Koblitz curves that have a=0'); - } - if (typeof endo !== 'object' || - typeof endo.beta !== 'bigint' || - typeof endo.splitScalar !== 'function') { - throw new Error('Expected endomorphism with beta: bigint and splitScalar: function'); - } - } - return Object.freeze({ ...opts }); -} -// ASN.1 DER encoding utilities -const { bytesToNumberBE: b2n, hexToBytes: h2b } = ut; -export const DER = { - // asn.1 DER encoding utils - Err: class DERErr extends Error { - constructor(m = '') { - super(m); - } - }, - _parseInt(data) { - const { Err: E } = DER; - if (data.length < 2 || data[0] !== 0x02) - throw new E('Invalid signature integer tag'); - const len = data[1]; - const res = data.subarray(2, len + 2); - if (!len || res.length !== len) - throw new E('Invalid signature integer: wrong length'); - // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, - // since we always use positive integers here. It must always be empty: - // - add zero byte if exists - // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) - if (res[0] & 0b10000000) - throw new E('Invalid signature integer: negative'); - if (res[0] === 0x00 && !(res[1] & 0b10000000)) - throw new E('Invalid signature integer: unnecessary leading zero'); - return { d: b2n(res), l: data.subarray(len + 2) }; // d is data, l is left - }, - toSig(hex) { - // parse DER signature - const { Err: E } = DER; - const data = typeof hex === 'string' ? h2b(hex) : hex; - if (!(data instanceof Uint8Array)) - throw new Error('ui8a expected'); - let l = data.length; - if (l < 2 || data[0] != 0x30) - throw new E('Invalid signature tag'); - if (data[1] !== l - 2) - throw new E('Invalid signature: incorrect length'); - const { d: r, l: sBytes } = DER._parseInt(data.subarray(2)); - const { d: s, l: rBytesLeft } = DER._parseInt(sBytes); - if (rBytesLeft.length) - throw new E('Invalid signature: left bytes after parsing'); - return { r, s }; - }, - hexFromSig(sig) { - // Add leading zero if first byte has negative bit enabled. More details in '_parseInt' - const slice = (s) => (Number.parseInt(s[0], 16) & 0b1000 ? '00' + s : s); - const h = (num) => { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; - }; - const s = slice(h(sig.s)); - const r = slice(h(sig.r)); - const shl = s.length / 2; - const rhl = r.length / 2; - const sl = h(shl); - const rl = h(rhl); - return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`; - }, -}; -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); -export function weierstrassPoints(opts) { - const CURVE = validatePointOpts(opts); - const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ - const toBytes = CURVE.toBytes || - ((c, point, isCompressed) => { - const a = point.toAffine(); - return ut.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y)); - }); - const fromBytes = CURVE.fromBytes || - ((bytes) => { - // const head = bytes[0]; - const tail = bytes.subarray(1); - // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported'); - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - }); - /** - * y² = x³ + ax + b: Short weierstrass curve formula - * @returns y² - */ - function weierstrassEquation(x) { - const { a, b } = CURVE; - const x2 = Fp.sqr(x); // x * x - const x3 = Fp.mul(x2, x); // x2 * x - return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b - } - // Validate whether the passed curve params are valid. - // We check if curve equation works for generator point. - // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381. - // ProjectivePoint class has not been initialized yet. - if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx))) - throw new Error('bad generator point: equation left != right'); - // Valid group elements reside in range 1..n-1 - function isWithinCurveOrder(num) { - return typeof num === 'bigint' && _0n < num && num < CURVE.n; - } - function assertGE(num) { - if (!isWithinCurveOrder(num)) - throw new Error('Expected valid bigint: 0 < bigint < curve.n'); - } - // Validates if priv key is valid and converts it to bigint. - // Supports options allowedPrivateKeyLengths and wrapPrivateKey. - function normPrivateKeyToScalar(key) { - const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE; - if (lengths && typeof key !== 'bigint') { - if (key instanceof Uint8Array) - key = ut.bytesToHex(key); - // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes - if (typeof key !== 'string' || !lengths.includes(key.length)) - throw new Error('Invalid key'); - key = key.padStart(nByteLength * 2, '0'); - } - let num; - try { - num = - typeof key === 'bigint' - ? key - : ut.bytesToNumberBE(ensureBytes('private key', key, nByteLength)); - } - catch (error) { - throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`); - } - if (wrapPrivateKey) - num = mod.mod(num, n); // disabled by default, enabled for BLS - assertGE(num); // num in range [1..N-1] - return num; - } - const pointPrecomputes = new Map(); - function assertPrjPoint(other) { - if (!(other instanceof Point)) - throw new Error('ProjectivePoint expected'); - } - /** - * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z) - * Default Point works in 2d / affine coordinates: (x, y) - * We're doing calculations in projective, because its operations don't require costly inversion. - */ - class Point { - constructor(px, py, pz) { - this.px = px; - this.py = py; - this.pz = pz; - if (px == null || !Fp.isValid(px)) - throw new Error('x required'); - if (py == null || !Fp.isValid(py)) - throw new Error('y required'); - if (pz == null || !Fp.isValid(pz)) - throw new Error('z required'); - } - // Does not validate if the point is on-curve. - // Use fromHex instead, or call assertValidity() later. - static fromAffine(p) { - const { x, y } = p || {}; - if (!p || !Fp.isValid(x) || !Fp.isValid(y)) - throw new Error('invalid affine point'); - if (p instanceof Point) - throw new Error('projective point not allowed'); - const is0 = (i) => Fp.eql(i, Fp.ZERO); - // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0) - if (is0(x) && is0(y)) - return Point.ZERO; - return new Point(x, y, Fp.ONE); - } - get x() { - return this.toAffine().x; - } - get y() { - return this.toAffine().y; - } - /** - * Takes a bunch of Projective Points but executes only one - * inversion on all of them. Inversion is very slow operation, - * so this improves performance massively. - * Optimization: converts a list of projective points to a list of identical points with Z=1. - */ - static normalizeZ(points) { - const toInv = Fp.invertBatch(points.map((p) => p.pz)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - /** - * Converts hash string or Uint8Array to Point. - * @param hex short/long ECDSA hex - */ - static fromHex(hex) { - const P = Point.fromAffine(fromBytes(ensureBytes('pointHex', hex))); - P.assertValidity(); - return P; - } - // Multiplies generator point by privateKey. - static fromPrivateKey(privateKey) { - return Point.BASE.multiply(normPrivateKeyToScalar(privateKey)); - } - // "Private method", don't use it directly - _setWindowSize(windowSize) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - // A point on curve is valid if it conforms to equation. - assertValidity() { - // Zero is valid point too! - if (this.is0()) { - if (CURVE.allowInfinityPoint) - return; - throw new Error('bad point: ZERO'); - } - // Some 3rd-party test vectors require different wording between here & `fromCompressedHex` - const { x, y } = this.toAffine(); - // Check if x, y are valid field elements - if (!Fp.isValid(x) || !Fp.isValid(y)) - throw new Error('bad point: x or y not FE'); - const left = Fp.sqr(y); // y² - const right = weierstrassEquation(x); // x³ + ax + b - if (!Fp.eql(left, right)) - throw new Error('bad point: equation left != right'); - if (!this.isTorsionFree()) - throw new Error('bad point: not in prime-order subgroup'); - } - hasEvenY() { - const { y } = this.toAffine(); - if (Fp.isOdd) - return !Fp.isOdd(y); - throw new Error("Field doesn't support isOdd"); - } - /** - * Compare one point to another. - */ - equals(other) { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1)); - const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1)); - return U1 && U2; - } - /** - * Flips point to one corresponding to (x, -y) in Affine coordinates. - */ - negate() { - return new Point(this.px, Fp.neg(this.py), this.pz); - } - // Renes-Costello-Batina exception-free doubling formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 3 - // Cost: 8M + 3S + 3*a + 2*b3 + 15add. - double() { - const { a, b } = CURVE; - const b3 = Fp.mul(b, _3n); - const { px: X1, py: Y1, pz: Z1 } = this; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - let t0 = Fp.mul(X1, X1); // step 1 - let t1 = Fp.mul(Y1, Y1); - let t2 = Fp.mul(Z1, Z1); - let t3 = Fp.mul(X1, Y1); - t3 = Fp.add(t3, t3); // step 5 - Z3 = Fp.mul(X1, Z1); - Z3 = Fp.add(Z3, Z3); - X3 = Fp.mul(a, Z3); - Y3 = Fp.mul(b3, t2); - Y3 = Fp.add(X3, Y3); // step 10 - X3 = Fp.sub(t1, Y3); - Y3 = Fp.add(t1, Y3); - Y3 = Fp.mul(X3, Y3); - X3 = Fp.mul(t3, X3); - Z3 = Fp.mul(b3, Z3); // step 15 - t2 = Fp.mul(a, t2); - t3 = Fp.sub(t0, t2); - t3 = Fp.mul(a, t3); - t3 = Fp.add(t3, Z3); - Z3 = Fp.add(t0, t0); // step 20 - t0 = Fp.add(Z3, t0); - t0 = Fp.add(t0, t2); - t0 = Fp.mul(t0, t3); - Y3 = Fp.add(Y3, t0); - t2 = Fp.mul(Y1, Z1); // step 25 - t2 = Fp.add(t2, t2); - t0 = Fp.mul(t2, t3); - X3 = Fp.sub(X3, t0); - Z3 = Fp.mul(t2, t1); - Z3 = Fp.add(Z3, Z3); // step 30 - Z3 = Fp.add(Z3, Z3); - return new Point(X3, Y3, Z3); - } - // Renes-Costello-Batina exception-free addition formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 1 - // Cost: 12M + 0S + 3*a + 3*b3 + 23add. - add(other) { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - const a = CURVE.a; - const b3 = Fp.mul(CURVE.b, _3n); - let t0 = Fp.mul(X1, X2); // step 1 - let t1 = Fp.mul(Y1, Y2); - let t2 = Fp.mul(Z1, Z2); - let t3 = Fp.add(X1, Y1); - let t4 = Fp.add(X2, Y2); // step 5 - t3 = Fp.mul(t3, t4); - t4 = Fp.add(t0, t1); - t3 = Fp.sub(t3, t4); - t4 = Fp.add(X1, Z1); - let t5 = Fp.add(X2, Z2); // step 10 - t4 = Fp.mul(t4, t5); - t5 = Fp.add(t0, t2); - t4 = Fp.sub(t4, t5); - t5 = Fp.add(Y1, Z1); - X3 = Fp.add(Y2, Z2); // step 15 - t5 = Fp.mul(t5, X3); - X3 = Fp.add(t1, t2); - t5 = Fp.sub(t5, X3); - Z3 = Fp.mul(a, t4); - X3 = Fp.mul(b3, t2); // step 20 - Z3 = Fp.add(X3, Z3); - X3 = Fp.sub(t1, Z3); - Z3 = Fp.add(t1, Z3); - Y3 = Fp.mul(X3, Z3); - t1 = Fp.add(t0, t0); // step 25 - t1 = Fp.add(t1, t0); - t2 = Fp.mul(a, t2); - t4 = Fp.mul(b3, t4); - t1 = Fp.add(t1, t2); - t2 = Fp.sub(t0, t2); // step 30 - t2 = Fp.mul(a, t2); - t4 = Fp.add(t4, t2); - t0 = Fp.mul(t1, t4); - Y3 = Fp.add(Y3, t0); - t0 = Fp.mul(t5, t4); // step 35 - X3 = Fp.mul(t3, X3); - X3 = Fp.sub(X3, t0); - t0 = Fp.mul(t3, t1); - Z3 = Fp.mul(t5, Z3); - Z3 = Fp.add(Z3, t0); // step 40 - return new Point(X3, Y3, Z3); - } - subtract(other) { - return this.add(other.negate()); - } - is0() { - return this.equals(Point.ZERO); - } - wNAF(n) { - return wnaf.wNAFCached(this, pointPrecomputes, n, (comp) => { - const toInv = Fp.invertBatch(comp.map((p) => p.pz)); - return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - }); - } - /** - * Non-constant-time multiplication. Uses double-and-add algorithm. - * It's faster, but should only be used when you don't care about - * an exposed private key e.g. sig verification, which works over *public* keys. - */ - multiplyUnsafe(n) { - const I = Point.ZERO; - if (n === _0n) - return I; - assertGE(n); // Will throw on 0 - if (n === _1n) - return this; - const { endo } = CURVE; - if (!endo) - return wnaf.unsafeLadder(this, n); - // Apply endomorphism - let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let k1p = I; - let k2p = I; - let d = this; - while (k1 > _0n || k2 > _0n) { - if (k1 & _1n) - k1p = k1p.add(d); - if (k2 & _1n) - k2p = k2p.add(d); - d = d.double(); - k1 >>= _1n; - k2 >>= _1n; - } - if (k1neg) - k1p = k1p.negate(); - if (k2neg) - k2p = k2p.negate(); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - return k1p.add(k2p); - } - /** - * Constant time multiplication. - * Uses wNAF method. Windowed method may be 10% faster, - * but takes 2x longer to generate and consumes 2x memory. - * Uses precomputes when available. - * Uses endomorphism for Koblitz curves. - * @param scalar by which the point would be multiplied - * @returns New point - */ - multiply(scalar) { - assertGE(scalar); - let n = scalar; - let point, fake; // Fake point is used to const-time mult - const { endo } = CURVE; - if (endo) { - const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let { p: k1p, f: f1p } = this.wNAF(k1); - let { p: k2p, f: f2p } = this.wNAF(k2); - k1p = wnaf.constTimeNegate(k1neg, k1p); - k2p = wnaf.constTimeNegate(k2neg, k2p); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - point = k1p.add(k2p); - fake = f1p.add(f2p); - } - else { - const { p, f } = this.wNAF(n); - point = p; - fake = f; - } - // Normalize `z` for both points, but return only real one - return Point.normalizeZ([point, fake])[0]; - } - /** - * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. - * Not using Strauss-Shamir trick: precomputation tables are faster. - * The trick could be useful if both P and Q are not G (not in our case). - * @returns non-zero affine point - */ - multiplyAndAddUnsafe(Q, a, b) { - const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes - const mul = (P, a // Select faster multiply() method - ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a)); - const sum = mul(this, a).add(mul(Q, b)); - return sum.is0() ? undefined : sum; - } - // Converts Projective point to affine (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - // (x, y, z) ∋ (x=x/z, y=y/z) - toAffine(iz) { - const { px: x, py: y, pz: z } = this; - const is0 = this.is0(); - // If invZ was 0, we return zero point. However we still want to execute - // all operations, so we replace invZ with a random number, 1. - if (iz == null) - iz = is0 ? Fp.ONE : Fp.inv(z); - const ax = Fp.mul(x, iz); - const ay = Fp.mul(y, iz); - const zz = Fp.mul(z, iz); - if (is0) - return { x: Fp.ZERO, y: Fp.ZERO }; - if (!Fp.eql(zz, Fp.ONE)) - throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - isTorsionFree() { - const { h: cofactor, isTorsionFree } = CURVE; - if (cofactor === _1n) - return true; // No subgroups, always torsion-free - if (isTorsionFree) - return isTorsionFree(Point, this); - throw new Error('isTorsionFree() has not been declared for the elliptic curve'); - } - clearCofactor() { - const { h: cofactor, clearCofactor } = CURVE; - if (cofactor === _1n) - return this; // Fast-path - if (clearCofactor) - return clearCofactor(Point, this); - return this.multiplyUnsafe(CURVE.h); - } - toRawBytes(isCompressed = true) { - this.assertValidity(); - return toBytes(Point, this, isCompressed); - } - toHex(isCompressed = true) { - return ut.bytesToHex(this.toRawBytes(isCompressed)); - } - } - Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE); - Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO); - const _bits = CURVE.nBitLength; - const wnaf = wNAF(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits); - // Validate if generator point is on curve - return { - CURVE, - ProjectivePoint: Point, - normPrivateKeyToScalar, - weierstrassEquation, - isWithinCurveOrder, - }; -} -function validateOpts(curve) { - const opts = validateBasic(curve); - ut.validateObject(opts, { - hash: 'hash', - hmac: 'function', - randomBytes: 'function', - }, { - bits2int: 'function', - bits2int_modN: 'function', - lowS: 'boolean', - }); - return Object.freeze({ lowS: true, ...opts }); -} -export function weierstrass(curveDef) { - const CURVE = validateOpts(curveDef); - const { Fp, n: CURVE_ORDER } = CURVE; - const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32 - const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32 - function isValidFieldElement(num) { - return _0n < num && num < Fp.ORDER; // 0 is banned since it's not invertible FE - } - function modN(a) { - return mod.mod(a, CURVE_ORDER); - } - function invN(a) { - return mod.invert(a, CURVE_ORDER); - } - const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder, } = weierstrassPoints({ - ...CURVE, - toBytes(c, point, isCompressed) { - const a = point.toAffine(); - const x = Fp.toBytes(a.x); - const cat = ut.concatBytes; - if (isCompressed) { - return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x); - } - else { - return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y)); - } - }, - fromBytes(bytes) { - const len = bytes.length; - const head = bytes[0]; - const tail = bytes.subarray(1); - // this.assertValidity() is done inside of fromHex - if (len === compressedLen && (head === 0x02 || head === 0x03)) { - const x = ut.bytesToNumberBE(tail); - if (!isValidFieldElement(x)) - throw new Error('Point is not on curve'); - const y2 = weierstrassEquation(x); // y² = x³ + ax + b - let y = Fp.sqrt(y2); // y = y² ^ (p+1)/4 - const isYOdd = (y & _1n) === _1n; - // ECDSA - const isHeadOdd = (head & 1) === 1; - if (isHeadOdd !== isYOdd) - y = Fp.neg(y); - return { x, y }; - } - else if (len === uncompressedLen && head === 0x04) { - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - } - else { - throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`); - } - }, - }); - const numToNByteStr = (num) => ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength)); - function isBiggerThanHalfOrder(number) { - const HALF = CURVE_ORDER >> _1n; - return number > HALF; - } - function normalizeS(s) { - return isBiggerThanHalfOrder(s) ? modN(-s) : s; - } - // slice bytes num - const slcNum = (b, from, to) => ut.bytesToNumberBE(b.slice(from, to)); - /** - * ECDSA signature with its (r, s) properties. Supports DER & compact representations. - */ - class Signature { - constructor(r, s, recovery) { - this.r = r; - this.s = s; - this.recovery = recovery; - this.assertValidity(); - } - // pair (bytes of r, bytes of s) - static fromCompact(hex) { - const l = CURVE.nByteLength; - hex = ensureBytes('compactSignature', hex, l * 2); - return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l)); - } - // DER encoded ECDSA signature - // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script - static fromDER(hex) { - const { r, s } = DER.toSig(ensureBytes('DER', hex)); - return new Signature(r, s); - } - assertValidity() { - // can use assertGE here - if (!isWithinCurveOrder(this.r)) - throw new Error('r must be 0 < r < CURVE.n'); - if (!isWithinCurveOrder(this.s)) - throw new Error('s must be 0 < s < CURVE.n'); - } - addRecoveryBit(recovery) { - return new Signature(this.r, this.s, recovery); - } - recoverPublicKey(msgHash) { - const { r, s, recovery: rec } = this; - const h = bits2int_modN(ensureBytes('msgHash', msgHash)); // Truncate hash - if (rec == null || ![0, 1, 2, 3].includes(rec)) - throw new Error('recovery id invalid'); - const radj = rec === 2 || rec === 3 ? r + CURVE.n : r; - if (radj >= Fp.ORDER) - throw new Error('recovery id 2 or 3 invalid'); - const prefix = (rec & 1) === 0 ? '02' : '03'; - const R = Point.fromHex(prefix + numToNByteStr(radj)); - const ir = invN(radj); // r^-1 - const u1 = modN(-h * ir); // -hr^-1 - const u2 = modN(s * ir); // sr^-1 - const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1) - if (!Q) - throw new Error('point at infinify'); // unsafe is fine: no priv data leaked - Q.assertValidity(); - return Q; - } - // Signatures should be low-s, to prevent malleability. - hasHighS() { - return isBiggerThanHalfOrder(this.s); - } - normalizeS() { - return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this; - } - // DER-encoded - toDERRawBytes() { - return ut.hexToBytes(this.toDERHex()); - } - toDERHex() { - return DER.hexFromSig({ r: this.r, s: this.s }); - } - // padded bytes of r, then padded bytes of s - toCompactRawBytes() { - return ut.hexToBytes(this.toCompactHex()); - } - toCompactHex() { - return numToNByteStr(this.r) + numToNByteStr(this.s); - } - } - const utils = { - isValidPrivateKey(privateKey) { - try { - normPrivateKeyToScalar(privateKey); - return true; - } - catch (error) { - return false; - } - }, - normPrivateKeyToScalar: normPrivateKeyToScalar, - /** - * Produces cryptographically secure private key from random of size (nBitLength+64) - * as per FIPS 186 B.4.1 with modulo bias being neglible. - */ - randomPrivateKey: () => { - const rand = CURVE.randomBytes(Fp.BYTES + 8); - const num = mod.hashToPrivateScalar(rand, CURVE_ORDER); - return ut.numberToBytesBE(num, CURVE.nByteLength); - }, - /** - * Creates precompute table for an arbitrary EC point. Makes point "cached". - * Allows to massively speed-up `point.multiply(scalar)`. - * @returns cached point - * @example - * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); - * fast.multiply(privKey); // much faster ECDH now - */ - precompute(windowSize = 8, point = Point.BASE) { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here - return point; - }, - }; - /** - * Computes public key for a private key. Checks for validity of the private key. - * @param privateKey private key - * @param isCompressed whether to return compact (default), or full key - * @returns Public key, full when isCompressed=false; short when isCompressed=true - */ - function getPublicKey(privateKey, isCompressed = true) { - return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed); - } - /** - * Quick and dirty check for item being public key. Does not validate hex, or being on-curve. - */ - function isProbPub(item) { - const arr = item instanceof Uint8Array; - const str = typeof item === 'string'; - const len = (arr || str) && item.length; - if (arr) - return len === compressedLen || len === uncompressedLen; - if (str) - return len === 2 * compressedLen || len === 2 * uncompressedLen; - if (item instanceof Point) - return true; - return false; - } - /** - * ECDH (Elliptic Curve Diffie Hellman). - * Computes shared public key from private key and public key. - * Checks: 1) private key validity 2) shared key is on-curve. - * Does NOT hash the result. - * @param privateA private key - * @param publicB different public key - * @param isCompressed whether to return compact (default), or full key - * @returns shared public key - */ - function getSharedSecret(privateA, publicB, isCompressed = true) { - if (isProbPub(privateA)) - throw new Error('first arg must be private key'); - if (!isProbPub(publicB)) - throw new Error('second arg must be public key'); - const b = Point.fromHex(publicB); // check for being on-curve - return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed); - } - // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets. - // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int. - // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same. - // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors - const bits2int = CURVE.bits2int || - function (bytes) { - // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m) - // for some cases, since bytes.length * 8 is not actual bitLength. - const num = ut.bytesToNumberBE(bytes); // check for == u8 done here - const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits - return delta > 0 ? num >> BigInt(delta) : num; - }; - const bits2int_modN = CURVE.bits2int_modN || - function (bytes) { - return modN(bits2int(bytes)); // can't use bytesToNumberBE here - }; - // NOTE: pads output with zero as per spec - const ORDER_MASK = ut.bitMask(CURVE.nBitLength); - /** - * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`. - */ - function int2octets(num) { - if (typeof num !== 'bigint') - throw new Error('bigint expected'); - if (!(_0n <= num && num < ORDER_MASK)) - throw new Error(`bigint expected < 2^${CURVE.nBitLength}`); - // works with order, can have different size than numToField! - return ut.numberToBytesBE(num, CURVE.nByteLength); - } - // Steps A, D of RFC6979 3.2 - // Creates RFC6979 seed; converts msg/privKey to numbers. - // Used only in sign, not in verify. - // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order, this will be wrong at least for P521. - // Also it can be bigger for P224 + SHA256 - function prepSig(msgHash, privateKey, opts = defaultSigOpts) { - if (['recovered', 'canonical'].some((k) => k in opts)) - throw new Error('sign() legacy options not supported'); - const { hash, randomBytes } = CURVE; - let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default - if (lowS == null) - lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash - msgHash = ensureBytes('msgHash', msgHash); - if (prehash) - msgHash = ensureBytes('prehashed msgHash', hash(msgHash)); - // We can't later call bits2octets, since nested bits2int is broken for curves - // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call. - // const bits2octets = (bits) => int2octets(bits2int_modN(bits)) - const h1int = bits2int_modN(msgHash); - const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint - const seedArgs = [int2octets(d), int2octets(h1int)]; - // extraEntropy. RFC6979 3.6: additional k' (optional). - if (ent != null) { - // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k') - const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is - seedArgs.push(ensureBytes('extraEntropy', e, Fp.BYTES)); // check for being of size BYTES - } - const seed = ut.concatBytes(...seedArgs); // Step D of RFC6979 3.2 - const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash! - // Converts signature params into point w r/s, checks result for validity. - function k2sig(kBytes) { - // RFC 6979 Section 3.2, step 3: k = bits2int(T) - const k = bits2int(kBytes); // Cannot use fields methods, since it is group element - if (!isWithinCurveOrder(k)) - return; // Important: all mod() calls here must be done over N - const ik = invN(k); // k^-1 mod n - const q = Point.BASE.multiply(k).toAffine(); // q = Gk - const r = modN(q.x); // r = q.x mod n - if (r === _0n) - return; - // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to - // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it: - // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT - const s = modN(ik * modN(m + r * d)); // Not using blinding here - if (s === _0n) - return; - let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n) - let normS = s; - if (lowS && isBiggerThanHalfOrder(s)) { - normS = normalizeS(s); // if lowS was passed, ensure s is always - recovery ^= 1; // // in the bottom half of N - } - return new Signature(r, normS, recovery); // use normS, not s - } - return { seed, k2sig }; - } - const defaultSigOpts = { lowS: CURVE.lowS, prehash: false }; - const defaultVerOpts = { lowS: CURVE.lowS, prehash: false }; - /** - * Signs message hash with a private key. - * ``` - * sign(m, d, k) where - * (x, y) = G × k - * r = x mod n - * s = (m + dr)/k mod n - * ``` - * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`. - * @param privKey private key - * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg. - * @returns signature with recovery param - */ - function sign(msgHash, privKey, opts = defaultSigOpts) { - const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2. - const C = CURVE; - const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac); - return drbg(seed, k2sig); // Steps B, C, D, E, F, G - } - // Enable precomputes. Slows down first publicKey computation by 20ms. - Point.BASE._setWindowSize(8); - // utils.precompute(8, ProjectivePoint.BASE) - /** - * Verifies a signature against message hash and public key. - * Rejects lowS signatures by default: to override, - * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf: - * - * ``` - * verify(r, s, h, P) where - * U1 = hs^-1 mod n - * U2 = rs^-1 mod n - * R = U1⋅G - U2⋅P - * mod(R.x, n) == r - * ``` - */ - function verify(signature, msgHash, publicKey, opts = defaultVerOpts) { - const sg = signature; - msgHash = ensureBytes('msgHash', msgHash); - publicKey = ensureBytes('publicKey', publicKey); - if ('strict' in opts) - throw new Error('options.strict was renamed to lowS'); - const { lowS, prehash } = opts; - let _sig = undefined; - let P; - try { - if (typeof sg === 'string' || sg instanceof Uint8Array) { - // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length). - // Since DER can also be 2*nByteLength bytes, we check for it first. - try { - _sig = Signature.fromDER(sg); - } - catch (derError) { - if (!(derError instanceof DER.Err)) - throw derError; - _sig = Signature.fromCompact(sg); - } - } - else if (typeof sg === 'object' && typeof sg.r === 'bigint' && typeof sg.s === 'bigint') { - const { r, s } = sg; - _sig = new Signature(r, s); - } - else { - throw new Error('PARSE'); - } - P = Point.fromHex(publicKey); - } - catch (error) { - if (error.message === 'PARSE') - throw new Error(`signature must be Signature instance, Uint8Array or hex string`); - return false; - } - if (lowS && _sig.hasHighS()) - return false; - if (prehash) - msgHash = CURVE.hash(msgHash); - const { r, s } = _sig; - const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element - const is = invN(s); // s^-1 - const u1 = modN(h * is); // u1 = hs^-1 mod n - const u2 = modN(r * is); // u2 = rs^-1 mod n - const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P - if (!R) - return false; - const v = modN(R.x); - return v === r; - } - return { - CURVE, - getPublicKey, - getSharedSecret, - sign, - verify, - ProjectivePoint: Point, - Signature, - utils, - }; -} -/** - * Implementation of the Shallue and van de Woestijne method for any weierstrass curve. - * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular. - * b = True and y = sqrt(u / v) if (u / v) is square in F, and - * b = False and y = sqrt(Z * (u / v)) otherwise. - * @param Fp - * @param Z - * @returns - */ -export function SWUFpSqrtRatio(Fp, Z) { - // Generic implementation - const q = Fp.ORDER; - let l = _0n; - for (let o = q - _1n; o % _2n === _0n; o /= _2n) - l += _1n; - const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1. - // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<. - // 2n ** c1 == 2n << (c1-1) - const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n); - const _2n_pow_c1 = _2n_pow_c1_1 * _2n; - const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic - const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic - const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic - const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic - const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2 - const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2) - let sqrtRatio = (u, v) => { - let tv1 = c6; // 1. tv1 = c6 - let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4 - let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2 - tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v - let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3 - tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3 - tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2 - tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v - tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u - let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2 - tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5 - let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1 - tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7 - tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR) - tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR) - // 17. for i in (c1, c1 - 1, ..., 2): - for (let i = c1; i > _1n; i--) { - let tv5 = i - _2n; // 18. tv5 = i - 2 - tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5 - let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5 - const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1 - tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1 - tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1 - tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1) - tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1) - } - return { isValid: isQR, value: tv3 }; - }; - if (Fp.ORDER % _4n === _3n) { - // sqrt_ratio_3mod4(u, v) - const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic - const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z) - sqrtRatio = (u, v) => { - let tv1 = Fp.sqr(v); // 1. tv1 = v^2 - const tv2 = Fp.mul(u, v); // 2. tv2 = u * v - tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2 - let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1 - y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2 - const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2 - const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v - const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u - let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR) - return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2 - }; - } - // No curves uses that - // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8 - return sqrtRatio; -} -/** - * From draft-irtf-cfrg-hash-to-curve-16 - */ -export function mapToCurveSimpleSWU(Fp, opts) { - mod.validateField(Fp); - if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z)) - throw new Error('mapToCurveSimpleSWU: invalid opts'); - const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z); - if (!Fp.isOdd) - throw new Error('Fp.isOdd is not implemented!'); - // Input: u, an element of F. - // Output: (x, y), a point on E. - return (u) => { - // prettier-ignore - let tv1, tv2, tv3, tv4, tv5, tv6, x, y; - tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1 - tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2 - tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1 - tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1 - tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3 - tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0) - tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4 - tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2 - tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2 - tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6 - tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5 - tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3 - tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4 - tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6 - tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5 - x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3 - const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6) - y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1 - y = Fp.mul(y, value); // 20. y = y * y1 - x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square) - y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square) - const e1 = Fp.isOdd(u) === Fp.isOdd(y); // 23. e1 = sgn0(u) == sgn0(y) - y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1) - x = Fp.div(x, tv4); // 25. x = x / tv4 - return { x, y }; - }; -} -//# sourceMappingURL=weierstrass.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js.map deleted file mode 100644 index 7d2bc4b7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weierstrass.js","sourceRoot":"","sources":["../../src/abstract/weierstrass.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4DAA4D;AAC5D,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAuB,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAA2B,IAAI,EAAc,aAAa,EAAe,MAAM,YAAY,CAAC;AAqFnG,SAAS,iBAAiB,CAAI,KAAyB;IACrD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,EAAE,CAAC,cAAc,CACf,IAAI,EACJ;QACE,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,OAAO;KACX,EACD;QACE,wBAAwB,EAAE,OAAO;QACjC,cAAc,EAAE,SAAS;QACzB,aAAa,EAAE,UAAU;QACzB,aAAa,EAAE,UAAU;QACzB,kBAAkB,EAAE,SAAS;QAC7B,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,UAAU;KACpB,CACF,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;SACtF;QACD,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC7B,OAAO,IAAI,CAAC,WAAW,KAAK,UAAU,EACtC;YACA,MAAM,IAAI,KAA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AAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,uCAAuC;QACvE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;QACzE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,4BAA4B;QAC3D,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,oBAAoB;QACxC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js deleted file mode 100644 index 41730442..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js +++ /dev/null @@ -1,1173 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// bls12-381 pairing-friendly Barreto-Lynn-Scott elliptic curve construction allows to: -// - Construct zk-SNARKs at the 128-bit security -// - Use threshold signatures, which allows a user to sign lots of messages with one signature and -// verify them swiftly in a batch, using Boneh-Lynn-Shacham signature scheme. -// -// The library uses G1 for public keys and G2 for signatures. Support for G1 signatures is planned. -// Compatible with Algorand, Chia, Dfinity, Ethereum, FIL, Zcash. Matches specs -// [pairing-curves-11](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-11), -// [bls-sigs-04](https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04), -// [hash-to-curve-12](https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-12). -// -// ### Summary -// 1. BLS Relies on Bilinear Pairing (expensive) -// 2. Private Keys: 32 bytes -// 3. Public Keys: 48 bytes: 381 bit affine x coordinate, encoded into 48 big-endian bytes. -// 4. Signatures: 96 bytes: two 381 bit integers (affine x coordinate), encoded into two 48 big-endian byte arrays. -// - The signature is a point on the G2 subgroup, which is defined over a finite field -// with elements twice as big as the G1 curve (G2 is over Fp2 rather than Fp. Fp2 is analogous to the complex numbers). -// 5. The 12 stands for the Embedding degree. -// -// ### Formulas -// - `P = pk x G` - public keys -// - `S = pk x H(m)` - signing -// - `e(P, H(m)) == e(G, S)` - verification using pairings -// - `e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si))` - signature aggregation -// Filecoin uses little endian byte arrays for private keys - -// so ensure to reverse byte order if you'll use it with FIL. -import { sha256 } from '@noble/hashes/sha256'; -import { randomBytes } from '@noble/hashes/utils'; -import { bls } from './abstract/bls.js'; -import * as mod from './abstract/modular.js'; -import { concatBytes as concatB, ensureBytes, numberToBytesBE, bytesToNumberBE, bitLen, bitSet, bitGet, bitMask, bytesToHex, } from './abstract/utils.js'; -// Types -import { mapToCurveSimpleSWU, } from './abstract/weierstrass.js'; -import { isogenyMap } from './abstract/hash-to-curve.js'; -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); -// prettier-ignore -const _8n = BigInt(8), _16n = BigInt(16); -// CURVE FIELDS -// Finite field over p. -const Fp_raw = BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab'); -const Fp = mod.Field(Fp_raw); -// Finite field over r. -// This particular field is not used anywhere in bls12-381, but it is still useful. -const Fr = mod.Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')); -const Fp2Add = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp.add(c0, r0), - c1: Fp.add(c1, r1), -}); -const Fp2Subtract = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp.sub(c0, r0), - c1: Fp.sub(c1, r1), -}); -const Fp2Multiply = ({ c0, c1 }, rhs) => { - if (typeof rhs === 'bigint') - return { c0: Fp.mul(c0, rhs), c1: Fp.mul(c1, rhs) }; - // (a+bi)(c+di) = (ac−bd) + (ad+bc)i - const { c0: r0, c1: r1 } = rhs; - let t1 = Fp.mul(c0, r0); // c0 * o0 - let t2 = Fp.mul(c1, r1); // c1 * o1 - // (T1 - T2) + ((c0 + c1) * (r0 + r1) - (T1 + T2))*i - const o0 = Fp.sub(t1, t2); - const o1 = Fp.sub(Fp.mul(Fp.add(c0, c1), Fp.add(r0, r1)), Fp.add(t1, t2)); - return { c0: o0, c1: o1 }; -}; -const Fp2Square = ({ c0, c1 }) => { - const a = Fp.add(c0, c1); - const b = Fp.sub(c0, c1); - const c = Fp.add(c0, c0); - return { c0: Fp.mul(a, b), c1: Fp.mul(c, c1) }; -}; -// G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), -// where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where -// G² - 1 -// h2q -// NOTE: ORDER was wrong! -const FP2_ORDER = Fp_raw * Fp_raw; -const Fp2 = { - ORDER: FP2_ORDER, - BITS: bitLen(FP2_ORDER), - BYTES: Math.ceil(bitLen(FP2_ORDER) / 8), - MASK: bitMask(bitLen(FP2_ORDER)), - ZERO: { c0: Fp.ZERO, c1: Fp.ZERO }, - ONE: { c0: Fp.ONE, c1: Fp.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => typeof c0 === 'bigint' && typeof c1 === 'bigint', - is0: ({ c0, c1 }) => Fp.is0(c0) && Fp.is0(c1), - eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp.eql(c0, r0) && Fp.eql(c1, r1), - neg: ({ c0, c1 }) => ({ c0: Fp.neg(c0), c1: Fp.neg(c1) }), - pow: (num, power) => mod.FpPow(Fp2, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp2, nums), - // Normalized - add: Fp2Add, - sub: Fp2Subtract, - mul: Fp2Multiply, - sqr: Fp2Square, - // NonNormalized stuff - addN: Fp2Add, - subN: Fp2Subtract, - mulN: Fp2Multiply, - sqrN: Fp2Square, - // Why inversion for bigint inside Fp instead of Fp2? it is even used in that context? - div: (lhs, rhs) => Fp2.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp2.inv(rhs)), - inv: ({ c0: a, c1: b }) => { - // We wish to find the multiplicative inverse of a nonzero - // element a + bu in Fp2. We leverage an identity - // - // (a + bu)(a - bu) = a² + b² - // - // which holds because u² = -1. This can be rewritten as - // - // (a + bu)(a - bu)/(a² + b²) = 1 - // - // because a² + b² = 0 has no nonzero solutions for (a, b). - // This gives that (a - bu)/(a² + b²) is the inverse - // of (a + bu). Importantly, this can be computing using - // only a single inversion in Fp. - const factor = Fp.inv(Fp.create(a * a + b * b)); - return { c0: Fp.mul(factor, Fp.create(a)), c1: Fp.mul(factor, Fp.create(-b)) }; - }, - sqrt: (num) => { - if (Fp2.eql(num, Fp2.ZERO)) - return Fp2.ZERO; // Algo doesn't handles this case - // TODO: Optimize this line. It's extremely slow. - // Speeding this up would boost aggregateSignatures. - // https://eprint.iacr.org/2012/685.pdf applicable? - // https://github.com/zkcrypto/bls12_381/blob/080eaa74ec0e394377caa1ba302c8c121df08b07/src/fp2.rs#L250 - // https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/src/exp2.c#L1 - // Inspired by https://github.com/dalek-cryptography/curve25519-dalek/blob/17698df9d4c834204f83a3574143abacb4fc81a5/src/field.rs#L99 - const candidateSqrt = Fp2.pow(num, (Fp2.ORDER + _8n) / _16n); - const check = Fp2.div(Fp2.sqr(candidateSqrt), num); // candidateSqrt.square().div(this); - const R = FP2_ROOTS_OF_UNITY; - const divisor = [R[0], R[2], R[4], R[6]].find((r) => Fp2.eql(r, check)); - if (!divisor) - throw new Error('No root'); - const index = R.indexOf(divisor); - const root = R[index / 2]; - if (!root) - throw new Error('Invalid root'); - const x1 = Fp2.div(candidateSqrt, root); - const x2 = Fp2.neg(x1); - const { re: re1, im: im1 } = Fp2.reim(x1); - const { re: re2, im: im2 } = Fp2.reim(x2); - if (im1 > im2 || (im1 === im2 && re1 > re2)) - return x1; - return x2; - }, - // Same as sgn0_fp2 in draft-irtf-cfrg-hash-to-curve-16 - isOdd: (x) => { - const { re: x0, im: x1 } = Fp2.reim(x); - const sign_0 = x0 % _2n; - const zero_0 = x0 === _0n; - const sign_1 = x1 % _2n; - return BigInt(sign_0 || (zero_0 && sign_1)) == _1n; - }, - // Bytes util - fromBytes(b) { - if (b.length !== Fp2.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { c0: Fp.fromBytes(b.subarray(0, Fp.BYTES)), c1: Fp.fromBytes(b.subarray(Fp.BYTES)) }; - }, - toBytes: ({ c0, c1 }) => concatB(Fp.toBytes(c0), Fp.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp.cmov(c0, r0, c), - c1: Fp.cmov(c1, r1, c), - }), - // Specific utils - // toString() { - // return `Fp2(${this.c0} + ${this.c1}×i)`; - // } - reim: ({ c0, c1 }) => ({ re: c0, im: c1 }), - // multiply by u + 1 - mulByNonresidue: ({ c0, c1 }) => ({ c0: Fp.sub(c0, c1), c1: Fp.add(c0, c1) }), - multiplyByB: ({ c0, c1 }) => { - let t0 = Fp.mul(c0, _4n); // 4 * c0 - let t1 = Fp.mul(c1, _4n); // 4 * c1 - // (T0-T1) + (T0+T1)*i - return { c0: Fp.sub(t0, t1), c1: Fp.add(t0, t1) }; - }, - fromBigTuple: (tuple) => { - if (tuple.length !== 2) - throw new Error('Invalid tuple'); - const fps = tuple.map((n) => Fp.create(n)); - return { c0: fps[0], c1: fps[1] }; - }, - frobeniusMap: ({ c0, c1 }, power) => ({ - c0, - c1: Fp.mul(c1, FP2_FROBENIUS_COEFFICIENTS[power % 2]), - }), -}; -// Finite extension field over irreducible polynominal. -// Fp(u) / (u² - β) where β = -1 -const FP2_FROBENIUS_COEFFICIENTS = [ - BigInt('0x1'), - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), -].map((item) => Fp.create(item)); -// For Fp2 roots of unity. -const rv1 = BigInt('0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'); -// const ev1 = -// BigInt('0x699be3b8c6870965e5bf892ad5d2cc7b0e85a117402dfd83b7f4a947e02d978498255a2aaec0ac627b5afbdf1bf1c90'); -// const ev2 = -// BigInt('0x8157cd83046453f5dd0972b6e3949e4288020b5b8a9cc99ca07e27089a2ce2436d965026adad3ef7baba37f2183e9b5'); -// const ev3 = -// BigInt('0xab1c2ffdd6c253ca155231eb3e71ba044fd562f6f72bc5bad5ec46a0b7a3b0247cf08ce6c6317f40edbc653a72dee17'); -// const ev4 = -// BigInt('0xaa404866706722864480885d68ad0ccac1967c7544b447873cc37e0181271e006df72162a3d3e0287bf597fbf7f8fc1'); -// Eighth roots of unity, used for computing square roots in Fp2. -// To verify or re-calculate: -// Array(8).fill(new Fp2([1n, 1n])).map((fp2, k) => fp2.pow(Fp2.ORDER * BigInt(k) / 8n)) -const FP2_ROOTS_OF_UNITY = [ - [_1n, _0n], - [rv1, -rv1], - [_0n, _1n], - [rv1, rv1], - [-_1n, _0n], - [-rv1, rv1], - [_0n, -_1n], - [-rv1, -rv1], -].map((pair) => Fp2.fromBigTuple(pair)); -const Fp6Add = ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => ({ - c0: Fp2.add(c0, r0), - c1: Fp2.add(c1, r1), - c2: Fp2.add(c2, r2), -}); -const Fp6Subtract = ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => ({ - c0: Fp2.sub(c0, r0), - c1: Fp2.sub(c1, r1), - c2: Fp2.sub(c2, r2), -}); -const Fp6Multiply = ({ c0, c1, c2 }, rhs) => { - if (typeof rhs === 'bigint') { - return { - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }; - } - const { c0: r0, c1: r1, c2: r2 } = rhs; - const t0 = Fp2.mul(c0, r0); // c0 * o0 - const t1 = Fp2.mul(c1, r1); // c1 * o1 - const t2 = Fp2.mul(c2, r2); // c2 * o2 - return { - // t0 + (c1 + c2) * (r1 * r2) - (T1 + T2) * (u + 1) - c0: Fp2.add(t0, Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), Fp2.add(r1, r2)), Fp2.add(t1, t2)))), - // (c0 + c1) * (r0 + r1) - (T0 + T1) + T2 * (u + 1) - c1: Fp2.add(Fp2.sub(Fp2.mul(Fp2.add(c0, c1), Fp2.add(r0, r1)), Fp2.add(t0, t1)), Fp2.mulByNonresidue(t2)), - // T1 + (c0 + c2) * (r0 + r2) - T0 + T2 - c2: Fp2.sub(Fp2.add(t1, Fp2.mul(Fp2.add(c0, c2), Fp2.add(r0, r2))), Fp2.add(t0, t2)), - }; -}; -const Fp6Square = ({ c0, c1, c2 }) => { - let t0 = Fp2.sqr(c0); // c0² - let t1 = Fp2.mul(Fp2.mul(c0, c1), _2n); // 2 * c0 * c1 - let t3 = Fp2.mul(Fp2.mul(c1, c2), _2n); // 2 * c1 * c2 - let t4 = Fp2.sqr(c2); // c2² - return { - c0: Fp2.add(Fp2.mulByNonresidue(t3), t0), - c1: Fp2.add(Fp2.mulByNonresidue(t4), t1), - // T1 + (c0 - c1 + c2)² + T3 - T0 - T4 - c2: Fp2.sub(Fp2.sub(Fp2.add(Fp2.add(t1, Fp2.sqr(Fp2.add(Fp2.sub(c0, c1), c2))), t3), t0), t4), - }; -}; -const Fp6 = { - ORDER: Fp2.ORDER, - BITS: 3 * Fp2.BITS, - BYTES: 3 * Fp2.BYTES, - MASK: bitMask(3 * Fp2.BITS), - ZERO: { c0: Fp2.ZERO, c1: Fp2.ZERO, c2: Fp2.ZERO }, - ONE: { c0: Fp2.ONE, c1: Fp2.ZERO, c2: Fp2.ZERO }, - create: (num) => num, - isValid: ({ c0, c1, c2 }) => Fp2.isValid(c0) && Fp2.isValid(c1) && Fp2.isValid(c2), - is0: ({ c0, c1, c2 }) => Fp2.is0(c0) && Fp2.is0(c1) && Fp2.is0(c2), - neg: ({ c0, c1, c2 }) => ({ c0: Fp2.neg(c0), c1: Fp2.neg(c1), c2: Fp2.neg(c2) }), - eql: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => Fp2.eql(c0, r0) && Fp2.eql(c1, r1) && Fp2.eql(c2, r2), - sqrt: () => { - throw new Error('Not implemented'); - }, - // Do we need division by bigint at all? Should be done via order: - div: (lhs, rhs) => Fp6.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp6.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp6, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp6, nums), - // Normalized - add: Fp6Add, - sub: Fp6Subtract, - mul: Fp6Multiply, - sqr: Fp6Square, - // NonNormalized stuff - addN: Fp6Add, - subN: Fp6Subtract, - mulN: Fp6Multiply, - sqrN: Fp6Square, - inv: ({ c0, c1, c2 }) => { - let t0 = Fp2.sub(Fp2.sqr(c0), Fp2.mulByNonresidue(Fp2.mul(c2, c1))); // c0² - c2 * c1 * (u + 1) - let t1 = Fp2.sub(Fp2.mulByNonresidue(Fp2.sqr(c2)), Fp2.mul(c0, c1)); // c2² * (u + 1) - c0 * c1 - let t2 = Fp2.sub(Fp2.sqr(c1), Fp2.mul(c0, c2)); // c1² - c0 * c2 - // 1/(((c2 * T1 + c1 * T2) * v) + c0 * T0) - let t4 = Fp2.inv(Fp2.add(Fp2.mulByNonresidue(Fp2.add(Fp2.mul(c2, t1), Fp2.mul(c1, t2))), Fp2.mul(c0, t0))); - return { c0: Fp2.mul(t4, t0), c1: Fp2.mul(t4, t1), c2: Fp2.mul(t4, t2) }; - }, - // Bytes utils - fromBytes: (b) => { - if (b.length !== Fp6.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp2.fromBytes(b.subarray(0, Fp2.BYTES)), - c1: Fp2.fromBytes(b.subarray(Fp2.BYTES, 2 * Fp2.BYTES)), - c2: Fp2.fromBytes(b.subarray(2 * Fp2.BYTES)), - }; - }, - toBytes: ({ c0, c1, c2 }) => concatB(Fp2.toBytes(c0), Fp2.toBytes(c1), Fp2.toBytes(c2)), - cmov: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }, c) => ({ - c0: Fp2.cmov(c0, r0, c), - c1: Fp2.cmov(c1, r1, c), - c2: Fp2.cmov(c2, r2, c), - }), - // Utils - // fromTriple(triple: [Fp2, Fp2, Fp2]) { - // return new Fp6(...triple); - // } - // toString() { - // return `Fp6(${this.c0} + ${this.c1} * v, ${this.c2} * v^2)`; - // } - fromBigSix: (t) => { - if (!Array.isArray(t) || t.length !== 6) - throw new Error('Invalid Fp6 usage'); - return { - c0: Fp2.fromBigTuple(t.slice(0, 2)), - c1: Fp2.fromBigTuple(t.slice(2, 4)), - c2: Fp2.fromBigTuple(t.slice(4, 6)), - }; - }, - frobeniusMap: ({ c0, c1, c2 }, power) => ({ - c0: Fp2.frobeniusMap(c0, power), - c1: Fp2.mul(Fp2.frobeniusMap(c1, power), FP6_FROBENIUS_COEFFICIENTS_1[power % 6]), - c2: Fp2.mul(Fp2.frobeniusMap(c2, power), FP6_FROBENIUS_COEFFICIENTS_2[power % 6]), - }), - mulByNonresidue: ({ c0, c1, c2 }) => ({ c0: Fp2.mulByNonresidue(c2), c1: c0, c2: c1 }), - // Sparse multiplication - multiplyBy1: ({ c0, c1, c2 }, b1) => ({ - c0: Fp2.mulByNonresidue(Fp2.mul(c2, b1)), - c1: Fp2.mul(c0, b1), - c2: Fp2.mul(c1, b1), - }), - // Sparse multiplication - multiplyBy01({ c0, c1, c2 }, b0, b1) { - let t0 = Fp2.mul(c0, b0); // c0 * b0 - let t1 = Fp2.mul(c1, b1); // c1 * b1 - return { - // ((c1 + c2) * b1 - T1) * (u + 1) + T0 - c0: Fp2.add(Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), b1), t1)), t0), - // (b0 + b1) * (c0 + c1) - T0 - T1 - c1: Fp2.sub(Fp2.sub(Fp2.mul(Fp2.add(b0, b1), Fp2.add(c0, c1)), t0), t1), - // (c0 + c2) * b0 - T0 + T1 - c2: Fp2.add(Fp2.sub(Fp2.mul(Fp2.add(c0, c2), b0), t0), t1), - }; - }, - multiplyByFp2: ({ c0, c1, c2 }, rhs) => ({ - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }), -}; -const FP6_FROBENIUS_COEFFICIENTS_1 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x0'), - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [BigInt('0x0'), BigInt('0x1')], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x0'), - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - ], -].map((pair) => Fp2.fromBigTuple(pair)); -const FP6_FROBENIUS_COEFFICIENTS_2 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - BigInt('0x0'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - BigInt('0x0'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - BigInt('0x0'), - ], -].map((pair) => Fp2.fromBigTuple(pair)); -// The BLS parameter x for BLS12-381 -const BLS_X = BigInt('0xd201000000010000'); -const BLS_X_LEN = bitLen(BLS_X); -const Fp12Add = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp6.add(c0, r0), - c1: Fp6.add(c1, r1), -}); -const Fp12Subtract = ({ c0, c1 }, { c0: r0, c1: r1 }) => ({ - c0: Fp6.sub(c0, r0), - c1: Fp6.sub(c1, r1), -}); -const Fp12Multiply = ({ c0, c1 }, rhs) => { - if (typeof rhs === 'bigint') - return { c0: Fp6.mul(c0, rhs), c1: Fp6.mul(c1, rhs) }; - let { c0: r0, c1: r1 } = rhs; - let t1 = Fp6.mul(c0, r0); // c0 * r0 - let t2 = Fp6.mul(c1, r1); // c1 * r1 - return { - c0: Fp6.add(t1, Fp6.mulByNonresidue(t2)), - // (c0 + c1) * (r0 + r1) - (T1 + T2) - c1: Fp6.sub(Fp6.mul(Fp6.add(c0, c1), Fp6.add(r0, r1)), Fp6.add(t1, t2)), - }; -}; -const Fp12Square = ({ c0, c1 }) => { - let ab = Fp6.mul(c0, c1); // c0 * c1 - return { - // (c1 * v + c0) * (c0 + c1) - AB - AB * v - c0: Fp6.sub(Fp6.sub(Fp6.mul(Fp6.add(Fp6.mulByNonresidue(c1), c0), Fp6.add(c0, c1)), ab), Fp6.mulByNonresidue(ab)), - c1: Fp6.add(ab, ab), - }; // AB + AB -}; -function Fp4Square(a, b) { - const a2 = Fp2.sqr(a); - const b2 = Fp2.sqr(b); - return { - first: Fp2.add(Fp2.mulByNonresidue(b2), a2), - second: Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(a, b)), a2), b2), // (a + b)² - a² - b² - }; -} -const Fp12 = { - ORDER: Fp2.ORDER, - BITS: 2 * Fp2.BITS, - BYTES: 2 * Fp2.BYTES, - MASK: bitMask(2 * Fp2.BITS), - ZERO: { c0: Fp6.ZERO, c1: Fp6.ZERO }, - ONE: { c0: Fp6.ONE, c1: Fp6.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => Fp6.isValid(c0) && Fp6.isValid(c1), - is0: ({ c0, c1 }) => Fp6.is0(c0) && Fp6.is0(c1), - neg: ({ c0, c1 }) => ({ c0: Fp6.neg(c0), c1: Fp6.neg(c1) }), - eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp6.eql(c0, r0) && Fp6.eql(c1, r1), - sqrt: () => { - throw new Error('Not implemented'); - }, - inv: ({ c0, c1 }) => { - let t = Fp6.inv(Fp6.sub(Fp6.sqr(c0), Fp6.mulByNonresidue(Fp6.sqr(c1)))); // 1 / (c0² - c1² * v) - return { c0: Fp6.mul(c0, t), c1: Fp6.neg(Fp6.mul(c1, t)) }; // ((C0 * T) * T) + (-C1 * T) * w - }, - div: (lhs, rhs) => Fp12.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp12.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp12, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp12, nums), - // Normalized - add: Fp12Add, - sub: Fp12Subtract, - mul: Fp12Multiply, - sqr: Fp12Square, - // NonNormalized stuff - addN: Fp12Add, - subN: Fp12Subtract, - mulN: Fp12Multiply, - sqrN: Fp12Square, - // Bytes utils - fromBytes: (b) => { - if (b.length !== Fp12.BYTES) - throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp6.fromBytes(b.subarray(0, Fp6.BYTES)), - c1: Fp6.fromBytes(b.subarray(Fp6.BYTES)), - }; - }, - toBytes: ({ c0, c1 }) => concatB(Fp6.toBytes(c0), Fp6.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp6.cmov(c0, r0, c), - c1: Fp6.cmov(c1, r1, c), - }), - // Utils - // toString() { - // return `Fp12(${this.c0} + ${this.c1} * w)`; - // }, - // fromTuple(c: [Fp6, Fp6]) { - // return new Fp12(...c); - // } - fromBigTwelve: (t) => ({ - c0: Fp6.fromBigSix(t.slice(0, 6)), - c1: Fp6.fromBigSix(t.slice(6, 12)), - }), - // Raises to q**i -th power - frobeniusMap(lhs, power) { - const r0 = Fp6.frobeniusMap(lhs.c0, power); - const { c0, c1, c2 } = Fp6.frobeniusMap(lhs.c1, power); - const coeff = FP12_FROBENIUS_COEFFICIENTS[power % 12]; - return { - c0: r0, - c1: Fp6.create({ - c0: Fp2.mul(c0, coeff), - c1: Fp2.mul(c1, coeff), - c2: Fp2.mul(c2, coeff), - }), - }; - }, - // Sparse multiplication - multiplyBy014: ({ c0, c1 }, o0, o1, o4) => { - let t0 = Fp6.multiplyBy01(c0, o0, o1); - let t1 = Fp6.multiplyBy1(c1, o4); - return { - c0: Fp6.add(Fp6.mulByNonresidue(t1), t0), - // (c1 + c0) * [o0, o1+o4] - T0 - T1 - c1: Fp6.sub(Fp6.sub(Fp6.multiplyBy01(Fp6.add(c1, c0), o0, Fp2.add(o1, o4)), t0), t1), - }; - }, - multiplyByFp2: ({ c0, c1 }, rhs) => ({ - c0: Fp6.multiplyByFp2(c0, rhs), - c1: Fp6.multiplyByFp2(c1, rhs), - }), - conjugate: ({ c0, c1 }) => ({ c0, c1: Fp6.neg(c1) }), - // A cyclotomic group is a subgroup of Fp^n defined by - // GΦₙ(p) = {α ∈ Fpⁿ : α^Φₙ(p) = 1} - // The result of any pairing is in a cyclotomic subgroup - // https://eprint.iacr.org/2009/565.pdf - _cyclotomicSquare: ({ c0, c1 }) => { - const { c0: c0c0, c1: c0c1, c2: c0c2 } = c0; - const { c0: c1c0, c1: c1c1, c2: c1c2 } = c1; - const { first: t3, second: t4 } = Fp4Square(c0c0, c1c1); - const { first: t5, second: t6 } = Fp4Square(c1c0, c0c2); - const { first: t7, second: t8 } = Fp4Square(c0c1, c1c2); - let t9 = Fp2.mulByNonresidue(t8); // T8 * (u + 1) - return { - c0: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.sub(t3, c0c0), _2n), t3), - c1: Fp2.add(Fp2.mul(Fp2.sub(t5, c0c1), _2n), t5), - c2: Fp2.add(Fp2.mul(Fp2.sub(t7, c0c2), _2n), t7), - }), - c1: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.add(t9, c1c0), _2n), t9), - c1: Fp2.add(Fp2.mul(Fp2.add(t4, c1c1), _2n), t4), - c2: Fp2.add(Fp2.mul(Fp2.add(t6, c1c2), _2n), t6), - }), - }; // 2 * (T6 + c1c2) + T6 - }, - _cyclotomicExp(num, n) { - let z = Fp12.ONE; - for (let i = BLS_X_LEN - 1; i >= 0; i--) { - z = Fp12._cyclotomicSquare(z); - if (bitGet(n, i)) - z = Fp12.mul(z, num); - } - return z; - }, - // https://eprint.iacr.org/2010/354.pdf - // https://eprint.iacr.org/2009/565.pdf - finalExponentiate: (num) => { - const x = BLS_X; - // this^(q⁶) / this - const t0 = Fp12.div(Fp12.frobeniusMap(num, 6), num); - // t0^(q²) * t0 - const t1 = Fp12.mul(Fp12.frobeniusMap(t0, 2), t0); - const t2 = Fp12.conjugate(Fp12._cyclotomicExp(t1, x)); - const t3 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicSquare(t1)), t2); - const t4 = Fp12.conjugate(Fp12._cyclotomicExp(t3, x)); - const t5 = Fp12.conjugate(Fp12._cyclotomicExp(t4, x)); - const t6 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicExp(t5, x)), Fp12._cyclotomicSquare(t2)); - const t7 = Fp12.conjugate(Fp12._cyclotomicExp(t6, x)); - const t2_t5_pow_q2 = Fp12.frobeniusMap(Fp12.mul(t2, t5), 2); - const t4_t1_pow_q3 = Fp12.frobeniusMap(Fp12.mul(t4, t1), 3); - const t6_t1c_pow_q1 = Fp12.frobeniusMap(Fp12.mul(t6, Fp12.conjugate(t1)), 1); - const t7_t3c_t1 = Fp12.mul(Fp12.mul(t7, Fp12.conjugate(t3)), t1); - // (t2 * t5)^(q²) * (t4 * t1)^(q³) * (t6 * t1.conj)^(q^1) * t7 * t3.conj * t1 - return Fp12.mul(Fp12.mul(Fp12.mul(t2_t5_pow_q2, t4_t1_pow_q3), t6_t1c_pow_q1), t7_t3c_t1); - }, -}; -const FP12_FROBENIUS_COEFFICIENTS = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8'), - BigInt('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - BigInt('0x0'), - ], - [ - BigInt('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2'), - BigInt('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'), - ], - [ - BigInt('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - BigInt('0x0'), - ], - [ - BigInt('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995'), - BigInt('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116'), - ], - [ - BigInt('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - BigInt('0x0'), - ], - [ - BigInt('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3'), - BigInt('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - BigInt('0x0'), - ], - [ - BigInt('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'), - BigInt('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2'), - ], - [ - BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - BigInt('0x0'), - ], - [ - BigInt('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116'), - BigInt('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995'), - ], -].map((n) => Fp2.fromBigTuple(n)); -// END OF CURVE FIELDS -// HashToCurve -// 3-isogeny map from E' to E -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#appendix-E.3 -const isogenyMapG2 = isogenyMap(Fp2, [ - // xNum - [ - [ - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - ], - [ - '0x0', - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d', - ], - [ - '0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1', - '0x0', - ], - ], - // xDen - [ - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63', - ], - [ - '0xc', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f', - ], - ['0x1', '0x0'], // LAST 1 - ], - // yNum - [ - [ - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - ], - [ - '0x0', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f', - ], - [ - '0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10', - '0x0', - ], - ], - // yDen - [ - [ - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - ], - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3', - ], - [ - '0x12', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99', - ], - ['0x1', '0x0'], // LAST 1 - ], -].map((i) => i.map((pair) => Fp2.fromBigTuple(pair.map(BigInt))))); -// 11-isogeny map from E' to E -const isogenyMapG1 = isogenyMap(Fp, [ - // xNum - [ - '0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7', - '0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb', - '0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0', - '0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861', - '0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9', - '0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983', - '0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84', - '0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e', - '0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317', - '0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e', - '0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b', - '0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229', - ], - // xDen - [ - '0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c', - '0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff', - '0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19', - '0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8', - '0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e', - '0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5', - '0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a', - '0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e', - '0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641', - '0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33', - '0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696', - '0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6', - '0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb', - '0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb', - '0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0', - '0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2', - '0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29', - '0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587', - '0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30', - '0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132', - '0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e', - '0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8', - '0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133', - '0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b', - '0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604', - ], - // yDen - [ - '0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1', - '0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d', - '0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2', - '0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416', - '0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d', - '0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac', - '0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c', - '0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9', - '0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a', - '0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55', - '0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8', - '0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092', - '0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc', - '0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7', - '0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], -].map((i) => i.map((j) => BigInt(j)))); -// SWU Map - Fp2 to G2': y² = x³ + 240i * x + 1012 + 1012i -const G2_SWU = mapToCurveSimpleSWU(Fp2, { - A: Fp2.create({ c0: Fp.create(_0n), c1: Fp.create(BigInt(240)) }), - B: Fp2.create({ c0: Fp.create(BigInt(1012)), c1: Fp.create(BigInt(1012)) }), - Z: Fp2.create({ c0: Fp.create(BigInt(-2)), c1: Fp.create(BigInt(-1)) }), // Z: -(2 + I) -}); -// Optimized SWU Map - Fp to G1 -const G1_SWU = mapToCurveSimpleSWU(Fp, { - A: Fp.create(BigInt('0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d')), - B: Fp.create(BigInt('0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0')), - Z: Fp.create(BigInt(11)), -}); -// Endomorphisms (for fast cofactor clearing) -// Ψ(P) endomorphism -const ut_root = Fp6.create({ c0: Fp2.ZERO, c1: Fp2.ONE, c2: Fp2.ZERO }); -const wsq = Fp12.create({ c0: ut_root, c1: Fp6.ZERO }); -const wcu = Fp12.create({ c0: Fp6.ZERO, c1: ut_root }); -const [wsq_inv, wcu_inv] = Fp12.invertBatch([wsq, wcu]); -function psi(x, y) { - // Untwist Fp2->Fp12 && frobenius(1) && twist back - const x2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wsq_inv, x), 1), wsq).c0.c0; - const y2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wcu_inv, y), 1), wcu).c0.c0; - return [x2, y2]; -} -// Ψ endomorphism -function G2psi(c, P) { - const affine = P.toAffine(); - const p = psi(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} -// Ψ²(P) endomorphism -// 1 / F2(2)^((p-1)/3) in GF(p²) -const PSI2_C1 = BigInt('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'); -function psi2(x, y) { - return [Fp2.mul(x, PSI2_C1), Fp2.neg(y)]; -} -function G2psi2(c, P) { - const affine = P.toAffine(); - const p = psi2(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} -// Default hash_to_field options are for hash to G2. -// -// Parameter definitions are in section 5.3 of the spec unless otherwise noted. -// Parameter values come from section 8.8.2 of the spec. -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-8.8.2 -// -// Base field F is GF(p^m) -// p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab -// m = 2 (or 1 for G1 see section 8.8.1) -// k = 128 -const htfDefaults = Object.freeze({ - // DST: a domain separation tag - // defined in section 2.2.5 - // Use utils.getDSTLabel(), utils.setDSTLabel(value) - DST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - encodeDST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - // p: the characteristic of F - // where F is a finite field of characteristic p and order q = p^m - p: Fp.ORDER, - // m: the extension degree of F, m >= 1 - // where F is a finite field of characteristic p and order q = p^m - m: 2, - // k: the target security level for the suite in bits - // defined in section 5.1 - k: 128, - // option to use a message that has already been processed by - // expand_message_xmd - expand: 'xmd', - // Hash functions for: expand_message_xmd is appropriate for use with a - // wide range of hash functions, including SHA-2, SHA-3, BLAKE2, and others. - // BBS+ uses blake2: https://github.com/hyperledger/aries-framework-go/issues/2247 - hash: sha256, -}); -// Encoding utils -// Point on G1 curve: (x, y) -const C_BIT_POS = Fp.BITS; // C_bit, compression bit for serialization flag -const I_BIT_POS = Fp.BITS + 1; // I_bit, point-at-infinity bit for serialization flag -const S_BIT_POS = Fp.BITS + 2; // S_bit, sign bit for serialization flag -// Compressed point of infinity -const COMPRESSED_ZERO = Fp.toBytes(bitSet(bitSet(_0n, I_BIT_POS, true), S_BIT_POS, true)); // set compressed & point-at-infinity bits -function signatureG2ToRawBytes(point) { - // NOTE: by some reasons it was missed in bls12-381, looks like bug - point.assertValidity(); - const len = Fp.BYTES; - if (point.equals(bls12_381.G2.ProjectivePoint.ZERO)) - return concatB(COMPRESSED_ZERO, numberToBytesBE(_0n, len)); - const { x, y } = point.toAffine(); - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - const tmp = y1 > _0n ? y1 * _2n : y0 * _2n; - const aflag1 = Boolean((tmp / Fp.ORDER) & _1n); - const z1 = bitSet(bitSet(x1, 381, aflag1), S_BIT_POS, true); - const z2 = x0; - return concatB(numberToBytesBE(z1, len), numberToBytesBE(z2, len)); -} -// To verify curve parameters, see pairing-friendly-curves spec: -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-pairing-friendly-curves-09 -// Basic math is done over finite fields over p. -// More complicated math is done over polynominal extension fields. -// To simplify calculations in Fp12, we construct extension tower: -// Fp₁₂ = Fp₆² => Fp₂³ -// Fp(u) / (u² - β) where β = -1 -// Fp₂(v) / (v³ - ξ) where ξ = u + 1 -// Fp₆(w) / (w² - γ) where γ = v -// Here goes constants && point encoding format -export const bls12_381 = bls({ - // Fields - fields: { - Fp, - Fp2, - Fp6, - Fp12, - Fr, - }, - // G1 is the order-q subgroup of E1(Fp) : y² = x³ + 4, #E1(Fp) = h1q, where - // characteristic; z + (z⁴ - z² + 1)(z - 1)²/3 - G1: { - Fp, - // cofactor; (z - 1)²/3 - h: BigInt('0x396c8c005555e1568c00aaab0000aaab'), - // generator's coordinates - // x = 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507 - // y = 1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569 - Gx: BigInt('0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb'), - Gy: BigInt('0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1'), - a: Fp.ZERO, - b: _4n, - htfDefaults: { ...htfDefaults, m: 1 }, - wrapPrivateKey: true, - allowInfinityPoint: true, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, point) => { - // φ endomorphism - const cubicRootOfUnityModP = BigInt('0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'); - const phi = new c(Fp.mul(point.px, cubicRootOfUnityModP), point.py, point.pz); - // todo: unroll - const xP = point.multiplyUnsafe(bls12_381.params.x).negate(); // [x]P - const u2P = xP.multiplyUnsafe(bls12_381.params.x); // [u2]P - return u2P.equals(phi); - // https://eprint.iacr.org/2019/814.pdf - // (z² − 1)/3 - // const c1 = BigInt('0x396c8c005555e1560000000055555555'); - // const P = this; - // const S = P.sigma(); - // const Q = S.double(); - // const S2 = S.sigma(); - // // [(z² − 1)/3](2σ(P) − P − σ²(P)) − σ²(P) = O - // const left = Q.subtract(P).subtract(S2).multiplyUnsafe(c1); - // const C = left.subtract(S2); - // return C.isZero(); - }, - // Clear cofactor of G1 - // https://eprint.iacr.org/2019/403 - clearCofactor: (c, point) => { - // return this.multiplyUnsafe(CURVE.h); - return point.multiplyUnsafe(bls12_381.params.x).add(point); // x*P + P - }, - mapToCurve: (scalars) => { - const { x, y } = G1_SWU(Fp.create(scalars[0])); - return isogenyMapG1(x, y); - }, - fromBytes: (bytes) => { - bytes = bytes.slice(); - if (bytes.length === 48) { - // TODO: Fp.bytes - const P = Fp.ORDER; - const compressedValue = bytesToNumberBE(bytes); - const bflag = bitGet(compressedValue, I_BIT_POS); - // Zero - if (bflag === _1n) - return { x: _0n, y: _0n }; - const x = Fp.create(compressedValue & Fp.MASK); - const right = Fp.add(Fp.pow(x, _3n), Fp.create(bls12_381.params.G1b)); // y² = x³ + b - let y = Fp.sqrt(right); - if (!y) - throw new Error('Invalid compressed G1 point'); - const aflag = bitGet(compressedValue, C_BIT_POS); - if ((y * _2n) / P !== aflag) - y = Fp.neg(y); - return { x: Fp.create(x), y: Fp.create(y) }; - } - else if (bytes.length === 96) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) - return bls12_381.G1.ProjectivePoint.ZERO.toAffine(); - const x = bytesToNumberBE(bytes.subarray(0, Fp.BYTES)); - const y = bytesToNumberBE(bytes.subarray(Fp.BYTES)); - return { x: Fp.create(x), y: Fp.create(y) }; - } - else { - throw new Error('Invalid point G1, expected 48/96 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) - return COMPRESSED_ZERO.slice(); - const P = Fp.ORDER; - let num; - num = bitSet(x, C_BIT_POS, Boolean((y * _2n) / P)); // set aflag - num = bitSet(num, S_BIT_POS, true); - return numberToBytesBE(num, Fp.BYTES); - } - else { - if (isZero) { - // 2x PUBLIC_KEY_LENGTH - const x = concatB(new Uint8Array([0x40]), new Uint8Array(2 * Fp.BYTES - 1)); - return x; - } - else { - return concatB(numberToBytesBE(x, Fp.BYTES), numberToBytesBE(y, Fp.BYTES)); - } - } - }, - }, - // G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), - // where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where - // G² - 1 - // h2q - G2: { - Fp: Fp2, - // cofactor - h: BigInt('0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5'), - Gx: Fp2.fromBigTuple([ - BigInt('0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8'), - BigInt('0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e'), - ]), - // y = - // 927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582, - // 1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905 - Gy: Fp2.fromBigTuple([ - BigInt('0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801'), - BigInt('0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be'), - ]), - a: Fp2.ZERO, - b: Fp2.fromBigTuple([_4n, _4n]), - hEff: BigInt('0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551'), - htfDefaults: { ...htfDefaults }, - wrapPrivateKey: true, - allowInfinityPoint: true, - mapToCurve: (scalars) => { - const { x, y } = G2_SWU(Fp2.fromBigTuple(scalars)); - return isogenyMapG2(x, y); - }, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, P) => { - return P.multiplyUnsafe(bls12_381.params.x).negate().equals(G2psi(c, P)); // ψ(P) == [u](P) - // Older version: https://eprint.iacr.org/2019/814.pdf - // Ψ²(P) => Ψ³(P) => [z]Ψ³(P) where z = -x => [z]Ψ³(P) - Ψ²(P) + P == O - // return P.psi2().psi().mulNegX().subtract(psi2).add(P).isZero(); - }, - // Maps the point into the prime-order subgroup G2. - // clear_cofactor_bls12381_g2 from cfrg-hash-to-curve-11 - // https://eprint.iacr.org/2017/419.pdf - // prettier-ignore - clearCofactor: (c, P) => { - const x = bls12_381.params.x; - let t1 = P.multiplyUnsafe(x).negate(); // [-x]P - let t2 = G2psi(c, P); // Ψ(P) - let t3 = P.double(); // 2P - t3 = G2psi2(c, t3); // Ψ²(2P) - t3 = t3.subtract(t2); // Ψ²(2P) - Ψ(P) - t2 = t1.add(t2); // [-x]P + Ψ(P) - t2 = t2.multiplyUnsafe(x).negate(); // [x²]P - [x]Ψ(P) - t3 = t3.add(t2); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) - t3 = t3.subtract(t1); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - const Q = t3.subtract(P); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - 1P - return Q; // [x²-x-1]P + [x-1]Ψ(P) + Ψ²(2P) - }, - fromBytes: (bytes) => { - bytes = bytes.slice(); - const m_byte = bytes[0] & 0xe0; - if (m_byte === 0x20 || m_byte === 0x60 || m_byte === 0xe0) { - throw new Error('Invalid encoding flag: ' + m_byte); - } - const bitC = m_byte & 0x80; // compression bit - const bitI = m_byte & 0x40; // point at infinity bit - const bitS = m_byte & 0x20; // sign bit - const L = Fp.BYTES; - const slc = (b, from, to) => bytesToNumberBE(b.slice(from, to)); - if (bytes.length === 96 && bitC) { - const b = bls12_381.params.G2b; - const P = Fp.ORDER; - bytes[0] = bytes[0] & 0x1f; // clear flags - if (bitI) { - // check that all bytes are 0 - if (bytes.reduce((p, c) => (p !== 0 ? c + 1 : c), 0) > 0) { - throw new Error('Invalid compressed G2 point'); - } - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x_1 = slc(bytes, 0, L); - const x_0 = slc(bytes, L, 2 * L); - const x = Fp2.create({ c0: Fp.create(x_0), c1: Fp.create(x_1) }); - const right = Fp2.add(Fp2.pow(x, _3n), b); // y² = x³ + 4 * (u+1) = x³ + b - let y = Fp2.sqrt(right); - const Y_bit = y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P ? _1n : _0n; - y = bitS > 0 && Y_bit > 0 ? y : Fp2.neg(y); - return { x, y }; - } - else if (bytes.length === 192 && !bitC) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) { - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x1 = slc(bytes, 0, L); - const x0 = slc(bytes, L, 2 * L); - const y1 = slc(bytes, 2 * L, 3 * L); - const y0 = slc(bytes, 3 * L, 4 * L); - return { x: Fp2.fromBigTuple([x0, x1]), y: Fp2.fromBigTuple([y0, y1]) }; - } - else { - throw new Error('Invalid point G2, expected 96/192 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const { BYTES: len, ORDER: P } = Fp; - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) - return concatB(COMPRESSED_ZERO, numberToBytesBE(_0n, len)); - const flag = Boolean(y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P); - // set compressed & sign bits (looks like different offsets than for G1/Fp?) - let x_1 = bitSet(x.c1, C_BIT_POS, flag); - x_1 = bitSet(x_1, S_BIT_POS, true); - return concatB(numberToBytesBE(x_1, len), numberToBytesBE(x.c0, len)); - } - else { - if (isZero) - return concatB(new Uint8Array([0x40]), new Uint8Array(4 * len - 1)); // bytes[0] |= 1 << 6; - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - return concatB(numberToBytesBE(x1, len), numberToBytesBE(x0, len), numberToBytesBE(y1, len), numberToBytesBE(y0, len)); - } - }, - Signature: { - // TODO: Optimize, it's very slow because of sqrt. - fromHex(hex) { - hex = ensureBytes('signatureHex', hex); - const P = Fp.ORDER; - const half = hex.length / 2; - if (half !== 48 && half !== 96) - throw new Error('Invalid compressed signature length, must be 96 or 192'); - const z1 = bytesToNumberBE(hex.slice(0, half)); - const z2 = bytesToNumberBE(hex.slice(half)); - // Indicates the infinity point - const bflag1 = bitGet(z1, I_BIT_POS); - if (bflag1 === _1n) - return bls12_381.G2.ProjectivePoint.ZERO; - const x1 = Fp.create(z1 & Fp.MASK); - const x2 = Fp.create(z2); - const x = Fp2.create({ c0: x2, c1: x1 }); - const y2 = Fp2.add(Fp2.pow(x, _3n), bls12_381.params.G2b); // y² = x³ + 4 - // The slow part - let y = Fp2.sqrt(y2); - if (!y) - throw new Error('Failed to find a square root'); - // Choose the y whose leftmost bit of the imaginary part is equal to the a_flag1 - // If y1 happens to be zero, then use the bit of y0 - const { re: y0, im: y1 } = Fp2.reim(y); - const aflag1 = bitGet(z1, 381); - const isGreater = y1 > _0n && (y1 * _2n) / P !== aflag1; - const isZero = y1 === _0n && (y0 * _2n) / P !== aflag1; - if (isGreater || isZero) - y = Fp2.neg(y); - const point = bls12_381.G2.ProjectivePoint.fromAffine({ x, y }); - point.assertValidity(); - return point; - }, - toRawBytes(point) { - return signatureG2ToRawBytes(point); - }, - toHex(point) { - return bytesToHex(signatureG2ToRawBytes(point)); - }, - }, - }, - params: { - x: BLS_X, - r: Fr.ORDER, // order; z⁴ − z² + 1; CURVE.n from other curves - }, - htfDefaults, - hash: sha256, - randomBytes, -}); -//# sourceMappingURL=bls12-381.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js.map deleted file mode 100644 index 09f0c124..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bls12-381.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bls12-381.js","sourceRoot":"","sources":["../src/bls12-381.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,uFAAuF;AACvF,gDAAgD;AAChD,kGAAkG;AAClG,+EAA+E;AAC/E,EAAE;AACF,mGAAmG;AACnG,+EAA+E;AAC/E,+FAA+F;AAC/F,+EAA+E;AAC/E,oFAAoF;AACpF,EAAE;AACF,cAAc;AACd,gDAAgD;AAChD,4BAA4B;AAC5B,2FAA2F;AAC3F,mHAAmH;AACnH,0FAA0F;AAC1F,2HAA2H;AAC3H,6CAA6C;AAC7C,EAAE;AACF,eAAe;AACf,+BAA+B;AAC/B,8BAA8B;AAC9B,0DAA0D;AAC1D,4EAA4E;AAC5E,6DAA6D;AAC7D,6DAA6D;AAC7D,OAA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K,GAAG,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAChE,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACf,CAAC;YACD,UAAU,CAAC,KAAyB;gBAClC,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC;YACD,KAAK,CAAC,KAAyB;gBAC7B,OAAO,UAAU,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;YAClD,CAAC;SACF;KACF;IACD,MAAM,EAAE;QACN,CAAC,EAAE,KAAK;QACR,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,gDAAgD;KAC9D;IACD,WAAW;IACX,IAAI,EAAE,MAAM;IACZ,WAAW;CACZ,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js deleted file mode 100644 index 6b4f7c67..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js +++ /dev/null @@ -1,22 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { weierstrass } from './abstract/weierstrass.js'; -import { getHash } from './_shortw_utils.js'; -import { Field } from './abstract/modular.js'; -/** - * bn254 pairing-friendly curve. - * Previously known as alt_bn_128, when it had 128-bit security. - * Recent research shown it's weaker, the naming has been adjusted to its prime bit count. - * https://github.com/zcash/zcash/issues/2502 - */ -export const bn254 = weierstrass({ - a: BigInt(0), - b: BigInt(3), - Fp: Field(BigInt('0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47')), - n: BigInt('0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001'), - Gx: BigInt(1), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); -//# sourceMappingURL=bn254.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js.map deleted file mode 100644 index e0ec0235..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/bn254.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bn254.js","sourceRoot":"","sources":["../src/bn254.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;IAC/B,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC;IACvF,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,OAAO,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js deleted file mode 100644 index 01ee630d..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js +++ /dev/null @@ -1,430 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha512 } from '@noble/hashes/sha512'; -import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils'; -import { twistedEdwards } from './abstract/edwards.js'; -import { montgomery } from './abstract/montgomery.js'; -import { Field, FpSqrtEven, isNegativeLE, mod, pow2 } from './abstract/modular.js'; -import { bytesToHex, bytesToNumberLE, ensureBytes, equalBytes, numberToBytesLE, } from './abstract/utils.js'; -import { createHasher, expand_message_xmd } from './abstract/hash-to-curve.js'; -/** - * ed25519 Twisted Edwards curve with following addons: - * - X25519 ECDH - * - Ristretto cofactor elimination - * - Elligator hash-to-group / point indistinguishability - */ -const ED25519_P = BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'); -// √(-1) aka √(a) aka 2^((p-1)/4) -const ED25519_SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752'); -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _5n = BigInt(5); -// prettier-ignore -const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80); -function ed25519_pow_2_252_3(x) { - const P = ED25519_P; - const x2 = (x * x) % P; - const b2 = (x2 * x) % P; // x^3, 11 - const b4 = (pow2(b2, _2n, P) * b2) % P; // x^15, 1111 - const b5 = (pow2(b4, _1n, P) * x) % P; // x^31 - const b10 = (pow2(b5, _5n, P) * b5) % P; - const b20 = (pow2(b10, _10n, P) * b10) % P; - const b40 = (pow2(b20, _20n, P) * b20) % P; - const b80 = (pow2(b40, _40n, P) * b40) % P; - const b160 = (pow2(b80, _80n, P) * b80) % P; - const b240 = (pow2(b160, _80n, P) * b80) % P; - const b250 = (pow2(b240, _10n, P) * b10) % P; - const pow_p_5_8 = (pow2(b250, _2n, P) * x) % P; - // ^ To pow to (p+3)/8, multiply it by x. - return { pow_p_5_8, b2 }; -} -function adjustScalarBytes(bytes) { - // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar, - // set the three least significant bits of the first byte - bytes[0] &= 248; // 0b1111_1000 - // and the most significant bit of the last to zero, - bytes[31] &= 127; // 0b0111_1111 - // set the second most significant bit of the last byte to 1 - bytes[31] |= 64; // 0b0100_0000 - return bytes; -} -// sqrt(u/v) -function uvRatio(u, v) { - const P = ED25519_P; - const v3 = mod(v * v * v, P); // v³ - const v7 = mod(v3 * v3 * v, P); // v⁷ - // (p+3)/8 and (p-5)/8 - const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8; - let x = mod(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8 - const vx2 = mod(v * x * x, P); // vx² - const root1 = x; // First root candidate - const root2 = mod(x * ED25519_SQRT_M1, P); // Second root candidate - const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root - const useRoot2 = vx2 === mod(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4) - const noRoot = vx2 === mod(-u * ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1) - if (useRoot1) - x = root1; - if (useRoot2 || noRoot) - x = root2; // We return root2 anyway, for const-time - if (isNegativeLE(x, P)) - x = mod(-x, P); - return { isValid: useRoot1 || useRoot2, value: x }; -} -// Just in case -export const ED25519_TORSION_SUBGROUP = [ - '0100000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a', - '0000000000000000000000000000000000000000000000000000000000000080', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05', - 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85', - '0000000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa', -]; -const Fp = Field(ED25519_P, undefined, true); -const ed25519Defaults = { - // Param: a - a: BigInt(-1), - // d is equal to -121665/121666 over finite field. - // Negative number is P - number, and division is invert(number, P) - d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'), - // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n - Fp, - // Subgroup order: how many points curve has - // 2n**252n + 27742317777372353535851937790883648493n; - n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'), - Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'), - hash: sha512, - randomBytes, - adjustScalarBytes, - // dom2 - // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3. - // Constant-time, u/√v - uvRatio, -}; -export const ed25519 = twistedEdwards(ed25519Defaults); -function ed25519_domain(data, ctx, phflag) { - if (ctx.length > 255) - throw new Error('Context is too big'); - return concatBytes(utf8ToBytes('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data); -} -export const ed25519ctx = twistedEdwards({ ...ed25519Defaults, domain: ed25519_domain }); -export const ed25519ph = twistedEdwards({ - ...ed25519Defaults, - domain: ed25519_domain, - prehash: sha512, -}); -export const x25519 = /* @__PURE__ */ (() => montgomery({ - P: ED25519_P, - a: BigInt(486662), - montgomeryBits: 255, - nByteLength: 32, - Gu: BigInt(9), - powPminus2: (x) => { - const P = ED25519_P; - // x^(p-2) aka x^(2^255-21) - const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x); - return mod(pow2(pow_p_5_8, BigInt(3), P) * b2, P); - }, - adjustScalarBytes, - randomBytes, -}))(); -/** - * Converts ed25519 public key to x25519 public key. Uses formula: - * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)` - * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))` - * @example - * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey()); - * const aPriv = x25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub)) - */ -export function edwardsToMontgomeryPub(edwardsPub) { - const { y } = ed25519.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((_1n + y) * Fp.inv(_1n - y))); -} -export const edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated -/** - * Converts ed25519 secret key to x25519 secret key. - * @example - * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey()); - * const aPriv = ed25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub) - */ -export function edwardsToMontgomeryPriv(edwardsPriv) { - const hashed = ed25519Defaults.hash(edwardsPriv.subarray(0, 32)); - return ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32); -} -// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator) -// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since -// SageMath returns different root first and everything falls apart -const ELL2_C1 = (Fp.ORDER + BigInt(3)) / BigInt(8); // 1. c1 = (q + 3) / 8 # Integer arithmetic -const ELL2_C2 = Fp.pow(_2n, ELL2_C1); // 2. c2 = 2^c1 -const ELL2_C3 = Fp.sqrt(Fp.neg(Fp.ONE)); // 3. c3 = sqrt(-1) -const ELL2_C4 = (Fp.ORDER - BigInt(5)) / BigInt(8); // 4. c4 = (q - 5) / 8 # Integer arithmetic -const ELL2_J = BigInt(486662); -// prettier-ignore -function map_to_curve_elligator2_curve25519(u) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1 - let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not - let x1n = Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2) - let tv2 = Fp.sqr(xd); // 5. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 11. tv3 = gxd^2 - tv2 = Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4 - tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3 - tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3 - tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7 - let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8) - y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8) - let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3 - tv2 = Fp.sqr(y11); // 19. tv2 = y11^2 - tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd - let e1 = Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1 - let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt - let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd - let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u - y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2 - let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3 - let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1) - tv2 = Fp.sqr(y21); // 28. tv2 = y21^2 - tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2 - let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt - tv2 = Fp.sqr(y1); // 32. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd - let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2 - let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4) - return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1) -} -const ELL2_C1_EDWARDS = FpSqrtEven(Fp, Fp.neg(BigInt(486664))); // sgn0(c1) MUST equal 0 -function map_to_curve_elligator2_edwards25519(u) { - const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) = - // map_to_curve_elligator2_curve25519(u) - let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd - xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1 - let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM - let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd - let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d) - let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd - let e = Fp.eql(tv1, Fp.ZERO); // 8. e = tv1 == 0 - xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e) - xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e) - yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e) - yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e) - const inv = Fp.invertBatch([xd, yd]); // batch division - return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd) -} -const htf = /* @__PURE__ */ (() => createHasher(ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), { - DST: 'edwards25519_XMD:SHA-512_ELL2_RO_', - encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha512, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -function assertRstPoint(other) { - if (!(other instanceof RistPoint)) - throw new Error('RistrettoPoint expected'); -} -// √(-1) aka √(a) aka 2^((p-1)/4) -const SQRT_M1 = ED25519_SQRT_M1; -// √(ad - 1) -const SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235'); -// 1 / √(a-d) -const INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578'); -// 1-d² -const ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838'); -// (d-1)² -const D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952'); -// Calculates 1/√(number) -const invertSqrt = (number) => uvRatio(_1n, number); -const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const bytes255ToNumberLE = (bytes) => ed25519.CURVE.Fp.create(bytesToNumberLE(bytes) & MAX_255B); -// Computes Elligator map for Ristretto -// https://ristretto.group/formulas/elligator.html -function calcElligatorRistrettoMap(r0) { - const { d } = ed25519.CURVE; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const r = mod(SQRT_M1 * r0 * r0); // 1 - const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2 - let c = BigInt(-1); // 3 - const D = mod((c - d * r) * mod(r + d)); // 4 - let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D); // 5 - let s_ = mod(s * r0); // 6 - if (!isNegativeLE(s_, P)) - s_ = mod(-s_); - if (!Ns_D_is_sq) - s = s_; // 7 - if (!Ns_D_is_sq) - c = r; // 8 - const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D); // 9 - const s2 = s * s; - const W0 = mod((s + s) * D); // 10 - const W1 = mod(Nt * SQRT_AD_MINUS_ONE); // 11 - const W2 = mod(_1n - s2); // 12 - const W3 = mod(_1n + s2); // 13 - return new ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2)); -} -/** - * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be - * a source of bugs for protocols like ring signatures. Ristretto was created to solve this. - * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint, - * but it should work in its own namespace: do not combine those two. - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448 - */ -class RistPoint { - // Private property to discourage combining ExtendedPoint + RistrettoPoint - // Always use Ristretto encoding/decoding instead. - constructor(ep) { - this.ep = ep; - } - static fromAffine(ap) { - return new RistPoint(ed25519.ExtendedPoint.fromAffine(ap)); - } - /** - * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`. - * The hash-to-group operation applies Elligator twice and adds the results. - * **Note:** this is one-way map, there is no conversion from point to hash. - * https://ristretto.group/formulas/elligator.html - * @param hex 64-byte output of a hash function - */ - static hashToCurve(hex) { - hex = ensureBytes('ristrettoHash', hex, 64); - const r1 = bytes255ToNumberLE(hex.slice(0, 32)); - const R1 = calcElligatorRistrettoMap(r1); - const r2 = bytes255ToNumberLE(hex.slice(32, 64)); - const R2 = calcElligatorRistrettoMap(r2); - return new RistPoint(R1.add(R2)); - } - /** - * Converts ristretto-encoded string to ristretto point. - * https://ristretto.group/formulas/decoding.html - * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding - */ - static fromHex(hex) { - hex = ensureBytes('ristrettoHex', hex, 32); - const { a, d } = ed25519.CURVE; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint'; - const s = bytes255ToNumberLE(hex); - // 1. Check that s_bytes is the canonical encoding of a field element, or else abort. - // 3. Check that s is non-negative, or else abort - if (!equalBytes(numberToBytesLE(s, 32), hex) || isNegativeLE(s, P)) - throw new Error(emsg); - const s2 = mod(s * s); - const u1 = mod(_1n + a * s2); // 4 (a is -1) - const u2 = mod(_1n - a * s2); // 5 - const u1_2 = mod(u1 * u1); - const u2_2 = mod(u2 * u2); - const v = mod(a * d * u1_2 - u2_2); // 6 - const { isValid, value: I } = invertSqrt(mod(v * u2_2)); // 7 - const Dx = mod(I * u2); // 8 - const Dy = mod(I * Dx * v); // 9 - let x = mod((s + s) * Dx); // 10 - if (isNegativeLE(x, P)) - x = mod(-x); // 10 - const y = mod(u1 * Dy); // 11 - const t = mod(x * y); // 12 - if (!isValid || isNegativeLE(t, P) || y === _0n) - throw new Error(emsg); - return new RistPoint(new ed25519.ExtendedPoint(x, y, _1n, t)); - } - /** - * Encodes ristretto point to Uint8Array. - * https://ristretto.group/formulas/encoding.html - */ - toRawBytes() { - let { ex: x, ey: y, ez: z, et: t } = this.ep; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const u1 = mod(mod(z + y) * mod(z - y)); // 1 - const u2 = mod(x * y); // 2 - // Square root always exists - const u2sq = mod(u2 * u2); - const { value: invsqrt } = invertSqrt(mod(u1 * u2sq)); // 3 - const D1 = mod(invsqrt * u1); // 4 - const D2 = mod(invsqrt * u2); // 5 - const zInv = mod(D1 * D2 * t); // 6 - let D; // 7 - if (isNegativeLE(t * zInv, P)) { - let _x = mod(y * SQRT_M1); - let _y = mod(x * SQRT_M1); - x = _x; - y = _y; - D = mod(D1 * INVSQRT_A_MINUS_D); - } - else { - D = D2; // 8 - } - if (isNegativeLE(x * zInv, P)) - y = mod(-y); // 9 - let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a)) - if (isNegativeLE(s, P)) - s = mod(-s); - return numberToBytesLE(s, 32); // 11 - } - toHex() { - return bytesToHex(this.toRawBytes()); - } - toString() { - return this.toHex(); - } - // Compare one point to another. - equals(other) { - assertRstPoint(other); - const { ex: X1, ey: Y1 } = this.ep; - const { ex: X2, ey: Y2 } = other.ep; - const mod = ed25519.CURVE.Fp.create; - // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2) - const one = mod(X1 * Y2) === mod(Y1 * X2); - const two = mod(Y1 * Y2) === mod(X1 * X2); - return one || two; - } - add(other) { - assertRstPoint(other); - return new RistPoint(this.ep.add(other.ep)); - } - subtract(other) { - assertRstPoint(other); - return new RistPoint(this.ep.subtract(other.ep)); - } - multiply(scalar) { - return new RistPoint(this.ep.multiply(scalar)); - } - multiplyUnsafe(scalar) { - return new RistPoint(this.ep.multiplyUnsafe(scalar)); - } -} -export const RistrettoPoint = /* @__PURE__ */ (() => { - if (!RistPoint.BASE) - RistPoint.BASE = new RistPoint(ed25519.ExtendedPoint.BASE); - if (!RistPoint.ZERO) - RistPoint.ZERO = new RistPoint(ed25519.ExtendedPoint.ZERO); - return RistPoint; -})(); -// https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/14/ -// Appendix B. Hashing to ristretto255 -export const hash_to_ristretto255 = (msg, options) => { - const d = options.DST; - const DST = typeof d === 'string' ? utf8ToBytes(d) : d; - const uniform_bytes = expand_message_xmd(msg, DST, 64, sha512); - const P = RistPoint.hashToCurve(uniform_bytes); - return P; -}; -//# sourceMappingURL=ed25519.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js.map deleted file mode 100644 index 5a84c434..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed25519.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,EAEV,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAgB,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAG7F;;;;;GAKG;AAEH,MAAM,SAAS,GAAG,MAAM,CACtB,+EAA+E,CAChF,CAAC;AACF,iCAAiC;AACjC,MAAM,eAAe,GAAG,MAAM,CAC5B,+EAA+E,CAChF,CAAC;AAEF,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,kBAAkB;AAClB,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,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;IACnD,CAAC;IAED,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,cAAc,CAAC,MAAc;QAC3B,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AACD,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IAClD,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC,EAAE,CAAC;AAEL,qEAAqE;AACrE,uCAAuC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAe,EAAE,OAAqB,EAAE,EAAE;IAC7E,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IACtB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js deleted file mode 100644 index 76b46336..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js +++ /dev/null @@ -1,215 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { shake256 } from '@noble/hashes/sha3'; -import { concatBytes, randomBytes, utf8ToBytes, wrapConstructor } from '@noble/hashes/utils'; -import { twistedEdwards } from './abstract/edwards.js'; -import { mod, pow2, Field } from './abstract/modular.js'; -import { montgomery } from './abstract/montgomery.js'; -import { createHasher } from './abstract/hash-to-curve.js'; -/** - * Edwards448 (not Ed448-Goldilocks) curve with following addons: - * * X448 ECDH - * Conforms to RFC 8032 https://www.rfc-editor.org/rfc/rfc8032.html#section-5.2 - */ -const shake256_114 = wrapConstructor(() => shake256.create({ dkLen: 114 })); -const shake256_64 = wrapConstructor(() => shake256.create({ dkLen: 64 })); -const ed448P = BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439'); -// powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4. -// Used for efficient square root calculation. -// ((P-3)/4).toString(2) would produce bits [223x 1, 0, 222x 1] -function ed448_pow_Pminus3div4(x) { - const P = ed448P; - // prettier-ignore - const _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _11n = BigInt(11); - // prettier-ignore - const _22n = BigInt(22), _44n = BigInt(44), _88n = BigInt(88), _223n = BigInt(223); - const b2 = (x * x * x) % P; - const b3 = (b2 * b2 * x) % P; - const b6 = (pow2(b3, _3n, P) * b3) % P; - const b9 = (pow2(b6, _3n, P) * b3) % P; - const b11 = (pow2(b9, _2n, P) * b2) % P; - const b22 = (pow2(b11, _11n, P) * b11) % P; - const b44 = (pow2(b22, _22n, P) * b22) % P; - const b88 = (pow2(b44, _44n, P) * b44) % P; - const b176 = (pow2(b88, _88n, P) * b88) % P; - const b220 = (pow2(b176, _44n, P) * b44) % P; - const b222 = (pow2(b220, _2n, P) * b2) % P; - const b223 = (pow2(b222, _1n, P) * x) % P; - return (pow2(b223, _223n, P) * b222) % P; -} -function adjustScalarBytes(bytes) { - // Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0, and the most - // significant bit of the last byte to 1. - bytes[0] &= 252; // 0b11111100 - // and the most significant bit of the last byte to 1. - bytes[55] |= 128; // 0b10000000 - // NOTE: is is NOOP for 56 bytes scalars (X25519/X448) - bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits) - return bytes; -} -const Fp = Field(ed448P, 456, true); -const _4n = BigInt(4); -const ED448_DEF = { - // Param: a - a: BigInt(1), - // -39081. Negative number is P - number - d: BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358'), - // Finite field 𝔽p over which we'll do calculations; 2n**448n - 2n**224n - 1n - Fp, - // Subgroup order: how many points curve has; - // 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n - n: BigInt('181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779'), - nBitLength: 456, - // Cofactor - h: BigInt(4), - // Base point (x, y) aka generator point - Gx: BigInt('224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710'), - Gy: BigInt('298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660'), - // SHAKE256(dom4(phflag,context)||x, 114) - hash: shake256_114, - randomBytes, - adjustScalarBytes, - // dom4 - domain: (data, ctx, phflag) => { - if (ctx.length > 255) - throw new Error(`Context is too big: ${ctx.length}`); - return concatBytes(utf8ToBytes('SigEd448'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data); - }, - // Constant-time ratio of u to v. Allows to combine inversion and square root u/√v. - // Uses algo from RFC8032 5.1.3. - uvRatio: (u, v) => { - const P = ed448P; - // https://datatracker.ietf.org/doc/html/rfc8032#section-5.2.3 - // To compute the square root of (u/v), the first step is to compute the - // candidate root x = (u/v)^((p+1)/4). This can be done using the - // following trick, to use a single modular powering for both the - // inversion of v and the square root: - // x = (u/v)^((p+1)/4) = u³v(u⁵v³)^((p-3)/4) (mod p) - const u2v = mod(u * u * v, P); // u²v - const u3v = mod(u2v * u, P); // u³v - const u5v3 = mod(u3v * u2v * v, P); // u⁵v³ - const root = ed448_pow_Pminus3div4(u5v3); - const x = mod(u3v * root, P); - // Verify that root is exists - const x2 = mod(x * x, P); // x² - // If vx² = u, the recovered x-coordinate is x. Otherwise, no - // square root exists, and the decoding fails. - return { isValid: mod(x2 * v, P) === u, value: x }; - }, -}; -export const ed448 = twistedEdwards(ED448_DEF); -// NOTE: there is no ed448ctx, since ed448 supports ctx by default -export const ed448ph = twistedEdwards({ ...ED448_DEF, prehash: shake256_64 }); -export const x448 = /* @__PURE__ */ (() => montgomery({ - a: BigInt(156326), - montgomeryBits: 448, - nByteLength: 57, - P: ed448P, - Gu: BigInt(5), - powPminus2: (x) => { - const P = ed448P; - const Pminus3div4 = ed448_pow_Pminus3div4(x); - const Pminus3 = pow2(Pminus3div4, BigInt(2), P); - return mod(Pminus3 * x, P); // Pminus3 * x = Pminus2 - }, - adjustScalarBytes, - randomBytes, -}))(); -/** - * Converts edwards448 public key to x448 public key. Uses formula: - * * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)` - * * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))` - * @example - * const aPub = ed448.getPublicKey(utils.randomPrivateKey()); - * x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub)) - */ -export function edwardsToMontgomeryPub(edwardsPub) { - const { y } = ed448.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((y - _1n) * Fp.inv(y + _1n))); -} -export const edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated -// Hash To Curve Elligator2 Map -const ELL2_C1 = (Fp.ORDER - BigInt(3)) / BigInt(4); // 1. c1 = (q - 3) / 4 # Integer arithmetic -const ELL2_J = BigInt(156326); -function map_to_curve_elligator2_curve448(u) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - let e1 = Fp.eql(tv1, Fp.ONE); // 2. e1 = tv1 == 1 - tv1 = Fp.cmov(tv1, Fp.ZERO, e1); // 3. tv1 = CMOV(tv1, 0, e1) # If Z * u^2 == -1, set tv1 = 0 - let xd = Fp.sub(Fp.ONE, tv1); // 4. xd = 1 - tv1 - let x1n = Fp.neg(ELL2_J); // 5. x1n = -J - let tv2 = Fp.sqr(xd); // 6. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 7. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, Fp.neg(ELL2_J)); // 8. gx1 = -J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 9. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 10. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 11. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 12. tv3 = gxd^2 - tv2 = Fp.mul(gx1, gxd); // 13. tv2 = gx1 * gxd # gx1 * gxd - tv3 = Fp.mul(tv3, tv2); // 14. tv3 = tv3 * tv2 # gx1 * gxd^3 - let y1 = Fp.pow(tv3, ELL2_C1); // 15. y1 = tv3^c1 # (gx1 * gxd^3)^((p - 3) / 4) - y1 = Fp.mul(y1, tv2); // 16. y1 = y1 * tv2 # gx1 * gxd * (gx1 * gxd^3)^((p - 3) / 4) - let x2n = Fp.mul(x1n, Fp.neg(tv1)); // 17. x2n = -tv1 * x1n # x2 = x2n / xd = -1 * u^2 * x1n / xd - let y2 = Fp.mul(y1, u); // 18. y2 = y1 * u - y2 = Fp.cmov(y2, Fp.ZERO, e1); // 19. y2 = CMOV(y2, 0, e1) - tv2 = Fp.sqr(y1); // 20. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 21. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx1); // 22. e2 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e2); // 23. xn = CMOV(x2n, x1n, e2) # If e2, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e2); // 24. y = CMOV(y2, y1, e2) # If e2, y = y1, else y = y2 - let e3 = Fp.isOdd(y); // 25. e3 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e2 !== e3); // 26. y = CMOV(y, -y, e2 XOR e3) - return { xn, xd, yn: y, yd: Fp.ONE }; // 27. return (xn, xd, y, 1) -} -function map_to_curve_elligator2_edwards448(u) { - let { xn, xd, yn, yd } = map_to_curve_elligator2_curve448(u); // 1. (xn, xd, yn, yd) = map_to_curve_elligator2_curve448(u) - let xn2 = Fp.sqr(xn); // 2. xn2 = xn^2 - let xd2 = Fp.sqr(xd); // 3. xd2 = xd^2 - let xd4 = Fp.sqr(xd2); // 4. xd4 = xd2^2 - let yn2 = Fp.sqr(yn); // 5. yn2 = yn^2 - let yd2 = Fp.sqr(yd); // 6. yd2 = yd^2 - let xEn = Fp.sub(xn2, xd2); // 7. xEn = xn2 - xd2 - let tv2 = Fp.sub(xEn, xd2); // 8. tv2 = xEn - xd2 - xEn = Fp.mul(xEn, xd2); // 9. xEn = xEn * xd2 - xEn = Fp.mul(xEn, yd); // 10. xEn = xEn * yd - xEn = Fp.mul(xEn, yn); // 11. xEn = xEn * yn - xEn = Fp.mul(xEn, _4n); // 12. xEn = xEn * 4 - tv2 = Fp.mul(tv2, xn2); // 13. tv2 = tv2 * xn2 - tv2 = Fp.mul(tv2, yd2); // 14. tv2 = tv2 * yd2 - let tv3 = Fp.mul(yn2, _4n); // 15. tv3 = 4 * yn2 - let tv1 = Fp.add(tv3, yd2); // 16. tv1 = tv3 + yd2 - tv1 = Fp.mul(tv1, xd4); // 17. tv1 = tv1 * xd4 - let xEd = Fp.add(tv1, tv2); // 18. xEd = tv1 + tv2 - tv2 = Fp.mul(tv2, xn); // 19. tv2 = tv2 * xn - let tv4 = Fp.mul(xn, xd4); // 20. tv4 = xn * xd4 - let yEn = Fp.sub(tv3, yd2); // 21. yEn = tv3 - yd2 - yEn = Fp.mul(yEn, tv4); // 22. yEn = yEn * tv4 - yEn = Fp.sub(yEn, tv2); // 23. yEn = yEn - tv2 - tv1 = Fp.add(xn2, xd2); // 24. tv1 = xn2 + xd2 - tv1 = Fp.mul(tv1, xd2); // 25. tv1 = tv1 * xd2 - tv1 = Fp.mul(tv1, xd); // 26. tv1 = tv1 * xd - tv1 = Fp.mul(tv1, yn2); // 27. tv1 = tv1 * yn2 - tv1 = Fp.mul(tv1, BigInt(-2)); // 28. tv1 = -2 * tv1 - let yEd = Fp.add(tv2, tv1); // 29. yEd = tv2 + tv1 - tv4 = Fp.mul(tv4, yd2); // 30. tv4 = tv4 * yd2 - yEd = Fp.add(yEd, tv4); // 31. yEd = yEd + tv4 - tv1 = Fp.mul(xEd, yEd); // 32. tv1 = xEd * yEd - let e = Fp.eql(tv1, Fp.ZERO); // 33. e = tv1 == 0 - xEn = Fp.cmov(xEn, Fp.ZERO, e); // 34. xEn = CMOV(xEn, 0, e) - xEd = Fp.cmov(xEd, Fp.ONE, e); // 35. xEd = CMOV(xEd, 1, e) - yEn = Fp.cmov(yEn, Fp.ONE, e); // 36. yEn = CMOV(yEn, 1, e) - yEd = Fp.cmov(yEd, Fp.ONE, e); // 37. yEd = CMOV(yEd, 1, e) - const inv = Fp.invertBatch([xEd, yEd]); // batch division - return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd) -} -const htf = /* @__PURE__ */ (() => createHasher(ed448.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), { - DST: 'edwards448_XOF:SHAKE256_ELL2_RO_', - encodeDST: 'edwards448_XOF:SHAKE256_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 224, - expand: 'xof', - hash: shake256, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -//# sourceMappingURL=ed448.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js.map deleted file mode 100644 index e8774075..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/ed448.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ed448.js","sourceRoot":"","sources":["../src/ed448.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;;GAIG;AAEH,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC5E,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,GAAG,MAAM,CACnB,yIAAyI,CAC1I,CAAC;AAEF,8DAA8D;AAC9D,8CAA8C;AAC9C,+DAA+D;AAC/D,SAAS,qBAAqB,CAAC,CAAS;IACtC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjB,kBAAkB;IAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG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AG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js deleted file mode 100644 index ac4f2231..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -throw new Error('Incorrect usage. Import submodules instead'); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js.map deleted file mode 100644 index b5117dcd..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js deleted file mode 100644 index 2b1f575d..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js +++ /dev/null @@ -1,54 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha512 } from '@noble/hashes/sha512'; -import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils'; -import { twistedEdwards } from './abstract/edwards.js'; -import { blake2s } from '@noble/hashes/blake2s'; -import { Field } from './abstract/modular.js'; -/** - * jubjub Twisted Edwards curve. - * https://neuromancer.sk/std/other/JubJub - * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them. - */ -export const jubjub = twistedEdwards({ - // Params: a, d - a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'), - d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'), - // Finite field 𝔽p over which we'll do calculations - // Same value as bls12-381 Fr (not Fp) - Fp: Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')), - // Subgroup order: how many points curve has - n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'), - Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'), - hash: sha512, - randomBytes, -}); -const GH_FIRST_BLOCK = utf8ToBytes('096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'); -// Returns point at JubJub curve which is prime order and not zero -export function groupHash(tag, personalization) { - const h = blake2s.create({ personalization, dkLen: 32 }); - h.update(GH_FIRST_BLOCK); - h.update(tag); - // NOTE: returns ExtendedPoint, in case it will be multiplied later - let p = jubjub.ExtendedPoint.fromHex(h.digest()); - // NOTE: cannot replace with isSmallOrder, returns Point*8 - p = p.multiply(jubjub.CURVE.h); - if (p.equals(jubjub.ExtendedPoint.ZERO)) - throw new Error('Point has small order'); - return p; -} -export function findGroupHash(m, personalization) { - const tag = concatBytes(m, new Uint8Array([0])); - for (let i = 0; i < 256; i++) { - tag[tag.length - 1] = i; - try { - return groupHash(tag, personalization); - } - catch (e) { } - } - throw new Error('findGroupHash tag overflow'); -} -//# sourceMappingURL=jubjub.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js.map deleted file mode 100644 index 41ad6bb7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/jubjub.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jubjub.js","sourceRoot":"","sources":["../src/jubjub.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C;;;;GAIG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC;IACnC,eAAe;IACf,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,oDAAoD;IACpD,sCAAsC;IACtC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC;IACvF,4CAA4C;IAC5C,CAAC,EAAE,MAAM,CAAC,mEAAmE,CAAC;IAC9E,WAAW;IACX,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAChF,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAChF,IAAI,EAAE,MAAM;IACZ,WAAW;CACH,CAAC,CAAC;AAEZ,MAAM,cAAc,GAAG,WAAW,CAChC,kEAAkE,CACnE,CAAC;AAEF,kEAAkE;AAClE,MAAM,UAAU,SAAS,CAAC,GAAe,EAAE,eAA2B;IACpE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACzB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACd,mEAAmE;IACnE,IAAI,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,0DAA0D;IAC1D,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAClF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAa,EAAE,eAA2B;IACtE,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC5B,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI;YACF,OAAO,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SACxC;QAAC,OAAO,CAAC,EAAE,GAAE;KACf;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAChD,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js deleted file mode 100644 index 5e2e89e1..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js +++ /dev/null @@ -1,42 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha256 } from '@noble/hashes/sha256'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; -// NIST secp256r1 aka p256 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256 -const Fp = Field(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff')); -const CURVE_A = Fp.create(BigInt('-3')); -const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b'); -// prettier-ignore -export const p256 = createCurve({ - a: CURVE_A, - b: CURVE_B, - Fp, - // Curve order, total count of valid points in the field - n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'), - // Base (generator) point (x, y) - Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'), - Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'), - h: BigInt(1), - lowS: false, -}, sha256); -export const secp256r1 = p256; -const mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-10')), -}))(); -const htf = /* @__PURE__ */ (() => createHasher(secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P256_XMD:SHA-256_SSWU_RO_', - encodeDST: 'P256_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -//# sourceMappingURL=p256.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js.map deleted file mode 100644 index 1efec390..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p256.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,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CAAC;AAER,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,YAAY,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js deleted file mode 100644 index 21d9308b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js +++ /dev/null @@ -1,46 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha384 } from '@noble/hashes/sha512'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; -// NIST secp384r1 aka p384 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384 -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff'); -const Fp = Field(P); -const CURVE_A = Fp.create(BigInt('-3')); -// prettier-ignore -const CURVE_B = BigInt('0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef'); -// prettier-ignore -export const p384 = createCurve({ - a: CURVE_A, - b: CURVE_B, - Fp, - // Curve order, total count of valid points in the field. - n: BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973'), - // Base (generator) point (x, y) - Gx: BigInt('0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7'), - Gy: BigInt('0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f'), - h: BigInt(1), - lowS: false, -}, sha384); -export const secp384r1 = p384; -const mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-12')), -}))(); -const htf = /* @__PURE__ */ (() => createHasher(secp384r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P384_XMD:SHA-384_SSWU_RO_', - encodeDST: 'P384_XMD:SHA-384_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 192, - expand: 'xmd', - hash: sha384, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -//# sourceMappingURL=p384.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js.map deleted file mode 100644 index bf8b8eda..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p384.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p384.js","sourceRoot":"","sources":["../src/p384.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,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AG,EAAE,CAChC,YAAY,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p521.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p521.js deleted file mode 100644 index 0131155b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p521.js +++ /dev/null @@ -1,53 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha512 } from '@noble/hashes/sha512'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; -// NIST secp521r1 aka p521 -// Note that it's 521, which differs from 512 of its hash function. -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521 -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const Fp = Field(P); -const CURVE = { - a: Fp.create(BigInt('-3')), - b: BigInt('0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00'), - Fp, - n: BigInt('0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409'), - Gx: BigInt('0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66'), - Gy: BigInt('0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650'), - h: BigInt(1), -}; -// prettier-ignore -export const p521 = createCurve({ - a: CURVE.a, - b: CURVE.b, - Fp, - // Curve order, total count of valid points in the field - n: CURVE.n, - Gx: CURVE.Gx, - Gy: CURVE.Gy, - h: CURVE.h, - lowS: false, - allowedPrivateKeyLengths: [130, 131, 132] // P521 keys are variable-length. Normalize to 132b -}, sha512); -export const secp521r1 = p521; -const mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, { - A: CURVE.a, - B: CURVE.b, - Z: Fp.create(BigInt('-4')), -}))(); -const htf = /* @__PURE__ */ (() => createHasher(secp521r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P521_XMD:SHA-512_SSWU_RO_', - encodeDST: 'P521_XMD:SHA-512_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 256, - expand: 'xmd', - hash: sha512, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -//# sourceMappingURL=p521.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/p521.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/p521.js.map deleted file mode 100644 index cd24eb59..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/cur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AE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,mDAAmD;CACrF,EAAE,MAAM,CAAC,CAAC;AACpB,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAE9B,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CACnC,mBAAmB,CAAC,EAAE,EAAE;IACtB,CAAC,EAAE,KAAK,CAAC,CAAC;IACV,CAAC,EAAE,KAAK,CAAC,CAAC;IACV,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC,CAAC,EAAE,CAAC;AAER,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,YAAY,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/package.json b/node_modules/nostr-tools/node_modules/@noble/curves/esm/package.json deleted file mode 100644 index 267769c6..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "module", - "browser": { - "crypto": false, - "./crypto": "./esm/crypto.js" - } -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js deleted file mode 100644 index fa5ca528..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js +++ /dev/null @@ -1,30 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { weierstrass } from './abstract/weierstrass.js'; -import { getHash } from './_shortw_utils.js'; -import * as mod from './abstract/modular.js'; -export const p = BigInt('0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001'); -export const q = BigInt('0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001'); -// https://neuromancer.sk/std/other/Pallas -export const pallas = weierstrass({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(p), - n: q, - Gx: mod.mod(BigInt(-1), p), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); -// https://neuromancer.sk/std/other/Vesta -export const vesta = weierstrass({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(q), - n: p, - Gx: mod.mod(BigInt(-1), q), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); -//# sourceMappingURL=pasta.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js.map deleted file mode 100644 index 4942dd2e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/pasta.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pasta.js","sourceRoot":"","sources":["../src/pasta.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,uBAAuB,CAAC;AAE7C,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAE9F,0CAA0C;AAC1C,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC;IAChC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAChB,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,OAAO,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC;AACH,yCAAyC;AACzC,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;IAC/B,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAChB,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,OAAO,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js b/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js deleted file mode 100644 index eb36ebc7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js +++ /dev/null @@ -1,254 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { randomBytes } from '@noble/hashes/utils'; -import { Field, mod, pow2 } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { bytesToNumberBE, concatBytes, ensureBytes, numberToBytesBE } from './abstract/utils.js'; -import { createHasher, isogenyMap } from './abstract/hash-to-curve.js'; -import { createCurve } from './_shortw_utils.js'; -const secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'); -const secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'); -const _1n = BigInt(1); -const _2n = BigInt(2); -const divNearest = (a, b) => (a + b / _2n) / b; -/** - * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit. - * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00] - */ -function sqrtMod(y) { - const P = secp256k1P; - // prettier-ignore - const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22); - // prettier-ignore - const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88); - const b2 = (y * y * y) % P; // x^3, 11 - const b3 = (b2 * b2 * y) % P; // x^7 - const b6 = (pow2(b3, _3n, P) * b3) % P; - const b9 = (pow2(b6, _3n, P) * b3) % P; - const b11 = (pow2(b9, _2n, P) * b2) % P; - const b22 = (pow2(b11, _11n, P) * b11) % P; - const b44 = (pow2(b22, _22n, P) * b22) % P; - const b88 = (pow2(b44, _44n, P) * b44) % P; - const b176 = (pow2(b88, _88n, P) * b88) % P; - const b220 = (pow2(b176, _44n, P) * b44) % P; - const b223 = (pow2(b220, _3n, P) * b3) % P; - const t1 = (pow2(b223, _23n, P) * b22) % P; - const t2 = (pow2(t1, _6n, P) * b2) % P; - const root = pow2(t2, _2n, P); - if (!Fp.eql(Fp.sqr(root), y)) - throw new Error('Cannot find square root'); - return root; -} -const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod }); -export const secp256k1 = createCurve({ - a: BigInt(0), - b: BigInt(7), - Fp, - n: secp256k1N, - // Base point (x, y) aka generator point - Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'), - Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'), - h: BigInt(1), - lowS: true, - /** - * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism. - * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%. - * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit. - * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066 - */ - endo: { - beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'), - splitScalar: (k) => { - const n = secp256k1N; - const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15'); - const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3'); - const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8'); - const b2 = a1; - const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16) - const c1 = divNearest(b2 * k, n); - const c2 = divNearest(-b1 * k, n); - let k1 = mod(k - c1 * a1 - c2 * a2, n); - let k2 = mod(-c1 * b1 - c2 * b2, n); - const k1neg = k1 > POW_2_128; - const k2neg = k2 > POW_2_128; - if (k1neg) - k1 = n - k1; - if (k2neg) - k2 = n - k2; - if (k1 > POW_2_128 || k2 > POW_2_128) { - throw new Error('splitScalar: Endomorphism failed, k=' + k); - } - return { k1neg, k1, k2neg, k2 }; - }, - }, -}, sha256); -// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code. -// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki -const _0n = BigInt(0); -const fe = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1P; -const ge = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1N; -/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */ -const TAGGED_HASH_PREFIXES = {}; -function taggedHash(tag, ...messages) { - let tagP = TAGGED_HASH_PREFIXES[tag]; - if (tagP === undefined) { - const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0))); - tagP = concatBytes(tagH, tagH); - TAGGED_HASH_PREFIXES[tag] = tagP; - } - return sha256(concatBytes(tagP, ...messages)); -} -// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03 -const pointToBytes = (point) => point.toRawBytes(true).slice(1); -const numTo32b = (n) => numberToBytesBE(n, 32); -const modP = (x) => mod(x, secp256k1P); -const modN = (x) => mod(x, secp256k1N); -const Point = secp256k1.ProjectivePoint; -const GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b); -// Calculate point, scalar and bytes -function schnorrGetExtPubKey(priv) { - let d_ = secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey - let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside - const scalar = p.hasEvenY() ? d_ : modN(-d_); - return { scalar: scalar, bytes: pointToBytes(p) }; -} -/** - * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point. - * @returns valid point checked for being on-curve - */ -function lift_x(x) { - if (!fe(x)) - throw new Error('bad x: need 0 < x < p'); // Fail if x ≥ p. - const xx = modP(x * x); - const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p. - let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p. - if (y % _2n !== _0n) - y = modP(-y); // Return the unique point P such that x(P) = x and - const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise. - p.assertValidity(); - return p; -} -/** - * Create tagged hash, convert it to bigint, reduce modulo-n. - */ -function challenge(...args) { - return modN(bytesToNumberBE(taggedHash('BIP0340/challenge', ...args))); -} -/** - * Schnorr public key is just `x` coordinate of Point as per BIP340. - */ -function schnorrGetPublicKey(privateKey) { - return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G) -} -/** - * Creates Schnorr signature as per BIP340. Verifies itself before returning anything. - * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous. - */ -function schnorrSign(message, privateKey, auxRand = randomBytes(32)) { - const m = ensureBytes('message', message); - const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder - const a = ensureBytes('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array - const t = numTo32b(d ^ bytesToNumberBE(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a) - const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m) - const k_ = modN(bytesToNumberBE(rand)); // Let k' = int(rand) mod n - if (k_ === _0n) - throw new Error('sign failed: k is zero'); // Fail if k' = 0. - const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G. - const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n. - const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n). - sig.set(rx, 0); - sig.set(numTo32b(modN(k + e * d)), 32); - // If Verify(bytes(P), m, sig) (see below) returns failure, abort - if (!schnorrVerify(sig, m, px)) - throw new Error('sign: Invalid signature produced'); - return sig; -} -/** - * Verifies Schnorr signature. - * Will swallow errors & return false except for initial type validation of arguments. - */ -function schnorrVerify(signature, message, publicKey) { - const sig = ensureBytes('signature', signature, 64); - const m = ensureBytes('message', message); - const pub = ensureBytes('publicKey', publicKey, 32); - try { - const P = lift_x(bytesToNumberBE(pub)); // P = lift_x(int(pk)); fail if that fails - const r = bytesToNumberBE(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p. - if (!fe(r)) - return false; - const s = bytesToNumberBE(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n. - if (!ge(s)) - return false; - const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n - const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P - if (!R || !R.hasEvenY() || R.toAffine().x !== r) - return false; // -eP == (n-e)P - return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r. - } - catch (error) { - return false; - } -} -export const schnorr = /* @__PURE__ */ (() => ({ - getPublicKey: schnorrGetPublicKey, - sign: schnorrSign, - verify: schnorrVerify, - utils: { - randomPrivateKey: secp256k1.utils.randomPrivateKey, - lift_x, - pointToBytes, - numberToBytesBE, - bytesToNumberBE, - taggedHash, - mod, - }, -}))(); -const isoMap = /* @__PURE__ */ (() => isogenyMap(Fp, [ - // xNum - [ - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7', - '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581', - '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262', - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c', - ], - // xDen - [ - '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b', - '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c', - '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3', - '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931', - '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84', - ], - // yDen - [ - '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b', - '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573', - '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], -].map((i) => i.map((j) => BigInt(j)))))(); -const mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, { - A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'), - B: BigInt('1771'), - Z: Fp.create(BigInt('-11')), -}))(); -const htf = /* @__PURE__ */ (() => createHasher(secp256k1.ProjectivePoint, (scalars) => { - const { x, y } = mapSWU(Fp.create(scalars[0])); - return isoMap(x, y); -}, { - DST: 'secp256k1_XMD:SHA-256_SSWU_RO_', - encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256, -}))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); -//# sourceMappingURL=secp256k1.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js.map deleted file mode 100644 index 692678a2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../src/secp256k1.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAA8B,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,O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ACtB,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC,CAAC,EAAE,CAAC;AACR,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,YAAY,CACV,SAAS,CAAC,eAAe,EACzB,CAAC,OAAiB,EAAE,EAAE;IACpB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtB,CAAC,EACD;IACE,GAAG,EAAE,gCAAgC;IACrC,SAAS,EAAE,gCAAgC;IAC3C,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,MAAM;CACb,CACF,CAAC,EAAE,CAAC;AACP,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts deleted file mode 100644 index f36479a7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts.map deleted file mode 100644 index 4e8c5816..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/index.js b/node_modules/nostr-tools/node_modules/@noble/curves/index.js deleted file mode 100644 index ac4f2231..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/index.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -throw new Error('Incorrect usage. Import submodules instead'); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/index.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/index.js.map deleted file mode 100644 index 292b53a2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts deleted file mode 100644 index 7d2c398a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * jubjub Twisted Edwards curve. - * https://neuromancer.sk/std/other/JubJub - * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them. - */ -export declare const jubjub: import("./abstract/edwards.js").CurveFn; -export declare function groupHash(tag: Uint8Array, personalization: Uint8Array): import("./abstract/edwards.js").ExtPointType; -export declare function findGroupHash(m: Uint8Array, personalization: Uint8Array): import("./abstract/edwards.js").ExtPointType; -//# sourceMappingURL=jubjub.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts.map deleted file mode 100644 index e79099df..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jubjub.d.ts","sourceRoot":"","sources":["src/jubjub.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH,eAAO,MAAM,MAAM,yCAgBR,CAAC;AAOZ,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,gDAUrE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,gDASvE"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js b/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js deleted file mode 100644 index 60c83296..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.findGroupHash = exports.groupHash = exports.jubjub = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha512_1 = require("@noble/hashes/sha512"); -const utils_1 = require("@noble/hashes/utils"); -const edwards_js_1 = require("./abstract/edwards.js"); -const blake2s_1 = require("@noble/hashes/blake2s"); -const modular_js_1 = require("./abstract/modular.js"); -/** - * jubjub Twisted Edwards curve. - * https://neuromancer.sk/std/other/JubJub - * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them. - */ -exports.jubjub = (0, edwards_js_1.twistedEdwards)({ - // Params: a, d - a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'), - d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'), - // Finite field 𝔽p over which we'll do calculations - // Same value as bls12-381 Fr (not Fp) - Fp: (0, modular_js_1.Field)(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')), - // Subgroup order: how many points curve has - n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'), - Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'), - hash: sha512_1.sha512, - randomBytes: utils_1.randomBytes, -}); -const GH_FIRST_BLOCK = (0, utils_1.utf8ToBytes)('096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'); -// Returns point at JubJub curve which is prime order and not zero -function groupHash(tag, personalization) { - const h = blake2s_1.blake2s.create({ personalization, dkLen: 32 }); - h.update(GH_FIRST_BLOCK); - h.update(tag); - // NOTE: returns ExtendedPoint, in case it will be multiplied later - let p = exports.jubjub.ExtendedPoint.fromHex(h.digest()); - // NOTE: cannot replace with isSmallOrder, returns Point*8 - p = p.multiply(exports.jubjub.CURVE.h); - if (p.equals(exports.jubjub.ExtendedPoint.ZERO)) - throw new Error('Point has small order'); - return p; -} -exports.groupHash = groupHash; -function findGroupHash(m, personalization) { - const tag = (0, utils_1.concatBytes)(m, new Uint8Array([0])); - for (let i = 0; i < 256; i++) { - tag[tag.length - 1] = i; - try { - return groupHash(tag, personalization); - } - catch (e) { } - } - throw new Error('findGroupHash tag overflow'); -} -exports.findGroupHash = findGroupHash; -//# sourceMappingURL=jubjub.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js.map deleted file mode 100644 index 08b1694f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/jubjub.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jubjub.js","sourceRoot":"","sources":["src/jubjub.ts"],"names":[],"mappings":";;;A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I,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAClF,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,8BAUC;AAED,SAAgB,aAAa,CAAC,CAAa,EAAE,eAA2B;IACtE,MAAM,GAAG,GAAG,IAAA,mBAAW,EAAC,CAAC,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC5B,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI;YACF,OAAO,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SACxC;QAAC,OAAO,CAAC,EAAE,GAAE;KACf;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAChD,CAAC;AATD,sCASC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts deleted file mode 100644 index cf8c0d6e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -export declare const p256: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const secp256r1: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -//# sourceMappingURL=p256.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts.map deleted file mode 100644 index d16f8128..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p256.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p256.d.ts","sourceRoot":"","sources":["src/p256.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWE,CAAC;AACpB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAO,CAAC;AAmB9B,eAAO,MAAM,WAAW,uJAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,uJAA8C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p256.js b/node_modules/nostr-tools/node_modules/@noble/curves/p256.js deleted file mode 100644 index 1e7e8094..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p256.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodeToCurve = exports.hashToCurve = exports.secp256r1 = exports.p256 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const sha256_1 = require("@noble/hashes/sha256"); -const modular_js_1 = require("./abstract/modular.js"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -// NIST secp256r1 aka p256 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256 -const Fp = (0, modular_js_1.Field)(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff')); -const CURVE_A = Fp.create(BigInt('-3')); -const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b'); -// prettier-ignore -exports.p256 = (0, _shortw_utils_js_1.createCurve)({ - a: CURVE_A, - b: CURVE_B, - Fp, - // Curve order, total count of valid points in the field - n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'), - // Base (generator) point (x, y) - Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'), - Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'), - h: BigInt(1), - lowS: false, -}, sha256_1.sha256); -exports.secp256r1 = exports.p256; -const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-10')), -}))(); -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P256_XMD:SHA-256_SSWU_RO_', - encodeDST: 'P256_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256_1.sha256, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -//# sourceMappingURL=p256.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p256.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/p256.js.map deleted file mode 100644 index 0459df9c..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p256.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p256.js","sourceRoot":"","sources":["src/p256.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,yDAAiD;AACjD,iDAA8C;AAC9C,sDAA8C;AAC9C,8DAAgE;AAChE,kEAA2D;AAE3D,0BAA0B;AAC1B,0EAA0E;AAE1E,MAAM,EAAE,GAAG,IAAA,kBAAK,EAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC,CAAC;AAC/F,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,MAAM,OAAO,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAE7F,kBAAkB;AACL,QAAA,IAAI,GAAG,IAAA,8BAAW,EAAC;IAC9B,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;IACV,EAAE;IACF,wDAAwD;IACxD,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAChF,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAChF,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,IAAI,EAAE,KAAK;CACH,EAAE,eAAM,CAAC,CAAC;AACP,QAAA,SAAS,GAAG,YAAI,CAAC;AAE9B,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CACnC,IAAA,oCAAmB,EAAC,EAAE,EAAE;IACtB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC,CAAC,EAAE,CAAC;AAER,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,IAAA,+BAAY,EAAC,iBAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACK,QAAA,WAAW,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxD,QAAA,aAAa,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts deleted file mode 100644 index 0be42541..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -export declare const p384: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const secp384r1: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -//# sourceMappingURL=p384.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts.map deleted file mode 100644 index 547746d3..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p384.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p384.d.ts","sourceRoot":"","sources":["src/p384.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWE,CAAC;AACpB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAO,CAAC;AAmB9B,eAAO,MAAM,WAAW,uJAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,uJAA8C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p384.js b/node_modules/nostr-tools/node_modules/@noble/curves/p384.js deleted file mode 100644 index d3a472bd..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p384.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodeToCurve = exports.hashToCurve = exports.secp384r1 = exports.p384 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const sha512_1 = require("@noble/hashes/sha512"); -const modular_js_1 = require("./abstract/modular.js"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -// NIST secp384r1 aka p384 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384 -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff'); -const Fp = (0, modular_js_1.Field)(P); -const CURVE_A = Fp.create(BigInt('-3')); -// prettier-ignore -const CURVE_B = BigInt('0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef'); -// prettier-ignore -exports.p384 = (0, _shortw_utils_js_1.createCurve)({ - a: CURVE_A, - b: CURVE_B, - Fp, - // Curve order, total count of valid points in the field. - n: BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973'), - // Base (generator) point (x, y) - Gx: BigInt('0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7'), - Gy: BigInt('0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f'), - h: BigInt(1), - lowS: false, -}, sha512_1.sha384); -exports.secp384r1 = exports.p384; -const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-12')), -}))(); -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp384r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P384_XMD:SHA-384_SSWU_RO_', - encodeDST: 'P384_XMD:SHA-384_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 192, - expand: 'xmd', - hash: sha512_1.sha384, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -//# sourceMappingURL=p384.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p384.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/p384.js.map deleted file mode 100644 index 6816f0d2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p384.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p384.js","sourceRoot":"","sources":["src/p384.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,yDAAiD;AACjD,iDAA8C;AAC9C,sDAA8C;AAC9C,8DAAgE;AAChE,kEAA2D;AAE3D,0BAA0B;AAC1B,0EAA0E;AAE1E,0CAA0C;AAC1C,kBAAkB;AAClB,MAAM,CAAC,GAAG,MAAM,CAAC,oGAAoG,CAAC,CAAC;AACvH,MAAM,EAAE,GAAG,IAAA,kBAAK,EAAC,CAAC,CAAC,CAAC;AACpB,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,kBAAkB;AAClB,MAAM,OAAO,GAAG,MAAM,CAAC,oGAAoG,CAAC,CAAC;AAE7H,kBAAkB;AACL,QAAA,IAAI,GAAG,IAAA,8BAAW,EAAC;IAC9B,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;IACV,EAAE;IACF,yDAAyD;IACzD,CAAC,EAAE,MAAM,CAAC,oGAAoG,CAAC;IAC/G,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC,oGAAoG,CAAC;IAChH,EAAE,EAAE,MAAM,CAAC,oGAAoG,CAAC;IAChH,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,IAAI,EAAE,KAAK;CACH,EAAE,eAAM,CAAC,CAAC;AACP,QAAA,SAAS,GAAG,YAAI,CAAC;AAE9B,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CACnC,IAAA,oCAAmB,EAAC,EAAE,EAAE;IACtB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC,CAAC,EAAE,CAAC;AAER,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,IAAA,+BAAY,EAAC,iBAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACK,QAAA,WAAW,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxD,QAAA,aAAa,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts deleted file mode 100644 index 47cca466..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -export declare const p521: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const secp521r1: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: import("./abstract/weierstrass.js").ProjPointType) => import("./abstract/weierstrass.js").ProjPointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: import("./abstract/utils.js").Hex | { - r: bigint; - s: bigint; - }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; - isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType | undefined) => import("./abstract/weierstrass.js").ProjPointType; - }; -}>; -export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -//# sourceMappingURL=p521.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts.map deleted file mode 100644 index 1c3cdaa2..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p521.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p521.d.ts","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWE,CAAC;AACpB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAO,CAAC;AAmB9B,eAAO,MAAM,WAAW,uJAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,uJAA8C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p521.js b/node_modules/nostr-tools/node_modules/@noble/curves/p521.js deleted file mode 100644 index c1c0e22a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p521.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodeToCurve = exports.hashToCurve = exports.secp521r1 = exports.p521 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const sha512_1 = require("@noble/hashes/sha512"); -const modular_js_1 = require("./abstract/modular.js"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -// NIST secp521r1 aka p521 -// Note that it's 521, which differs from 512 of its hash function. -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521 -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const Fp = (0, modular_js_1.Field)(P); -const CURVE = { - a: Fp.create(BigInt('-3')), - b: BigInt('0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00'), - Fp, - n: BigInt('0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409'), - Gx: BigInt('0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66'), - Gy: BigInt('0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650'), - h: BigInt(1), -}; -// prettier-ignore -exports.p521 = (0, _shortw_utils_js_1.createCurve)({ - a: CURVE.a, - b: CURVE.b, - Fp, - // Curve order, total count of valid points in the field - n: CURVE.n, - Gx: CURVE.Gx, - Gy: CURVE.Gy, - h: CURVE.h, - lowS: false, - allowedPrivateKeyLengths: [130, 131, 132] // P521 keys are variable-length. Normalize to 132b -}, sha512_1.sha512); -exports.secp521r1 = exports.p521; -const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp, { - A: CURVE.a, - B: CURVE.b, - Z: Fp.create(BigInt('-4')), -}))(); -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp521r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), { - DST: 'P521_XMD:SHA-512_SSWU_RO_', - encodeDST: 'P521_XMD:SHA-512_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 256, - expand: 'xmd', - hash: sha512_1.sha512, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -//# sourceMappingURL=p521.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/p521.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/p521.js.map deleted file mode 100644 index f79e5f0f..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/p521.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"p521.js","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,yDAAiD;AACjD,iDAA8C;AAC9C,sDAA8C;AAC9C,8DAAgE;AAChE,kEAA2D;AAE3D,0BAA0B;AAC1B,mEAAmE;AACnE,0EAA0E;AAE1E,0CAA0C;AAC1C,kBAAkB;AAClB,MAAM,CAAC,GAAG,MAAM,CAAC,uIAAuI,CAAC,CAAC;AAC1J,MAAM,EAAE,GAAG,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AM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACK,QAAA,WAAW,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxD,QAAA,aAAa,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/package.json b/node_modules/nostr-tools/node_modules/@noble/curves/package.json deleted file mode 100644 index 8d59a95e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/package.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "name": "@noble/curves", - "version": "1.1.0", - "description": "Audited & minimal JS implementation of elliptic curve cryptography", - "files": [ - "abstract", - "esm", - "src", - "*.js", - "*.js.map", - "*.d.ts", - "*.d.ts.map" - ], - "scripts": { - "bench": "cd benchmark; node secp256k1.js; node curves.js; node ecdh.js; node hash-to-curve.js; node modular.js; node bls.js", - "build": "tsc && tsc -p tsconfig.esm.json", - "build:release": "rollup -c rollup.config.js", - "build:clean": "rm *.{js,d.ts,d.ts.map,js.map} esm/*.{js,d.ts,d.ts.map,js.map} 2> /dev/null", - "lint": "prettier --check 'src/**/*.{js,ts}' 'test/*.js'", - "format": "prettier --write 'src/**/*.{js,ts}' 'test/*.js'", - "test": "node test/index.test.js" - }, - "author": "Paul Miller (https://paulmillr.com)", - "homepage": "https://paulmillr.com/noble/", - "repository": { - "type": "git", - "url": "https://github.com/paulmillr/noble-curves.git" - }, - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "devDependencies": { - "fast-check": "3.0.0", - "micro-bmark": "0.3.1", - "micro-should": "0.4.0", - "prettier": "2.8.4", - "typescript": "5.0.2" - }, - "main": "index.js", - "exports": { - ".": { - "types": "./index.d.ts", - "import": "./esm/index.js", - "default": "./index.js" - }, - "./abstract/edwards": { - "types": "./abstract/edwards.d.ts", - "import": "./esm/abstract/edwards.js", - "default": "./abstract/edwards.js" - }, - "./abstract/modular": { - "types": "./abstract/modular.d.ts", - "import": "./esm/abstract/modular.js", - "default": "./abstract/modular.js" - }, - "./abstract/montgomery": { - "types": "./abstract/montgomery.d.ts", - "import": "./esm/abstract/montgomery.js", - "default": "./abstract/montgomery.js" - }, - "./abstract/weierstrass": { - "types": "./abstract/weierstrass.d.ts", - "import": "./esm/abstract/weierstrass.js", - "default": "./abstract/weierstrass.js" - }, - "./abstract/bls": { - "types": "./abstract/bls.d.ts", - "import": "./esm/abstract/bls.js", - "default": "./abstract/bls.js" - }, - "./abstract/hash-to-curve": { - "types": "./abstract/hash-to-curve.d.ts", - "import": "./esm/abstract/hash-to-curve.js", - "default": "./abstract/hash-to-curve.js" - }, - "./abstract/curve": { - "types": "./abstract/curve.d.ts", - "import": "./esm/abstract/curve.js", - "default": "./abstract/curve.js" - }, - "./abstract/utils": { - "types": "./abstract/utils.d.ts", - "import": "./esm/abstract/utils.js", - "default": "./abstract/utils.js" - }, - "./abstract/poseidon": { - "types": "./abstract/poseidon.d.ts", - "import": "./esm/abstract/poseidon.js", - "default": "./abstract/poseidon.js" - }, - "./_shortw_utils": { - "types": "./_shortw_utils.d.ts", - "import": "./esm/_shortw_utils.js", - "default": "./_shortw_utils.js" - }, - "./bls12-381": { - "types": "./bls12-381.d.ts", - "import": "./esm/bls12-381.js", - "default": "./bls12-381.js" - }, - "./bn254": { - "types": "./bn254.d.ts", - "import": "./esm/bn254.js", - "default": "./bn254.js" - }, - "./ed25519": { - "types": "./ed25519.d.ts", - "import": "./esm/ed25519.js", - "default": "./ed25519.js" - }, - "./ed448": { - "types": "./ed448.d.ts", - "import": "./esm/ed448.js", - "default": "./ed448.js" - }, - "./index": { - "types": "./index.d.ts", - "import": "./esm/index.js", - "default": "./index.js" - }, - "./jubjub": { - "types": "./jubjub.d.ts", - "import": "./esm/jubjub.js", - "default": "./jubjub.js" - }, - "./p256": { - "types": "./p256.d.ts", - "import": "./esm/p256.js", - "default": "./p256.js" - }, - "./p384": { - "types": "./p384.d.ts", - "import": "./esm/p384.js", - "default": "./p384.js" - }, - "./p521": { - "types": "./p521.d.ts", - "import": "./esm/p521.js", - "default": "./p521.js" - }, - "./pasta": { - "types": "./pasta.d.ts", - "import": "./esm/pasta.js", - "default": "./pasta.js" - }, - "./secp256k1": { - "types": "./secp256k1.d.ts", - "import": "./esm/secp256k1.js", - "default": "./secp256k1.js" - } - }, - "keywords": [ - "elliptic", - "curve", - "cryptography", - "weierstrass", - "montgomery", - "edwards", - "p256", - "p384", - "p521", - "secp256r1", - "secp256k1", - "ed25519", - "ed448", - "x25519", - "ed25519", - "bls12-381", - "bn254", - "pasta", - "bls", - "noble", - "ecc", - "ecdsa", - "eddsa", - "schnorr" - ], - "funding": "https://paulmillr.com/funding/" -} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts deleted file mode 100644 index 9e1f4ed4..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare const p: bigint; -export declare const q: bigint; -export declare const pallas: import("./abstract/weierstrass.js").CurveFn; -export declare const vesta: import("./abstract/weierstrass.js").CurveFn; -//# sourceMappingURL=pasta.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts.map deleted file mode 100644 index d4e6dd52..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pasta.d.ts","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,CAAC,QAA+E,CAAC;AAC9F,eAAO,MAAM,CAAC,QAA+E,CAAC;AAG9F,eAAO,MAAM,MAAM,6CASjB,CAAC;AAEH,eAAO,MAAM,KAAK,6CAShB,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js b/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js deleted file mode 100644 index c3bee21d..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.vesta = exports.pallas = exports.q = exports.p = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha256_1 = require("@noble/hashes/sha256"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const mod = require("./abstract/modular.js"); -exports.p = BigInt('0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001'); -exports.q = BigInt('0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001'); -// https://neuromancer.sk/std/other/Pallas -exports.pallas = (0, weierstrass_js_1.weierstrass)({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(exports.p), - n: exports.q, - Gx: mod.mod(BigInt(-1), exports.p), - Gy: BigInt(2), - h: BigInt(1), - ...(0, _shortw_utils_js_1.getHash)(sha256_1.sha256), -}); -// https://neuromancer.sk/std/other/Vesta -exports.vesta = (0, weierstrass_js_1.weierstrass)({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(exports.q), - n: exports.p, - Gx: mod.mod(BigInt(-1), exports.q), - Gy: BigInt(2), - h: BigInt(1), - ...(0, _shortw_utils_js_1.getHash)(sha256_1.sha256), -}); -//# sourceMappingURL=pasta.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js.map deleted file mode 100644 index 5ea530cc..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/pasta.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pasta.js","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,8DAAwD;AACxD,yDAA6C;AAC7C,6CAA6C;AAEhC,QAAA,CAAC,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AACjF,QAAA,CAAC,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAE9F,0CAA0C;AAC7B,QAAA,MAAM,GAAG,IAAA,4BAAW,EAAC;IAChC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,SAAC,CAAC;IAChB,CAAC,EAAE,SAAC;IACJ,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,SAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,IAAA,0BAAO,EAAC,eAAM,CAAC;CACnB,CAAC,CAAC;AACH,yCAAyC;AAC5B,QAAA,KAAK,GAAG,IAAA,4BAAW,EAAC;IAC/B,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,SAAC,CAAC;IAChB,CAAC,EAAE,SAAC;IACJ,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,SAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,GAAG,IAAA,0BAAO,EAAC,eAAM,CAAC;CACnB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts b/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts deleted file mode 100644 index b94df777..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { mod } from './abstract/modular.js'; -import { ProjPointType as PointType } from './abstract/weierstrass.js'; -import type { Hex, PrivKey } from './abstract/utils.js'; -import { bytesToNumberBE, numberToBytesBE } from './abstract/utils.js'; -export declare const secp256k1: Readonly<{ - create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn; - CURVE: Readonly<{ - readonly nBitLength: number; - readonly nByteLength: number; - readonly Fp: import("./abstract/modular.js").IField; - readonly n: bigint; - readonly h: bigint; - readonly hEff?: bigint | undefined; - readonly Gx: bigint; - readonly Gy: bigint; - readonly allowInfinityPoint?: boolean | undefined; - readonly a: bigint; - readonly b: bigint; - readonly allowedPrivateKeyLengths?: readonly number[] | undefined; - readonly wrapPrivateKey?: boolean | undefined; - readonly endo?: { - beta: bigint; - splitScalar: (k: bigint) => { - k1neg: boolean; - k1: bigint; - k2neg: boolean; - k2: bigint; - }; - } | undefined; - readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: PointType) => boolean) | undefined; - readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor, point: PointType) => PointType) | undefined; - readonly hash: import("./abstract/utils.js").CHash; - readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; - readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array; - lowS: boolean; - readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined; - readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined; - readonly p: bigint; - }>; - getPublicKey: (privateKey: PrivKey, isCompressed?: boolean | undefined) => Uint8Array; - getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean | undefined) => Uint8Array; - sign: (msgHash: Hex, privKey: PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").RecoveredSignatureType; - verify: (signature: Hex | { - r: bigint; - s: bigint; - }, msgHash: Hex, publicKey: Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean; - ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor; - Signature: import("./abstract/weierstrass.js").SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: PrivKey) => bigint; - isValidPrivateKey(privateKey: PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number | undefined, point?: PointType | undefined) => PointType; - }; -}>; -declare function taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array; -/** - * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point. - * @returns valid point checked for being on-curve - */ -declare function lift_x(x: bigint): PointType; -/** - * Schnorr public key is just `x` coordinate of Point as per BIP340. - */ -declare function schnorrGetPublicKey(privateKey: Hex): Uint8Array; -/** - * Creates Schnorr signature as per BIP340. Verifies itself before returning anything. - * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous. - */ -declare function schnorrSign(message: Hex, privateKey: PrivKey, auxRand?: Hex): Uint8Array; -/** - * Verifies Schnorr signature. - * Will swallow errors & return false except for initial type validation of arguments. - */ -declare function schnorrVerify(signature: Hex, message: Hex, publicKey: Hex): boolean; -export declare const schnorr: { - getPublicKey: typeof schnorrGetPublicKey; - sign: typeof schnorrSign; - verify: typeof schnorrVerify; - utils: { - randomPrivateKey: () => Uint8Array; - lift_x: typeof lift_x; - pointToBytes: (point: PointType) => Uint8Array; - numberToBytesBE: typeof numberToBytesBE; - bytesToNumberBE: typeof bytesToNumberBE; - taggedHash: typeof taggedHash; - mod: typeof mod; - }; -}; -export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts | undefined) => import("./abstract/hash-to-curve.js").H2CPoint; -export {}; -//# sourceMappingURL=secp256k1.d.ts.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts.map b/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts.map deleted file mode 100644 index c6ddafc7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["src/secp256k1.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,GAAG,EAAQ,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,IAAI,SAAS,EAAuB,MAAM,2BAA2B,CAAC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAA4B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAwCjG,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CrB,CAAC;AASF,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,GAAG,UAAU,CAQtE;AAkBD;;;GAGG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAS5C;AAQD;;GAEG;AACH,iBAAS,mBAAmB,CAAC,UAAU,EAAE,GAAG,GAAG,UAAU,CAExD;AAED;;;GAGG;AACH,iBAAS,WAAW,CAClB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,GAAqB,GAC7B,UAAU,CAgBZ;AAED;;;GAGG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,OAAO,CAiB5E;AAED,eAAO,MAAM,OAAO;;;;;;;8BA5FS,UAAU,MAAM,CAAC;;;;;;CAyGzC,CAAC;AA0DN,eAAO,MAAM,WAAW,uJAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,uJAA8C,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js b/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js deleted file mode 100644 index 463edccb..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js +++ /dev/null @@ -1,257 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodeToCurve = exports.hashToCurve = exports.schnorr = exports.secp256k1 = void 0; -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sha256_1 = require("@noble/hashes/sha256"); -const utils_1 = require("@noble/hashes/utils"); -const modular_js_1 = require("./abstract/modular.js"); -const weierstrass_js_1 = require("./abstract/weierstrass.js"); -const utils_js_1 = require("./abstract/utils.js"); -const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js"); -const _shortw_utils_js_1 = require("./_shortw_utils.js"); -const secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'); -const secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'); -const _1n = BigInt(1); -const _2n = BigInt(2); -const divNearest = (a, b) => (a + b / _2n) / b; -/** - * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit. - * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00] - */ -function sqrtMod(y) { - const P = secp256k1P; - // prettier-ignore - const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22); - // prettier-ignore - const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88); - const b2 = (y * y * y) % P; // x^3, 11 - const b3 = (b2 * b2 * y) % P; // x^7 - const b6 = ((0, modular_js_1.pow2)(b3, _3n, P) * b3) % P; - const b9 = ((0, modular_js_1.pow2)(b6, _3n, P) * b3) % P; - const b11 = ((0, modular_js_1.pow2)(b9, _2n, P) * b2) % P; - const b22 = ((0, modular_js_1.pow2)(b11, _11n, P) * b11) % P; - const b44 = ((0, modular_js_1.pow2)(b22, _22n, P) * b22) % P; - const b88 = ((0, modular_js_1.pow2)(b44, _44n, P) * b44) % P; - const b176 = ((0, modular_js_1.pow2)(b88, _88n, P) * b88) % P; - const b220 = ((0, modular_js_1.pow2)(b176, _44n, P) * b44) % P; - const b223 = ((0, modular_js_1.pow2)(b220, _3n, P) * b3) % P; - const t1 = ((0, modular_js_1.pow2)(b223, _23n, P) * b22) % P; - const t2 = ((0, modular_js_1.pow2)(t1, _6n, P) * b2) % P; - const root = (0, modular_js_1.pow2)(t2, _2n, P); - if (!Fp.eql(Fp.sqr(root), y)) - throw new Error('Cannot find square root'); - return root; -} -const Fp = (0, modular_js_1.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod }); -exports.secp256k1 = (0, _shortw_utils_js_1.createCurve)({ - a: BigInt(0), - b: BigInt(7), - Fp, - n: secp256k1N, - // Base point (x, y) aka generator point - Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'), - Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'), - h: BigInt(1), - lowS: true, - /** - * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism. - * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%. - * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit. - * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066 - */ - endo: { - beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'), - splitScalar: (k) => { - const n = secp256k1N; - const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15'); - const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3'); - const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8'); - const b2 = a1; - const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16) - const c1 = divNearest(b2 * k, n); - const c2 = divNearest(-b1 * k, n); - let k1 = (0, modular_js_1.mod)(k - c1 * a1 - c2 * a2, n); - let k2 = (0, modular_js_1.mod)(-c1 * b1 - c2 * b2, n); - const k1neg = k1 > POW_2_128; - const k2neg = k2 > POW_2_128; - if (k1neg) - k1 = n - k1; - if (k2neg) - k2 = n - k2; - if (k1 > POW_2_128 || k2 > POW_2_128) { - throw new Error('splitScalar: Endomorphism failed, k=' + k); - } - return { k1neg, k1, k2neg, k2 }; - }, - }, -}, sha256_1.sha256); -// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code. -// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki -const _0n = BigInt(0); -const fe = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1P; -const ge = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1N; -/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */ -const TAGGED_HASH_PREFIXES = {}; -function taggedHash(tag, ...messages) { - let tagP = TAGGED_HASH_PREFIXES[tag]; - if (tagP === undefined) { - const tagH = (0, sha256_1.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0))); - tagP = (0, utils_js_1.concatBytes)(tagH, tagH); - TAGGED_HASH_PREFIXES[tag] = tagP; - } - return (0, sha256_1.sha256)((0, utils_js_1.concatBytes)(tagP, ...messages)); -} -// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03 -const pointToBytes = (point) => point.toRawBytes(true).slice(1); -const numTo32b = (n) => (0, utils_js_1.numberToBytesBE)(n, 32); -const modP = (x) => (0, modular_js_1.mod)(x, secp256k1P); -const modN = (x) => (0, modular_js_1.mod)(x, secp256k1N); -const Point = exports.secp256k1.ProjectivePoint; -const GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b); -// Calculate point, scalar and bytes -function schnorrGetExtPubKey(priv) { - let d_ = exports.secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey - let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside - const scalar = p.hasEvenY() ? d_ : modN(-d_); - return { scalar: scalar, bytes: pointToBytes(p) }; -} -/** - * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point. - * @returns valid point checked for being on-curve - */ -function lift_x(x) { - if (!fe(x)) - throw new Error('bad x: need 0 < x < p'); // Fail if x ≥ p. - const xx = modP(x * x); - const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p. - let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p. - if (y % _2n !== _0n) - y = modP(-y); // Return the unique point P such that x(P) = x and - const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise. - p.assertValidity(); - return p; -} -/** - * Create tagged hash, convert it to bigint, reduce modulo-n. - */ -function challenge(...args) { - return modN((0, utils_js_1.bytesToNumberBE)(taggedHash('BIP0340/challenge', ...args))); -} -/** - * Schnorr public key is just `x` coordinate of Point as per BIP340. - */ -function schnorrGetPublicKey(privateKey) { - return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G) -} -/** - * Creates Schnorr signature as per BIP340. Verifies itself before returning anything. - * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous. - */ -function schnorrSign(message, privateKey, auxRand = (0, utils_1.randomBytes)(32)) { - const m = (0, utils_js_1.ensureBytes)('message', message); - const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder - const a = (0, utils_js_1.ensureBytes)('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array - const t = numTo32b(d ^ (0, utils_js_1.bytesToNumberBE)(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a) - const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m) - const k_ = modN((0, utils_js_1.bytesToNumberBE)(rand)); // Let k' = int(rand) mod n - if (k_ === _0n) - throw new Error('sign failed: k is zero'); // Fail if k' = 0. - const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G. - const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n. - const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n). - sig.set(rx, 0); - sig.set(numTo32b(modN(k + e * d)), 32); - // If Verify(bytes(P), m, sig) (see below) returns failure, abort - if (!schnorrVerify(sig, m, px)) - throw new Error('sign: Invalid signature produced'); - return sig; -} -/** - * Verifies Schnorr signature. - * Will swallow errors & return false except for initial type validation of arguments. - */ -function schnorrVerify(signature, message, publicKey) { - const sig = (0, utils_js_1.ensureBytes)('signature', signature, 64); - const m = (0, utils_js_1.ensureBytes)('message', message); - const pub = (0, utils_js_1.ensureBytes)('publicKey', publicKey, 32); - try { - const P = lift_x((0, utils_js_1.bytesToNumberBE)(pub)); // P = lift_x(int(pk)); fail if that fails - const r = (0, utils_js_1.bytesToNumberBE)(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p. - if (!fe(r)) - return false; - const s = (0, utils_js_1.bytesToNumberBE)(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n. - if (!ge(s)) - return false; - const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n - const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P - if (!R || !R.hasEvenY() || R.toAffine().x !== r) - return false; // -eP == (n-e)P - return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r. - } - catch (error) { - return false; - } -} -exports.schnorr = (() => ({ - getPublicKey: schnorrGetPublicKey, - sign: schnorrSign, - verify: schnorrVerify, - utils: { - randomPrivateKey: exports.secp256k1.utils.randomPrivateKey, - lift_x, - pointToBytes, - numberToBytesBE: utils_js_1.numberToBytesBE, - bytesToNumberBE: utils_js_1.bytesToNumberBE, - taggedHash, - mod: modular_js_1.mod, - }, -}))(); -const isoMap = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.isogenyMap)(Fp, [ - // xNum - [ - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7', - '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581', - '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262', - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c', - ], - // xDen - [ - '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b', - '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c', - '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3', - '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931', - '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84', - ], - // yDen - [ - '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b', - '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573', - '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], -].map((i) => i.map((j) => BigInt(j)))))(); -const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp, { - A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'), - B: BigInt('1771'), - Z: Fp.create(BigInt('-11')), -}))(); -const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp256k1.ProjectivePoint, (scalars) => { - const { x, y } = mapSWU(Fp.create(scalars[0])); - return isoMap(x, y); -}, { - DST: 'secp256k1_XMD:SHA-256_SSWU_RO_', - encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256_1.sha256, -}))(); -exports.hashToCurve = (() => htf.hashToCurve)(); -exports.encodeToCurve = (() => htf.encodeToCurve)(); -//# sourceMappingURL=secp256k1.js.map \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js.map b/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js.map deleted file mode 100644 index 4d76de26..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/secp256k1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["src/secp256k1.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,+CAAkD;AAClD,sDAAyD;AACzD,8DAA4F;AAE5F,kDAAiG;AACjG,kEAAuE;AACvE,yDAAiD;AAEjD,MAAM,UAAU,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAChG,MAAM,UAAU,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AAChG,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;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BAAS,CAAC,eAAe,EACzB,CAAC,OAAiB,EAAE,EAAE;IACpB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtB,CAAC,EACD;IACE,GAAG,EAAE,gCAAgC;IACrC,SAAS,EAAE,gCAAgC;IAC3C,CAAC,EAAE,EAAE,CAAC,KAAK;IACX,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CACF,CAAC,EAAE,CAAC;AACM,QAAA,WAAW,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxD,QAAA,aAAa,GAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/_shortw_utils.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/_shortw_utils.ts deleted file mode 100644 index 3ae5ca43..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/_shortw_utils.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { hmac } from '@noble/hashes/hmac'; -import { concatBytes, randomBytes } from '@noble/hashes/utils'; -import { weierstrass, CurveType } from './abstract/weierstrass.js'; -import { CHash } from './abstract/utils.js'; - -// connects noble-curves to noble-hashes -export function getHash(hash: CHash) { - return { - hash, - hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => hmac(hash, key, concatBytes(...msgs)), - randomBytes, - }; -} -// Same API as @noble/hashes, with ability to create curve with custom hash -type CurveDef = Readonly>; -export function createCurve(curveDef: CurveDef, defHash: CHash) { - const create = (hash: CHash) => weierstrass({ ...curveDef, ...getHash(hash) }); - return Object.freeze({ ...create(defHash), create }); -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/bls.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/bls.ts deleted file mode 100644 index 7e965b28..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/bls.ts +++ /dev/null @@ -1,398 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -/** - * BLS (Barreto-Lynn-Scott) family of pairing-friendly curves. - * Implements BLS (Boneh-Lynn-Shacham) signatures. - * Consists of two curves: G1 and G2: - * - G1 is a subgroup of (x, y) E(Fq) over y² = x³ + 4. - * - G2 is a subgroup of ((x₁, x₂+i), (y₁, y₂+i)) E(Fq²) over y² = x³ + 4(1 + i) where i is √-1 - * - Gt, created by bilinear (ate) pairing e(G1, G2), consists of p-th roots of unity in - * Fq^k where k is embedding degree. Only degree 12 is currently supported, 24 is not. - * Pairing is used to aggregate and verify signatures. - * We are using Fp for private keys (shorter) and Fp₂ for signatures (longer). - * Some projects may prefer to swap this relation, it is not supported for now. - */ -import { AffinePoint } from './curve.js'; -import { IField, hashToPrivateScalar } from './modular.js'; -import { Hex, PrivKey, CHash, bitLen, bitGet, ensureBytes } from './utils.js'; -import * as htf from './hash-to-curve.js'; -import { - CurvePointsType, - ProjPointType as ProjPointType, - CurvePointsRes, - weierstrassPoints, -} from './weierstrass.js'; - -type Fp = bigint; // Can be different field? - -// prettier-ignore -const _2n = BigInt(2), _3n = BigInt(3); - -export type SignatureCoder = { - fromHex(hex: Hex): ProjPointType; - toRawBytes(point: ProjPointType): Uint8Array; - toHex(point: ProjPointType): string; -}; - -export type CurveType = { - G1: Omit, 'n'> & { - mapToCurve: htf.MapToCurve; - htfDefaults: htf.Opts; - }; - G2: Omit, 'n'> & { - Signature: SignatureCoder; - mapToCurve: htf.MapToCurve; - htfDefaults: htf.Opts; - }; - fields: { - Fp: IField; - Fr: IField; - Fp2: IField & { - reim: (num: Fp2) => { re: bigint; im: bigint }; - multiplyByB: (num: Fp2) => Fp2; - frobeniusMap(num: Fp2, power: number): Fp2; - }; - Fp6: IField; - Fp12: IField & { - frobeniusMap(num: Fp12, power: number): Fp12; - multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12; - conjugate(num: Fp12): Fp12; - finalExponentiate(num: Fp12): Fp12; - }; - }; - params: { - x: bigint; - r: bigint; - }; - htfDefaults: htf.Opts; - hash: CHash; // Because we need outputLen for DRBG - randomBytes: (bytesLength?: number) => Uint8Array; -}; - -export type CurveFn = { - getPublicKey: (privateKey: PrivKey) => Uint8Array; - sign: { - (message: Hex, privateKey: PrivKey): Uint8Array; - (message: ProjPointType, privateKey: PrivKey): ProjPointType; - }; - verify: ( - signature: Hex | ProjPointType, - message: Hex | ProjPointType, - publicKey: Hex | ProjPointType - ) => boolean; - verifyBatch: ( - signature: Hex | ProjPointType, - messages: (Hex | ProjPointType)[], - publicKeys: (Hex | ProjPointType)[] - ) => boolean; - aggregatePublicKeys: { - (publicKeys: Hex[]): Uint8Array; - (publicKeys: ProjPointType[]): ProjPointType; - }; - aggregateSignatures: { - (signatures: Hex[]): Uint8Array; - (signatures: ProjPointType[]): ProjPointType; - }; - millerLoop: (ell: [Fp2, Fp2, Fp2][], g1: [Fp, Fp]) => Fp12; - pairing: (P: ProjPointType, Q: ProjPointType, withFinalExponent?: boolean) => Fp12; - G1: CurvePointsRes & ReturnType>; - G2: CurvePointsRes & ReturnType>; - Signature: SignatureCoder; - params: { - x: bigint; - r: bigint; - G1b: bigint; - G2b: Fp2; - }; - fields: { - Fp: IField; - Fp2: IField; - Fp6: IField; - Fp12: IField; - Fr: IField; - }; - utils: { - randomPrivateKey: () => Uint8Array; - calcPairingPrecomputes: (p: AffinePoint) => [Fp2, Fp2, Fp2][]; - }; -}; - -export function bls( - CURVE: CurveType -): CurveFn { - // Fields are specific for curve, so for now we'll need to pass them with opts - const { Fp, Fr, Fp2, Fp6, Fp12 } = CURVE.fields; - const BLS_X_LEN = bitLen(CURVE.params.x); - const groupLen = 32; // TODO: calculate; hardcoded for now - - // Pre-compute coefficients for sparse multiplication - // Point addition and point double calculations is reused for coefficients - function calcPairingPrecomputes(p: AffinePoint) { - const { x, y } = p; - // prettier-ignore - const Qx = x, Qy = y, Qz = Fp2.ONE; - // prettier-ignore - let Rx = Qx, Ry = Qy, Rz = Qz; - let ell_coeff: [Fp2, Fp2, Fp2][] = []; - for (let i = BLS_X_LEN - 2; i >= 0; i--) { - // Double - let t0 = Fp2.sqr(Ry); // Ry² - let t1 = Fp2.sqr(Rz); // Rz² - let t2 = Fp2.multiplyByB(Fp2.mul(t1, _3n)); // 3 * T1 * B - let t3 = Fp2.mul(t2, _3n); // 3 * T2 - let t4 = Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(Ry, Rz)), t1), t0); // (Ry + Rz)² - T1 - T0 - ell_coeff.push([ - Fp2.sub(t2, t0), // T2 - T0 - Fp2.mul(Fp2.sqr(Rx), _3n), // 3 * Rx² - Fp2.neg(t4), // -T4 - ]); - Rx = Fp2.div(Fp2.mul(Fp2.mul(Fp2.sub(t0, t3), Rx), Ry), _2n); // ((T0 - T3) * Rx * Ry) / 2 - Ry = Fp2.sub(Fp2.sqr(Fp2.div(Fp2.add(t0, t3), _2n)), Fp2.mul(Fp2.sqr(t2), _3n)); // ((T0 + T3) / 2)² - 3 * T2² - Rz = Fp2.mul(t0, t4); // T0 * T4 - if (bitGet(CURVE.params.x, i)) { - // Addition - let t0 = Fp2.sub(Ry, Fp2.mul(Qy, Rz)); // Ry - Qy * Rz - let t1 = Fp2.sub(Rx, Fp2.mul(Qx, Rz)); // Rx - Qx * Rz - ell_coeff.push([ - Fp2.sub(Fp2.mul(t0, Qx), Fp2.mul(t1, Qy)), // T0 * Qx - T1 * Qy - Fp2.neg(t0), // -T0 - t1, // T1 - ]); - let t2 = Fp2.sqr(t1); // T1² - let t3 = Fp2.mul(t2, t1); // T2 * T1 - let t4 = Fp2.mul(t2, Rx); // T2 * Rx - let t5 = Fp2.add(Fp2.sub(t3, Fp2.mul(t4, _2n)), Fp2.mul(Fp2.sqr(t0), Rz)); // T3 - 2 * T4 + T0² * Rz - Rx = Fp2.mul(t1, t5); // T1 * T5 - Ry = Fp2.sub(Fp2.mul(Fp2.sub(t4, t5), t0), Fp2.mul(t3, Ry)); // (T4 - T5) * T0 - T3 * Ry - Rz = Fp2.mul(Rz, t3); // Rz * T3 - } - } - return ell_coeff; - } - - function millerLoop(ell: [Fp2, Fp2, Fp2][], g1: [Fp, Fp]): Fp12 { - const { x } = CURVE.params; - const Px = g1[0]; - const Py = g1[1]; - let f12 = Fp12.ONE; - for (let j = 0, i = BLS_X_LEN - 2; i >= 0; i--, j++) { - const E = ell[j]; - f12 = Fp12.multiplyBy014(f12, E[0], Fp2.mul(E[1], Px), Fp2.mul(E[2], Py)); - if (bitGet(x, i)) { - j += 1; - const F = ell[j]; - f12 = Fp12.multiplyBy014(f12, F[0], Fp2.mul(F[1], Px), Fp2.mul(F[2], Py)); - } - if (i !== 0) f12 = Fp12.sqr(f12); - } - return Fp12.conjugate(f12); - } - - const utils = { - randomPrivateKey: (): Uint8Array => { - return Fr.toBytes(hashToPrivateScalar(CURVE.randomBytes(groupLen + 8), CURVE.params.r)); - }, - calcPairingPrecomputes, - }; - - // Point on G1 curve: (x, y) - const G1_ = weierstrassPoints({ n: Fr.ORDER, ...CURVE.G1 }); - const G1 = Object.assign( - G1_, - htf.createHasher(G1_.ProjectivePoint, CURVE.G1.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G1.htfDefaults, - }) - ); - - // Sparse multiplication against precomputed coefficients - // TODO: replace with weakmap? - type withPairingPrecomputes = { _PPRECOMPUTES: [Fp2, Fp2, Fp2][] | undefined }; - function pairingPrecomputes(point: G2): [Fp2, Fp2, Fp2][] { - const p = point as G2 & withPairingPrecomputes; - if (p._PPRECOMPUTES) return p._PPRECOMPUTES; - p._PPRECOMPUTES = calcPairingPrecomputes(point.toAffine()); - return p._PPRECOMPUTES; - } - - // TODO: export - // function clearPairingPrecomputes(point: G2) { - // const p = point as G2 & withPairingPrecomputes; - // p._PPRECOMPUTES = undefined; - // } - - // Point on G2 curve (complex numbers): (x₁, x₂+i), (y₁, y₂+i) - const G2_ = weierstrassPoints({ n: Fr.ORDER, ...CURVE.G2 }); - const G2 = Object.assign( - G2_, - htf.createHasher(G2_.ProjectivePoint as htf.H2CPointConstructor, CURVE.G2.mapToCurve, { - ...CURVE.htfDefaults, - ...CURVE.G2.htfDefaults, - }) - ); - - const { Signature } = CURVE.G2; - - // Calculates bilinear pairing - function pairing(Q: G1, P: G2, withFinalExponent: boolean = true): Fp12 { - if (Q.equals(G1.ProjectivePoint.ZERO) || P.equals(G2.ProjectivePoint.ZERO)) - throw new Error('pairing is not available for ZERO point'); - Q.assertValidity(); - P.assertValidity(); - // Performance: 9ms for millerLoop and ~14ms for exp. - const Qa = Q.toAffine(); - const looped = millerLoop(pairingPrecomputes(P), [Qa.x, Qa.y]); - return withFinalExponent ? Fp12.finalExponentiate(looped) : looped; - } - type G1 = typeof G1.ProjectivePoint.BASE; - type G2 = typeof G2.ProjectivePoint.BASE; - - type G1Hex = Hex | G1; - type G2Hex = Hex | G2; - function normP1(point: G1Hex): G1 { - return point instanceof G1.ProjectivePoint ? (point as G1) : G1.ProjectivePoint.fromHex(point); - } - function normP2(point: G2Hex): G2 { - return point instanceof G2.ProjectivePoint ? point : Signature.fromHex(point); - } - function normP2Hash(point: G2Hex, htfOpts?: htf.htfBasicOpts): G2 { - return point instanceof G2.ProjectivePoint - ? point - : (G2.hashToCurve(ensureBytes('point', point), htfOpts) as G2); - } - - // Multiplies generator by private key. - // P = pk x G - function getPublicKey(privateKey: PrivKey): Uint8Array { - return G1.ProjectivePoint.fromPrivateKey(privateKey).toRawBytes(true); - } - - // Executes `hashToCurve` on the message and then multiplies the result by private key. - // S = pk x H(m) - function sign(message: Hex, privateKey: PrivKey, htfOpts?: htf.htfBasicOpts): Uint8Array; - function sign(message: G2, privateKey: PrivKey, htfOpts?: htf.htfBasicOpts): G2; - function sign(message: G2Hex, privateKey: PrivKey, htfOpts?: htf.htfBasicOpts): Uint8Array | G2 { - const msgPoint = normP2Hash(message, htfOpts); - msgPoint.assertValidity(); - const sigPoint = msgPoint.multiply(G1.normPrivateKeyToScalar(privateKey)); - if (message instanceof G2.ProjectivePoint) return sigPoint; - return Signature.toRawBytes(sigPoint); - } - - // Checks if pairing of public key & hash is equal to pairing of generator & signature. - // e(P, H(m)) == e(G, S) - function verify( - signature: G2Hex, - message: G2Hex, - publicKey: G1Hex, - htfOpts?: htf.htfBasicOpts - ): boolean { - const P = normP1(publicKey); - const Hm = normP2Hash(message, htfOpts); - const G = G1.ProjectivePoint.BASE; - const S = normP2(signature); - // Instead of doing 2 exponentiations, we use property of billinear maps - // and do one exp after multiplying 2 points. - const ePHm = pairing(P.negate(), Hm, false); - const eGS = pairing(G, S, false); - const exp = Fp12.finalExponentiate(Fp12.mul(eGS, ePHm)); - return Fp12.eql(exp, Fp12.ONE); - } - - // Adds a bunch of public key points together. - // pk1 + pk2 + pk3 = pkA - function aggregatePublicKeys(publicKeys: Hex[]): Uint8Array; - function aggregatePublicKeys(publicKeys: G1[]): G1; - function aggregatePublicKeys(publicKeys: G1Hex[]): Uint8Array | G1 { - if (!publicKeys.length) throw new Error('Expected non-empty array'); - const agg = publicKeys.map(normP1).reduce((sum, p) => sum.add(p), G1.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (publicKeys[0] instanceof G1.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - // toRawBytes ensures point validity - return aggAffine.toRawBytes(true); - } - - // Adds a bunch of signature points together. - function aggregateSignatures(signatures: Hex[]): Uint8Array; - function aggregateSignatures(signatures: G2[]): G2; - function aggregateSignatures(signatures: G2Hex[]): Uint8Array | G2 { - if (!signatures.length) throw new Error('Expected non-empty array'); - const agg = signatures.map(normP2).reduce((sum, s) => sum.add(s), G2.ProjectivePoint.ZERO); - const aggAffine = agg; //.toAffine(); - if (signatures[0] instanceof G2.ProjectivePoint) { - aggAffine.assertValidity(); - return aggAffine; - } - return Signature.toRawBytes(aggAffine); - } - - // https://ethresear.ch/t/fast-verification-of-multiple-bls-signatures/5407 - // e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si)) - function verifyBatch( - signature: G2Hex, - messages: G2Hex[], - publicKeys: G1Hex[], - htfOpts?: htf.htfBasicOpts - ): boolean { - // @ts-ignore - // console.log('verifyBatch', bytesToHex(signature as any), messages, publicKeys.map(bytesToHex)); - - if (!messages.length) throw new Error('Expected non-empty messages array'); - if (publicKeys.length !== messages.length) - throw new Error('Pubkey count should equal msg count'); - const sig = normP2(signature); - const nMessages = messages.map((i) => normP2Hash(i, htfOpts)); - const nPublicKeys = publicKeys.map(normP1); - try { - const paired = []; - for (const message of new Set(nMessages)) { - const groupPublicKey = nMessages.reduce( - (groupPublicKey, subMessage, i) => - subMessage === message ? groupPublicKey.add(nPublicKeys[i]) : groupPublicKey, - G1.ProjectivePoint.ZERO - ); - // const msg = message instanceof PointG2 ? message : await PointG2.hashToCurve(message); - // Possible to batch pairing for same msg with different groupPublicKey here - paired.push(pairing(groupPublicKey, message, false)); - } - paired.push(pairing(G1.ProjectivePoint.BASE.negate(), sig, false)); - const product = paired.reduce((a, b) => Fp12.mul(a, b), Fp12.ONE); - const exp = Fp12.finalExponentiate(product); - return Fp12.eql(exp, Fp12.ONE); - } catch { - return false; - } - } - - G1.ProjectivePoint.BASE._setWindowSize(4); - - return { - getPublicKey, - sign, - verify, - verifyBatch, - aggregatePublicKeys, - aggregateSignatures, - millerLoop, - pairing, - G1, - G2, - Signature, - fields: { - Fr, - Fp, - Fp2, - Fp6, - Fp12, - }, - params: { - x: CURVE.params.x, - r: CURVE.params.r, - G1b: CURVE.G1.b, - G2b: CURVE.G2.b, - }, - utils, - }; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/curve.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/curve.ts deleted file mode 100644 index 2876377b..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/curve.ts +++ /dev/null @@ -1,203 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Abelian group utilities -import { IField, validateField, nLength } from './modular.js'; -import { validateObject } from './utils.js'; -const _0n = BigInt(0); -const _1n = BigInt(1); - -export type AffinePoint = { - x: T; - y: T; -} & { z?: never; t?: never }; - -export interface Group> { - double(): T; - negate(): T; - add(other: T): T; - subtract(other: T): T; - equals(other: T): boolean; - multiply(scalar: bigint): T; -} - -export type GroupConstructor = { - BASE: T; - ZERO: T; -}; -export type Mapper = (i: T[]) => T[]; - -// Elliptic curve multiplication of Point by scalar. Fragile. -// Scalars should always be less than curve order: this should be checked inside of a curve itself. -// Creates precomputation tables for fast multiplication: -// - private scalar is split by fixed size windows of W bits -// - every window point is collected from window's table & added to accumulator -// - since windows are different, same point inside tables won't be accessed more than once per calc -// - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar) -// - +1 window is neccessary for wNAF -// - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication -// TODO: Research returning 2d JS array of windows, instead of a single window. This would allow -// windows to be in different memory locations -export function wNAF>(c: GroupConstructor, bits: number) { - const constTimeNegate = (condition: boolean, item: T): T => { - const neg = item.negate(); - return condition ? neg : item; - }; - const opts = (W: number) => { - const windows = Math.ceil(bits / W) + 1; // +1, because - const windowSize = 2 ** (W - 1); // -1 because we skip zero - return { windows, windowSize }; - }; - return { - constTimeNegate, - // non-const time multiplication ladder - unsafeLadder(elm: T, n: bigint) { - let p = c.ZERO; - let d: T = elm; - while (n > _0n) { - if (n & _1n) p = p.add(d); - d = d.double(); - n >>= _1n; - } - return p; - }, - - /** - * Creates a wNAF precomputation window. Used for caching. - * Default window size is set by `utils.precompute()` and is equal to 8. - * Number of precomputed points depends on the curve size: - * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: - * - 𝑊 is the window size - * - 𝑛 is the bitlength of the curve order. - * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. - * @returns precomputed point tables flattened to a single array - */ - precomputeWindow(elm: T, W: number): Group[] { - const { windows, windowSize } = opts(W); - const points: T[] = []; - let p: T = elm; - let base = p; - for (let window = 0; window < windows; window++) { - base = p; - points.push(base); - // =1, because we skip zero - for (let i = 1; i < windowSize; i++) { - base = base.add(p); - points.push(base); - } - p = base.double(); - } - return points; - }, - - /** - * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. - * @param W window size - * @param precomputes precomputed tables - * @param n scalar (we don't check here, but should be less than curve order) - * @returns real and fake (for const-time) points - */ - wNAF(W: number, precomputes: T[], n: bigint): { p: T; f: T } { - // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise - // But need to carefully remove other checks before wNAF. ORDER == bits here - const { windows, windowSize } = opts(W); - - let p = c.ZERO; - let f = c.BASE; - - const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc. - const maxNumber = 2 ** W; - const shiftBy = BigInt(W); - - for (let window = 0; window < windows; window++) { - const offset = window * windowSize; - // Extract W bits. - let wbits = Number(n & mask); - - // Shift number by W bits. - n >>= shiftBy; - - // If the bits are bigger than max size, we'll split those. - // +224 => 256 - 32 - if (wbits > windowSize) { - wbits -= maxNumber; - n += _1n; - } - - // This code was first written with assumption that 'f' and 'p' will never be infinity point: - // since each addition is multiplied by 2 ** W, it cannot cancel each other. However, - // there is negate now: it is possible that negated element from low value - // would be the same as high element, which will create carry into next window. - // It's not obvious how this can fail, but still worth investigating later. - - // Check if we're onto Zero point. - // Add random point inside current window to f. - const offset1 = offset; - const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero - const cond1 = window % 2 !== 0; - const cond2 = wbits < 0; - if (wbits === 0) { - // The most important part for const-time getPublicKey - f = f.add(constTimeNegate(cond1, precomputes[offset1])); - } else { - p = p.add(constTimeNegate(cond2, precomputes[offset2])); - } - } - // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ() - // Even if the variable is still unused, there are some checks which will - // throw an exception, so compiler needs to prove they won't happen, which is hard. - // At this point there is a way to F be infinity-point even if p is not, - // which makes it less const-time: around 1 bigint multiply. - return { p, f }; - }, - - wNAFCached(P: T, precomputesMap: Map, n: bigint, transform: Mapper): { p: T; f: T } { - // @ts-ignore - const W: number = P._WINDOW_SIZE || 1; - // Calculate precomputes on a first run, reuse them after - let comp = precomputesMap.get(P); - if (!comp) { - comp = this.precomputeWindow(P, W) as T[]; - if (W !== 1) { - precomputesMap.set(P, transform(comp)); - } - } - return this.wNAF(W, comp, n); - }, - }; -} - -// Generic BasicCurve interface: works even for polynomial fields (BLS): P, n, h would be ok. -// Though generator can be different (Fp2 / Fp6 for BLS). -export type BasicCurve = { - Fp: IField; // Field over which we'll do calculations (Fp) - n: bigint; // Curve order, total count of valid points in the field - nBitLength?: number; // bit length of curve order - nByteLength?: number; // byte length of curve order - h: bigint; // cofactor. we can assign default=1, but users will just ignore it w/o validation - hEff?: bigint; // Number to multiply to clear cofactor - Gx: T; // base point X coordinate - Gy: T; // base point Y coordinate - allowInfinityPoint?: boolean; // bls12-381 requires it. ZERO point is valid, but invalid pubkey -}; - -export function validateBasic(curve: BasicCurve & T) { - validateField(curve.Fp); - validateObject( - curve, - { - n: 'bigint', - h: 'bigint', - Gx: 'field', - Gy: 'field', - }, - { - nBitLength: 'isSafeInteger', - nByteLength: 'isSafeInteger', - } - ); - // Set defaults - return Object.freeze({ - ...nLength(curve.n, curve.nBitLength), - ...curve, - ...{ p: curve.Fp.ORDER }, - } as const); -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/edwards.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/edwards.ts deleted file mode 100644 index 9124f66a..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/edwards.ts +++ /dev/null @@ -1,513 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y² -import { mod } from './modular.js'; -import * as ut from './utils.js'; -import { ensureBytes, FHash, Hex } from './utils.js'; -import { Group, GroupConstructor, wNAF, BasicCurve, validateBasic, AffinePoint } from './curve.js'; - -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _8n = BigInt(8); - -// Edwards curves must declare params a & d. -export type CurveType = BasicCurve & { - a: bigint; // curve param a - d: bigint; // curve param d - hash: FHash; // Hashing - randomBytes: (bytesLength?: number) => Uint8Array; // CSPRNG - adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array; // clears bits to get valid field elemtn - domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array; // Used for hashing - uvRatio?: (u: bigint, v: bigint) => { isValid: boolean; value: bigint }; // Ratio √(u/v) - prehash?: FHash; // RFC 8032 pre-hashing of messages to sign() / verify() - mapToCurve?: (scalar: bigint[]) => AffinePoint; // for hash-to-curve standard -}; - -// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex: -const VERIFY_DEFAULT = { zip215: true }; - -function validateOpts(curve: CurveType) { - const opts = validateBasic(curve); - ut.validateObject( - curve, - { - hash: 'function', - a: 'bigint', - d: 'bigint', - randomBytes: 'function', - }, - { - adjustScalarBytes: 'function', - domain: 'function', - uvRatio: 'function', - mapToCurve: 'function', - } - ); - // Set defaults - return Object.freeze({ ...opts } as const); -} - -// Instance of Extended Point with coordinates in X, Y, Z, T -export interface ExtPointType extends Group { - readonly ex: bigint; - readonly ey: bigint; - readonly ez: bigint; - readonly et: bigint; - get x(): bigint; - get y(): bigint; - assertValidity(): void; - multiply(scalar: bigint): ExtPointType; - multiplyUnsafe(scalar: bigint): ExtPointType; - isSmallOrder(): boolean; - isTorsionFree(): boolean; - clearCofactor(): ExtPointType; - toAffine(iz?: bigint): AffinePoint; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; -} -// Static methods of Extended Point with coordinates in X, Y, Z, T -export interface ExtPointConstructor extends GroupConstructor { - new (x: bigint, y: bigint, z: bigint, t: bigint): ExtPointType; - fromAffine(p: AffinePoint): ExtPointType; - fromHex(hex: Hex): ExtPointType; - fromPrivateKey(privateKey: Hex): ExtPointType; -} - -export type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: Hex) => Uint8Array; - sign: (message: Hex, privateKey: Hex, options?: { context?: Hex }) => Uint8Array; - verify: ( - sig: Hex, - message: Hex, - publicKey: Hex, - options?: { context?: Hex; zip215: boolean } - ) => boolean; - ExtendedPoint: ExtPointConstructor; - utils: { - randomPrivateKey: () => Uint8Array; - getExtendedPublicKey: (key: Hex) => { - head: Uint8Array; - prefix: Uint8Array; - scalar: bigint; - point: ExtPointType; - pointBytes: Uint8Array; - }; - }; -}; - -// It is not generic twisted curve for now, but ed25519/ed448 generic implementation -export function twistedEdwards(curveDef: CurveType): CurveFn { - const CURVE = validateOpts(curveDef) as ReturnType; - const { - Fp, - n: CURVE_ORDER, - prehash: prehash, - hash: cHash, - randomBytes, - nByteLength, - h: cofactor, - } = CURVE; - const MASK = _2n << (BigInt(nByteLength * 8) - _1n); - const modP = Fp.create; // Function overrides - - // sqrt(u/v) - const uvRatio = - CURVE.uvRatio || - ((u: bigint, v: bigint) => { - try { - return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) }; - } catch (e) { - return { isValid: false, value: _0n }; - } - }); - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes: Uint8Array) => bytes); // NOOP - const domain = - CURVE.domain || - ((data: Uint8Array, ctx: Uint8Array, phflag: boolean) => { - if (ctx.length || phflag) throw new Error('Contexts/pre-hash are not supported'); - return data; - }); // NOOP - const inBig = (n: bigint) => typeof n === 'bigint' && _0n < n; // n in [1..] - const inRange = (n: bigint, max: bigint) => inBig(n) && inBig(max) && n < max; // n in [1..max-1] - const in0MaskRange = (n: bigint) => n === _0n || inRange(n, MASK); // n in [0..MASK-1] - function assertInRange(n: bigint, max: bigint) { - // n in [1..max-1] - if (inRange(n, max)) return n; - throw new Error(`Expected valid scalar < ${max}, got ${typeof n} ${n}`); - } - function assertGE0(n: bigint) { - // n in [0..CURVE_ORDER-1] - return n === _0n ? n : assertInRange(n, CURVE_ORDER); // GE = prime subgroup, not full group - } - const pointPrecomputes = new Map(); - function isPoint(other: unknown) { - if (!(other instanceof Point)) throw new Error('ExtendedPoint expected'); - } - // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy). - // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates - class Point implements ExtPointType { - static readonly BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy)); - static readonly ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0 - - constructor( - readonly ex: bigint, - readonly ey: bigint, - readonly ez: bigint, - readonly et: bigint - ) { - if (!in0MaskRange(ex)) throw new Error('x required'); - if (!in0MaskRange(ey)) throw new Error('y required'); - if (!in0MaskRange(ez)) throw new Error('z required'); - if (!in0MaskRange(et)) throw new Error('t required'); - } - - get x(): bigint { - return this.toAffine().x; - } - get y(): bigint { - return this.toAffine().y; - } - - static fromAffine(p: AffinePoint): Point { - if (p instanceof Point) throw new Error('extended point not allowed'); - const { x, y } = p || {}; - if (!in0MaskRange(x) || !in0MaskRange(y)) throw new Error('invalid affine point'); - return new Point(x, y, _1n, modP(x * y)); - } - static normalizeZ(points: Point[]): Point[] { - const toInv = Fp.invertBatch(points.map((p) => p.ez)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - - // We calculate precomputes for elliptic curve point multiplication - // using windowed method. This specifies window size and - // stores precomputed values. Usually only base point would be precomputed. - _WINDOW_SIZE?: number; - - // "Private method", don't use it directly - _setWindowSize(windowSize: number) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - // Not required for fromHex(), which always creates valid points. - // Could be useful for fromAffine(). - assertValidity(): void { - const { a, d } = CURVE; - if (this.is0()) throw new Error('bad point: ZERO'); // TODO: optimize, with vars below? - // Equation in affine coordinates: ax² + y² = 1 + dx²y² - // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y² - const { ex: X, ey: Y, ez: Z, et: T } = this; - const X2 = modP(X * X); // X² - const Y2 = modP(Y * Y); // Y² - const Z2 = modP(Z * Z); // Z² - const Z4 = modP(Z2 * Z2); // Z⁴ - const aX2 = modP(X2 * a); // aX² - const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z² - const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y² - if (left !== right) throw new Error('bad point: equation left != right (1)'); - // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T - const XY = modP(X * Y); - const ZT = modP(Z * T); - if (XY !== ZT) throw new Error('bad point: equation left != right (2)'); - } - - // Compare one point to another. - equals(other: Point): boolean { - isPoint(other); - const { ex: X1, ey: Y1, ez: Z1 } = this; - const { ex: X2, ey: Y2, ez: Z2 } = other; - const X1Z2 = modP(X1 * Z2); - const X2Z1 = modP(X2 * Z1); - const Y1Z2 = modP(Y1 * Z2); - const Y2Z1 = modP(Y2 * Z1); - return X1Z2 === X2Z1 && Y1Z2 === Y2Z1; - } - - protected is0(): boolean { - return this.equals(Point.ZERO); - } - - negate(): Point { - // Flips point sign to a negative one (-x, y in affine coords) - return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et)); - } - - // Fast algo for doubling Extended Point. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd - // Cost: 4M + 4S + 1*a + 6add + 1*2. - double(): Point { - const { a } = CURVE; - const { ex: X1, ey: Y1, ez: Z1 } = this; - const A = modP(X1 * X1); // A = X12 - const B = modP(Y1 * Y1); // B = Y12 - const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12 - const D = modP(a * A); // D = a*A - const x1y1 = X1 + Y1; - const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B - const G = D + B; // G = D+B - const F = G - C; // F = G-C - const H = D - B; // H = D-B - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - return new Point(X3, Y3, Z3, T3); - } - - // Fast algo for adding 2 Extended Points. - // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd - // Cost: 9M + 1*a + 1*d + 7add. - add(other: Point) { - isPoint(other); - const { a, d } = CURVE; - const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this; - const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other; - // Faster algo for adding 2 Extended Points when curve's a=-1. - // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4 - // Cost: 8M + 8add + 2*2. - // Note: It does not check whether the `other` point is valid. - if (a === BigInt(-1)) { - const A = modP((Y1 - X1) * (Y2 + X2)); - const B = modP((Y1 + X1) * (Y2 - X2)); - const F = modP(B - A); - if (F === _0n) return this.double(); // Same point. Tests say it doesn't affect timing - const C = modP(Z1 * _2n * T2); - const D = modP(T1 * _2n * Z2); - const E = D + C; - const G = B + A; - const H = D - C; - const X3 = modP(E * F); - const Y3 = modP(G * H); - const T3 = modP(E * H); - const Z3 = modP(F * G); - return new Point(X3, Y3, Z3, T3); - } - const A = modP(X1 * X2); // A = X1*X2 - const B = modP(Y1 * Y2); // B = Y1*Y2 - const C = modP(T1 * d * T2); // C = T1*d*T2 - const D = modP(Z1 * Z2); // D = Z1*Z2 - const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B - const F = D - C; // F = D-C - const G = D + C; // G = D+C - const H = modP(B - a * A); // H = B-a*A - const X3 = modP(E * F); // X3 = E*F - const Y3 = modP(G * H); // Y3 = G*H - const T3 = modP(E * H); // T3 = E*H - const Z3 = modP(F * G); // Z3 = F*G - - return new Point(X3, Y3, Z3, T3); - } - - subtract(other: Point): Point { - return this.add(other.negate()); - } - - private wNAF(n: bigint): { p: Point; f: Point } { - return wnaf.wNAFCached(this, pointPrecomputes, n, Point.normalizeZ); - } - - // Constant-time multiplication. - multiply(scalar: bigint): Point { - const { p, f } = this.wNAF(assertInRange(scalar, CURVE_ORDER)); - return Point.normalizeZ([p, f])[0]; - } - - // Non-constant-time multiplication. Uses double-and-add algorithm. - // It's faster, but should only be used when you don't care about - // an exposed private key e.g. sig verification. - // Does NOT allow scalars higher than CURVE.n. - multiplyUnsafe(scalar: bigint): Point { - let n = assertGE0(scalar); // 0 <= scalar < CURVE.n - if (n === _0n) return I; - if (this.equals(I) || n === _1n) return this; - if (this.equals(G)) return this.wNAF(n).p; - return wnaf.unsafeLadder(this, n); - } - - // Checks if point is of small order. - // If you add something to small order point, you will have "dirty" - // point with torsion component. - // Multiplies point by cofactor and checks if the result is 0. - isSmallOrder(): boolean { - return this.multiplyUnsafe(cofactor).is0(); - } - - // Multiplies point by curve order and checks if the result is 0. - // Returns `false` is the point is dirty. - isTorsionFree(): boolean { - return wnaf.unsafeLadder(this, CURVE_ORDER).is0(); - } - - // Converts Extended point to default (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - toAffine(iz?: bigint): AffinePoint { - const { ex: x, ey: y, ez: z } = this; - const is0 = this.is0(); - if (iz == null) iz = is0 ? _8n : (Fp.inv(z) as bigint); // 8 was chosen arbitrarily - const ax = modP(x * iz); - const ay = modP(y * iz); - const zz = modP(z * iz); - if (is0) return { x: _0n, y: _1n }; - if (zz !== _1n) throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - - clearCofactor(): Point { - const { h: cofactor } = CURVE; - if (cofactor === _1n) return this; - return this.multiplyUnsafe(cofactor); - } - - // Converts hash string or Uint8Array to Point. - // Uses algo from RFC8032 5.1.3. - static fromHex(hex: Hex, zip215 = false): Point { - const { d, a } = CURVE; - const len = Fp.BYTES; - hex = ensureBytes('pointHex', hex, len); // copy hex to a new array - const normed = hex.slice(); // copy again, we'll manipulate it - const lastByte = hex[len - 1]; // select last byte - normed[len - 1] = lastByte & ~0x80; // clear last bit - const y = ut.bytesToNumberLE(normed); - if (y === _0n) { - // y=0 is allowed - } else { - // RFC8032 prohibits >= p, but ZIP215 doesn't - if (zip215) assertInRange(y, MASK); // zip215=true [1..P-1] (2^255-19-1 for ed25519) - else assertInRange(y, Fp.ORDER); // zip215=false [1..MASK-1] (2^256-1 for ed25519) - } - - // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case: - // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a) - const y2 = modP(y * y); // denominator is always non-0 mod p. - const u = modP(y2 - _1n); // u = y² - 1 - const v = modP(d * y2 - a); // v = d y² + 1. - let { isValid, value: x } = uvRatio(u, v); // √(u/v) - if (!isValid) throw new Error('Point.fromHex: invalid y coordinate'); - const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper - const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit - if (!zip215 && x === _0n && isLastByteOdd) - // if x=0 and x_0 = 1, fail - throw new Error('Point.fromHex: x=0 and x_0=1'); - if (isLastByteOdd !== isXOdd) x = modP(-x); // if x_0 != x mod 2, set x = p-x - return Point.fromAffine({ x, y }); - } - static fromPrivateKey(privKey: Hex) { - return getExtendedPublicKey(privKey).point; - } - toRawBytes(): Uint8Array { - const { x, y } = this.toAffine(); - const bytes = ut.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y) - bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y - return bytes; // and use the last byte to encode sign of x - } - toHex(): string { - return ut.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string. - } - } - const { BASE: G, ZERO: I } = Point; - const wnaf = wNAF(Point, nByteLength * 8); - - function modN(a: bigint) { - return mod(a, CURVE_ORDER); - } - // Little-endian SHA512 with modulo n - function modN_LE(hash: Uint8Array): bigint { - return modN(ut.bytesToNumberLE(hash)); - } - - /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */ - function getExtendedPublicKey(key: Hex) { - const len = nByteLength; - key = ensureBytes('private key', key, len); - // Hash private key with curve's hash function to produce uniformingly random input - // Check byte lengths: ensure(64, h(ensure(32, key))) - const hashed = ensureBytes('hashed private key', cHash(key), 2 * len); - const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE - const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6) - const scalar = modN_LE(head); // The actual private scalar - const point = G.multiply(scalar); // Point on Edwards curve aka public key - const pointBytes = point.toRawBytes(); // Uint8Array representation - return { head, prefix, scalar, point, pointBytes }; - } - - // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared - function getPublicKey(privKey: Hex): Uint8Array { - return getExtendedPublicKey(privKey).pointBytes; - } - - // int('LE', SHA512(dom2(F, C) || msgs)) mod N - function hashDomainToScalar(context: Hex = new Uint8Array(), ...msgs: Uint8Array[]) { - const msg = ut.concatBytes(...msgs); - return modN_LE(cHash(domain(msg, ensureBytes('context', context), !!prehash))); - } - - /** Signs message with privateKey. RFC8032 5.1.6 */ - function sign(msg: Hex, privKey: Hex, options: { context?: Hex } = {}): Uint8Array { - msg = ensureBytes('message', msg); - if (prehash) msg = prehash(msg); // for ed25519ph etc. - const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey); - const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M) - const R = G.multiply(r).toRawBytes(); // R = rG - const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M) - const s = modN(r + k * scalar); // S = (r + k * s) mod L - assertGE0(s); // 0 <= s < l - const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES)); - return ensureBytes('result', res, nByteLength * 2); // 64-byte signature - } - - const verifyOpts: { context?: Hex; zip215?: boolean } = VERIFY_DEFAULT; - function verify(sig: Hex, msg: Hex, publicKey: Hex, options = verifyOpts): boolean { - const { context, zip215 } = options; - const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7. - sig = ensureBytes('signature', sig, 2 * len); // An extended group equation is checked. - msg = ensureBytes('message', msg); - if (prehash) msg = prehash(msg); // for ed25519ph, etc - - const s = ut.bytesToNumberLE(sig.slice(len, 2 * len)); - // zip215: true is good for consensus-critical apps and allows points < 2^256 - // zip215: false follows RFC8032 / NIST186-5 and restricts points to CURVE.p - let A, R, SB; - try { - A = Point.fromHex(publicKey, zip215); - R = Point.fromHex(sig.slice(0, len), zip215); - SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside - } catch (error) { - return false; - } - if (!zip215 && A.isSmallOrder()) return false; - - const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg); - const RkA = R.add(A.multiplyUnsafe(k)); - // [8][S]B = [8]R + [8][k]A' - return RkA.subtract(SB).clearCofactor().equals(Point.ZERO); - } - - G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms. - - const utils = { - getExtendedPublicKey, - // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1. - randomPrivateKey: (): Uint8Array => randomBytes(Fp.BYTES), - - /** - * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT - * values. This slows down first getPublicKey() by milliseconds (see Speed section), - * but allows to speed-up subsequent getPublicKey() calls up to 20x. - * @param windowSize 2, 4, 8, 16 - */ - precompute(windowSize = 8, point = Point.BASE): typeof Point.BASE { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); - return point; - }, - }; - - return { - CURVE, - getPublicKey, - sign, - verify, - ExtendedPoint: Point, - utils, - }; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/hash-to-curve.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/hash-to-curve.ts deleted file mode 100644 index 38d31d4c..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/hash-to-curve.ts +++ /dev/null @@ -1,223 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import type { Group, GroupConstructor, AffinePoint } from './curve.js'; -import { mod, IField } from './modular.js'; -import { bytesToNumberBE, CHash, concatBytes, utf8ToBytes, validateObject } from './utils.js'; - -/** - * * `DST` is a domain separation tag, defined in section 2.2.5 - * * `p` characteristic of F, where F is a finite field of characteristic p and order q = p^m - * * `m` is extension degree (1 for prime fields) - * * `k` is the target security target in bits (e.g. 128), from section 5.1 - * * `expand` is `xmd` (SHA2, SHA3, BLAKE) or `xof` (SHAKE, BLAKE-XOF) - * * `hash` conforming to `utils.CHash` interface, with `outputLen` / `blockLen` props - */ -type UnicodeOrBytes = string | Uint8Array; -export type Opts = { - DST: UnicodeOrBytes; - p: bigint; - m: number; - k: number; - expand: 'xmd' | 'xof'; - hash: CHash; -}; - -function validateDST(dst: UnicodeOrBytes): Uint8Array { - if (dst instanceof Uint8Array) return dst; - if (typeof dst === 'string') return utf8ToBytes(dst); - throw new Error('DST must be Uint8Array or string'); -} - -// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE. -const os2ip = bytesToNumberBE; - -// Integer to Octet Stream (numberToBytesBE) -function i2osp(value: number, length: number): Uint8Array { - if (value < 0 || value >= 1 << (8 * length)) { - throw new Error(`bad I2OSP call: value=${value} length=${length}`); - } - const res = Array.from({ length }).fill(0) as number[]; - for (let i = length - 1; i >= 0; i--) { - res[i] = value & 0xff; - value >>>= 8; - } - return new Uint8Array(res); -} - -function strxor(a: Uint8Array, b: Uint8Array): Uint8Array { - const arr = new Uint8Array(a.length); - for (let i = 0; i < a.length; i++) { - arr[i] = a[i] ^ b[i]; - } - return arr; -} - -function isBytes(item: unknown): void { - if (!(item instanceof Uint8Array)) throw new Error('Uint8Array expected'); -} -function isNum(item: unknown): void { - if (!Number.isSafeInteger(item)) throw new Error('number expected'); -} - -// Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1 -export function expand_message_xmd( - msg: Uint8Array, - DST: Uint8Array, - lenInBytes: number, - H: CHash -): Uint8Array { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - if (DST.length > 255) DST = H(concatBytes(utf8ToBytes('H2C-OVERSIZE-DST-'), DST)); - const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H; - const ell = Math.ceil(lenInBytes / b_in_bytes); - if (ell > 255) throw new Error('Invalid xmd length'); - const DST_prime = concatBytes(DST, i2osp(DST.length, 1)); - const Z_pad = i2osp(0, r_in_bytes); - const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str - const b = new Array(ell); - const b_0 = H(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime)); - b[0] = H(concatBytes(b_0, i2osp(1, 1), DST_prime)); - for (let i = 1; i <= ell; i++) { - const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime]; - b[i] = H(concatBytes(...args)); - } - const pseudo_random_bytes = concatBytes(...b); - return pseudo_random_bytes.slice(0, lenInBytes); -} - -export function expand_message_xof( - msg: Uint8Array, - DST: Uint8Array, - lenInBytes: number, - k: number, - H: CHash -): Uint8Array { - isBytes(msg); - isBytes(DST); - isNum(lenInBytes); - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8)); - if (DST.length > 255) { - const dkLen = Math.ceil((2 * k) / 8); - DST = H.create({ dkLen }).update(utf8ToBytes('H2C-OVERSIZE-DST-')).update(DST).digest(); - } - if (lenInBytes > 65535 || DST.length > 255) - throw new Error('expand_message_xof: invalid lenInBytes'); - return ( - H.create({ dkLen: lenInBytes }) - .update(msg) - .update(i2osp(lenInBytes, 2)) - // 2. DST_prime = DST || I2OSP(len(DST), 1) - .update(DST) - .update(i2osp(DST.length, 1)) - .digest() - ); -} - -/** - * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.3 - * @param msg a byte string containing the message to hash - * @param count the number of elements of F to output - * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above - * @returns [u_0, ..., u_(count - 1)], a list of field elements. - */ -export function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][] { - validateObject(options, { - DST: 'string', - p: 'bigint', - m: 'isSafeInteger', - k: 'isSafeInteger', - hash: 'hash', - }); - const { p, k, m, hash, expand, DST: _DST } = options; - isBytes(msg); - isNum(count); - const DST = validateDST(_DST); - const log2p = p.toString(2).length; - const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above - const len_in_bytes = count * m * L; - let prb; // pseudo_random_bytes - if (expand === 'xmd') { - prb = expand_message_xmd(msg, DST, len_in_bytes, hash); - } else if (expand === 'xof') { - prb = expand_message_xof(msg, DST, len_in_bytes, k, hash); - } else if (expand === '_internal_pass') { - // for internal tests only - prb = msg; - } else { - throw new Error('expand must be "xmd" or "xof"'); - } - const u = new Array(count); - for (let i = 0; i < count; i++) { - const e = new Array(m); - for (let j = 0; j < m; j++) { - const elm_offset = L * (j + i * m); - const tv = prb.subarray(elm_offset, elm_offset + L); - e[j] = mod(os2ip(tv), p); - } - u[i] = e; - } - return u; -} - -export function isogenyMap>(field: F, map: [T[], T[], T[], T[]]) { - // Make same order as in spec - const COEFF = map.map((i) => Array.from(i).reverse()); - return (x: T, y: T) => { - const [xNum, xDen, yNum, yDen] = COEFF.map((val) => - val.reduce((acc, i) => field.add(field.mul(acc, x), i)) - ); - x = field.div(xNum, xDen); // xNum / xDen - y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev) - return { x, y }; - }; -} - -export interface H2CPoint extends Group> { - add(rhs: H2CPoint): H2CPoint; - toAffine(iz?: bigint): AffinePoint; - clearCofactor(): H2CPoint; - assertValidity(): void; -} - -export interface H2CPointConstructor extends GroupConstructor> { - fromAffine(ap: AffinePoint): H2CPoint; -} - -export type MapToCurve = (scalar: bigint[]) => AffinePoint; - -// Separated from initialization opts, so users won't accidentally change per-curve parameters -// (changing DST is ok!) -export type htfBasicOpts = { DST: UnicodeOrBytes }; - -export function createHasher( - Point: H2CPointConstructor, - mapToCurve: MapToCurve, - def: Opts & { encodeDST?: UnicodeOrBytes } -) { - if (typeof mapToCurve !== 'function') throw new Error('mapToCurve() must be defined'); - return { - // Encodes byte string to elliptic curve - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - hashToCurve(msg: Uint8Array, options?: htfBasicOpts) { - const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options } as Opts); - const u0 = Point.fromAffine(mapToCurve(u[0])); - const u1 = Point.fromAffine(mapToCurve(u[1])); - const P = u0.add(u1).clearCofactor(); - P.assertValidity(); - return P; - }, - - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-3 - encodeToCurve(msg: Uint8Array, options?: htfBasicOpts) { - const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options } as Opts); - const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor(); - P.assertValidity(); - return P; - }, - }; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/modular.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/modular.ts deleted file mode 100644 index bb1061bc..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/modular.ts +++ /dev/null @@ -1,425 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Utilities for modular arithmetics and finite fields -import { - bitMask, - numberToBytesBE, - numberToBytesLE, - bytesToNumberBE, - bytesToNumberLE, - ensureBytes, - validateObject, -} from './utils.js'; -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3); -// prettier-ignore -const _4n = BigInt(4), _5n = BigInt(5), _8n = BigInt(8); -// prettier-ignore -const _9n = BigInt(9), _16n = BigInt(16); - -// Calculates a modulo b -export function mod(a: bigint, b: bigint): bigint { - const result = a % b; - return result >= _0n ? result : b + result; -} -/** - * Efficiently raise num to power and do modular division. - * Unsafe in some contexts: uses ladder, so can expose bigint bits. - * @example - * pow(2n, 6n, 11n) // 64n % 11n == 9n - */ -// TODO: use field version && remove -export function pow(num: bigint, power: bigint, modulo: bigint): bigint { - if (modulo <= _0n || power < _0n) throw new Error('Expected power/modulo > 0'); - if (modulo === _1n) return _0n; - let res = _1n; - while (power > _0n) { - if (power & _1n) res = (res * num) % modulo; - num = (num * num) % modulo; - power >>= _1n; - } - return res; -} - -// Does x ^ (2 ^ power) mod p. pow2(30, 4) == 30 ^ (2 ^ 4) -export function pow2(x: bigint, power: bigint, modulo: bigint): bigint { - let res = x; - while (power-- > _0n) { - res *= res; - res %= modulo; - } - return res; -} - -// Inverses number over modulo -export function invert(number: bigint, modulo: bigint): bigint { - if (number === _0n || modulo <= _0n) { - throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`); - } - // Euclidean GCD https://brilliant.org/wiki/extended-euclidean-algorithm/ - // Fermat's little theorem "CT-like" version inv(n) = n^(m-2) mod m is 30x slower. - let a = mod(number, modulo); - let b = modulo; - // prettier-ignore - let x = _0n, y = _1n, u = _1n, v = _0n; - while (a !== _0n) { - // JIT applies optimization if those two lines follow each other - const q = b / a; - const r = b % a; - const m = x - u * q; - const n = y - v * q; - // prettier-ignore - b = a, a = r, x = u, y = v, u = m, v = n; - } - const gcd = b; - if (gcd !== _1n) throw new Error('invert: does not exist'); - return mod(x, modulo); -} - -// Tonelli-Shanks algorithm -// Paper 1: https://eprint.iacr.org/2012/685.pdf (page 12) -// Paper 2: Square Roots from 1; 24, 51, 10 to Dan Shanks -export function tonelliShanks(P: bigint) { - // Legendre constant: used to calculate Legendre symbol (a | p), - // which denotes the value of a^((p-1)/2) (mod p). - // (a | p) ≡ 1 if a is a square (mod p) - // (a | p) ≡ -1 if a is not a square (mod p) - // (a | p) ≡ 0 if a ≡ 0 (mod p) - const legendreC = (P - _1n) / _2n; - - let Q: bigint, S: number, Z: bigint; - // Step 1: By factoring out powers of 2 from p - 1, - // find q and s such that p - 1 = q*(2^s) with q odd - for (Q = P - _1n, S = 0; Q % _2n === _0n; Q /= _2n, S++); - - // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq - for (Z = _2n; Z < P && pow(Z, legendreC, P) !== P - _1n; Z++); - - // Fast-path - if (S === 1) { - const p1div4 = (P + _1n) / _4n; - return function tonelliFast(Fp: IField, n: T) { - const root = Fp.pow(n, p1div4); - if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root'); - return root; - }; - } - - // Slow-path - const Q1div2 = (Q + _1n) / _2n; - return function tonelliSlow(Fp: IField, n: T): T { - // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1 - if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) throw new Error('Cannot find square root'); - let r = S; - // TODO: will fail at Fp2/etc - let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b - let x = Fp.pow(n, Q1div2); // first guess at the square root - let b = Fp.pow(n, Q); // first guess at the fudge factor - - while (!Fp.eql(b, Fp.ONE)) { - if (Fp.eql(b, Fp.ZERO)) return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0) - // Find m such b^(2^m)==1 - let m = 1; - for (let t2 = Fp.sqr(b); m < r; m++) { - if (Fp.eql(t2, Fp.ONE)) break; - t2 = Fp.sqr(t2); // t2 *= t2 - } - // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow - const ge = Fp.pow(g, _1n << BigInt(r - m - 1)); // ge = 2^(r-m-1) - g = Fp.sqr(ge); // g = ge * ge - x = Fp.mul(x, ge); // x *= ge - b = Fp.mul(b, g); // b *= g - r = m; - } - return x; - }; -} - -export function FpSqrt(P: bigint) { - // NOTE: different algorithms can give different roots, it is up to user to decide which one they want. - // For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve). - - // P ≡ 3 (mod 4) - // √n = n^((P+1)/4) - if (P % _4n === _3n) { - // Not all roots possible! - // const ORDER = - // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn; - // const NUM = 72057594037927816n; - const p1div4 = (P + _1n) / _4n; - return function sqrt3mod4(Fp: IField, n: T) { - const root = Fp.pow(n, p1div4); - // Throw if root**2 != n - if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root'); - return root; - }; - } - - // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10) - if (P % _8n === _5n) { - const c1 = (P - _5n) / _8n; - return function sqrt5mod8(Fp: IField, n: T) { - const n2 = Fp.mul(n, _2n); - const v = Fp.pow(n2, c1); - const nv = Fp.mul(n, v); - const i = Fp.mul(Fp.mul(nv, _2n), v); - const root = Fp.mul(nv, Fp.sub(i, Fp.ONE)); - if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root'); - return root; - }; - } - - // P ≡ 9 (mod 16) - if (P % _16n === _9n) { - // NOTE: tonelli is too slow for bls-Fp2 calculations even on start - // Means we cannot use sqrt for constants at all! - // - // const c1 = Fp.sqrt(Fp.negate(Fp.ONE)); // 1. c1 = sqrt(-1) in F, i.e., (c1^2) == -1 in F - // const c2 = Fp.sqrt(c1); // 2. c2 = sqrt(c1) in F, i.e., (c2^2) == c1 in F - // const c3 = Fp.sqrt(Fp.negate(c1)); // 3. c3 = sqrt(-c1) in F, i.e., (c3^2) == -c1 in F - // const c4 = (P + _7n) / _16n; // 4. c4 = (q + 7) / 16 # Integer arithmetic - // sqrt = (x) => { - // let tv1 = Fp.pow(x, c4); // 1. tv1 = x^c4 - // let tv2 = Fp.mul(c1, tv1); // 2. tv2 = c1 * tv1 - // const tv3 = Fp.mul(c2, tv1); // 3. tv3 = c2 * tv1 - // let tv4 = Fp.mul(c3, tv1); // 4. tv4 = c3 * tv1 - // const e1 = Fp.equals(Fp.square(tv2), x); // 5. e1 = (tv2^2) == x - // const e2 = Fp.equals(Fp.square(tv3), x); // 6. e2 = (tv3^2) == x - // tv1 = Fp.cmov(tv1, tv2, e1); // 7. tv1 = CMOV(tv1, tv2, e1) # Select tv2 if (tv2^2) == x - // tv2 = Fp.cmov(tv4, tv3, e2); // 8. tv2 = CMOV(tv4, tv3, e2) # Select tv3 if (tv3^2) == x - // const e3 = Fp.equals(Fp.square(tv2), x); // 9. e3 = (tv2^2) == x - // return Fp.cmov(tv1, tv2, e3); // 10. z = CMOV(tv1, tv2, e3) # Select the sqrt from tv1 and tv2 - // } - } - - // Other cases: Tonelli-Shanks algorithm - return tonelliShanks(P); -} - -// Little-endian check for first LE bit (last BE bit); -export const isNegativeLE = (num: bigint, modulo: bigint) => (mod(num, modulo) & _1n) === _1n; - -// Field is not always over prime, Fp2 for example has ORDER(q)=p^m -export interface IField { - ORDER: bigint; - BYTES: number; - BITS: number; - MASK: bigint; - ZERO: T; - ONE: T; - // 1-arg - create: (num: T) => T; - isValid: (num: T) => boolean; - is0: (num: T) => boolean; - neg(num: T): T; - inv(num: T): T; - sqrt(num: T): T; - sqr(num: T): T; - // 2-args - eql(lhs: T, rhs: T): boolean; - add(lhs: T, rhs: T): T; - sub(lhs: T, rhs: T): T; - mul(lhs: T, rhs: T | bigint): T; - pow(lhs: T, power: bigint): T; - div(lhs: T, rhs: T | bigint): T; - // N for NonNormalized (for now) - addN(lhs: T, rhs: T): T; - subN(lhs: T, rhs: T): T; - mulN(lhs: T, rhs: T | bigint): T; - sqrN(num: T): T; - - // Optional - // Should be same as sgn0 function in https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/ - // NOTE: sgn0 is 'negative in LE', which is same as odd. And negative in LE is kinda strange definition anyway. - isOdd?(num: T): boolean; // Odd instead of even since we have it for Fp2 - // legendre?(num: T): T; - pow(lhs: T, power: bigint): T; - invertBatch: (lst: T[]) => T[]; - toBytes(num: T): Uint8Array; - fromBytes(bytes: Uint8Array): T; - // If c is False, CMOV returns a, otherwise it returns b. - cmov(a: T, b: T, c: boolean): T; -} -// prettier-ignore -const FIELD_FIELDS = [ - 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr', - 'eql', 'add', 'sub', 'mul', 'pow', 'div', - 'addN', 'subN', 'mulN', 'sqrN' -] as const; -export function validateField(field: IField) { - const initial = { - ORDER: 'bigint', - MASK: 'bigint', - BYTES: 'isSafeInteger', - BITS: 'isSafeInteger', - } as Record; - const opts = FIELD_FIELDS.reduce((map, val: string) => { - map[val] = 'function'; - return map; - }, initial); - return validateObject(field, opts); -} - -// Generic field functions -export function FpPow(f: IField, num: T, power: bigint): T { - // Should have same speed as pow for bigints - // TODO: benchmark! - if (power < _0n) throw new Error('Expected power > 0'); - if (power === _0n) return f.ONE; - if (power === _1n) return num; - let p = f.ONE; - let d = num; - while (power > _0n) { - if (power & _1n) p = f.mul(p, d); - d = f.sqr(d); - power >>= _1n; - } - return p; -} - -// 0 is non-invertible: non-batched version will throw on 0 -export function FpInvertBatch(f: IField, nums: T[]): T[] { - const tmp = new Array(nums.length); - // Walk from first to last, multiply them by each other MOD p - const lastMultiplied = nums.reduce((acc, num, i) => { - if (f.is0(num)) return acc; - tmp[i] = acc; - return f.mul(acc, num); - }, f.ONE); - // Invert last element - const inverted = f.inv(lastMultiplied); - // Walk from last to first, multiply them by inverted each other MOD p - nums.reduceRight((acc, num, i) => { - if (f.is0(num)) return acc; - tmp[i] = f.mul(acc, tmp[i]); - return f.mul(acc, num); - }, inverted); - return tmp; -} - -export function FpDiv(f: IField, lhs: T, rhs: T | bigint): T { - return f.mul(lhs, typeof rhs === 'bigint' ? invert(rhs, f.ORDER) : f.inv(rhs)); -} - -// This function returns True whenever the value x is a square in the field F. -export function FpIsSquare(f: IField) { - const legendreConst = (f.ORDER - _1n) / _2n; // Integer arithmetic - return (x: T): boolean => { - const p = f.pow(x, legendreConst); - return f.eql(p, f.ZERO) || f.eql(p, f.ONE); - }; -} - -// CURVE.n lengths -export function nLength(n: bigint, nBitLength?: number) { - // Bit size, byte size of CURVE.n - const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length; - const nByteLength = Math.ceil(_nBitLength / 8); - return { nBitLength: _nBitLength, nByteLength }; -} - -type FpField = IField & Required, 'isOdd'>>; -/** - * Initializes a galois field over prime. Non-primes are not supported for now. - * Do not init in loop: slow. Very fragile: always run a benchmark on change. - * Major performance gains: - * a) non-normalized operations like mulN instead of mul - * b) `Object.freeze` - * c) Same object shape: never add or remove keys - * @param ORDER prime positive bigint - * @param bitLen how many bits the field consumes - * @param isLE (def: false) if encoding / decoding should be in little-endian - * @param redef optional faster redefinitions of sqrt and other methods - */ -export function Field( - ORDER: bigint, - bitLen?: number, - isLE = false, - redef: Partial> = {} -): Readonly { - if (ORDER <= _0n) throw new Error(`Expected Fp ORDER > 0, got ${ORDER}`); - const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen); - if (BYTES > 2048) throw new Error('Field lengths over 2048 bytes are not supported'); - const sqrtP = FpSqrt(ORDER); - const f: Readonly = Object.freeze({ - ORDER, - BITS, - BYTES, - MASK: bitMask(BITS), - ZERO: _0n, - ONE: _1n, - create: (num) => mod(num, ORDER), - isValid: (num) => { - if (typeof num !== 'bigint') - throw new Error(`Invalid field element: expected bigint, got ${typeof num}`); - return _0n <= num && num < ORDER; // 0 is valid element, but it's not invertible - }, - is0: (num) => num === _0n, - isOdd: (num) => (num & _1n) === _1n, - neg: (num) => mod(-num, ORDER), - eql: (lhs, rhs) => lhs === rhs, - - sqr: (num) => mod(num * num, ORDER), - add: (lhs, rhs) => mod(lhs + rhs, ORDER), - sub: (lhs, rhs) => mod(lhs - rhs, ORDER), - mul: (lhs, rhs) => mod(lhs * rhs, ORDER), - pow: (num, power) => FpPow(f, num, power), - div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER), - - // Same as above, but doesn't normalize - sqrN: (num) => num * num, - addN: (lhs, rhs) => lhs + rhs, - subN: (lhs, rhs) => lhs - rhs, - mulN: (lhs, rhs) => lhs * rhs, - - inv: (num) => invert(num, ORDER), - sqrt: redef.sqrt || ((n) => sqrtP(f, n)), - invertBatch: (lst) => FpInvertBatch(f, lst), - // TODO: do we really need constant cmov? - // We don't have const-time bigints anyway, so probably will be not very useful - cmov: (a, b, c) => (c ? b : a), - toBytes: (num) => (isLE ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES)), - fromBytes: (bytes) => { - if (bytes.length !== BYTES) - throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes.length}`); - return isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes); - }, - } as FpField); - return Object.freeze(f); -} - -export function FpSqrtOdd(Fp: IField, elm: T) { - if (!Fp.isOdd) throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? root : Fp.neg(root); -} - -export function FpSqrtEven(Fp: IField, elm: T) { - if (!Fp.isOdd) throw new Error(`Field doesn't have isOdd`); - const root = Fp.sqrt(elm); - return Fp.isOdd(root) ? Fp.neg(root) : root; -} - -/** - * FIPS 186 B.4.1-compliant "constant-time" private key generation utility. - * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF - * and convert them into private scalar, with the modulo bias being negligible. - * Needs at least 40 bytes of input for 32-byte private key. - * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ - * @param hash hash output from SHA3 or a similar function - * @param groupOrder size of subgroup - (e.g. curveFn.CURVE.n) - * @param isLE interpret hash bytes as LE num - * @returns valid private scalar - */ -export function hashToPrivateScalar( - hash: string | Uint8Array, - groupOrder: bigint, - isLE = false -): bigint { - hash = ensureBytes('privateHash', hash); - const hashLen = hash.length; - const minLen = nLength(groupOrder).nByteLength + 8; - if (minLen < 24 || hashLen < minLen || hashLen > 1024) - throw new Error(`hashToPrivateScalar: expected ${minLen}-1024 bytes of input, got ${hashLen}`); - const num = isLE ? bytesToNumberLE(hash) : bytesToNumberBE(hash); - return mod(num, groupOrder - _1n) + _1n; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/montgomery.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/montgomery.ts deleted file mode 100644 index 64d1b531..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/montgomery.ts +++ /dev/null @@ -1,189 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { mod, pow } from './modular.js'; -import { bytesToNumberLE, ensureBytes, numberToBytesLE, validateObject } from './utils.js'; - -const _0n = BigInt(0); -const _1n = BigInt(1); -type Hex = string | Uint8Array; - -export type CurveType = { - P: bigint; // finite field prime - nByteLength: number; - adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array; - domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array; - a: bigint; - montgomeryBits: number; - powPminus2?: (x: bigint) => bigint; - xyToU?: (x: bigint, y: bigint) => bigint; - Gu: bigint; - randomBytes?: (bytesLength?: number) => Uint8Array; -}; -export type CurveFn = { - scalarMult: (scalar: Hex, u: Hex) => Uint8Array; - scalarMultBase: (scalar: Hex) => Uint8Array; - getSharedSecret: (privateKeyA: Hex, publicKeyB: Hex) => Uint8Array; - getPublicKey: (privateKey: Hex) => Uint8Array; - utils: { randomPrivateKey: () => Uint8Array }; - GuBytes: Uint8Array; -}; - -function validateOpts(curve: CurveType) { - validateObject( - curve, - { - a: 'bigint', - }, - { - montgomeryBits: 'isSafeInteger', - nByteLength: 'isSafeInteger', - adjustScalarBytes: 'function', - domain: 'function', - powPminus2: 'function', - Gu: 'bigint', - } - ); - // Set defaults - return Object.freeze({ ...curve } as const); -} - -// NOTE: not really montgomery curve, just bunch of very specific methods for X25519/X448 (RFC 7748, https://www.rfc-editor.org/rfc/rfc7748) -// Uses only one coordinate instead of two -export function montgomery(curveDef: CurveType): CurveFn { - const CURVE = validateOpts(curveDef); - const { P } = CURVE; - const modP = (n: bigint) => mod(n, P); - const montgomeryBits = CURVE.montgomeryBits; - const montgomeryBytes = Math.ceil(montgomeryBits / 8); - const fieldLen = CURVE.nByteLength; - const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes: Uint8Array) => bytes); - const powPminus2 = CURVE.powPminus2 || ((x: bigint) => pow(x, P - BigInt(2), P)); - - // cswap from RFC7748. But it is not from RFC7748! - /* - cswap(swap, x_2, x_3): - dummy = mask(swap) AND (x_2 XOR x_3) - x_2 = x_2 XOR dummy - x_3 = x_3 XOR dummy - Return (x_2, x_3) - Where mask(swap) is the all-1 or all-0 word of the same length as x_2 - and x_3, computed, e.g., as mask(swap) = 0 - swap. - */ - function cswap(swap: bigint, x_2: bigint, x_3: bigint): [bigint, bigint] { - const dummy = modP(swap * (x_2 - x_3)); - x_2 = modP(x_2 - dummy); - x_3 = modP(x_3 + dummy); - return [x_2, x_3]; - } - - // Accepts 0 as well - function assertFieldElement(n: bigint): bigint { - if (typeof n === 'bigint' && _0n <= n && n < P) return n; - throw new Error('Expected valid scalar 0 < scalar < CURVE.P'); - } - - // x25519 from 4 - // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519 - const a24 = (CURVE.a - BigInt(2)) / BigInt(4); - /** - * - * @param pointU u coordinate (x) on Montgomery Curve 25519 - * @param scalar by which the point would be multiplied - * @returns new Point on Montgomery curve - */ - function montgomeryLadder(pointU: bigint, scalar: bigint): bigint { - const u = assertFieldElement(pointU); - // Section 5: Implementations MUST accept non-canonical values and process them as - // if they had been reduced modulo the field prime. - const k = assertFieldElement(scalar); - const x_1 = u; - let x_2 = _1n; - let z_2 = _0n; - let x_3 = u; - let z_3 = _1n; - let swap = _0n; - let sw: [bigint, bigint]; - for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) { - const k_t = (k >> t) & _1n; - swap ^= k_t; - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - swap = k_t; - - const A = x_2 + z_2; - const AA = modP(A * A); - const B = x_2 - z_2; - const BB = modP(B * B); - const E = AA - BB; - const C = x_3 + z_3; - const D = x_3 - z_3; - const DA = modP(D * A); - const CB = modP(C * B); - const dacb = DA + CB; - const da_cb = DA - CB; - x_3 = modP(dacb * dacb); - z_3 = modP(x_1 * modP(da_cb * da_cb)); - x_2 = modP(AA * BB); - z_2 = modP(E * (AA + modP(a24 * E))); - } - // (x_2, x_3) = cswap(swap, x_2, x_3) - sw = cswap(swap, x_2, x_3); - x_2 = sw[0]; - x_3 = sw[1]; - // (z_2, z_3) = cswap(swap, z_2, z_3) - sw = cswap(swap, z_2, z_3); - z_2 = sw[0]; - z_3 = sw[1]; - // z_2^(p - 2) - const z2 = powPminus2(z_2); - // Return x_2 * (z_2^(p - 2)) - return modP(x_2 * z2); - } - - function encodeUCoordinate(u: bigint): Uint8Array { - return numberToBytesLE(modP(u), montgomeryBytes); - } - - function decodeUCoordinate(uEnc: Hex): bigint { - // Section 5: When receiving such an array, implementations of X25519 - // MUST mask the most significant bit in the final byte. - // This is very ugly way, but it works because fieldLen-1 is outside of bounds for X448, so this becomes NOOP - // fieldLen - scalaryBytes = 1 for X448 and = 0 for X25519 - const u = ensureBytes('u coordinate', uEnc, montgomeryBytes); - // u[fieldLen-1] crashes QuickJS (TypeError: out-of-bound numeric index) - if (fieldLen === montgomeryBytes) u[fieldLen - 1] &= 127; // 0b0111_1111 - return bytesToNumberLE(u); - } - function decodeScalar(n: Hex): bigint { - const bytes = ensureBytes('scalar', n); - if (bytes.length !== montgomeryBytes && bytes.length !== fieldLen) - throw new Error(`Expected ${montgomeryBytes} or ${fieldLen} bytes, got ${bytes.length}`); - return bytesToNumberLE(adjustScalarBytes(bytes)); - } - function scalarMult(scalar: Hex, u: Hex): Uint8Array { - const pointU = decodeUCoordinate(u); - const _scalar = decodeScalar(scalar); - const pu = montgomeryLadder(pointU, _scalar); - // The result was not contributory - // https://cr.yp.to/ecdh.html#validate - if (pu === _0n) throw new Error('Invalid private or public key received'); - return encodeUCoordinate(pu); - } - // Computes public key from private. By doing scalar multiplication of base point. - const GuBytes = encodeUCoordinate(CURVE.Gu); - function scalarMultBase(scalar: Hex): Uint8Array { - return scalarMult(scalar, GuBytes); - } - - return { - scalarMult, - scalarMultBase, - getSharedSecret: (privateKey: Hex, publicKey: Hex) => scalarMult(privateKey, publicKey), - getPublicKey: (privateKey: Hex): Uint8Array => scalarMultBase(privateKey), - utils: { randomPrivateKey: () => CURVE.randomBytes!(CURVE.nByteLength) }, - GuBytes: GuBytes, - }; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/poseidon.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/poseidon.ts deleted file mode 100644 index 38ab17d7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/poseidon.ts +++ /dev/null @@ -1,119 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Poseidon Hash: https://eprint.iacr.org/2019/458.pdf, https://www.poseidon-hash.info -import { IField, FpPow, validateField } from './modular.js'; -// We don't provide any constants, since different implementations use different constants. -// For reference constants see './test/poseidon.test.js'. -export type PoseidonOpts = { - Fp: IField; - t: number; - roundsFull: number; - roundsPartial: number; - sboxPower?: number; - reversePartialPowIdx?: boolean; // Hack for stark - mds: bigint[][]; - roundConstants: bigint[][]; -}; - -export function validateOpts(opts: PoseidonOpts) { - const { Fp } = opts; - validateField(Fp); - for (const i of ['t', 'roundsFull', 'roundsPartial'] as const) { - if (typeof opts[i] !== 'number' || !Number.isSafeInteger(opts[i])) - throw new Error(`Poseidon: invalid param ${i}=${opts[i]} (${typeof opts[i]})`); - } - if (opts.reversePartialPowIdx !== undefined && typeof opts.reversePartialPowIdx !== 'boolean') - throw new Error(`Poseidon: invalid param reversePartialPowIdx=${opts.reversePartialPowIdx}`); - // Default is 5, but by some reasons stark uses 3 - let sboxPower = opts.sboxPower; - if (sboxPower === undefined) sboxPower = 5; - if (typeof sboxPower !== 'number' || !Number.isSafeInteger(sboxPower)) - throw new Error(`Poseidon wrong sboxPower=${sboxPower}`); - - const _sboxPower = BigInt(sboxPower); - let sboxFn = (n: bigint) => FpPow(Fp, n, _sboxPower); - // Unwrapped sbox power for common cases (195->142μs) - if (sboxPower === 3) sboxFn = (n: bigint) => Fp.mul(Fp.sqrN(n), n); - else if (sboxPower === 5) sboxFn = (n: bigint) => Fp.mul(Fp.sqrN(Fp.sqrN(n)), n); - - if (opts.roundsFull % 2 !== 0) - throw new Error(`Poseidon roundsFull is not even: ${opts.roundsFull}`); - const rounds = opts.roundsFull + opts.roundsPartial; - - if (!Array.isArray(opts.roundConstants) || opts.roundConstants.length !== rounds) - throw new Error('Poseidon: wrong round constants'); - const roundConstants = opts.roundConstants.map((rc) => { - if (!Array.isArray(rc) || rc.length !== opts.t) - throw new Error(`Poseidon wrong round constants: ${rc}`); - return rc.map((i) => { - if (typeof i !== 'bigint' || !Fp.isValid(i)) - throw new Error(`Poseidon wrong round constant=${i}`); - return Fp.create(i); - }); - }); - // MDS is TxT matrix - if (!Array.isArray(opts.mds) || opts.mds.length !== opts.t) - throw new Error('Poseidon: wrong MDS matrix'); - const mds = opts.mds.map((mdsRow) => { - if (!Array.isArray(mdsRow) || mdsRow.length !== opts.t) - throw new Error(`Poseidon MDS matrix row: ${mdsRow}`); - return mdsRow.map((i) => { - if (typeof i !== 'bigint') throw new Error(`Poseidon MDS matrix value=${i}`); - return Fp.create(i); - }); - }); - return Object.freeze({ ...opts, rounds, sboxFn, roundConstants, mds }); -} - -export function splitConstants(rc: bigint[], t: number) { - if (typeof t !== 'number') throw new Error('poseidonSplitConstants: wrong t'); - if (!Array.isArray(rc) || rc.length % t) throw new Error('poseidonSplitConstants: wrong rc'); - const res = []; - let tmp = []; - for (let i = 0; i < rc.length; i++) { - tmp.push(rc[i]); - if (tmp.length === t) { - res.push(tmp); - tmp = []; - } - } - return res; -} - -export function poseidon(opts: PoseidonOpts) { - const { t, Fp, rounds, sboxFn, reversePartialPowIdx } = validateOpts(opts); - const halfRoundsFull = Math.floor(opts.roundsFull / 2); - const partialIdx = reversePartialPowIdx ? t - 1 : 0; - const poseidonRound = (values: bigint[], isFull: boolean, idx: number) => { - values = values.map((i, j) => Fp.add(i, opts.roundConstants[idx][j])); - - if (isFull) values = values.map((i) => sboxFn(i)); - else values[partialIdx] = sboxFn(values[partialIdx]); - // Matrix multiplication - values = opts.mds.map((i) => - i.reduce((acc, i, j) => Fp.add(acc, Fp.mulN(i, values[j])), Fp.ZERO) - ); - return values; - }; - const poseidonHash = function poseidonHash(values: bigint[]) { - if (!Array.isArray(values) || values.length !== t) - throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`); - values = values.map((i) => { - if (typeof i !== 'bigint') throw new Error(`Poseidon: wrong value=${i} (${typeof i})`); - return Fp.create(i); - }); - let round = 0; - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) values = poseidonRound(values, true, round++); - // Apply r_p partial rounds. - for (let i = 0; i < opts.roundsPartial; i++) values = poseidonRound(values, false, round++); - // Apply r_f/2 full rounds. - for (let i = 0; i < halfRoundsFull; i++) values = poseidonRound(values, true, round++); - - if (round !== rounds) - throw new Error(`Poseidon: wrong number of rounds: last round=${round}, total=${rounds}`); - return values; - }; - // For verification in tests - poseidonHash.roundConstants = opts.roundConstants; - return poseidonHash; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/utils.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/utils.ts deleted file mode 100644 index 00fc18f3..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/utils.ts +++ /dev/null @@ -1,287 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// 100 lines of code in the file are duplicated from noble-hashes (utils). -// This is OK: `abstract` directory does not use noble-hashes. -// User may opt-in into using different hashing library. This way, noble-hashes -// won't be included into their bundle. -const _0n = BigInt(0); -const _1n = BigInt(1); -const _2n = BigInt(2); -const u8a = (a: any): a is Uint8Array => a instanceof Uint8Array; -export type Hex = Uint8Array | string; // hex strings are accepted for simplicity -export type PrivKey = Hex | bigint; // bigints are accepted to ease learning curve -export type CHash = { - (message: Uint8Array | string): Uint8Array; - blockLen: number; - outputLen: number; - create(opts?: { dkLen?: number }): any; // For shake -}; -export type FHash = (message: Uint8Array | string) => Uint8Array; - -const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0')); -/** - * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' - */ -export function bytesToHex(bytes: Uint8Array): string { - if (!u8a(bytes)) throw new Error('Uint8Array expected'); - // pre-caching improves the speed 6x - let hex = ''; - for (let i = 0; i < bytes.length; i++) { - hex += hexes[bytes[i]]; - } - return hex; -} - -export function numberToHexUnpadded(num: number | bigint): string { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; -} - -export function hexToNumber(hex: string): bigint { - if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); - // Big Endian - return BigInt(hex === '' ? '0' : `0x${hex}`); -} - -/** - * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) - */ -export function hexToBytes(hex: string): Uint8Array { - if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); - const len = hex.length; - if (len % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + len); - const array = new Uint8Array(len / 2); - for (let i = 0; i < array.length; i++) { - const j = i * 2; - const hexByte = hex.slice(j, j + 2); - const byte = Number.parseInt(hexByte, 16); - if (Number.isNaN(byte) || byte < 0) throw new Error('Invalid byte sequence'); - array[i] = byte; - } - return array; -} - -// BE: Big Endian, LE: Little Endian -export function bytesToNumberBE(bytes: Uint8Array): bigint { - return hexToNumber(bytesToHex(bytes)); -} -export function bytesToNumberLE(bytes: Uint8Array): bigint { - if (!u8a(bytes)) throw new Error('Uint8Array expected'); - return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); -} - -export function numberToBytesBE(n: number | bigint, len: number): Uint8Array { - return hexToBytes(n.toString(16).padStart(len * 2, '0')); -} -export function numberToBytesLE(n: number | bigint, len: number): Uint8Array { - return numberToBytesBE(n, len).reverse(); -} -// Unpadded, rarely used -export function numberToVarBytesBE(n: number | bigint): Uint8Array { - return hexToBytes(numberToHexUnpadded(n)); -} - -/** - * Takes hex string or Uint8Array, converts to Uint8Array. - * Validates output length. - * Will throw error for other types. - * @param title descriptive title for an error e.g. 'private key' - * @param hex hex string or Uint8Array - * @param expectedLength optional, will compare to result array's length - * @returns - */ -export function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array { - let res: Uint8Array; - if (typeof hex === 'string') { - try { - res = hexToBytes(hex); - } catch (e) { - throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`); - } - } else if (u8a(hex)) { - // Uint8Array.from() instead of hash.slice() because node.js Buffer - // is instance of Uint8Array, and its slice() creates **mutable** copy - res = Uint8Array.from(hex); - } else { - throw new Error(`${title} must be hex string or Uint8Array`); - } - const len = res.length; - if (typeof expectedLength === 'number' && len !== expectedLength) - throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`); - return res; -} - -/** - * Copies several Uint8Arrays into one. - */ -export function concatBytes(...arrays: Uint8Array[]): Uint8Array { - const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0)); - let pad = 0; // walk through each item, ensure they have proper type - arrays.forEach((a) => { - if (!u8a(a)) throw new Error('Uint8Array expected'); - r.set(a, pad); - pad += a.length; - }); - return r; -} - -export function equalBytes(b1: Uint8Array, b2: Uint8Array) { - // We don't care about timing attacks here - if (b1.length !== b2.length) return false; - for (let i = 0; i < b1.length; i++) if (b1[i] !== b2[i]) return false; - return true; -} - -// Global symbols in both browsers and Node.js since v11 -// See https://github.com/microsoft/TypeScript/issues/31535 -declare const TextEncoder: any; - -/** - * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) - */ -export function utf8ToBytes(str: string): Uint8Array { - if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`); - return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 -} - -// Bit operations - -/** - * Calculates amount of bits in a bigint. - * Same as `n.toString(2).length` - */ -export function bitLen(n: bigint) { - let len; - for (len = 0; n > _0n; n >>= _1n, len += 1); - return len; -} - -/** - * Gets single bit at position. - * NOTE: first bit position is 0 (same as arrays) - * Same as `!!+Array.from(n.toString(2)).reverse()[pos]` - */ -export function bitGet(n: bigint, pos: number) { - return (n >> BigInt(pos)) & _1n; -} - -/** - * Sets single bit at position. - */ -export const bitSet = (n: bigint, pos: number, value: boolean) => { - return n | ((value ? _1n : _0n) << BigInt(pos)); -}; - -/** - * Calculate mask for N bits. Not using ** operator with bigints because of old engines. - * Same as BigInt(`0b${Array(i).fill('1').join('')}`) - */ -export const bitMask = (n: number) => (_2n << BigInt(n - 1)) - _1n; - -// DRBG - -const u8n = (data?: any) => new Uint8Array(data); // creates Uint8Array -const u8fr = (arr: any) => Uint8Array.from(arr); // another shortcut -type Pred = (v: Uint8Array) => T | undefined; -/** - * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - * @returns function that will call DRBG until 2nd arg returns something meaningful - * @example - * const drbg = createHmacDRBG(32, 32, hmac); - * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined - */ -export function createHmacDrbg( - hashLen: number, - qByteLen: number, - hmacFn: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array -): (seed: Uint8Array, predicate: Pred) => T { - if (typeof hashLen !== 'number' || hashLen < 2) throw new Error('hashLen must be a number'); - if (typeof qByteLen !== 'number' || qByteLen < 2) throw new Error('qByteLen must be a number'); - if (typeof hmacFn !== 'function') throw new Error('hmacFn must be a function'); - // Step B, Step C: set hashLen to 8*ceil(hlen/8) - let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs. - let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same - let i = 0; // Iterations counter, will throw when over 1000 - const reset = () => { - v.fill(1); - k.fill(0); - i = 0; - }; - const h = (...b: Uint8Array[]) => hmacFn(k, v, ...b); // hmac(k)(v, ...values) - const reseed = (seed = u8n()) => { - // HMAC-DRBG reseed() function. Steps D-G - k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed) - v = h(); // v = hmac(k || v) - if (seed.length === 0) return; - k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed) - v = h(); // v = hmac(k || v) - }; - const gen = () => { - // HMAC-DRBG generate() function - if (i++ >= 1000) throw new Error('drbg: tried 1000 values'); - let len = 0; - const out: Uint8Array[] = []; - while (len < qByteLen) { - v = h(); - const sl = v.slice(); - out.push(sl); - len += v.length; - } - return concatBytes(...out); - }; - const genUntil = (seed: Uint8Array, pred: Pred): T => { - reset(); - reseed(seed); // Steps D-G - let res: T | undefined = undefined; // Step H: grind until k is in [1..n-1] - while (!(res = pred(gen()))) reseed(); - reset(); - return res; - }; - return genUntil; -} - -// Validating curves and fields - -const validatorFns = { - bigint: (val: any) => typeof val === 'bigint', - function: (val: any) => typeof val === 'function', - boolean: (val: any) => typeof val === 'boolean', - string: (val: any) => typeof val === 'string', - isSafeInteger: (val: any) => Number.isSafeInteger(val), - array: (val: any) => Array.isArray(val), - field: (val: any, object: any) => (object as any).Fp.isValid(val), - hash: (val: any) => typeof val === 'function' && Number.isSafeInteger(val.outputLen), -} as const; -type Validator = keyof typeof validatorFns; -type ValMap> = { [K in keyof T]?: Validator }; -// type Record = { [P in K]: T; } - -export function validateObject>( - object: T, - validators: ValMap, - optValidators: ValMap = {} -) { - const checkField = (fieldName: keyof T, type: Validator, isOptional: boolean) => { - const checkVal = validatorFns[type]; - if (typeof checkVal !== 'function') - throw new Error(`Invalid validator "${type}", expected function`); - - const val = object[fieldName as keyof typeof object]; - if (isOptional && val === undefined) return; - if (!checkVal(val, object)) { - throw new Error( - `Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}` - ); - } - }; - for (const [fieldName, type] of Object.entries(validators)) checkField(fieldName, type!, false); - for (const [fieldName, type] of Object.entries(optValidators)) checkField(fieldName, type!, true); - return object; -} -// validate type tests -// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 }; -// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok! -// // Should fail type-check -// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' }); -// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' }); -// const z3 = validateObject(o, { test: 'boolean', z: 'bug' }); -// const z4 = validateObject(o, { a: 'boolean', z: 'bug' }); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/weierstrass.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/weierstrass.ts deleted file mode 100644 index 5981ca4e..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/abstract/weierstrass.ts +++ /dev/null @@ -1,1220 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -// Short Weierstrass curve. The formula is: y² = x³ + ax + b -import * as mod from './modular.js'; -import * as ut from './utils.js'; -import { CHash, Hex, PrivKey, ensureBytes } from './utils.js'; -import { Group, GroupConstructor, wNAF, BasicCurve, validateBasic, AffinePoint } from './curve.js'; - -export type { AffinePoint }; -type HmacFnSync = (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array; -type EndomorphismOpts = { - beta: bigint; - splitScalar: (k: bigint) => { k1neg: boolean; k1: bigint; k2neg: boolean; k2: bigint }; -}; -export type BasicWCurve = BasicCurve & { - // Params: a, b - a: T; - b: T; - - // Optional params - allowedPrivateKeyLengths?: readonly number[]; // for P521 - wrapPrivateKey?: boolean; // bls12-381 requires mod(n) instead of rejecting keys >= n - endo?: EndomorphismOpts; // Endomorphism options for Koblitz curves - // When a cofactor != 1, there can be an effective methods to: - // 1. Determine whether a point is torsion-free - isTorsionFree?: (c: ProjConstructor, point: ProjPointType) => boolean; - // 2. Clear torsion component - clearCofactor?: (c: ProjConstructor, point: ProjPointType) => ProjPointType; -}; - -type Entropy = Hex | true; -export type SignOpts = { lowS?: boolean; extraEntropy?: Entropy; prehash?: boolean }; -export type VerOpts = { lowS?: boolean; prehash?: boolean }; - -/** - * ### Design rationale for types - * - * * Interaction between classes from different curves should fail: - * `k256.Point.BASE.add(p256.Point.BASE)` - * * For this purpose we want to use `instanceof` operator, which is fast and works during runtime - * * Different calls of `curve()` would return different classes - - * `curve(params) !== curve(params)`: if somebody decided to monkey-patch their curve, - * it won't affect others - * - * TypeScript can't infer types for classes created inside a function. Classes is one instance of nominative types in TypeScript and interfaces only check for shape, so it's hard to create unique type for every function call. - * - * We can use generic types via some param, like curve opts, but that would: - * 1. Enable interaction between `curve(params)` and `curve(params)` (curves of same params) - * which is hard to debug. - * 2. Params can be generic and we can't enforce them to be constant value: - * if somebody creates curve from non-constant params, - * it would be allowed to interact with other curves with non-constant params - * - * TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol - */ - -// Instance for 3d XYZ points -export interface ProjPointType extends Group> { - readonly px: T; - readonly py: T; - readonly pz: T; - get x(): T; - get y(): T; - multiply(scalar: bigint): ProjPointType; - toAffine(iz?: T): AffinePoint; - isTorsionFree(): boolean; - clearCofactor(): ProjPointType; - assertValidity(): void; - hasEvenY(): boolean; - toRawBytes(isCompressed?: boolean): Uint8Array; - toHex(isCompressed?: boolean): string; - - multiplyUnsafe(scalar: bigint): ProjPointType; - multiplyAndAddUnsafe(Q: ProjPointType, a: bigint, b: bigint): ProjPointType | undefined; - _setWindowSize(windowSize: number): void; -} -// Static methods for 3d XYZ points -export interface ProjConstructor extends GroupConstructor> { - new (x: T, y: T, z: T): ProjPointType; - fromAffine(p: AffinePoint): ProjPointType; - fromHex(hex: Hex): ProjPointType; - fromPrivateKey(privateKey: PrivKey): ProjPointType; - normalizeZ(points: ProjPointType[]): ProjPointType[]; -} - -export type CurvePointsType = BasicWCurve & { - // Bytes - fromBytes?: (bytes: Uint8Array) => AffinePoint; - toBytes?: (c: ProjConstructor, point: ProjPointType, isCompressed: boolean) => Uint8Array; -}; - -function validatePointOpts(curve: CurvePointsType) { - const opts = validateBasic(curve); - ut.validateObject( - opts, - { - a: 'field', - b: 'field', - }, - { - allowedPrivateKeyLengths: 'array', - wrapPrivateKey: 'boolean', - isTorsionFree: 'function', - clearCofactor: 'function', - allowInfinityPoint: 'boolean', - fromBytes: 'function', - toBytes: 'function', - } - ); - const { endo, Fp, a } = opts; - if (endo) { - if (!Fp.eql(a, Fp.ZERO)) { - throw new Error('Endomorphism can only be defined for Koblitz curves that have a=0'); - } - if ( - typeof endo !== 'object' || - typeof endo.beta !== 'bigint' || - typeof endo.splitScalar !== 'function' - ) { - throw new Error('Expected endomorphism with beta: bigint and splitScalar: function'); - } - } - return Object.freeze({ ...opts } as const); -} - -export type CurvePointsRes = { - ProjectivePoint: ProjConstructor; - normPrivateKeyToScalar: (key: PrivKey) => bigint; - weierstrassEquation: (x: T) => T; - isWithinCurveOrder: (num: bigint) => boolean; -}; - -// ASN.1 DER encoding utilities -const { bytesToNumberBE: b2n, hexToBytes: h2b } = ut; -export const DER = { - // asn.1 DER encoding utils - Err: class DERErr extends Error { - constructor(m = '') { - super(m); - } - }, - _parseInt(data: Uint8Array): { d: bigint; l: Uint8Array } { - const { Err: E } = DER; - if (data.length < 2 || data[0] !== 0x02) throw new E('Invalid signature integer tag'); - const len = data[1]; - const res = data.subarray(2, len + 2); - if (!len || res.length !== len) throw new E('Invalid signature integer: wrong length'); - // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, - // since we always use positive integers here. It must always be empty: - // - add zero byte if exists - // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) - if (res[0] & 0b10000000) throw new E('Invalid signature integer: negative'); - if (res[0] === 0x00 && !(res[1] & 0b10000000)) - throw new E('Invalid signature integer: unnecessary leading zero'); - return { d: b2n(res), l: data.subarray(len + 2) }; // d is data, l is left - }, - toSig(hex: string | Uint8Array): { r: bigint; s: bigint } { - // parse DER signature - const { Err: E } = DER; - const data = typeof hex === 'string' ? h2b(hex) : hex; - if (!(data instanceof Uint8Array)) throw new Error('ui8a expected'); - let l = data.length; - if (l < 2 || data[0] != 0x30) throw new E('Invalid signature tag'); - if (data[1] !== l - 2) throw new E('Invalid signature: incorrect length'); - const { d: r, l: sBytes } = DER._parseInt(data.subarray(2)); - const { d: s, l: rBytesLeft } = DER._parseInt(sBytes); - if (rBytesLeft.length) throw new E('Invalid signature: left bytes after parsing'); - return { r, s }; - }, - hexFromSig(sig: { r: bigint; s: bigint }): string { - // Add leading zero if first byte has negative bit enabled. More details in '_parseInt' - const slice = (s: string): string => (Number.parseInt(s[0], 16) & 0b1000 ? '00' + s : s); - const h = (num: number | bigint) => { - const hex = num.toString(16); - return hex.length & 1 ? `0${hex}` : hex; - }; - const s = slice(h(sig.s)); - const r = slice(h(sig.r)); - const shl = s.length / 2; - const rhl = r.length / 2; - const sl = h(shl); - const rl = h(rhl); - return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`; - }, -}; - -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); - -export function weierstrassPoints(opts: CurvePointsType) { - const CURVE = validatePointOpts(opts); - const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ - - const toBytes = - CURVE.toBytes || - ((c: ProjConstructor, point: ProjPointType, isCompressed: boolean) => { - const a = point.toAffine(); - return ut.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y)); - }); - const fromBytes = - CURVE.fromBytes || - ((bytes: Uint8Array) => { - // const head = bytes[0]; - const tail = bytes.subarray(1); - // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported'); - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - }); - - /** - * y² = x³ + ax + b: Short weierstrass curve formula - * @returns y² - */ - function weierstrassEquation(x: T): T { - const { a, b } = CURVE; - const x2 = Fp.sqr(x); // x * x - const x3 = Fp.mul(x2, x); // x2 * x - return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b - } - // Validate whether the passed curve params are valid. - // We check if curve equation works for generator point. - // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381. - // ProjectivePoint class has not been initialized yet. - if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx))) - throw new Error('bad generator point: equation left != right'); - - // Valid group elements reside in range 1..n-1 - function isWithinCurveOrder(num: bigint): boolean { - return typeof num === 'bigint' && _0n < num && num < CURVE.n; - } - function assertGE(num: bigint) { - if (!isWithinCurveOrder(num)) throw new Error('Expected valid bigint: 0 < bigint < curve.n'); - } - // Validates if priv key is valid and converts it to bigint. - // Supports options allowedPrivateKeyLengths and wrapPrivateKey. - function normPrivateKeyToScalar(key: PrivKey): bigint { - const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE; - if (lengths && typeof key !== 'bigint') { - if (key instanceof Uint8Array) key = ut.bytesToHex(key); - // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes - if (typeof key !== 'string' || !lengths.includes(key.length)) throw new Error('Invalid key'); - key = key.padStart(nByteLength * 2, '0'); - } - let num: bigint; - try { - num = - typeof key === 'bigint' - ? key - : ut.bytesToNumberBE(ensureBytes('private key', key, nByteLength)); - } catch (error) { - throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`); - } - if (wrapPrivateKey) num = mod.mod(num, n); // disabled by default, enabled for BLS - assertGE(num); // num in range [1..N-1] - return num; - } - - const pointPrecomputes = new Map(); - function assertPrjPoint(other: unknown) { - if (!(other instanceof Point)) throw new Error('ProjectivePoint expected'); - } - /** - * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z) - * Default Point works in 2d / affine coordinates: (x, y) - * We're doing calculations in projective, because its operations don't require costly inversion. - */ - class Point implements ProjPointType { - static readonly BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE); - static readonly ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO); - - constructor(readonly px: T, readonly py: T, readonly pz: T) { - if (px == null || !Fp.isValid(px)) throw new Error('x required'); - if (py == null || !Fp.isValid(py)) throw new Error('y required'); - if (pz == null || !Fp.isValid(pz)) throw new Error('z required'); - } - - // Does not validate if the point is on-curve. - // Use fromHex instead, or call assertValidity() later. - static fromAffine(p: AffinePoint): Point { - const { x, y } = p || {}; - if (!p || !Fp.isValid(x) || !Fp.isValid(y)) throw new Error('invalid affine point'); - if (p instanceof Point) throw new Error('projective point not allowed'); - const is0 = (i: T) => Fp.eql(i, Fp.ZERO); - // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0) - if (is0(x) && is0(y)) return Point.ZERO; - return new Point(x, y, Fp.ONE); - } - - get x(): T { - return this.toAffine().x; - } - get y(): T { - return this.toAffine().y; - } - - /** - * Takes a bunch of Projective Points but executes only one - * inversion on all of them. Inversion is very slow operation, - * so this improves performance massively. - * Optimization: converts a list of projective points to a list of identical points with Z=1. - */ - static normalizeZ(points: Point[]): Point[] { - const toInv = Fp.invertBatch(points.map((p) => p.pz)); - return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - } - - /** - * Converts hash string or Uint8Array to Point. - * @param hex short/long ECDSA hex - */ - static fromHex(hex: Hex): Point { - const P = Point.fromAffine(fromBytes(ensureBytes('pointHex', hex))); - P.assertValidity(); - return P; - } - - // Multiplies generator point by privateKey. - static fromPrivateKey(privateKey: PrivKey) { - return Point.BASE.multiply(normPrivateKeyToScalar(privateKey)); - } - - // We calculate precomputes for elliptic curve point multiplication - // using windowed method. This specifies window size and - // stores precomputed values. Usually only base point would be precomputed. - _WINDOW_SIZE?: number; - - // "Private method", don't use it directly - _setWindowSize(windowSize: number) { - this._WINDOW_SIZE = windowSize; - pointPrecomputes.delete(this); - } - - // A point on curve is valid if it conforms to equation. - assertValidity(): void { - // Zero is valid point too! - if (this.is0()) { - if (CURVE.allowInfinityPoint) return; - throw new Error('bad point: ZERO'); - } - // Some 3rd-party test vectors require different wording between here & `fromCompressedHex` - const { x, y } = this.toAffine(); - // Check if x, y are valid field elements - if (!Fp.isValid(x) || !Fp.isValid(y)) throw new Error('bad point: x or y not FE'); - const left = Fp.sqr(y); // y² - const right = weierstrassEquation(x); // x³ + ax + b - if (!Fp.eql(left, right)) throw new Error('bad point: equation left != right'); - if (!this.isTorsionFree()) throw new Error('bad point: not in prime-order subgroup'); - } - hasEvenY(): boolean { - const { y } = this.toAffine(); - if (Fp.isOdd) return !Fp.isOdd(y); - throw new Error("Field doesn't support isOdd"); - } - - /** - * Compare one point to another. - */ - equals(other: Point): boolean { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1)); - const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1)); - return U1 && U2; - } - - /** - * Flips point to one corresponding to (x, -y) in Affine coordinates. - */ - negate(): Point { - return new Point(this.px, Fp.neg(this.py), this.pz); - } - - // Renes-Costello-Batina exception-free doubling formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 3 - // Cost: 8M + 3S + 3*a + 2*b3 + 15add. - double() { - const { a, b } = CURVE; - const b3 = Fp.mul(b, _3n); - const { px: X1, py: Y1, pz: Z1 } = this; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - let t0 = Fp.mul(X1, X1); // step 1 - let t1 = Fp.mul(Y1, Y1); - let t2 = Fp.mul(Z1, Z1); - let t3 = Fp.mul(X1, Y1); - t3 = Fp.add(t3, t3); // step 5 - Z3 = Fp.mul(X1, Z1); - Z3 = Fp.add(Z3, Z3); - X3 = Fp.mul(a, Z3); - Y3 = Fp.mul(b3, t2); - Y3 = Fp.add(X3, Y3); // step 10 - X3 = Fp.sub(t1, Y3); - Y3 = Fp.add(t1, Y3); - Y3 = Fp.mul(X3, Y3); - X3 = Fp.mul(t3, X3); - Z3 = Fp.mul(b3, Z3); // step 15 - t2 = Fp.mul(a, t2); - t3 = Fp.sub(t0, t2); - t3 = Fp.mul(a, t3); - t3 = Fp.add(t3, Z3); - Z3 = Fp.add(t0, t0); // step 20 - t0 = Fp.add(Z3, t0); - t0 = Fp.add(t0, t2); - t0 = Fp.mul(t0, t3); - Y3 = Fp.add(Y3, t0); - t2 = Fp.mul(Y1, Z1); // step 25 - t2 = Fp.add(t2, t2); - t0 = Fp.mul(t2, t3); - X3 = Fp.sub(X3, t0); - Z3 = Fp.mul(t2, t1); - Z3 = Fp.add(Z3, Z3); // step 30 - Z3 = Fp.add(Z3, Z3); - return new Point(X3, Y3, Z3); - } - - // Renes-Costello-Batina exception-free addition formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 1 - // Cost: 12M + 0S + 3*a + 3*b3 + 23add. - add(other: Point): Point { - assertPrjPoint(other); - const { px: X1, py: Y1, pz: Z1 } = this; - const { px: X2, py: Y2, pz: Z2 } = other; - let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore - const a = CURVE.a; - const b3 = Fp.mul(CURVE.b, _3n); - let t0 = Fp.mul(X1, X2); // step 1 - let t1 = Fp.mul(Y1, Y2); - let t2 = Fp.mul(Z1, Z2); - let t3 = Fp.add(X1, Y1); - let t4 = Fp.add(X2, Y2); // step 5 - t3 = Fp.mul(t3, t4); - t4 = Fp.add(t0, t1); - t3 = Fp.sub(t3, t4); - t4 = Fp.add(X1, Z1); - let t5 = Fp.add(X2, Z2); // step 10 - t4 = Fp.mul(t4, t5); - t5 = Fp.add(t0, t2); - t4 = Fp.sub(t4, t5); - t5 = Fp.add(Y1, Z1); - X3 = Fp.add(Y2, Z2); // step 15 - t5 = Fp.mul(t5, X3); - X3 = Fp.add(t1, t2); - t5 = Fp.sub(t5, X3); - Z3 = Fp.mul(a, t4); - X3 = Fp.mul(b3, t2); // step 20 - Z3 = Fp.add(X3, Z3); - X3 = Fp.sub(t1, Z3); - Z3 = Fp.add(t1, Z3); - Y3 = Fp.mul(X3, Z3); - t1 = Fp.add(t0, t0); // step 25 - t1 = Fp.add(t1, t0); - t2 = Fp.mul(a, t2); - t4 = Fp.mul(b3, t4); - t1 = Fp.add(t1, t2); - t2 = Fp.sub(t0, t2); // step 30 - t2 = Fp.mul(a, t2); - t4 = Fp.add(t4, t2); - t0 = Fp.mul(t1, t4); - Y3 = Fp.add(Y3, t0); - t0 = Fp.mul(t5, t4); // step 35 - X3 = Fp.mul(t3, X3); - X3 = Fp.sub(X3, t0); - t0 = Fp.mul(t3, t1); - Z3 = Fp.mul(t5, Z3); - Z3 = Fp.add(Z3, t0); // step 40 - return new Point(X3, Y3, Z3); - } - - subtract(other: Point) { - return this.add(other.negate()); - } - - private is0() { - return this.equals(Point.ZERO); - } - private wNAF(n: bigint): { p: Point; f: Point } { - return wnaf.wNAFCached(this, pointPrecomputes, n, (comp: Point[]) => { - const toInv = Fp.invertBatch(comp.map((p) => p.pz)); - return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); - }); - } - - /** - * Non-constant-time multiplication. Uses double-and-add algorithm. - * It's faster, but should only be used when you don't care about - * an exposed private key e.g. sig verification, which works over *public* keys. - */ - multiplyUnsafe(n: bigint): Point { - const I = Point.ZERO; - if (n === _0n) return I; - assertGE(n); // Will throw on 0 - if (n === _1n) return this; - const { endo } = CURVE; - if (!endo) return wnaf.unsafeLadder(this, n); - - // Apply endomorphism - let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let k1p = I; - let k2p = I; - let d: Point = this; - while (k1 > _0n || k2 > _0n) { - if (k1 & _1n) k1p = k1p.add(d); - if (k2 & _1n) k2p = k2p.add(d); - d = d.double(); - k1 >>= _1n; - k2 >>= _1n; - } - if (k1neg) k1p = k1p.negate(); - if (k2neg) k2p = k2p.negate(); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - return k1p.add(k2p); - } - - /** - * Constant time multiplication. - * Uses wNAF method. Windowed method may be 10% faster, - * but takes 2x longer to generate and consumes 2x memory. - * Uses precomputes when available. - * Uses endomorphism for Koblitz curves. - * @param scalar by which the point would be multiplied - * @returns New point - */ - multiply(scalar: bigint): Point { - assertGE(scalar); - let n = scalar; - let point: Point, fake: Point; // Fake point is used to const-time mult - const { endo } = CURVE; - if (endo) { - const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); - let { p: k1p, f: f1p } = this.wNAF(k1); - let { p: k2p, f: f2p } = this.wNAF(k2); - k1p = wnaf.constTimeNegate(k1neg, k1p); - k2p = wnaf.constTimeNegate(k2neg, k2p); - k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); - point = k1p.add(k2p); - fake = f1p.add(f2p); - } else { - const { p, f } = this.wNAF(n); - point = p; - fake = f; - } - // Normalize `z` for both points, but return only real one - return Point.normalizeZ([point, fake])[0]; - } - - /** - * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. - * Not using Strauss-Shamir trick: precomputation tables are faster. - * The trick could be useful if both P and Q are not G (not in our case). - * @returns non-zero affine point - */ - multiplyAndAddUnsafe(Q: Point, a: bigint, b: bigint): Point | undefined { - const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes - const mul = ( - P: Point, - a: bigint // Select faster multiply() method - ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a)); - const sum = mul(this, a).add(mul(Q, b)); - return sum.is0() ? undefined : sum; - } - - // Converts Projective point to affine (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - // (x, y, z) ∋ (x=x/z, y=y/z) - toAffine(iz?: T): AffinePoint { - const { px: x, py: y, pz: z } = this; - const is0 = this.is0(); - // If invZ was 0, we return zero point. However we still want to execute - // all operations, so we replace invZ with a random number, 1. - if (iz == null) iz = is0 ? Fp.ONE : Fp.inv(z); - const ax = Fp.mul(x, iz); - const ay = Fp.mul(y, iz); - const zz = Fp.mul(z, iz); - if (is0) return { x: Fp.ZERO, y: Fp.ZERO }; - if (!Fp.eql(zz, Fp.ONE)) throw new Error('invZ was invalid'); - return { x: ax, y: ay }; - } - isTorsionFree(): boolean { - const { h: cofactor, isTorsionFree } = CURVE; - if (cofactor === _1n) return true; // No subgroups, always torsion-free - if (isTorsionFree) return isTorsionFree(Point, this); - throw new Error('isTorsionFree() has not been declared for the elliptic curve'); - } - clearCofactor(): Point { - const { h: cofactor, clearCofactor } = CURVE; - if (cofactor === _1n) return this; // Fast-path - if (clearCofactor) return clearCofactor(Point, this) as Point; - return this.multiplyUnsafe(CURVE.h); - } - - toRawBytes(isCompressed = true): Uint8Array { - this.assertValidity(); - return toBytes(Point, this, isCompressed); - } - - toHex(isCompressed = true): string { - return ut.bytesToHex(this.toRawBytes(isCompressed)); - } - } - const _bits = CURVE.nBitLength; - const wnaf = wNAF(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits); - // Validate if generator point is on curve - return { - CURVE, - ProjectivePoint: Point as ProjConstructor, - normPrivateKeyToScalar, - weierstrassEquation, - isWithinCurveOrder, - }; -} - -// Instance -export interface SignatureType { - readonly r: bigint; - readonly s: bigint; - readonly recovery?: number; - assertValidity(): void; - addRecoveryBit(recovery: number): RecoveredSignatureType; - hasHighS(): boolean; - normalizeS(): SignatureType; - recoverPublicKey(msgHash: Hex): ProjPointType; - toCompactRawBytes(): Uint8Array; - toCompactHex(): string; - // DER-encoded - toDERRawBytes(isCompressed?: boolean): Uint8Array; - toDERHex(isCompressed?: boolean): string; -} -export type RecoveredSignatureType = SignatureType & { - readonly recovery: number; -}; -// Static methods -export type SignatureConstructor = { - new (r: bigint, s: bigint): SignatureType; - fromCompact(hex: Hex): SignatureType; - fromDER(hex: Hex): SignatureType; -}; -type SignatureLike = { r: bigint; s: bigint }; - -export type PubKey = Hex | ProjPointType; - -export type CurveType = BasicWCurve & { - hash: CHash; // CHash not FHash because we need outputLen for DRBG - hmac: HmacFnSync; - randomBytes: (bytesLength?: number) => Uint8Array; - lowS?: boolean; - bits2int?: (bytes: Uint8Array) => bigint; - bits2int_modN?: (bytes: Uint8Array) => bigint; -}; - -function validateOpts(curve: CurveType) { - const opts = validateBasic(curve); - ut.validateObject( - opts, - { - hash: 'hash', - hmac: 'function', - randomBytes: 'function', - }, - { - bits2int: 'function', - bits2int_modN: 'function', - lowS: 'boolean', - } - ); - return Object.freeze({ lowS: true, ...opts } as const); -} - -export type CurveFn = { - CURVE: ReturnType; - getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array; - getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean) => Uint8Array; - sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => RecoveredSignatureType; - verify: (signature: Hex | SignatureLike, msgHash: Hex, publicKey: Hex, opts?: VerOpts) => boolean; - ProjectivePoint: ProjConstructor; - Signature: SignatureConstructor; - utils: { - normPrivateKeyToScalar: (key: PrivKey) => bigint; - isValidPrivateKey(privateKey: PrivKey): boolean; - randomPrivateKey: () => Uint8Array; - precompute: (windowSize?: number, point?: ProjPointType) => ProjPointType; - }; -}; - -export function weierstrass(curveDef: CurveType): CurveFn { - const CURVE = validateOpts(curveDef) as ReturnType; - const { Fp, n: CURVE_ORDER } = CURVE; - const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32 - const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32 - - function isValidFieldElement(num: bigint): boolean { - return _0n < num && num < Fp.ORDER; // 0 is banned since it's not invertible FE - } - function modN(a: bigint) { - return mod.mod(a, CURVE_ORDER); - } - function invN(a: bigint) { - return mod.invert(a, CURVE_ORDER); - } - - const { - ProjectivePoint: Point, - normPrivateKeyToScalar, - weierstrassEquation, - isWithinCurveOrder, - } = weierstrassPoints({ - ...CURVE, - toBytes(c, point, isCompressed: boolean): Uint8Array { - const a = point.toAffine(); - const x = Fp.toBytes(a.x); - const cat = ut.concatBytes; - if (isCompressed) { - return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x); - } else { - return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y)); - } - }, - fromBytes(bytes: Uint8Array) { - const len = bytes.length; - const head = bytes[0]; - const tail = bytes.subarray(1); - // this.assertValidity() is done inside of fromHex - if (len === compressedLen && (head === 0x02 || head === 0x03)) { - const x = ut.bytesToNumberBE(tail); - if (!isValidFieldElement(x)) throw new Error('Point is not on curve'); - const y2 = weierstrassEquation(x); // y² = x³ + ax + b - let y = Fp.sqrt(y2); // y = y² ^ (p+1)/4 - const isYOdd = (y & _1n) === _1n; - // ECDSA - const isHeadOdd = (head & 1) === 1; - if (isHeadOdd !== isYOdd) y = Fp.neg(y); - return { x, y }; - } else if (len === uncompressedLen && head === 0x04) { - const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); - const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); - return { x, y }; - } else { - throw new Error( - `Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes` - ); - } - }, - }); - const numToNByteStr = (num: bigint): string => - ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength)); - - function isBiggerThanHalfOrder(number: bigint) { - const HALF = CURVE_ORDER >> _1n; - return number > HALF; - } - - function normalizeS(s: bigint) { - return isBiggerThanHalfOrder(s) ? modN(-s) : s; - } - // slice bytes num - const slcNum = (b: Uint8Array, from: number, to: number) => ut.bytesToNumberBE(b.slice(from, to)); - - /** - * ECDSA signature with its (r, s) properties. Supports DER & compact representations. - */ - class Signature implements SignatureType { - constructor(readonly r: bigint, readonly s: bigint, readonly recovery?: number) { - this.assertValidity(); - } - - // pair (bytes of r, bytes of s) - static fromCompact(hex: Hex) { - const l = CURVE.nByteLength; - hex = ensureBytes('compactSignature', hex, l * 2); - return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l)); - } - - // DER encoded ECDSA signature - // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script - static fromDER(hex: Hex) { - const { r, s } = DER.toSig(ensureBytes('DER', hex)); - return new Signature(r, s); - } - - assertValidity(): void { - // can use assertGE here - if (!isWithinCurveOrder(this.r)) throw new Error('r must be 0 < r < CURVE.n'); - if (!isWithinCurveOrder(this.s)) throw new Error('s must be 0 < s < CURVE.n'); - } - - addRecoveryBit(recovery: number): RecoveredSignature { - return new Signature(this.r, this.s, recovery) as RecoveredSignature; - } - - recoverPublicKey(msgHash: Hex): typeof Point.BASE { - const { r, s, recovery: rec } = this; - const h = bits2int_modN(ensureBytes('msgHash', msgHash)); // Truncate hash - if (rec == null || ![0, 1, 2, 3].includes(rec)) throw new Error('recovery id invalid'); - const radj = rec === 2 || rec === 3 ? r + CURVE.n : r; - if (radj >= Fp.ORDER) throw new Error('recovery id 2 or 3 invalid'); - const prefix = (rec & 1) === 0 ? '02' : '03'; - const R = Point.fromHex(prefix + numToNByteStr(radj)); - const ir = invN(radj); // r^-1 - const u1 = modN(-h * ir); // -hr^-1 - const u2 = modN(s * ir); // sr^-1 - const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1) - if (!Q) throw new Error('point at infinify'); // unsafe is fine: no priv data leaked - Q.assertValidity(); - return Q; - } - - // Signatures should be low-s, to prevent malleability. - hasHighS(): boolean { - return isBiggerThanHalfOrder(this.s); - } - - normalizeS() { - return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this; - } - - // DER-encoded - toDERRawBytes() { - return ut.hexToBytes(this.toDERHex()); - } - toDERHex() { - return DER.hexFromSig({ r: this.r, s: this.s }); - } - - // padded bytes of r, then padded bytes of s - toCompactRawBytes() { - return ut.hexToBytes(this.toCompactHex()); - } - toCompactHex() { - return numToNByteStr(this.r) + numToNByteStr(this.s); - } - } - type RecoveredSignature = Signature & { recovery: number }; - - const utils = { - isValidPrivateKey(privateKey: PrivKey) { - try { - normPrivateKeyToScalar(privateKey); - return true; - } catch (error) { - return false; - } - }, - normPrivateKeyToScalar: normPrivateKeyToScalar, - - /** - * Produces cryptographically secure private key from random of size (nBitLength+64) - * as per FIPS 186 B.4.1 with modulo bias being neglible. - */ - randomPrivateKey: (): Uint8Array => { - const rand = CURVE.randomBytes(Fp.BYTES + 8); - const num = mod.hashToPrivateScalar(rand, CURVE_ORDER); - return ut.numberToBytesBE(num, CURVE.nByteLength); - }, - - /** - * Creates precompute table for an arbitrary EC point. Makes point "cached". - * Allows to massively speed-up `point.multiply(scalar)`. - * @returns cached point - * @example - * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); - * fast.multiply(privKey); // much faster ECDH now - */ - precompute(windowSize = 8, point = Point.BASE): typeof Point.BASE { - point._setWindowSize(windowSize); - point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here - return point; - }, - }; - - /** - * Computes public key for a private key. Checks for validity of the private key. - * @param privateKey private key - * @param isCompressed whether to return compact (default), or full key - * @returns Public key, full when isCompressed=false; short when isCompressed=true - */ - function getPublicKey(privateKey: PrivKey, isCompressed = true): Uint8Array { - return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed); - } - - /** - * Quick and dirty check for item being public key. Does not validate hex, or being on-curve. - */ - function isProbPub(item: PrivKey | PubKey): boolean { - const arr = item instanceof Uint8Array; - const str = typeof item === 'string'; - const len = (arr || str) && (item as Hex).length; - if (arr) return len === compressedLen || len === uncompressedLen; - if (str) return len === 2 * compressedLen || len === 2 * uncompressedLen; - if (item instanceof Point) return true; - return false; - } - - /** - * ECDH (Elliptic Curve Diffie Hellman). - * Computes shared public key from private key and public key. - * Checks: 1) private key validity 2) shared key is on-curve. - * Does NOT hash the result. - * @param privateA private key - * @param publicB different public key - * @param isCompressed whether to return compact (default), or full key - * @returns shared public key - */ - function getSharedSecret(privateA: PrivKey, publicB: Hex, isCompressed = true): Uint8Array { - if (isProbPub(privateA)) throw new Error('first arg must be private key'); - if (!isProbPub(publicB)) throw new Error('second arg must be public key'); - const b = Point.fromHex(publicB); // check for being on-curve - return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed); - } - - // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets. - // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int. - // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same. - // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors - const bits2int = - CURVE.bits2int || - function (bytes: Uint8Array): bigint { - // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m) - // for some cases, since bytes.length * 8 is not actual bitLength. - const num = ut.bytesToNumberBE(bytes); // check for == u8 done here - const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits - return delta > 0 ? num >> BigInt(delta) : num; - }; - const bits2int_modN = - CURVE.bits2int_modN || - function (bytes: Uint8Array): bigint { - return modN(bits2int(bytes)); // can't use bytesToNumberBE here - }; - // NOTE: pads output with zero as per spec - const ORDER_MASK = ut.bitMask(CURVE.nBitLength); - /** - * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`. - */ - function int2octets(num: bigint): Uint8Array { - if (typeof num !== 'bigint') throw new Error('bigint expected'); - if (!(_0n <= num && num < ORDER_MASK)) - throw new Error(`bigint expected < 2^${CURVE.nBitLength}`); - // works with order, can have different size than numToField! - return ut.numberToBytesBE(num, CURVE.nByteLength); - } - - // Steps A, D of RFC6979 3.2 - // Creates RFC6979 seed; converts msg/privKey to numbers. - // Used only in sign, not in verify. - // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order, this will be wrong at least for P521. - // Also it can be bigger for P224 + SHA256 - function prepSig(msgHash: Hex, privateKey: PrivKey, opts = defaultSigOpts) { - if (['recovered', 'canonical'].some((k) => k in opts)) - throw new Error('sign() legacy options not supported'); - const { hash, randomBytes } = CURVE; - let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default - if (lowS == null) lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash - msgHash = ensureBytes('msgHash', msgHash); - if (prehash) msgHash = ensureBytes('prehashed msgHash', hash(msgHash)); - - // We can't later call bits2octets, since nested bits2int is broken for curves - // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call. - // const bits2octets = (bits) => int2octets(bits2int_modN(bits)) - const h1int = bits2int_modN(msgHash); - const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint - const seedArgs = [int2octets(d), int2octets(h1int)]; - // extraEntropy. RFC6979 3.6: additional k' (optional). - if (ent != null) { - // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k') - const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is - seedArgs.push(ensureBytes('extraEntropy', e, Fp.BYTES)); // check for being of size BYTES - } - const seed = ut.concatBytes(...seedArgs); // Step D of RFC6979 3.2 - const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash! - // Converts signature params into point w r/s, checks result for validity. - function k2sig(kBytes: Uint8Array): RecoveredSignature | undefined { - // RFC 6979 Section 3.2, step 3: k = bits2int(T) - const k = bits2int(kBytes); // Cannot use fields methods, since it is group element - if (!isWithinCurveOrder(k)) return; // Important: all mod() calls here must be done over N - const ik = invN(k); // k^-1 mod n - const q = Point.BASE.multiply(k).toAffine(); // q = Gk - const r = modN(q.x); // r = q.x mod n - if (r === _0n) return; - // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to - // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it: - // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT - const s = modN(ik * modN(m + r * d)); // Not using blinding here - if (s === _0n) return; - let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n) - let normS = s; - if (lowS && isBiggerThanHalfOrder(s)) { - normS = normalizeS(s); // if lowS was passed, ensure s is always - recovery ^= 1; // // in the bottom half of N - } - return new Signature(r, normS, recovery) as RecoveredSignature; // use normS, not s - } - return { seed, k2sig }; - } - const defaultSigOpts: SignOpts = { lowS: CURVE.lowS, prehash: false }; - const defaultVerOpts: VerOpts = { lowS: CURVE.lowS, prehash: false }; - - /** - * Signs message hash with a private key. - * ``` - * sign(m, d, k) where - * (x, y) = G × k - * r = x mod n - * s = (m + dr)/k mod n - * ``` - * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`. - * @param privKey private key - * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg. - * @returns signature with recovery param - */ - function sign(msgHash: Hex, privKey: PrivKey, opts = defaultSigOpts): RecoveredSignature { - const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2. - const C = CURVE; - const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac); - return drbg(seed, k2sig); // Steps B, C, D, E, F, G - } - - // Enable precomputes. Slows down first publicKey computation by 20ms. - Point.BASE._setWindowSize(8); - // utils.precompute(8, ProjectivePoint.BASE) - - /** - * Verifies a signature against message hash and public key. - * Rejects lowS signatures by default: to override, - * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf: - * - * ``` - * verify(r, s, h, P) where - * U1 = hs^-1 mod n - * U2 = rs^-1 mod n - * R = U1⋅G - U2⋅P - * mod(R.x, n) == r - * ``` - */ - function verify( - signature: Hex | SignatureLike, - msgHash: Hex, - publicKey: Hex, - opts = defaultVerOpts - ): boolean { - const sg = signature; - msgHash = ensureBytes('msgHash', msgHash); - publicKey = ensureBytes('publicKey', publicKey); - if ('strict' in opts) throw new Error('options.strict was renamed to lowS'); - const { lowS, prehash } = opts; - - let _sig: Signature | undefined = undefined; - let P: ProjPointType; - try { - if (typeof sg === 'string' || sg instanceof Uint8Array) { - // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length). - // Since DER can also be 2*nByteLength bytes, we check for it first. - try { - _sig = Signature.fromDER(sg); - } catch (derError) { - if (!(derError instanceof DER.Err)) throw derError; - _sig = Signature.fromCompact(sg); - } - } else if (typeof sg === 'object' && typeof sg.r === 'bigint' && typeof sg.s === 'bigint') { - const { r, s } = sg; - _sig = new Signature(r, s); - } else { - throw new Error('PARSE'); - } - P = Point.fromHex(publicKey); - } catch (error) { - if ((error as Error).message === 'PARSE') - throw new Error(`signature must be Signature instance, Uint8Array or hex string`); - return false; - } - if (lowS && _sig.hasHighS()) return false; - if (prehash) msgHash = CURVE.hash(msgHash); - const { r, s } = _sig; - const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element - const is = invN(s); // s^-1 - const u1 = modN(h * is); // u1 = hs^-1 mod n - const u2 = modN(r * is); // u2 = rs^-1 mod n - const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P - if (!R) return false; - const v = modN(R.x); - return v === r; - } - return { - CURVE, - getPublicKey, - getSharedSecret, - sign, - verify, - ProjectivePoint: Point, - Signature, - utils, - }; -} - -/** - * Implementation of the Shallue and van de Woestijne method for any weierstrass curve. - * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular. - * b = True and y = sqrt(u / v) if (u / v) is square in F, and - * b = False and y = sqrt(Z * (u / v)) otherwise. - * @param Fp - * @param Z - * @returns - */ -export function SWUFpSqrtRatio(Fp: mod.IField, Z: T) { - // Generic implementation - const q = Fp.ORDER; - let l = _0n; - for (let o = q - _1n; o % _2n === _0n; o /= _2n) l += _1n; - const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1. - // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<. - // 2n ** c1 == 2n << (c1-1) - const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n); - const _2n_pow_c1 = _2n_pow_c1_1 * _2n; - const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic - const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic - const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic - const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic - const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2 - const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2) - let sqrtRatio = (u: T, v: T): { isValid: boolean; value: T } => { - let tv1 = c6; // 1. tv1 = c6 - let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4 - let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2 - tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v - let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3 - tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3 - tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2 - tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v - tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u - let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2 - tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5 - let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1 - tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7 - tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR) - tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR) - // 17. for i in (c1, c1 - 1, ..., 2): - for (let i = c1; i > _1n; i--) { - let tv5 = i - _2n; // 18. tv5 = i - 2 - tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5 - let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5 - const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1 - tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1 - tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1 - tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1 - tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1) - tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1) - } - return { isValid: isQR, value: tv3 }; - }; - if (Fp.ORDER % _4n === _3n) { - // sqrt_ratio_3mod4(u, v) - const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic - const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z) - sqrtRatio = (u: T, v: T) => { - let tv1 = Fp.sqr(v); // 1. tv1 = v^2 - const tv2 = Fp.mul(u, v); // 2. tv2 = u * v - tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2 - let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1 - y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2 - const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2 - const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v - const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u - let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR) - return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2 - }; - } - // No curves uses that - // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8 - return sqrtRatio; -} -/** - * From draft-irtf-cfrg-hash-to-curve-16 - */ -export function mapToCurveSimpleSWU( - Fp: mod.IField, - opts: { - A: T; - B: T; - Z: T; - } -) { - mod.validateField(Fp); - if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z)) - throw new Error('mapToCurveSimpleSWU: invalid opts'); - const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z); - if (!Fp.isOdd) throw new Error('Fp.isOdd is not implemented!'); - // Input: u, an element of F. - // Output: (x, y), a point on E. - return (u: T): { x: T; y: T } => { - // prettier-ignore - let tv1, tv2, tv3, tv4, tv5, tv6, x, y; - tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1 - tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2 - tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1 - tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1 - tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3 - tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0) - tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4 - tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2 - tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2 - tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6 - tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5 - tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3 - tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4 - tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6 - tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5 - x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3 - const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6) - y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1 - y = Fp.mul(y, value); // 20. y = y * y1 - x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square) - y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square) - const e1 = Fp.isOdd!(u) === Fp.isOdd!(y); // 23. e1 = sgn0(u) == sgn0(y) - y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1) - x = Fp.div(x, tv4); // 25. x = x / tv4 - return { x, y }; - }; -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/bls12-381.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/bls12-381.ts deleted file mode 100644 index 5f6fdc28..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/bls12-381.ts +++ /dev/null @@ -1,1351 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ - -// bls12-381 pairing-friendly Barreto-Lynn-Scott elliptic curve construction allows to: -// - Construct zk-SNARKs at the 128-bit security -// - Use threshold signatures, which allows a user to sign lots of messages with one signature and -// verify them swiftly in a batch, using Boneh-Lynn-Shacham signature scheme. -// -// The library uses G1 for public keys and G2 for signatures. Support for G1 signatures is planned. -// Compatible with Algorand, Chia, Dfinity, Ethereum, FIL, Zcash. Matches specs -// [pairing-curves-11](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-11), -// [bls-sigs-04](https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04), -// [hash-to-curve-12](https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-12). -// -// ### Summary -// 1. BLS Relies on Bilinear Pairing (expensive) -// 2. Private Keys: 32 bytes -// 3. Public Keys: 48 bytes: 381 bit affine x coordinate, encoded into 48 big-endian bytes. -// 4. Signatures: 96 bytes: two 381 bit integers (affine x coordinate), encoded into two 48 big-endian byte arrays. -// - The signature is a point on the G2 subgroup, which is defined over a finite field -// with elements twice as big as the G1 curve (G2 is over Fp2 rather than Fp. Fp2 is analogous to the complex numbers). -// 5. The 12 stands for the Embedding degree. -// -// ### Formulas -// - `P = pk x G` - public keys -// - `S = pk x H(m)` - signing -// - `e(P, H(m)) == e(G, S)` - verification using pairings -// - `e(G, S) = e(G, SUM(n)(Si)) = MUL(n)(e(G, Si))` - signature aggregation -// Filecoin uses little endian byte arrays for private keys - -// so ensure to reverse byte order if you'll use it with FIL. -import { sha256 } from '@noble/hashes/sha256'; -import { randomBytes } from '@noble/hashes/utils'; -import { bls, CurveFn } from './abstract/bls.js'; -import * as mod from './abstract/modular.js'; -import { - concatBytes as concatB, - ensureBytes, - numberToBytesBE, - bytesToNumberBE, - bitLen, - bitSet, - bitGet, - Hex, - bitMask, - bytesToHex, -} from './abstract/utils.js'; -// Types -import { - ProjPointType, - ProjConstructor, - mapToCurveSimpleSWU, - AffinePoint, -} from './abstract/weierstrass.js'; -import { isogenyMap } from './abstract/hash-to-curve.js'; - -// Be friendly to bad ECMAScript parsers by not using bigint literals -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4); -// prettier-ignore -const _8n = BigInt(8), _16n = BigInt(16); - -// CURVE FIELDS -// Finite field over p. -const Fp_raw = BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab' -); -const Fp = mod.Field(Fp_raw); -type Fp = bigint; -// Finite field over r. -// This particular field is not used anywhere in bls12-381, but it is still useful. -const Fr = mod.Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')); - -// Fp₂ over complex plane -type BigintTuple = [bigint, bigint]; -type Fp2 = { c0: bigint; c1: bigint }; -const Fp2Add = ({ c0, c1 }: Fp2, { c0: r0, c1: r1 }: Fp2) => ({ - c0: Fp.add(c0, r0), - c1: Fp.add(c1, r1), -}); -const Fp2Subtract = ({ c0, c1 }: Fp2, { c0: r0, c1: r1 }: Fp2) => ({ - c0: Fp.sub(c0, r0), - c1: Fp.sub(c1, r1), -}); -const Fp2Multiply = ({ c0, c1 }: Fp2, rhs: Fp2) => { - if (typeof rhs === 'bigint') return { c0: Fp.mul(c0, rhs), c1: Fp.mul(c1, rhs) }; - // (a+bi)(c+di) = (ac−bd) + (ad+bc)i - const { c0: r0, c1: r1 } = rhs; - let t1 = Fp.mul(c0, r0); // c0 * o0 - let t2 = Fp.mul(c1, r1); // c1 * o1 - // (T1 - T2) + ((c0 + c1) * (r0 + r1) - (T1 + T2))*i - const o0 = Fp.sub(t1, t2); - const o1 = Fp.sub(Fp.mul(Fp.add(c0, c1), Fp.add(r0, r1)), Fp.add(t1, t2)); - return { c0: o0, c1: o1 }; -}; -const Fp2Square = ({ c0, c1 }: Fp2) => { - const a = Fp.add(c0, c1); - const b = Fp.sub(c0, c1); - const c = Fp.add(c0, c0); - return { c0: Fp.mul(a, b), c1: Fp.mul(c, c1) }; -}; -type Fp2Utils = { - fromBigTuple: (tuple: BigintTuple | bigint[]) => Fp2; - reim: (num: Fp2) => { re: bigint; im: bigint }; - mulByNonresidue: (num: Fp2) => Fp2; - multiplyByB: (num: Fp2) => Fp2; - frobeniusMap(num: Fp2, power: number): Fp2; -}; -// G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), -// where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where -// G² - 1 -// h2q -// NOTE: ORDER was wrong! -const FP2_ORDER = Fp_raw * Fp_raw; - -const Fp2: mod.IField & Fp2Utils = { - ORDER: FP2_ORDER, - BITS: bitLen(FP2_ORDER), - BYTES: Math.ceil(bitLen(FP2_ORDER) / 8), - MASK: bitMask(bitLen(FP2_ORDER)), - ZERO: { c0: Fp.ZERO, c1: Fp.ZERO }, - ONE: { c0: Fp.ONE, c1: Fp.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => typeof c0 === 'bigint' && typeof c1 === 'bigint', - is0: ({ c0, c1 }) => Fp.is0(c0) && Fp.is0(c1), - eql: ({ c0, c1 }: Fp2, { c0: r0, c1: r1 }: Fp2) => Fp.eql(c0, r0) && Fp.eql(c1, r1), - neg: ({ c0, c1 }) => ({ c0: Fp.neg(c0), c1: Fp.neg(c1) }), - pow: (num, power) => mod.FpPow(Fp2, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp2, nums), - // Normalized - add: Fp2Add, - sub: Fp2Subtract, - mul: Fp2Multiply, - sqr: Fp2Square, - // NonNormalized stuff - addN: Fp2Add, - subN: Fp2Subtract, - mulN: Fp2Multiply, - sqrN: Fp2Square, - // Why inversion for bigint inside Fp instead of Fp2? it is even used in that context? - div: (lhs, rhs) => Fp2.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp2.inv(rhs)), - inv: ({ c0: a, c1: b }) => { - // We wish to find the multiplicative inverse of a nonzero - // element a + bu in Fp2. We leverage an identity - // - // (a + bu)(a - bu) = a² + b² - // - // which holds because u² = -1. This can be rewritten as - // - // (a + bu)(a - bu)/(a² + b²) = 1 - // - // because a² + b² = 0 has no nonzero solutions for (a, b). - // This gives that (a - bu)/(a² + b²) is the inverse - // of (a + bu). Importantly, this can be computing using - // only a single inversion in Fp. - const factor = Fp.inv(Fp.create(a * a + b * b)); - return { c0: Fp.mul(factor, Fp.create(a)), c1: Fp.mul(factor, Fp.create(-b)) }; - }, - sqrt: (num) => { - if (Fp2.eql(num, Fp2.ZERO)) return Fp2.ZERO; // Algo doesn't handles this case - // TODO: Optimize this line. It's extremely slow. - // Speeding this up would boost aggregateSignatures. - // https://eprint.iacr.org/2012/685.pdf applicable? - // https://github.com/zkcrypto/bls12_381/blob/080eaa74ec0e394377caa1ba302c8c121df08b07/src/fp2.rs#L250 - // https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/src/exp2.c#L1 - // Inspired by https://github.com/dalek-cryptography/curve25519-dalek/blob/17698df9d4c834204f83a3574143abacb4fc81a5/src/field.rs#L99 - const candidateSqrt = Fp2.pow(num, (Fp2.ORDER + _8n) / _16n); - const check = Fp2.div(Fp2.sqr(candidateSqrt), num); // candidateSqrt.square().div(this); - const R = FP2_ROOTS_OF_UNITY; - const divisor = [R[0], R[2], R[4], R[6]].find((r) => Fp2.eql(r, check)); - if (!divisor) throw new Error('No root'); - const index = R.indexOf(divisor); - const root = R[index / 2]; - if (!root) throw new Error('Invalid root'); - const x1 = Fp2.div(candidateSqrt, root); - const x2 = Fp2.neg(x1); - const { re: re1, im: im1 } = Fp2.reim(x1); - const { re: re2, im: im2 } = Fp2.reim(x2); - if (im1 > im2 || (im1 === im2 && re1 > re2)) return x1; - return x2; - }, - // Same as sgn0_fp2 in draft-irtf-cfrg-hash-to-curve-16 - isOdd: (x: Fp2) => { - const { re: x0, im: x1 } = Fp2.reim(x); - const sign_0 = x0 % _2n; - const zero_0 = x0 === _0n; - const sign_1 = x1 % _2n; - return BigInt(sign_0 || (zero_0 && sign_1)) == _1n; - }, - // Bytes util - fromBytes(b: Uint8Array): Fp2 { - if (b.length !== Fp2.BYTES) throw new Error(`fromBytes wrong length=${b.length}`); - return { c0: Fp.fromBytes(b.subarray(0, Fp.BYTES)), c1: Fp.fromBytes(b.subarray(Fp.BYTES)) }; - }, - toBytes: ({ c0, c1 }) => concatB(Fp.toBytes(c0), Fp.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp.cmov(c0, r0, c), - c1: Fp.cmov(c1, r1, c), - }), - // Specific utils - // toString() { - // return `Fp2(${this.c0} + ${this.c1}×i)`; - // } - reim: ({ c0, c1 }) => ({ re: c0, im: c1 }), - // multiply by u + 1 - mulByNonresidue: ({ c0, c1 }) => ({ c0: Fp.sub(c0, c1), c1: Fp.add(c0, c1) }), - multiplyByB: ({ c0, c1 }) => { - let t0 = Fp.mul(c0, _4n); // 4 * c0 - let t1 = Fp.mul(c1, _4n); // 4 * c1 - // (T0-T1) + (T0+T1)*i - return { c0: Fp.sub(t0, t1), c1: Fp.add(t0, t1) }; - }, - fromBigTuple: (tuple: BigintTuple | bigint[]) => { - if (tuple.length !== 2) throw new Error('Invalid tuple'); - const fps = tuple.map((n) => Fp.create(n)) as [Fp, Fp]; - return { c0: fps[0], c1: fps[1] }; - }, - frobeniusMap: ({ c0, c1 }, power: number): Fp2 => ({ - c0, - c1: Fp.mul(c1, FP2_FROBENIUS_COEFFICIENTS[power % 2]), - }), -}; -// Finite extension field over irreducible polynominal. -// Fp(u) / (u² - β) where β = -1 -const FP2_FROBENIUS_COEFFICIENTS = [ - BigInt('0x1'), - BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa' - ), -].map((item) => Fp.create(item)); - -// For Fp2 roots of unity. -const rv1 = BigInt( - '0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09' -); -// const ev1 = -// BigInt('0x699be3b8c6870965e5bf892ad5d2cc7b0e85a117402dfd83b7f4a947e02d978498255a2aaec0ac627b5afbdf1bf1c90'); -// const ev2 = -// BigInt('0x8157cd83046453f5dd0972b6e3949e4288020b5b8a9cc99ca07e27089a2ce2436d965026adad3ef7baba37f2183e9b5'); -// const ev3 = -// BigInt('0xab1c2ffdd6c253ca155231eb3e71ba044fd562f6f72bc5bad5ec46a0b7a3b0247cf08ce6c6317f40edbc653a72dee17'); -// const ev4 = -// BigInt('0xaa404866706722864480885d68ad0ccac1967c7544b447873cc37e0181271e006df72162a3d3e0287bf597fbf7f8fc1'); - -// Eighth roots of unity, used for computing square roots in Fp2. -// To verify or re-calculate: -// Array(8).fill(new Fp2([1n, 1n])).map((fp2, k) => fp2.pow(Fp2.ORDER * BigInt(k) / 8n)) -const FP2_ROOTS_OF_UNITY = [ - [_1n, _0n], - [rv1, -rv1], - [_0n, _1n], - [rv1, rv1], - [-_1n, _0n], - [-rv1, rv1], - [_0n, -_1n], - [-rv1, -rv1], -].map((pair) => Fp2.fromBigTuple(pair)); -// eta values, used for computing sqrt(g(X1(t))) -// const FP2_ETAs = [ -// [ev1, ev2], -// [-ev2, ev1], -// [ev3, ev4], -// [-ev4, ev3], -// ].map((pair) => Fp2.fromBigTuple(pair)); - -// Finite extension field over irreducible polynominal. -// Fp2(v) / (v³ - ξ) where ξ = u + 1 -type BigintSix = [bigint, bigint, bigint, bigint, bigint, bigint]; -type Fp6 = { c0: Fp2; c1: Fp2; c2: Fp2 }; -const Fp6Add = ({ c0, c1, c2 }: Fp6, { c0: r0, c1: r1, c2: r2 }: Fp6) => ({ - c0: Fp2.add(c0, r0), - c1: Fp2.add(c1, r1), - c2: Fp2.add(c2, r2), -}); -const Fp6Subtract = ({ c0, c1, c2 }: Fp6, { c0: r0, c1: r1, c2: r2 }: Fp6) => ({ - c0: Fp2.sub(c0, r0), - c1: Fp2.sub(c1, r1), - c2: Fp2.sub(c2, r2), -}); -const Fp6Multiply = ({ c0, c1, c2 }: Fp6, rhs: Fp6 | bigint) => { - if (typeof rhs === 'bigint') { - return { - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }; - } - const { c0: r0, c1: r1, c2: r2 } = rhs; - const t0 = Fp2.mul(c0, r0); // c0 * o0 - const t1 = Fp2.mul(c1, r1); // c1 * o1 - const t2 = Fp2.mul(c2, r2); // c2 * o2 - return { - // t0 + (c1 + c2) * (r1 * r2) - (T1 + T2) * (u + 1) - c0: Fp2.add( - t0, - Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), Fp2.add(r1, r2)), Fp2.add(t1, t2))) - ), - // (c0 + c1) * (r0 + r1) - (T0 + T1) + T2 * (u + 1) - c1: Fp2.add( - Fp2.sub(Fp2.mul(Fp2.add(c0, c1), Fp2.add(r0, r1)), Fp2.add(t0, t1)), - Fp2.mulByNonresidue(t2) - ), - // T1 + (c0 + c2) * (r0 + r2) - T0 + T2 - c2: Fp2.sub(Fp2.add(t1, Fp2.mul(Fp2.add(c0, c2), Fp2.add(r0, r2))), Fp2.add(t0, t2)), - }; -}; -const Fp6Square = ({ c0, c1, c2 }: Fp6) => { - let t0 = Fp2.sqr(c0); // c0² - let t1 = Fp2.mul(Fp2.mul(c0, c1), _2n); // 2 * c0 * c1 - let t3 = Fp2.mul(Fp2.mul(c1, c2), _2n); // 2 * c1 * c2 - let t4 = Fp2.sqr(c2); // c2² - return { - c0: Fp2.add(Fp2.mulByNonresidue(t3), t0), // T3 * (u + 1) + T0 - c1: Fp2.add(Fp2.mulByNonresidue(t4), t1), // T4 * (u + 1) + T1 - // T1 + (c0 - c1 + c2)² + T3 - T0 - T4 - c2: Fp2.sub(Fp2.sub(Fp2.add(Fp2.add(t1, Fp2.sqr(Fp2.add(Fp2.sub(c0, c1), c2))), t3), t0), t4), - }; -}; -type Fp6Utils = { - fromBigSix: (tuple: BigintSix) => Fp6; - mulByNonresidue: (num: Fp6) => Fp6; - frobeniusMap(num: Fp6, power: number): Fp6; - multiplyBy1(num: Fp6, b1: Fp2): Fp6; - multiplyBy01(num: Fp6, b0: Fp2, b1: Fp2): Fp6; - multiplyByFp2(lhs: Fp6, rhs: Fp2): Fp6; -}; - -const Fp6: mod.IField & Fp6Utils = { - ORDER: Fp2.ORDER, // TODO: unused, but need to verify - BITS: 3 * Fp2.BITS, - BYTES: 3 * Fp2.BYTES, - MASK: bitMask(3 * Fp2.BITS), - ZERO: { c0: Fp2.ZERO, c1: Fp2.ZERO, c2: Fp2.ZERO }, - ONE: { c0: Fp2.ONE, c1: Fp2.ZERO, c2: Fp2.ZERO }, - create: (num) => num, - isValid: ({ c0, c1, c2 }) => Fp2.isValid(c0) && Fp2.isValid(c1) && Fp2.isValid(c2), - is0: ({ c0, c1, c2 }) => Fp2.is0(c0) && Fp2.is0(c1) && Fp2.is0(c2), - neg: ({ c0, c1, c2 }) => ({ c0: Fp2.neg(c0), c1: Fp2.neg(c1), c2: Fp2.neg(c2) }), - eql: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) => - Fp2.eql(c0, r0) && Fp2.eql(c1, r1) && Fp2.eql(c2, r2), - sqrt: () => { - throw new Error('Not implemented'); - }, - // Do we need division by bigint at all? Should be done via order: - div: (lhs, rhs) => Fp6.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp6.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp6, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp6, nums), - // Normalized - add: Fp6Add, - sub: Fp6Subtract, - mul: Fp6Multiply, - sqr: Fp6Square, - // NonNormalized stuff - addN: Fp6Add, - subN: Fp6Subtract, - mulN: Fp6Multiply, - sqrN: Fp6Square, - - inv: ({ c0, c1, c2 }) => { - let t0 = Fp2.sub(Fp2.sqr(c0), Fp2.mulByNonresidue(Fp2.mul(c2, c1))); // c0² - c2 * c1 * (u + 1) - let t1 = Fp2.sub(Fp2.mulByNonresidue(Fp2.sqr(c2)), Fp2.mul(c0, c1)); // c2² * (u + 1) - c0 * c1 - let t2 = Fp2.sub(Fp2.sqr(c1), Fp2.mul(c0, c2)); // c1² - c0 * c2 - // 1/(((c2 * T1 + c1 * T2) * v) + c0 * T0) - let t4 = Fp2.inv( - Fp2.add(Fp2.mulByNonresidue(Fp2.add(Fp2.mul(c2, t1), Fp2.mul(c1, t2))), Fp2.mul(c0, t0)) - ); - return { c0: Fp2.mul(t4, t0), c1: Fp2.mul(t4, t1), c2: Fp2.mul(t4, t2) }; - }, - // Bytes utils - fromBytes: (b: Uint8Array): Fp6 => { - if (b.length !== Fp6.BYTES) throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp2.fromBytes(b.subarray(0, Fp2.BYTES)), - c1: Fp2.fromBytes(b.subarray(Fp2.BYTES, 2 * Fp2.BYTES)), - c2: Fp2.fromBytes(b.subarray(2 * Fp2.BYTES)), - }; - }, - toBytes: ({ c0, c1, c2 }): Uint8Array => - concatB(Fp2.toBytes(c0), Fp2.toBytes(c1), Fp2.toBytes(c2)), - cmov: ({ c0, c1, c2 }: Fp6, { c0: r0, c1: r1, c2: r2 }: Fp6, c) => ({ - c0: Fp2.cmov(c0, r0, c), - c1: Fp2.cmov(c1, r1, c), - c2: Fp2.cmov(c2, r2, c), - }), - // Utils - // fromTriple(triple: [Fp2, Fp2, Fp2]) { - // return new Fp6(...triple); - // } - // toString() { - // return `Fp6(${this.c0} + ${this.c1} * v, ${this.c2} * v^2)`; - // } - fromBigSix: (t: BigintSix): Fp6 => { - if (!Array.isArray(t) || t.length !== 6) throw new Error('Invalid Fp6 usage'); - return { - c0: Fp2.fromBigTuple(t.slice(0, 2)), - c1: Fp2.fromBigTuple(t.slice(2, 4)), - c2: Fp2.fromBigTuple(t.slice(4, 6)), - }; - }, - frobeniusMap: ({ c0, c1, c2 }, power: number) => ({ - c0: Fp2.frobeniusMap(c0, power), - c1: Fp2.mul(Fp2.frobeniusMap(c1, power), FP6_FROBENIUS_COEFFICIENTS_1[power % 6]), - c2: Fp2.mul(Fp2.frobeniusMap(c2, power), FP6_FROBENIUS_COEFFICIENTS_2[power % 6]), - }), - mulByNonresidue: ({ c0, c1, c2 }) => ({ c0: Fp2.mulByNonresidue(c2), c1: c0, c2: c1 }), - - // Sparse multiplication - multiplyBy1: ({ c0, c1, c2 }, b1: Fp2): Fp6 => ({ - c0: Fp2.mulByNonresidue(Fp2.mul(c2, b1)), - c1: Fp2.mul(c0, b1), - c2: Fp2.mul(c1, b1), - }), - // Sparse multiplication - multiplyBy01({ c0, c1, c2 }, b0: Fp2, b1: Fp2): Fp6 { - let t0 = Fp2.mul(c0, b0); // c0 * b0 - let t1 = Fp2.mul(c1, b1); // c1 * b1 - return { - // ((c1 + c2) * b1 - T1) * (u + 1) + T0 - c0: Fp2.add(Fp2.mulByNonresidue(Fp2.sub(Fp2.mul(Fp2.add(c1, c2), b1), t1)), t0), - // (b0 + b1) * (c0 + c1) - T0 - T1 - c1: Fp2.sub(Fp2.sub(Fp2.mul(Fp2.add(b0, b1), Fp2.add(c0, c1)), t0), t1), - // (c0 + c2) * b0 - T0 + T1 - c2: Fp2.add(Fp2.sub(Fp2.mul(Fp2.add(c0, c2), b0), t0), t1), - }; - }, - - multiplyByFp2: ({ c0, c1, c2 }, rhs: Fp2): Fp6 => ({ - c0: Fp2.mul(c0, rhs), - c1: Fp2.mul(c1, rhs), - c2: Fp2.mul(c2, rhs), - }), -}; - -const FP6_FROBENIUS_COEFFICIENTS_1 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt('0x0'), - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' - ), - ], - [ - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' - ), - BigInt('0x0'), - ], - [BigInt('0x0'), BigInt('0x1')], - [ - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' - ), - BigInt('0x0'), - ], - [ - BigInt('0x0'), - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' - ), - ], -].map((pair) => Fp2.fromBigTuple(pair)); -const FP6_FROBENIUS_COEFFICIENTS_2 = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff' - ), - BigInt('0x0'), - ], -].map((pair) => Fp2.fromBigTuple(pair)); - -// Finite extension field over irreducible polynominal. -// Fp₁₂ = Fp₆² => Fp₂³ -// Fp₆(w) / (w² - γ) where γ = v -type Fp12 = { c0: Fp6; c1: Fp6 }; -// The BLS parameter x for BLS12-381 -const BLS_X = BigInt('0xd201000000010000'); -const BLS_X_LEN = bitLen(BLS_X); - -// prettier-ignore -type BigintTwelve = [ - bigint, bigint, bigint, bigint, bigint, bigint, - bigint, bigint, bigint, bigint, bigint, bigint - ]; -const Fp12Add = ({ c0, c1 }: Fp12, { c0: r0, c1: r1 }: Fp12) => ({ - c0: Fp6.add(c0, r0), - c1: Fp6.add(c1, r1), -}); -const Fp12Subtract = ({ c0, c1 }: Fp12, { c0: r0, c1: r1 }: Fp12) => ({ - c0: Fp6.sub(c0, r0), - c1: Fp6.sub(c1, r1), -}); -const Fp12Multiply = ({ c0, c1 }: Fp12, rhs: Fp12 | bigint) => { - if (typeof rhs === 'bigint') return { c0: Fp6.mul(c0, rhs), c1: Fp6.mul(c1, rhs) }; - let { c0: r0, c1: r1 } = rhs; - let t1 = Fp6.mul(c0, r0); // c0 * r0 - let t2 = Fp6.mul(c1, r1); // c1 * r1 - return { - c0: Fp6.add(t1, Fp6.mulByNonresidue(t2)), // T1 + T2 * v - // (c0 + c1) * (r0 + r1) - (T1 + T2) - c1: Fp6.sub(Fp6.mul(Fp6.add(c0, c1), Fp6.add(r0, r1)), Fp6.add(t1, t2)), - }; -}; -const Fp12Square = ({ c0, c1 }: Fp12) => { - let ab = Fp6.mul(c0, c1); // c0 * c1 - return { - // (c1 * v + c0) * (c0 + c1) - AB - AB * v - c0: Fp6.sub( - Fp6.sub(Fp6.mul(Fp6.add(Fp6.mulByNonresidue(c1), c0), Fp6.add(c0, c1)), ab), - Fp6.mulByNonresidue(ab) - ), - c1: Fp6.add(ab, ab), - }; // AB + AB -}; -function Fp4Square(a: Fp2, b: Fp2): { first: Fp2; second: Fp2 } { - const a2 = Fp2.sqr(a); - const b2 = Fp2.sqr(b); - return { - first: Fp2.add(Fp2.mulByNonresidue(b2), a2), // b² * Nonresidue + a² - second: Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(a, b)), a2), b2), // (a + b)² - a² - b² - }; -} -type Fp12Utils = { - fromBigTwelve: (t: BigintTwelve) => Fp12; - frobeniusMap(num: Fp12, power: number): Fp12; - multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12; - multiplyByFp2(lhs: Fp12, rhs: Fp2): Fp12; - conjugate(num: Fp12): Fp12; - finalExponentiate(num: Fp12): Fp12; - _cyclotomicSquare(num: Fp12): Fp12; - _cyclotomicExp(num: Fp12, n: bigint): Fp12; -}; - -const Fp12: mod.IField & Fp12Utils = { - ORDER: Fp2.ORDER, // TODO: unused, but need to verify - BITS: 2 * Fp2.BITS, - BYTES: 2 * Fp2.BYTES, - MASK: bitMask(2 * Fp2.BITS), - ZERO: { c0: Fp6.ZERO, c1: Fp6.ZERO }, - ONE: { c0: Fp6.ONE, c1: Fp6.ZERO }, - create: (num) => num, - isValid: ({ c0, c1 }) => Fp6.isValid(c0) && Fp6.isValid(c1), - is0: ({ c0, c1 }) => Fp6.is0(c0) && Fp6.is0(c1), - neg: ({ c0, c1 }) => ({ c0: Fp6.neg(c0), c1: Fp6.neg(c1) }), - eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp6.eql(c0, r0) && Fp6.eql(c1, r1), - sqrt: () => { - throw new Error('Not implemented'); - }, - inv: ({ c0, c1 }) => { - let t = Fp6.inv(Fp6.sub(Fp6.sqr(c0), Fp6.mulByNonresidue(Fp6.sqr(c1)))); // 1 / (c0² - c1² * v) - return { c0: Fp6.mul(c0, t), c1: Fp6.neg(Fp6.mul(c1, t)) }; // ((C0 * T) * T) + (-C1 * T) * w - }, - div: (lhs, rhs) => - Fp12.mul(lhs, typeof rhs === 'bigint' ? Fp.inv(Fp.create(rhs)) : Fp12.inv(rhs)), - pow: (num, power) => mod.FpPow(Fp12, num, power), - invertBatch: (nums) => mod.FpInvertBatch(Fp12, nums), - // Normalized - add: Fp12Add, - sub: Fp12Subtract, - mul: Fp12Multiply, - sqr: Fp12Square, - // NonNormalized stuff - addN: Fp12Add, - subN: Fp12Subtract, - mulN: Fp12Multiply, - sqrN: Fp12Square, - - // Bytes utils - fromBytes: (b: Uint8Array): Fp12 => { - if (b.length !== Fp12.BYTES) throw new Error(`fromBytes wrong length=${b.length}`); - return { - c0: Fp6.fromBytes(b.subarray(0, Fp6.BYTES)), - c1: Fp6.fromBytes(b.subarray(Fp6.BYTES)), - }; - }, - toBytes: ({ c0, c1 }): Uint8Array => concatB(Fp6.toBytes(c0), Fp6.toBytes(c1)), - cmov: ({ c0, c1 }, { c0: r0, c1: r1 }, c) => ({ - c0: Fp6.cmov(c0, r0, c), - c1: Fp6.cmov(c1, r1, c), - }), - // Utils - // toString() { - // return `Fp12(${this.c0} + ${this.c1} * w)`; - // }, - // fromTuple(c: [Fp6, Fp6]) { - // return new Fp12(...c); - // } - fromBigTwelve: (t: BigintTwelve): Fp12 => ({ - c0: Fp6.fromBigSix(t.slice(0, 6) as BigintSix), - c1: Fp6.fromBigSix(t.slice(6, 12) as BigintSix), - }), - // Raises to q**i -th power - frobeniusMap(lhs, power: number) { - const r0 = Fp6.frobeniusMap(lhs.c0, power); - const { c0, c1, c2 } = Fp6.frobeniusMap(lhs.c1, power); - const coeff = FP12_FROBENIUS_COEFFICIENTS[power % 12]; - return { - c0: r0, - c1: Fp6.create({ - c0: Fp2.mul(c0, coeff), - c1: Fp2.mul(c1, coeff), - c2: Fp2.mul(c2, coeff), - }), - }; - }, - // Sparse multiplication - multiplyBy014: ({ c0, c1 }, o0: Fp2, o1: Fp2, o4: Fp2) => { - let t0 = Fp6.multiplyBy01(c0, o0, o1); - let t1 = Fp6.multiplyBy1(c1, o4); - return { - c0: Fp6.add(Fp6.mulByNonresidue(t1), t0), // T1 * v + T0 - // (c1 + c0) * [o0, o1+o4] - T0 - T1 - c1: Fp6.sub(Fp6.sub(Fp6.multiplyBy01(Fp6.add(c1, c0), o0, Fp2.add(o1, o4)), t0), t1), - }; - }, - multiplyByFp2: ({ c0, c1 }, rhs: Fp2): Fp12 => ({ - c0: Fp6.multiplyByFp2(c0, rhs), - c1: Fp6.multiplyByFp2(c1, rhs), - }), - conjugate: ({ c0, c1 }): Fp12 => ({ c0, c1: Fp6.neg(c1) }), - - // A cyclotomic group is a subgroup of Fp^n defined by - // GΦₙ(p) = {α ∈ Fpⁿ : α^Φₙ(p) = 1} - // The result of any pairing is in a cyclotomic subgroup - // https://eprint.iacr.org/2009/565.pdf - _cyclotomicSquare: ({ c0, c1 }): Fp12 => { - const { c0: c0c0, c1: c0c1, c2: c0c2 } = c0; - const { c0: c1c0, c1: c1c1, c2: c1c2 } = c1; - const { first: t3, second: t4 } = Fp4Square(c0c0, c1c1); - const { first: t5, second: t6 } = Fp4Square(c1c0, c0c2); - const { first: t7, second: t8 } = Fp4Square(c0c1, c1c2); - let t9 = Fp2.mulByNonresidue(t8); // T8 * (u + 1) - return { - c0: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.sub(t3, c0c0), _2n), t3), // 2 * (T3 - c0c0) + T3 - c1: Fp2.add(Fp2.mul(Fp2.sub(t5, c0c1), _2n), t5), // 2 * (T5 - c0c1) + T5 - c2: Fp2.add(Fp2.mul(Fp2.sub(t7, c0c2), _2n), t7), - }), // 2 * (T7 - c0c2) + T7 - c1: Fp6.create({ - c0: Fp2.add(Fp2.mul(Fp2.add(t9, c1c0), _2n), t9), // 2 * (T9 + c1c0) + T9 - c1: Fp2.add(Fp2.mul(Fp2.add(t4, c1c1), _2n), t4), // 2 * (T4 + c1c1) + T4 - c2: Fp2.add(Fp2.mul(Fp2.add(t6, c1c2), _2n), t6), - }), - }; // 2 * (T6 + c1c2) + T6 - }, - _cyclotomicExp(num, n) { - let z = Fp12.ONE; - for (let i = BLS_X_LEN - 1; i >= 0; i--) { - z = Fp12._cyclotomicSquare(z); - if (bitGet(n, i)) z = Fp12.mul(z, num); - } - return z; - }, - // https://eprint.iacr.org/2010/354.pdf - // https://eprint.iacr.org/2009/565.pdf - finalExponentiate: (num) => { - const x = BLS_X; - // this^(q⁶) / this - const t0 = Fp12.div(Fp12.frobeniusMap(num, 6), num); - // t0^(q²) * t0 - const t1 = Fp12.mul(Fp12.frobeniusMap(t0, 2), t0); - const t2 = Fp12.conjugate(Fp12._cyclotomicExp(t1, x)); - const t3 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicSquare(t1)), t2); - const t4 = Fp12.conjugate(Fp12._cyclotomicExp(t3, x)); - const t5 = Fp12.conjugate(Fp12._cyclotomicExp(t4, x)); - const t6 = Fp12.mul(Fp12.conjugate(Fp12._cyclotomicExp(t5, x)), Fp12._cyclotomicSquare(t2)); - const t7 = Fp12.conjugate(Fp12._cyclotomicExp(t6, x)); - const t2_t5_pow_q2 = Fp12.frobeniusMap(Fp12.mul(t2, t5), 2); - const t4_t1_pow_q3 = Fp12.frobeniusMap(Fp12.mul(t4, t1), 3); - const t6_t1c_pow_q1 = Fp12.frobeniusMap(Fp12.mul(t6, Fp12.conjugate(t1)), 1); - const t7_t3c_t1 = Fp12.mul(Fp12.mul(t7, Fp12.conjugate(t3)), t1); - // (t2 * t5)^(q²) * (t4 * t1)^(q³) * (t6 * t1.conj)^(q^1) * t7 * t3.conj * t1 - return Fp12.mul(Fp12.mul(Fp12.mul(t2_t5_pow_q2, t4_t1_pow_q3), t6_t1c_pow_q1), t7_t3c_t1); - }, -}; -const FP12_FROBENIUS_COEFFICIENTS = [ - [BigInt('0x1'), BigInt('0x0')], - [ - BigInt( - '0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8' - ), - BigInt( - '0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3' - ), - ], - [ - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2' - ), - BigInt( - '0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09' - ), - ], - [ - BigInt( - '0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995' - ), - BigInt( - '0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116' - ), - ], - [ - BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3' - ), - BigInt( - '0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8' - ), - ], - [ - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09' - ), - BigInt( - '0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2' - ), - ], - [ - BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad' - ), - BigInt('0x0'), - ], - [ - BigInt( - '0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116' - ), - BigInt( - '0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995' - ), - ], -].map((n) => Fp2.fromBigTuple(n)); -// END OF CURVE FIELDS - -// HashToCurve - -// 3-isogeny map from E' to E -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#appendix-E.3 -const isogenyMapG2 = isogenyMap( - Fp2, - [ - // xNum - [ - [ - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6', - ], - [ - '0x0', - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d', - ], - [ - '0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1', - '0x0', - ], - ], - // xDen - [ - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63', - ], - [ - '0xc', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f', - ], - ['0x1', '0x0'], // LAST 1 - ], - // yNum - [ - [ - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - '0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706', - ], - [ - '0x0', - '0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be', - ], - [ - '0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c', - '0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f', - ], - [ - '0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10', - '0x0', - ], - ], - // yDen - [ - [ - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb', - ], - [ - '0x0', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3', - ], - [ - '0x12', - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99', - ], - ['0x1', '0x0'], // LAST 1 - ], - ].map((i) => i.map((pair) => Fp2.fromBigTuple(pair.map(BigInt)))) as [Fp2[], Fp2[], Fp2[], Fp2[]] -); -// 11-isogeny map from E' to E -const isogenyMapG1 = isogenyMap( - Fp, - [ - // xNum - [ - '0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7', - '0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb', - '0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0', - '0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861', - '0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9', - '0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983', - '0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84', - '0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e', - '0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317', - '0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e', - '0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b', - '0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229', - ], - // xDen - [ - '0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c', - '0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff', - '0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19', - '0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8', - '0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e', - '0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5', - '0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a', - '0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e', - '0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641', - '0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33', - '0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696', - '0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6', - '0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb', - '0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb', - '0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0', - '0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2', - '0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29', - '0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587', - '0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30', - '0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132', - '0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e', - '0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8', - '0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133', - '0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b', - '0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604', - ], - // yDen - [ - '0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1', - '0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d', - '0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2', - '0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416', - '0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d', - '0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac', - '0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c', - '0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9', - '0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a', - '0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55', - '0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8', - '0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092', - '0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc', - '0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7', - '0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f', - '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - ].map((i) => i.map((j) => BigInt(j))) as [Fp[], Fp[], Fp[], Fp[]] -); - -// SWU Map - Fp2 to G2': y² = x³ + 240i * x + 1012 + 1012i -const G2_SWU = mapToCurveSimpleSWU(Fp2, { - A: Fp2.create({ c0: Fp.create(_0n), c1: Fp.create(BigInt(240)) }), // A' = 240 * I - B: Fp2.create({ c0: Fp.create(BigInt(1012)), c1: Fp.create(BigInt(1012)) }), // B' = 1012 * (1 + I) - Z: Fp2.create({ c0: Fp.create(BigInt(-2)), c1: Fp.create(BigInt(-1)) }), // Z: -(2 + I) -}); -// Optimized SWU Map - Fp to G1 -const G1_SWU = mapToCurveSimpleSWU(Fp, { - A: Fp.create( - BigInt( - '0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d' - ) - ), - B: Fp.create( - BigInt( - '0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0' - ) - ), - Z: Fp.create(BigInt(11)), -}); - -// Endomorphisms (for fast cofactor clearing) -// Ψ(P) endomorphism -const ut_root = Fp6.create({ c0: Fp2.ZERO, c1: Fp2.ONE, c2: Fp2.ZERO }); -const wsq = Fp12.create({ c0: ut_root, c1: Fp6.ZERO }); -const wcu = Fp12.create({ c0: Fp6.ZERO, c1: ut_root }); -const [wsq_inv, wcu_inv] = Fp12.invertBatch([wsq, wcu]); -function psi(x: Fp2, y: Fp2): [Fp2, Fp2] { - // Untwist Fp2->Fp12 && frobenius(1) && twist back - const x2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wsq_inv, x), 1), wsq).c0.c0; - const y2 = Fp12.mul(Fp12.frobeniusMap(Fp12.multiplyByFp2(wcu_inv, y), 1), wcu).c0.c0; - return [x2, y2]; -} -// Ψ endomorphism -function G2psi(c: ProjConstructor, P: ProjPointType) { - const affine = P.toAffine(); - const p = psi(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} -// Ψ²(P) endomorphism -// 1 / F2(2)^((p-1)/3) in GF(p²) -const PSI2_C1 = BigInt( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' -); - -function psi2(x: Fp2, y: Fp2): [Fp2, Fp2] { - return [Fp2.mul(x, PSI2_C1), Fp2.neg(y)]; -} -function G2psi2(c: ProjConstructor, P: ProjPointType) { - const affine = P.toAffine(); - const p = psi2(affine.x, affine.y); - return new c(p[0], p[1], Fp2.ONE); -} - -// Default hash_to_field options are for hash to G2. -// -// Parameter definitions are in section 5.3 of the spec unless otherwise noted. -// Parameter values come from section 8.8.2 of the spec. -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-8.8.2 -// -// Base field F is GF(p^m) -// p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab -// m = 2 (or 1 for G1 see section 8.8.1) -// k = 128 -const htfDefaults = Object.freeze({ - // DST: a domain separation tag - // defined in section 2.2.5 - // Use utils.getDSTLabel(), utils.setDSTLabel(value) - DST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - encodeDST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', - // p: the characteristic of F - // where F is a finite field of characteristic p and order q = p^m - p: Fp.ORDER, - // m: the extension degree of F, m >= 1 - // where F is a finite field of characteristic p and order q = p^m - m: 2, - // k: the target security level for the suite in bits - // defined in section 5.1 - k: 128, - // option to use a message that has already been processed by - // expand_message_xmd - expand: 'xmd', - // Hash functions for: expand_message_xmd is appropriate for use with a - // wide range of hash functions, including SHA-2, SHA-3, BLAKE2, and others. - // BBS+ uses blake2: https://github.com/hyperledger/aries-framework-go/issues/2247 - hash: sha256, -} as const); - -// Encoding utils -// Point on G1 curve: (x, y) -const C_BIT_POS = Fp.BITS; // C_bit, compression bit for serialization flag -const I_BIT_POS = Fp.BITS + 1; // I_bit, point-at-infinity bit for serialization flag -const S_BIT_POS = Fp.BITS + 2; // S_bit, sign bit for serialization flag -// Compressed point of infinity -const COMPRESSED_ZERO = Fp.toBytes(bitSet(bitSet(_0n, I_BIT_POS, true), S_BIT_POS, true)); // set compressed & point-at-infinity bits - -function signatureG2ToRawBytes(point: ProjPointType) { - // NOTE: by some reasons it was missed in bls12-381, looks like bug - point.assertValidity(); - const len = Fp.BYTES; - if (point.equals(bls12_381.G2.ProjectivePoint.ZERO)) - return concatB(COMPRESSED_ZERO, numberToBytesBE(_0n, len)); - const { x, y } = point.toAffine(); - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - const tmp = y1 > _0n ? y1 * _2n : y0 * _2n; - const aflag1 = Boolean((tmp / Fp.ORDER) & _1n); - const z1 = bitSet(bitSet(x1, 381, aflag1), S_BIT_POS, true); - const z2 = x0; - return concatB(numberToBytesBE(z1, len), numberToBytesBE(z2, len)); -} - -// To verify curve parameters, see pairing-friendly-curves spec: -// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-pairing-friendly-curves-09 -// Basic math is done over finite fields over p. -// More complicated math is done over polynominal extension fields. -// To simplify calculations in Fp12, we construct extension tower: -// Fp₁₂ = Fp₆² => Fp₂³ -// Fp(u) / (u² - β) where β = -1 -// Fp₂(v) / (v³ - ξ) where ξ = u + 1 -// Fp₆(w) / (w² - γ) where γ = v -// Here goes constants && point encoding format -export const bls12_381: CurveFn = bls({ - // Fields - fields: { - Fp, - Fp2, - Fp6, - Fp12, - Fr, - }, - // G1 is the order-q subgroup of E1(Fp) : y² = x³ + 4, #E1(Fp) = h1q, where - // characteristic; z + (z⁴ - z² + 1)(z - 1)²/3 - G1: { - Fp, - // cofactor; (z - 1)²/3 - h: BigInt('0x396c8c005555e1568c00aaab0000aaab'), - // generator's coordinates - // x = 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507 - // y = 1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569 - Gx: BigInt( - '0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb' - ), - Gy: BigInt( - '0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1' - ), - a: Fp.ZERO, - b: _4n, - htfDefaults: { ...htfDefaults, m: 1 }, - wrapPrivateKey: true, - allowInfinityPoint: true, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, point): boolean => { - // φ endomorphism - const cubicRootOfUnityModP = BigInt( - '0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' - ); - const phi = new c(Fp.mul(point.px, cubicRootOfUnityModP), point.py, point.pz); - - // todo: unroll - const xP = point.multiplyUnsafe(bls12_381.params.x).negate(); // [x]P - const u2P = xP.multiplyUnsafe(bls12_381.params.x); // [u2]P - return u2P.equals(phi); - - // https://eprint.iacr.org/2019/814.pdf - // (z² − 1)/3 - // const c1 = BigInt('0x396c8c005555e1560000000055555555'); - // const P = this; - // const S = P.sigma(); - // const Q = S.double(); - // const S2 = S.sigma(); - // // [(z² − 1)/3](2σ(P) − P − σ²(P)) − σ²(P) = O - // const left = Q.subtract(P).subtract(S2).multiplyUnsafe(c1); - // const C = left.subtract(S2); - // return C.isZero(); - }, - // Clear cofactor of G1 - // https://eprint.iacr.org/2019/403 - clearCofactor: (c, point) => { - // return this.multiplyUnsafe(CURVE.h); - return point.multiplyUnsafe(bls12_381.params.x).add(point); // x*P + P - }, - mapToCurve: (scalars: bigint[]) => { - const { x, y } = G1_SWU(Fp.create(scalars[0])); - return isogenyMapG1(x, y); - }, - fromBytes: (bytes: Uint8Array): AffinePoint => { - bytes = bytes.slice(); - if (bytes.length === 48) { - // TODO: Fp.bytes - const P = Fp.ORDER; - const compressedValue = bytesToNumberBE(bytes); - const bflag = bitGet(compressedValue, I_BIT_POS); - // Zero - if (bflag === _1n) return { x: _0n, y: _0n }; - const x = Fp.create(compressedValue & Fp.MASK); - const right = Fp.add(Fp.pow(x, _3n), Fp.create(bls12_381.params.G1b)); // y² = x³ + b - let y = Fp.sqrt(right); - if (!y) throw new Error('Invalid compressed G1 point'); - const aflag = bitGet(compressedValue, C_BIT_POS); - if ((y * _2n) / P !== aflag) y = Fp.neg(y); - return { x: Fp.create(x), y: Fp.create(y) }; - } else if (bytes.length === 96) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) return bls12_381.G1.ProjectivePoint.ZERO.toAffine(); - const x = bytesToNumberBE(bytes.subarray(0, Fp.BYTES)); - const y = bytesToNumberBE(bytes.subarray(Fp.BYTES)); - return { x: Fp.create(x), y: Fp.create(y) }; - } else { - throw new Error('Invalid point G1, expected 48/96 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) return COMPRESSED_ZERO.slice(); - const P = Fp.ORDER; - let num; - num = bitSet(x, C_BIT_POS, Boolean((y * _2n) / P)); // set aflag - num = bitSet(num, S_BIT_POS, true); - return numberToBytesBE(num, Fp.BYTES); - } else { - if (isZero) { - // 2x PUBLIC_KEY_LENGTH - const x = concatB(new Uint8Array([0x40]), new Uint8Array(2 * Fp.BYTES - 1)); - return x; - } else { - return concatB(numberToBytesBE(x, Fp.BYTES), numberToBytesBE(y, Fp.BYTES)); - } - } - }, - }, - // G2 is the order-q subgroup of E2(Fp²) : y² = x³+4(1+√−1), - // where Fp2 is Fp[√−1]/(x2+1). #E2(Fp2 ) = h2q, where - // G² - 1 - // h2q - G2: { - Fp: Fp2, - // cofactor - h: BigInt( - '0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5' - ), - Gx: Fp2.fromBigTuple([ - BigInt( - '0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8' - ), - BigInt( - '0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e' - ), - ]), - // y = - // 927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582, - // 1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905 - Gy: Fp2.fromBigTuple([ - BigInt( - '0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801' - ), - BigInt( - '0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be' - ), - ]), - a: Fp2.ZERO, - b: Fp2.fromBigTuple([_4n, _4n]), - hEff: BigInt( - '0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551' - ), - htfDefaults: { ...htfDefaults }, - wrapPrivateKey: true, - allowInfinityPoint: true, - mapToCurve: (scalars: bigint[]) => { - const { x, y } = G2_SWU(Fp2.fromBigTuple(scalars)); - return isogenyMapG2(x, y); - }, - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - isTorsionFree: (c, P): boolean => { - return P.multiplyUnsafe(bls12_381.params.x).negate().equals(G2psi(c, P)); // ψ(P) == [u](P) - // Older version: https://eprint.iacr.org/2019/814.pdf - // Ψ²(P) => Ψ³(P) => [z]Ψ³(P) where z = -x => [z]Ψ³(P) - Ψ²(P) + P == O - // return P.psi2().psi().mulNegX().subtract(psi2).add(P).isZero(); - }, - // Maps the point into the prime-order subgroup G2. - // clear_cofactor_bls12381_g2 from cfrg-hash-to-curve-11 - // https://eprint.iacr.org/2017/419.pdf - // prettier-ignore - clearCofactor: (c, P) => { - const x = bls12_381.params.x; - let t1 = P.multiplyUnsafe(x).negate(); // [-x]P - let t2 = G2psi(c, P); // Ψ(P) - let t3 = P.double(); // 2P - t3 = G2psi2(c, t3); // Ψ²(2P) - t3 = t3.subtract(t2); // Ψ²(2P) - Ψ(P) - t2 = t1.add(t2); // [-x]P + Ψ(P) - t2 = t2.multiplyUnsafe(x).negate(); // [x²]P - [x]Ψ(P) - t3 = t3.add(t2); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) - t3 = t3.subtract(t1); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - const Q = t3.subtract(P); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - 1P - return Q; // [x²-x-1]P + [x-1]Ψ(P) + Ψ²(2P) - }, - fromBytes: (bytes: Uint8Array): AffinePoint => { - bytes = bytes.slice(); - const m_byte = bytes[0] & 0xe0; - if (m_byte === 0x20 || m_byte === 0x60 || m_byte === 0xe0) { - throw new Error('Invalid encoding flag: ' + m_byte); - } - const bitC = m_byte & 0x80; // compression bit - const bitI = m_byte & 0x40; // point at infinity bit - const bitS = m_byte & 0x20; // sign bit - const L = Fp.BYTES; - const slc = (b: Uint8Array, from: number, to?: number) => bytesToNumberBE(b.slice(from, to)); - if (bytes.length === 96 && bitC) { - const b = bls12_381.params.G2b; - const P = Fp.ORDER; - - bytes[0] = bytes[0] & 0x1f; // clear flags - if (bitI) { - // check that all bytes are 0 - if (bytes.reduce((p, c) => (p !== 0 ? c + 1 : c), 0) > 0) { - throw new Error('Invalid compressed G2 point'); - } - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x_1 = slc(bytes, 0, L); - const x_0 = slc(bytes, L, 2 * L); - const x = Fp2.create({ c0: Fp.create(x_0), c1: Fp.create(x_1) }); - const right = Fp2.add(Fp2.pow(x, _3n), b); // y² = x³ + 4 * (u+1) = x³ + b - let y = Fp2.sqrt(right); - const Y_bit = y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P ? _1n : _0n; - y = bitS > 0 && Y_bit > 0 ? y : Fp2.neg(y); - return { x, y }; - } else if (bytes.length === 192 && !bitC) { - // Check if the infinity flag is set - if ((bytes[0] & (1 << 6)) !== 0) { - return { x: Fp2.ZERO, y: Fp2.ZERO }; - } - const x1 = slc(bytes, 0, L); - const x0 = slc(bytes, L, 2 * L); - const y1 = slc(bytes, 2 * L, 3 * L); - const y0 = slc(bytes, 3 * L, 4 * L); - return { x: Fp2.fromBigTuple([x0, x1]), y: Fp2.fromBigTuple([y0, y1]) }; - } else { - throw new Error('Invalid point G2, expected 96/192 bytes'); - } - }, - toBytes: (c, point, isCompressed) => { - const { BYTES: len, ORDER: P } = Fp; - const isZero = point.equals(c.ZERO); - const { x, y } = point.toAffine(); - if (isCompressed) { - if (isZero) return concatB(COMPRESSED_ZERO, numberToBytesBE(_0n, len)); - const flag = Boolean(y.c1 === _0n ? (y.c0 * _2n) / P : (y.c1 * _2n) / P); - // set compressed & sign bits (looks like different offsets than for G1/Fp?) - let x_1 = bitSet(x.c1, C_BIT_POS, flag); - x_1 = bitSet(x_1, S_BIT_POS, true); - return concatB(numberToBytesBE(x_1, len), numberToBytesBE(x.c0, len)); - } else { - if (isZero) return concatB(new Uint8Array([0x40]), new Uint8Array(4 * len - 1)); // bytes[0] |= 1 << 6; - const { re: x0, im: x1 } = Fp2.reim(x); - const { re: y0, im: y1 } = Fp2.reim(y); - return concatB( - numberToBytesBE(x1, len), - numberToBytesBE(x0, len), - numberToBytesBE(y1, len), - numberToBytesBE(y0, len) - ); - } - }, - Signature: { - // TODO: Optimize, it's very slow because of sqrt. - fromHex(hex: Hex): ProjPointType { - hex = ensureBytes('signatureHex', hex); - const P = Fp.ORDER; - const half = hex.length / 2; - if (half !== 48 && half !== 96) - throw new Error('Invalid compressed signature length, must be 96 or 192'); - const z1 = bytesToNumberBE(hex.slice(0, half)); - const z2 = bytesToNumberBE(hex.slice(half)); - // Indicates the infinity point - const bflag1 = bitGet(z1, I_BIT_POS); - if (bflag1 === _1n) return bls12_381.G2.ProjectivePoint.ZERO; - - const x1 = Fp.create(z1 & Fp.MASK); - const x2 = Fp.create(z2); - const x = Fp2.create({ c0: x2, c1: x1 }); - const y2 = Fp2.add(Fp2.pow(x, _3n), bls12_381.params.G2b); // y² = x³ + 4 - // The slow part - let y = Fp2.sqrt(y2); - if (!y) throw new Error('Failed to find a square root'); - - // Choose the y whose leftmost bit of the imaginary part is equal to the a_flag1 - // If y1 happens to be zero, then use the bit of y0 - const { re: y0, im: y1 } = Fp2.reim(y); - const aflag1 = bitGet(z1, 381); - const isGreater = y1 > _0n && (y1 * _2n) / P !== aflag1; - const isZero = y1 === _0n && (y0 * _2n) / P !== aflag1; - if (isGreater || isZero) y = Fp2.neg(y); - const point = bls12_381.G2.ProjectivePoint.fromAffine({ x, y }); - point.assertValidity(); - return point; - }, - toRawBytes(point: ProjPointType) { - return signatureG2ToRawBytes(point); - }, - toHex(point: ProjPointType) { - return bytesToHex(signatureG2ToRawBytes(point)); - }, - }, - }, - params: { - x: BLS_X, // The BLS parameter x for BLS12-381 - r: Fr.ORDER, // order; z⁴ − z² + 1; CURVE.n from other curves - }, - htfDefaults, - hash: sha256, - randomBytes, -}); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/bn254.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/bn254.ts deleted file mode 100644 index 64ccfe0c..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/bn254.ts +++ /dev/null @@ -1,21 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { weierstrass } from './abstract/weierstrass.js'; -import { getHash } from './_shortw_utils.js'; -import { Field } from './abstract/modular.js'; -/** - * bn254 pairing-friendly curve. - * Previously known as alt_bn_128, when it had 128-bit security. - * Recent research shown it's weaker, the naming has been adjusted to its prime bit count. - * https://github.com/zcash/zcash/issues/2502 - */ -export const bn254 = weierstrass({ - a: BigInt(0), - b: BigInt(3), - Fp: Field(BigInt('0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47')), - n: BigInt('0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001'), - Gx: BigInt(1), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/ed25519.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/ed25519.ts deleted file mode 100644 index da610dc7..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/ed25519.ts +++ /dev/null @@ -1,486 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha512 } from '@noble/hashes/sha512'; -import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils'; -import { ExtPointType, twistedEdwards } from './abstract/edwards.js'; -import { montgomery } from './abstract/montgomery.js'; -import { Field, FpSqrtEven, isNegativeLE, mod, pow2 } from './abstract/modular.js'; -import { - bytesToHex, - bytesToNumberLE, - ensureBytes, - equalBytes, - Hex, - numberToBytesLE, -} from './abstract/utils.js'; -import { createHasher, htfBasicOpts, expand_message_xmd } from './abstract/hash-to-curve.js'; -import { AffinePoint } from './abstract/curve.js'; - -/** - * ed25519 Twisted Edwards curve with following addons: - * - X25519 ECDH - * - Ristretto cofactor elimination - * - Elligator hash-to-group / point indistinguishability - */ - -const ED25519_P = BigInt( - '57896044618658097711785492504343953926634992332820282019728792003956564819949' -); -// √(-1) aka √(a) aka 2^((p-1)/4) -const ED25519_SQRT_M1 = BigInt( - '19681161376707505956807079304988542015446066515923890162744021073123829784752' -); - -// prettier-ignore -const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _5n = BigInt(5); -// prettier-ignore -const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80); - -function ed25519_pow_2_252_3(x: bigint) { - const P = ED25519_P; - const x2 = (x * x) % P; - const b2 = (x2 * x) % P; // x^3, 11 - const b4 = (pow2(b2, _2n, P) * b2) % P; // x^15, 1111 - const b5 = (pow2(b4, _1n, P) * x) % P; // x^31 - const b10 = (pow2(b5, _5n, P) * b5) % P; - const b20 = (pow2(b10, _10n, P) * b10) % P; - const b40 = (pow2(b20, _20n, P) * b20) % P; - const b80 = (pow2(b40, _40n, P) * b40) % P; - const b160 = (pow2(b80, _80n, P) * b80) % P; - const b240 = (pow2(b160, _80n, P) * b80) % P; - const b250 = (pow2(b240, _10n, P) * b10) % P; - const pow_p_5_8 = (pow2(b250, _2n, P) * x) % P; - // ^ To pow to (p+3)/8, multiply it by x. - return { pow_p_5_8, b2 }; -} - -function adjustScalarBytes(bytes: Uint8Array): Uint8Array { - // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar, - // set the three least significant bits of the first byte - bytes[0] &= 248; // 0b1111_1000 - // and the most significant bit of the last to zero, - bytes[31] &= 127; // 0b0111_1111 - // set the second most significant bit of the last byte to 1 - bytes[31] |= 64; // 0b0100_0000 - return bytes; -} - -// sqrt(u/v) -function uvRatio(u: bigint, v: bigint): { isValid: boolean; value: bigint } { - const P = ED25519_P; - const v3 = mod(v * v * v, P); // v³ - const v7 = mod(v3 * v3 * v, P); // v⁷ - // (p+3)/8 and (p-5)/8 - const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8; - let x = mod(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8 - const vx2 = mod(v * x * x, P); // vx² - const root1 = x; // First root candidate - const root2 = mod(x * ED25519_SQRT_M1, P); // Second root candidate - const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root - const useRoot2 = vx2 === mod(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4) - const noRoot = vx2 === mod(-u * ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1) - if (useRoot1) x = root1; - if (useRoot2 || noRoot) x = root2; // We return root2 anyway, for const-time - if (isNegativeLE(x, P)) x = mod(-x, P); - return { isValid: useRoot1 || useRoot2, value: x }; -} - -// Just in case -export const ED25519_TORSION_SUBGROUP = [ - '0100000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a', - '0000000000000000000000000000000000000000000000000000000000000080', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05', - 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f', - '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85', - '0000000000000000000000000000000000000000000000000000000000000000', - 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa', -]; - -const Fp = Field(ED25519_P, undefined, true); - -const ed25519Defaults = { - // Param: a - a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster - // d is equal to -121665/121666 over finite field. - // Negative number is P - number, and division is invert(number, P) - d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'), - // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n - Fp, - // Subgroup order: how many points curve has - // 2n**252n + 27742317777372353535851937790883648493n; - n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'), - Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'), - hash: sha512, - randomBytes, - adjustScalarBytes, - // dom2 - // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3. - // Constant-time, u/√v - uvRatio, -} as const; - -export const ed25519 = twistedEdwards(ed25519Defaults); - -function ed25519_domain(data: Uint8Array, ctx: Uint8Array, phflag: boolean) { - if (ctx.length > 255) throw new Error('Context is too big'); - return concatBytes( - utf8ToBytes('SigEd25519 no Ed25519 collisions'), - new Uint8Array([phflag ? 1 : 0, ctx.length]), - ctx, - data - ); -} - -export const ed25519ctx = twistedEdwards({ ...ed25519Defaults, domain: ed25519_domain }); -export const ed25519ph = twistedEdwards({ - ...ed25519Defaults, - domain: ed25519_domain, - prehash: sha512, -}); - -export const x25519 = /* @__PURE__ */ (() => - montgomery({ - P: ED25519_P, - a: BigInt(486662), - montgomeryBits: 255, // n is 253 bits - nByteLength: 32, - Gu: BigInt(9), - powPminus2: (x: bigint): bigint => { - const P = ED25519_P; - // x^(p-2) aka x^(2^255-21) - const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x); - return mod(pow2(pow_p_5_8, BigInt(3), P) * b2, P); - }, - adjustScalarBytes, - randomBytes, - }))(); - -/** - * Converts ed25519 public key to x25519 public key. Uses formula: - * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)` - * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))` - * @example - * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey()); - * const aPriv = x25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub)) - */ -export function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array { - const { y } = ed25519.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((_1n + y) * Fp.inv(_1n - y))); -} -export const edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated - -/** - * Converts ed25519 secret key to x25519 secret key. - * @example - * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey()); - * const aPriv = ed25519.utils.randomPrivateKey(); - * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub) - */ -export function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array { - const hashed = ed25519Defaults.hash(edwardsPriv.subarray(0, 32)); - return ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32); -} - -// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator) -// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since -// SageMath returns different root first and everything falls apart - -const ELL2_C1 = (Fp.ORDER + BigInt(3)) / BigInt(8); // 1. c1 = (q + 3) / 8 # Integer arithmetic - -const ELL2_C2 = Fp.pow(_2n, ELL2_C1); // 2. c2 = 2^c1 -const ELL2_C3 = Fp.sqrt(Fp.neg(Fp.ONE)); // 3. c3 = sqrt(-1) -const ELL2_C4 = (Fp.ORDER - BigInt(5)) / BigInt(8); // 4. c4 = (q - 5) / 8 # Integer arithmetic -const ELL2_J = BigInt(486662); - -// prettier-ignore -function map_to_curve_elligator2_curve25519(u: bigint) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1 - let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not - let x1n = Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2) - let tv2 = Fp.sqr(xd); // 5. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 11. tv3 = gxd^2 - tv2 = Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4 - tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3 - tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3 - tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7 - let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8) - y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8) - let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3 - tv2 = Fp.sqr(y11); // 19. tv2 = y11^2 - tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd - let e1 = Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1 - let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt - let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd - let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u - y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2 - let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3 - let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1) - tv2 = Fp.sqr(y21); // 28. tv2 = y21^2 - tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2 - let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt - tv2 = Fp.sqr(y1); // 32. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd - let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2 - let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4) - return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1) -} - -const ELL2_C1_EDWARDS = FpSqrtEven(Fp, Fp.neg(BigInt(486664))); // sgn0(c1) MUST equal 0 -function map_to_curve_elligator2_edwards25519(u: bigint) { - const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) = - // map_to_curve_elligator2_curve25519(u) - let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd - xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1 - let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM - let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd - let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d) - let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd - let e = Fp.eql(tv1, Fp.ZERO); // 8. e = tv1 == 0 - xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e) - xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e) - yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e) - yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e) - - const inv = Fp.invertBatch([xd, yd]); // batch division - return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd) -} - -const htf = /* @__PURE__ */ (() => - createHasher( - ed25519.ExtendedPoint, - (scalars: bigint[]) => map_to_curve_elligator2_edwards25519(scalars[0]), - { - DST: 'edwards25519_XMD:SHA-512_ELL2_RO_', - encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha512, - } - ))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); - -function assertRstPoint(other: unknown) { - if (!(other instanceof RistPoint)) throw new Error('RistrettoPoint expected'); -} - -// √(-1) aka √(a) aka 2^((p-1)/4) -const SQRT_M1 = ED25519_SQRT_M1; -// √(ad - 1) -const SQRT_AD_MINUS_ONE = BigInt( - '25063068953384623474111414158702152701244531502492656460079210482610430750235' -); -// 1 / √(a-d) -const INVSQRT_A_MINUS_D = BigInt( - '54469307008909316920995813868745141605393597292927456921205312896311721017578' -); -// 1-d² -const ONE_MINUS_D_SQ = BigInt( - '1159843021668779879193775521855586647937357759715417654439879720876111806838' -); -// (d-1)² -const D_MINUS_ONE_SQ = BigInt( - '40440834346308536858101042469323190826248399146238708352240133220865137265952' -); -// Calculates 1/√(number) -const invertSqrt = (number: bigint) => uvRatio(_1n, number); - -const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const bytes255ToNumberLE = (bytes: Uint8Array) => - ed25519.CURVE.Fp.create(bytesToNumberLE(bytes) & MAX_255B); - -type ExtendedPoint = ExtPointType; - -// Computes Elligator map for Ristretto -// https://ristretto.group/formulas/elligator.html -function calcElligatorRistrettoMap(r0: bigint): ExtendedPoint { - const { d } = ed25519.CURVE; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const r = mod(SQRT_M1 * r0 * r0); // 1 - const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2 - let c = BigInt(-1); // 3 - const D = mod((c - d * r) * mod(r + d)); // 4 - let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D); // 5 - let s_ = mod(s * r0); // 6 - if (!isNegativeLE(s_, P)) s_ = mod(-s_); - if (!Ns_D_is_sq) s = s_; // 7 - if (!Ns_D_is_sq) c = r; // 8 - const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D); // 9 - const s2 = s * s; - const W0 = mod((s + s) * D); // 10 - const W1 = mod(Nt * SQRT_AD_MINUS_ONE); // 11 - const W2 = mod(_1n - s2); // 12 - const W3 = mod(_1n + s2); // 13 - return new ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2)); -} - -/** - * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be - * a source of bugs for protocols like ring signatures. Ristretto was created to solve this. - * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint, - * but it should work in its own namespace: do not combine those two. - * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448 - */ -class RistPoint { - static BASE: RistPoint; - static ZERO: RistPoint; - // Private property to discourage combining ExtendedPoint + RistrettoPoint - // Always use Ristretto encoding/decoding instead. - constructor(private readonly ep: ExtendedPoint) {} - - static fromAffine(ap: AffinePoint) { - return new RistPoint(ed25519.ExtendedPoint.fromAffine(ap)); - } - - /** - * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`. - * The hash-to-group operation applies Elligator twice and adds the results. - * **Note:** this is one-way map, there is no conversion from point to hash. - * https://ristretto.group/formulas/elligator.html - * @param hex 64-byte output of a hash function - */ - static hashToCurve(hex: Hex): RistPoint { - hex = ensureBytes('ristrettoHash', hex, 64); - const r1 = bytes255ToNumberLE(hex.slice(0, 32)); - const R1 = calcElligatorRistrettoMap(r1); - const r2 = bytes255ToNumberLE(hex.slice(32, 64)); - const R2 = calcElligatorRistrettoMap(r2); - return new RistPoint(R1.add(R2)); - } - - /** - * Converts ristretto-encoded string to ristretto point. - * https://ristretto.group/formulas/decoding.html - * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding - */ - static fromHex(hex: Hex): RistPoint { - hex = ensureBytes('ristrettoHex', hex, 32); - const { a, d } = ed25519.CURVE; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint'; - const s = bytes255ToNumberLE(hex); - // 1. Check that s_bytes is the canonical encoding of a field element, or else abort. - // 3. Check that s is non-negative, or else abort - if (!equalBytes(numberToBytesLE(s, 32), hex) || isNegativeLE(s, P)) throw new Error(emsg); - const s2 = mod(s * s); - const u1 = mod(_1n + a * s2); // 4 (a is -1) - const u2 = mod(_1n - a * s2); // 5 - const u1_2 = mod(u1 * u1); - const u2_2 = mod(u2 * u2); - const v = mod(a * d * u1_2 - u2_2); // 6 - const { isValid, value: I } = invertSqrt(mod(v * u2_2)); // 7 - const Dx = mod(I * u2); // 8 - const Dy = mod(I * Dx * v); // 9 - let x = mod((s + s) * Dx); // 10 - if (isNegativeLE(x, P)) x = mod(-x); // 10 - const y = mod(u1 * Dy); // 11 - const t = mod(x * y); // 12 - if (!isValid || isNegativeLE(t, P) || y === _0n) throw new Error(emsg); - return new RistPoint(new ed25519.ExtendedPoint(x, y, _1n, t)); - } - - /** - * Encodes ristretto point to Uint8Array. - * https://ristretto.group/formulas/encoding.html - */ - toRawBytes(): Uint8Array { - let { ex: x, ey: y, ez: z, et: t } = this.ep; - const P = ed25519.CURVE.Fp.ORDER; - const mod = ed25519.CURVE.Fp.create; - const u1 = mod(mod(z + y) * mod(z - y)); // 1 - const u2 = mod(x * y); // 2 - // Square root always exists - const u2sq = mod(u2 * u2); - const { value: invsqrt } = invertSqrt(mod(u1 * u2sq)); // 3 - const D1 = mod(invsqrt * u1); // 4 - const D2 = mod(invsqrt * u2); // 5 - const zInv = mod(D1 * D2 * t); // 6 - let D: bigint; // 7 - if (isNegativeLE(t * zInv, P)) { - let _x = mod(y * SQRT_M1); - let _y = mod(x * SQRT_M1); - x = _x; - y = _y; - D = mod(D1 * INVSQRT_A_MINUS_D); - } else { - D = D2; // 8 - } - if (isNegativeLE(x * zInv, P)) y = mod(-y); // 9 - let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a)) - if (isNegativeLE(s, P)) s = mod(-s); - return numberToBytesLE(s, 32); // 11 - } - - toHex(): string { - return bytesToHex(this.toRawBytes()); - } - - toString(): string { - return this.toHex(); - } - - // Compare one point to another. - equals(other: RistPoint): boolean { - assertRstPoint(other); - const { ex: X1, ey: Y1 } = this.ep; - const { ex: X2, ey: Y2 } = other.ep; - const mod = ed25519.CURVE.Fp.create; - // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2) - const one = mod(X1 * Y2) === mod(Y1 * X2); - const two = mod(Y1 * Y2) === mod(X1 * X2); - return one || two; - } - - add(other: RistPoint): RistPoint { - assertRstPoint(other); - return new RistPoint(this.ep.add(other.ep)); - } - - subtract(other: RistPoint): RistPoint { - assertRstPoint(other); - return new RistPoint(this.ep.subtract(other.ep)); - } - - multiply(scalar: bigint): RistPoint { - return new RistPoint(this.ep.multiply(scalar)); - } - - multiplyUnsafe(scalar: bigint): RistPoint { - return new RistPoint(this.ep.multiplyUnsafe(scalar)); - } -} -export const RistrettoPoint = /* @__PURE__ */ (() => { - if (!RistPoint.BASE) RistPoint.BASE = new RistPoint(ed25519.ExtendedPoint.BASE); - if (!RistPoint.ZERO) RistPoint.ZERO = new RistPoint(ed25519.ExtendedPoint.ZERO); - return RistPoint; -})(); - -// https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/14/ -// Appendix B. Hashing to ristretto255 -export const hash_to_ristretto255 = (msg: Uint8Array, options: htfBasicOpts) => { - const d = options.DST; - const DST = typeof d === 'string' ? utf8ToBytes(d) : d; - const uniform_bytes = expand_message_xmd(msg, DST, 64, sha512); - const P = RistPoint.hashToCurve(uniform_bytes); - return P; -}; diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/ed448.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/ed448.ts deleted file mode 100644 index b0cf63e9..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/ed448.ts +++ /dev/null @@ -1,247 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { shake256 } from '@noble/hashes/sha3'; -import { concatBytes, randomBytes, utf8ToBytes, wrapConstructor } from '@noble/hashes/utils'; -import { twistedEdwards } from './abstract/edwards.js'; -import { mod, pow2, Field } from './abstract/modular.js'; -import { montgomery } from './abstract/montgomery.js'; -import { createHasher } from './abstract/hash-to-curve.js'; - -/** - * Edwards448 (not Ed448-Goldilocks) curve with following addons: - * * X448 ECDH - * Conforms to RFC 8032 https://www.rfc-editor.org/rfc/rfc8032.html#section-5.2 - */ - -const shake256_114 = wrapConstructor(() => shake256.create({ dkLen: 114 })); -const shake256_64 = wrapConstructor(() => shake256.create({ dkLen: 64 })); -const ed448P = BigInt( - '726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439' -); - -// powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4. -// Used for efficient square root calculation. -// ((P-3)/4).toString(2) would produce bits [223x 1, 0, 222x 1] -function ed448_pow_Pminus3div4(x: bigint): bigint { - const P = ed448P; - // prettier-ignore - const _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _11n = BigInt(11); - // prettier-ignore - const _22n = BigInt(22), _44n = BigInt(44), _88n = BigInt(88), _223n = BigInt(223); - const b2 = (x * x * x) % P; - const b3 = (b2 * b2 * x) % P; - const b6 = (pow2(b3, _3n, P) * b3) % P; - const b9 = (pow2(b6, _3n, P) * b3) % P; - const b11 = (pow2(b9, _2n, P) * b2) % P; - const b22 = (pow2(b11, _11n, P) * b11) % P; - const b44 = (pow2(b22, _22n, P) * b22) % P; - const b88 = (pow2(b44, _44n, P) * b44) % P; - const b176 = (pow2(b88, _88n, P) * b88) % P; - const b220 = (pow2(b176, _44n, P) * b44) % P; - const b222 = (pow2(b220, _2n, P) * b2) % P; - const b223 = (pow2(b222, _1n, P) * x) % P; - return (pow2(b223, _223n, P) * b222) % P; -} - -function adjustScalarBytes(bytes: Uint8Array): Uint8Array { - // Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0, and the most - // significant bit of the last byte to 1. - bytes[0] &= 252; // 0b11111100 - // and the most significant bit of the last byte to 1. - bytes[55] |= 128; // 0b10000000 - // NOTE: is is NOOP for 56 bytes scalars (X25519/X448) - bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits) - return bytes; -} - -const Fp = Field(ed448P, 456, true); -const _4n = BigInt(4); - -const ED448_DEF = { - // Param: a - a: BigInt(1), - // -39081. Negative number is P - number - d: BigInt( - '726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358' - ), - // Finite field 𝔽p over which we'll do calculations; 2n**448n - 2n**224n - 1n - Fp, - // Subgroup order: how many points curve has; - // 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n - n: BigInt( - '181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779' - ), - nBitLength: 456, - // Cofactor - h: BigInt(4), - // Base point (x, y) aka generator point - Gx: BigInt( - '224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710' - ), - Gy: BigInt( - '298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660' - ), - // SHAKE256(dom4(phflag,context)||x, 114) - hash: shake256_114, - randomBytes, - adjustScalarBytes, - // dom4 - domain: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => { - if (ctx.length > 255) throw new Error(`Context is too big: ${ctx.length}`); - return concatBytes( - utf8ToBytes('SigEd448'), - new Uint8Array([phflag ? 1 : 0, ctx.length]), - ctx, - data - ); - }, - - // Constant-time ratio of u to v. Allows to combine inversion and square root u/√v. - // Uses algo from RFC8032 5.1.3. - uvRatio: (u: bigint, v: bigint): { isValid: boolean; value: bigint } => { - const P = ed448P; - // https://datatracker.ietf.org/doc/html/rfc8032#section-5.2.3 - // To compute the square root of (u/v), the first step is to compute the - // candidate root x = (u/v)^((p+1)/4). This can be done using the - // following trick, to use a single modular powering for both the - // inversion of v and the square root: - // x = (u/v)^((p+1)/4) = u³v(u⁵v³)^((p-3)/4) (mod p) - const u2v = mod(u * u * v, P); // u²v - const u3v = mod(u2v * u, P); // u³v - const u5v3 = mod(u3v * u2v * v, P); // u⁵v³ - const root = ed448_pow_Pminus3div4(u5v3); - const x = mod(u3v * root, P); - // Verify that root is exists - const x2 = mod(x * x, P); // x² - // If vx² = u, the recovered x-coordinate is x. Otherwise, no - // square root exists, and the decoding fails. - return { isValid: mod(x2 * v, P) === u, value: x }; - }, -} as const; - -export const ed448 = twistedEdwards(ED448_DEF); -// NOTE: there is no ed448ctx, since ed448 supports ctx by default -export const ed448ph = twistedEdwards({ ...ED448_DEF, prehash: shake256_64 }); - -export const x448 = /* @__PURE__ */ (() => - montgomery({ - a: BigInt(156326), - montgomeryBits: 448, - nByteLength: 57, - P: ed448P, - Gu: BigInt(5), - powPminus2: (x: bigint): bigint => { - const P = ed448P; - const Pminus3div4 = ed448_pow_Pminus3div4(x); - const Pminus3 = pow2(Pminus3div4, BigInt(2), P); - return mod(Pminus3 * x, P); // Pminus3 * x = Pminus2 - }, - adjustScalarBytes, - randomBytes, - }))(); - -/** - * Converts edwards448 public key to x448 public key. Uses formula: - * * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)` - * * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))` - * @example - * const aPub = ed448.getPublicKey(utils.randomPrivateKey()); - * x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub)) - */ -export function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array { - const { y } = ed448.ExtendedPoint.fromHex(edwardsPub); - const _1n = BigInt(1); - return Fp.toBytes(Fp.create((y - _1n) * Fp.inv(y + _1n))); -} -export const edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated - -// Hash To Curve Elligator2 Map -const ELL2_C1 = (Fp.ORDER - BigInt(3)) / BigInt(4); // 1. c1 = (q - 3) / 4 # Integer arithmetic -const ELL2_J = BigInt(156326); -function map_to_curve_elligator2_curve448(u: bigint) { - let tv1 = Fp.sqr(u); // 1. tv1 = u^2 - let e1 = Fp.eql(tv1, Fp.ONE); // 2. e1 = tv1 == 1 - tv1 = Fp.cmov(tv1, Fp.ZERO, e1); // 3. tv1 = CMOV(tv1, 0, e1) # If Z * u^2 == -1, set tv1 = 0 - let xd = Fp.sub(Fp.ONE, tv1); // 4. xd = 1 - tv1 - let x1n = Fp.neg(ELL2_J); // 5. x1n = -J - let tv2 = Fp.sqr(xd); // 6. tv2 = xd^2 - let gxd = Fp.mul(tv2, xd); // 7. gxd = tv2 * xd # gxd = xd^3 - let gx1 = Fp.mul(tv1, Fp.neg(ELL2_J)); // 8. gx1 = -J * tv1 # x1n + J * xd - gx1 = Fp.mul(gx1, x1n); // 9. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd - gx1 = Fp.add(gx1, tv2); // 10. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2 - gx1 = Fp.mul(gx1, x1n); // 11. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2 - let tv3 = Fp.sqr(gxd); // 12. tv3 = gxd^2 - tv2 = Fp.mul(gx1, gxd); // 13. tv2 = gx1 * gxd # gx1 * gxd - tv3 = Fp.mul(tv3, tv2); // 14. tv3 = tv3 * tv2 # gx1 * gxd^3 - let y1 = Fp.pow(tv3, ELL2_C1); // 15. y1 = tv3^c1 # (gx1 * gxd^3)^((p - 3) / 4) - y1 = Fp.mul(y1, tv2); // 16. y1 = y1 * tv2 # gx1 * gxd * (gx1 * gxd^3)^((p - 3) / 4) - let x2n = Fp.mul(x1n, Fp.neg(tv1)); // 17. x2n = -tv1 * x1n # x2 = x2n / xd = -1 * u^2 * x1n / xd - let y2 = Fp.mul(y1, u); // 18. y2 = y1 * u - y2 = Fp.cmov(y2, Fp.ZERO, e1); // 19. y2 = CMOV(y2, 0, e1) - tv2 = Fp.sqr(y1); // 20. tv2 = y1^2 - tv2 = Fp.mul(tv2, gxd); // 21. tv2 = tv2 * gxd - let e2 = Fp.eql(tv2, gx1); // 22. e2 = tv2 == gx1 - let xn = Fp.cmov(x2n, x1n, e2); // 23. xn = CMOV(x2n, x1n, e2) # If e2, x = x1, else x = x2 - let y = Fp.cmov(y2, y1, e2); // 24. y = CMOV(y2, y1, e2) # If e2, y = y1, else y = y2 - let e3 = Fp.isOdd(y); // 25. e3 = sgn0(y) == 1 # Fix sign of y - y = Fp.cmov(y, Fp.neg(y), e2 !== e3); // 26. y = CMOV(y, -y, e2 XOR e3) - return { xn, xd, yn: y, yd: Fp.ONE }; // 27. return (xn, xd, y, 1) -} -function map_to_curve_elligator2_edwards448(u: bigint) { - let { xn, xd, yn, yd } = map_to_curve_elligator2_curve448(u); // 1. (xn, xd, yn, yd) = map_to_curve_elligator2_curve448(u) - let xn2 = Fp.sqr(xn); // 2. xn2 = xn^2 - let xd2 = Fp.sqr(xd); // 3. xd2 = xd^2 - let xd4 = Fp.sqr(xd2); // 4. xd4 = xd2^2 - let yn2 = Fp.sqr(yn); // 5. yn2 = yn^2 - let yd2 = Fp.sqr(yd); // 6. yd2 = yd^2 - let xEn = Fp.sub(xn2, xd2); // 7. xEn = xn2 - xd2 - let tv2 = Fp.sub(xEn, xd2); // 8. tv2 = xEn - xd2 - xEn = Fp.mul(xEn, xd2); // 9. xEn = xEn * xd2 - xEn = Fp.mul(xEn, yd); // 10. xEn = xEn * yd - xEn = Fp.mul(xEn, yn); // 11. xEn = xEn * yn - xEn = Fp.mul(xEn, _4n); // 12. xEn = xEn * 4 - tv2 = Fp.mul(tv2, xn2); // 13. tv2 = tv2 * xn2 - tv2 = Fp.mul(tv2, yd2); // 14. tv2 = tv2 * yd2 - let tv3 = Fp.mul(yn2, _4n); // 15. tv3 = 4 * yn2 - let tv1 = Fp.add(tv3, yd2); // 16. tv1 = tv3 + yd2 - tv1 = Fp.mul(tv1, xd4); // 17. tv1 = tv1 * xd4 - let xEd = Fp.add(tv1, tv2); // 18. xEd = tv1 + tv2 - tv2 = Fp.mul(tv2, xn); // 19. tv2 = tv2 * xn - let tv4 = Fp.mul(xn, xd4); // 20. tv4 = xn * xd4 - let yEn = Fp.sub(tv3, yd2); // 21. yEn = tv3 - yd2 - yEn = Fp.mul(yEn, tv4); // 22. yEn = yEn * tv4 - yEn = Fp.sub(yEn, tv2); // 23. yEn = yEn - tv2 - tv1 = Fp.add(xn2, xd2); // 24. tv1 = xn2 + xd2 - tv1 = Fp.mul(tv1, xd2); // 25. tv1 = tv1 * xd2 - tv1 = Fp.mul(tv1, xd); // 26. tv1 = tv1 * xd - tv1 = Fp.mul(tv1, yn2); // 27. tv1 = tv1 * yn2 - tv1 = Fp.mul(tv1, BigInt(-2)); // 28. tv1 = -2 * tv1 - let yEd = Fp.add(tv2, tv1); // 29. yEd = tv2 + tv1 - tv4 = Fp.mul(tv4, yd2); // 30. tv4 = tv4 * yd2 - yEd = Fp.add(yEd, tv4); // 31. yEd = yEd + tv4 - tv1 = Fp.mul(xEd, yEd); // 32. tv1 = xEd * yEd - let e = Fp.eql(tv1, Fp.ZERO); // 33. e = tv1 == 0 - xEn = Fp.cmov(xEn, Fp.ZERO, e); // 34. xEn = CMOV(xEn, 0, e) - xEd = Fp.cmov(xEd, Fp.ONE, e); // 35. xEd = CMOV(xEd, 1, e) - yEn = Fp.cmov(yEn, Fp.ONE, e); // 36. yEn = CMOV(yEn, 1, e) - yEd = Fp.cmov(yEd, Fp.ONE, e); // 37. yEd = CMOV(yEd, 1, e) - - const inv = Fp.invertBatch([xEd, yEd]); // batch division - return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd) -} - -const htf = /* @__PURE__ */ (() => - createHasher( - ed448.ExtendedPoint, - (scalars: bigint[]) => map_to_curve_elligator2_edwards448(scalars[0]), - { - DST: 'edwards448_XOF:SHAKE256_ELL2_RO_', - encodeDST: 'edwards448_XOF:SHAKE256_ELL2_NU_', - p: Fp.ORDER, - m: 1, - k: 224, - expand: 'xof', - hash: shake256, - } - ))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/index.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/index.ts deleted file mode 100644 index 0ffab527..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -throw new Error('Incorrect usage. Import submodules instead'); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/jubjub.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/jubjub.ts deleted file mode 100644 index 203cfa11..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/jubjub.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha512 } from '@noble/hashes/sha512'; -import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils'; -import { twistedEdwards } from './abstract/edwards.js'; -import { blake2s } from '@noble/hashes/blake2s'; -import { Field } from './abstract/modular.js'; - -/** - * jubjub Twisted Edwards curve. - * https://neuromancer.sk/std/other/JubJub - * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them. - */ - -export const jubjub = twistedEdwards({ - // Params: a, d - a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'), - d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'), - // Finite field 𝔽p over which we'll do calculations - // Same value as bls12-381 Fr (not Fp) - Fp: Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')), - // Subgroup order: how many points curve has - n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'), - // Cofactor - h: BigInt(8), - // Base point (x, y) aka generator point - Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'), - Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'), - hash: sha512, - randomBytes, -} as const); - -const GH_FIRST_BLOCK = utf8ToBytes( - '096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0' -); - -// Returns point at JubJub curve which is prime order and not zero -export function groupHash(tag: Uint8Array, personalization: Uint8Array) { - const h = blake2s.create({ personalization, dkLen: 32 }); - h.update(GH_FIRST_BLOCK); - h.update(tag); - // NOTE: returns ExtendedPoint, in case it will be multiplied later - let p = jubjub.ExtendedPoint.fromHex(h.digest()); - // NOTE: cannot replace with isSmallOrder, returns Point*8 - p = p.multiply(jubjub.CURVE.h); - if (p.equals(jubjub.ExtendedPoint.ZERO)) throw new Error('Point has small order'); - return p; -} - -export function findGroupHash(m: Uint8Array, personalization: Uint8Array) { - const tag = concatBytes(m, new Uint8Array([0])); - for (let i = 0; i < 256; i++) { - tag[tag.length - 1] = i; - try { - return groupHash(tag, personalization); - } catch (e) {} - } - throw new Error('findGroupHash tag overflow'); -} diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/p256.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/p256.ts deleted file mode 100644 index 164c4706..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/p256.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha256 } from '@noble/hashes/sha256'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; - -// NIST secp256r1 aka p256 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256 - -const Fp = Field(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff')); -const CURVE_A = Fp.create(BigInt('-3')); -const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b'); - -// prettier-ignore -export const p256 = createCurve({ - a: CURVE_A, // Equation params: a, b - b: CURVE_B, - Fp, // Field: 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n - // Curve order, total count of valid points in the field - n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'), - // Base (generator) point (x, y) - Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'), - Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'), - h: BigInt(1), - lowS: false, -} as const, sha256); -export const secp256r1 = p256; - -const mapSWU = /* @__PURE__ */ (() => - mapToCurveSimpleSWU(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-10')), - }))(); - -const htf = /* @__PURE__ */ (() => - createHasher(secp256r1.ProjectivePoint, (scalars: bigint[]) => mapSWU(scalars[0]), { - DST: 'P256_XMD:SHA-256_SSWU_RO_', - encodeDST: 'P256_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256, - }))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/p384.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/p384.ts deleted file mode 100644 index 436de9bc..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/p384.ts +++ /dev/null @@ -1,52 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha384 } from '@noble/hashes/sha512'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; - -// NIST secp384r1 aka p384 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384 - -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff'); -const Fp = Field(P); -const CURVE_A = Fp.create(BigInt('-3')); -// prettier-ignore -const CURVE_B = BigInt('0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef'); - -// prettier-ignore -export const p384 = createCurve({ - a: CURVE_A, // Equation params: a, b - b: CURVE_B, - Fp, // Field: 2n**384n - 2n**128n - 2n**96n + 2n**32n - 1n - // Curve order, total count of valid points in the field. - n: BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973'), - // Base (generator) point (x, y) - Gx: BigInt('0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7'), - Gy: BigInt('0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f'), - h: BigInt(1), - lowS: false, -} as const, sha384); -export const secp384r1 = p384; - -const mapSWU = /* @__PURE__ */ (() => - mapToCurveSimpleSWU(Fp, { - A: CURVE_A, - B: CURVE_B, - Z: Fp.create(BigInt('-12')), - }))(); - -const htf = /* @__PURE__ */ (() => - createHasher(secp384r1.ProjectivePoint, (scalars: bigint[]) => mapSWU(scalars[0]), { - DST: 'P384_XMD:SHA-384_SSWU_RO_', - encodeDST: 'P384_XMD:SHA-384_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 192, - expand: 'xmd', - hash: sha384, - }))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/p521.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/p521.ts deleted file mode 100644 index cc9fbbcb..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/p521.ts +++ /dev/null @@ -1,68 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha512 } from '@noble/hashes/sha512'; -import { Field } from './abstract/modular.js'; -import { mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import { createHasher } from './abstract/hash-to-curve.js'; - -// NIST secp521r1 aka p521 -// Note that it's 521, which differs from 512 of its hash function. -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521 - -// Field over which we'll do calculations. -// prettier-ignore -const P = BigInt('0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); -const Fp = Field(P); - -const CURVE = { - a: Fp.create(BigInt('-3')), - b: BigInt( - '0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00' - ), - Fp, - n: BigInt( - '0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409' - ), - Gx: BigInt( - '0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66' - ), - Gy: BigInt( - '0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650' - ), - h: BigInt(1), -}; - -// prettier-ignore -export const p521 = createCurve({ - a: CURVE.a, // Equation params: a, b - b: CURVE.b, - Fp, // Field: 2n**521n - 1n - // Curve order, total count of valid points in the field - n: CURVE.n, - Gx: CURVE.Gx, // Base point (x, y) aka generator point - Gy: CURVE.Gy, - h: CURVE.h, - lowS: false, - allowedPrivateKeyLengths: [130, 131, 132] // P521 keys are variable-length. Normalize to 132b -} as const, sha512); -export const secp521r1 = p521; - -const mapSWU = /* @__PURE__ */ (() => - mapToCurveSimpleSWU(Fp, { - A: CURVE.a, - B: CURVE.b, - Z: Fp.create(BigInt('-4')), - }))(); - -const htf = /* @__PURE__ */ (() => - createHasher(secp521r1.ProjectivePoint, (scalars: bigint[]) => mapSWU(scalars[0]), { - DST: 'P521_XMD:SHA-512_SSWU_RO_', - encodeDST: 'P521_XMD:SHA-512_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 256, - expand: 'xmd', - hash: sha512, - }))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/pasta.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/pasta.ts deleted file mode 100644 index faed89e9..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/pasta.ts +++ /dev/null @@ -1,31 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { weierstrass } from './abstract/weierstrass.js'; -import { getHash } from './_shortw_utils.js'; -import * as mod from './abstract/modular.js'; - -export const p = BigInt('0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001'); -export const q = BigInt('0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001'); - -// https://neuromancer.sk/std/other/Pallas -export const pallas = weierstrass({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(p), - n: q, - Gx: mod.mod(BigInt(-1), p), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); -// https://neuromancer.sk/std/other/Vesta -export const vesta = weierstrass({ - a: BigInt(0), - b: BigInt(5), - Fp: mod.Field(q), - n: p, - Gx: mod.mod(BigInt(-1), q), - Gy: BigInt(2), - h: BigInt(1), - ...getHash(sha256), -}); diff --git a/node_modules/nostr-tools/node_modules/@noble/curves/src/secp256k1.ts b/node_modules/nostr-tools/node_modules/@noble/curves/src/secp256k1.ts deleted file mode 100644 index 7119222d..00000000 --- a/node_modules/nostr-tools/node_modules/@noble/curves/src/secp256k1.ts +++ /dev/null @@ -1,274 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { sha256 } from '@noble/hashes/sha256'; -import { randomBytes } from '@noble/hashes/utils'; -import { Field, mod, pow2 } from './abstract/modular.js'; -import { ProjPointType as PointType, mapToCurveSimpleSWU } from './abstract/weierstrass.js'; -import type { Hex, PrivKey } from './abstract/utils.js'; -import { bytesToNumberBE, concatBytes, ensureBytes, numberToBytesBE } from './abstract/utils.js'; -import { createHasher, isogenyMap } from './abstract/hash-to-curve.js'; -import { createCurve } from './_shortw_utils.js'; - -const secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'); -const secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'); -const _1n = BigInt(1); -const _2n = BigInt(2); -const divNearest = (a: bigint, b: bigint) => (a + b / _2n) / b; - -/** - * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit. - * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00] - */ -function sqrtMod(y: bigint): bigint { - const P = secp256k1P; - // prettier-ignore - const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22); - // prettier-ignore - const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88); - const b2 = (y * y * y) % P; // x^3, 11 - const b3 = (b2 * b2 * y) % P; // x^7 - const b6 = (pow2(b3, _3n, P) * b3) % P; - const b9 = (pow2(b6, _3n, P) * b3) % P; - const b11 = (pow2(b9, _2n, P) * b2) % P; - const b22 = (pow2(b11, _11n, P) * b11) % P; - const b44 = (pow2(b22, _22n, P) * b22) % P; - const b88 = (pow2(b44, _44n, P) * b44) % P; - const b176 = (pow2(b88, _88n, P) * b88) % P; - const b220 = (pow2(b176, _44n, P) * b44) % P; - const b223 = (pow2(b220, _3n, P) * b3) % P; - const t1 = (pow2(b223, _23n, P) * b22) % P; - const t2 = (pow2(t1, _6n, P) * b2) % P; - const root = pow2(t2, _2n, P); - if (!Fp.eql(Fp.sqr(root), y)) throw new Error('Cannot find square root'); - return root; -} - -const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod }); - -export const secp256k1 = createCurve( - { - a: BigInt(0), // equation params: a, b - b: BigInt(7), // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975 - Fp, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n - n: secp256k1N, // Curve order, total count of valid points in the field - // Base point (x, y) aka generator point - Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'), - Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'), - h: BigInt(1), // Cofactor - lowS: true, // Allow only low-S signatures by default in sign() and verify() - /** - * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism. - * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%. - * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit. - * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066 - */ - endo: { - beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'), - splitScalar: (k: bigint) => { - const n = secp256k1N; - const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15'); - const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3'); - const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8'); - const b2 = a1; - const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16) - - const c1 = divNearest(b2 * k, n); - const c2 = divNearest(-b1 * k, n); - let k1 = mod(k - c1 * a1 - c2 * a2, n); - let k2 = mod(-c1 * b1 - c2 * b2, n); - const k1neg = k1 > POW_2_128; - const k2neg = k2 > POW_2_128; - if (k1neg) k1 = n - k1; - if (k2neg) k2 = n - k2; - if (k1 > POW_2_128 || k2 > POW_2_128) { - throw new Error('splitScalar: Endomorphism failed, k=' + k); - } - return { k1neg, k1, k2neg, k2 }; - }, - }, - }, - sha256 -); - -// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code. -// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki -const _0n = BigInt(0); -const fe = (x: bigint) => typeof x === 'bigint' && _0n < x && x < secp256k1P; -const ge = (x: bigint) => typeof x === 'bigint' && _0n < x && x < secp256k1N; -/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */ -const TAGGED_HASH_PREFIXES: { [tag: string]: Uint8Array } = {}; -function taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array { - let tagP = TAGGED_HASH_PREFIXES[tag]; - if (tagP === undefined) { - const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0))); - tagP = concatBytes(tagH, tagH); - TAGGED_HASH_PREFIXES[tag] = tagP; - } - return sha256(concatBytes(tagP, ...messages)); -} - -// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03 -const pointToBytes = (point: PointType) => point.toRawBytes(true).slice(1); -const numTo32b = (n: bigint) => numberToBytesBE(n, 32); -const modP = (x: bigint) => mod(x, secp256k1P); -const modN = (x: bigint) => mod(x, secp256k1N); -const Point = secp256k1.ProjectivePoint; -const GmulAdd = (Q: PointType, a: bigint, b: bigint) => - Point.BASE.multiplyAndAddUnsafe(Q, a, b); - -// Calculate point, scalar and bytes -function schnorrGetExtPubKey(priv: PrivKey) { - let d_ = secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey - let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside - const scalar = p.hasEvenY() ? d_ : modN(-d_); - return { scalar: scalar, bytes: pointToBytes(p) }; -} -/** - * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point. - * @returns valid point checked for being on-curve - */ -function lift_x(x: bigint): PointType { - if (!fe(x)) throw new Error('bad x: need 0 < x < p'); // Fail if x ≥ p. - const xx = modP(x * x); - const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p. - let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p. - if (y % _2n !== _0n) y = modP(-y); // Return the unique point P such that x(P) = x and - const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise. - p.assertValidity(); - return p; -} -/** - * Create tagged hash, convert it to bigint, reduce modulo-n. - */ -function challenge(...args: Uint8Array[]): bigint { - return modN(bytesToNumberBE(taggedHash('BIP0340/challenge', ...args))); -} - -/** - * Schnorr public key is just `x` coordinate of Point as per BIP340. - */ -function schnorrGetPublicKey(privateKey: Hex): Uint8Array { - return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G) -} - -/** - * Creates Schnorr signature as per BIP340. Verifies itself before returning anything. - * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous. - */ -function schnorrSign( - message: Hex, - privateKey: PrivKey, - auxRand: Hex = randomBytes(32) -): Uint8Array { - const m = ensureBytes('message', message); - const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder - const a = ensureBytes('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array - const t = numTo32b(d ^ bytesToNumberBE(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a) - const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m) - const k_ = modN(bytesToNumberBE(rand)); // Let k' = int(rand) mod n - if (k_ === _0n) throw new Error('sign failed: k is zero'); // Fail if k' = 0. - const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G. - const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n. - const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n). - sig.set(rx, 0); - sig.set(numTo32b(modN(k + e * d)), 32); - // If Verify(bytes(P), m, sig) (see below) returns failure, abort - if (!schnorrVerify(sig, m, px)) throw new Error('sign: Invalid signature produced'); - return sig; -} - -/** - * Verifies Schnorr signature. - * Will swallow errors & return false except for initial type validation of arguments. - */ -function schnorrVerify(signature: Hex, message: Hex, publicKey: Hex): boolean { - const sig = ensureBytes('signature', signature, 64); - const m = ensureBytes('message', message); - const pub = ensureBytes('publicKey', publicKey, 32); - try { - const P = lift_x(bytesToNumberBE(pub)); // P = lift_x(int(pk)); fail if that fails - const r = bytesToNumberBE(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p. - if (!fe(r)) return false; - const s = bytesToNumberBE(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n. - if (!ge(s)) return false; - const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n - const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P - if (!R || !R.hasEvenY() || R.toAffine().x !== r) return false; // -eP == (n-e)P - return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r. - } catch (error) { - return false; - } -} - -export const schnorr = /* @__PURE__ */ (() => ({ - getPublicKey: schnorrGetPublicKey, - sign: schnorrSign, - verify: schnorrVerify, - utils: { - randomPrivateKey: secp256k1.utils.randomPrivateKey, - lift_x, - pointToBytes, - numberToBytesBE, - bytesToNumberBE, - taggedHash, - mod, - }, -}))(); - -const isoMap = /* @__PURE__ */ (() => - isogenyMap( - Fp, - [ - // xNum - [ - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7', - '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581', - '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262', - '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c', - ], - // xDen - [ - '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b', - '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - // yNum - [ - '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c', - '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3', - '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931', - '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84', - ], - // yDen - [ - '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b', - '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573', - '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f', - '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1 - ], - ].map((i) => i.map((j) => BigInt(j))) as [bigint[], bigint[], bigint[], bigint[]] - ))(); -const mapSWU = /* @__PURE__ */ (() => - mapToCurveSimpleSWU(Fp, { - A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'), - B: BigInt('1771'), - Z: Fp.create(BigInt('-11')), - }))(); -const htf = /* @__PURE__ */ (() => - createHasher( - secp256k1.ProjectivePoint, - (scalars: bigint[]) => { - const { x, y } = mapSWU(Fp.create(scalars[0])); - return isoMap(x, y); - }, - { - DST: 'secp256k1_XMD:SHA-256_SSWU_RO_', - encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_', - p: Fp.ORDER, - m: 1, - k: 128, - expand: 'xmd', - hash: sha256, - } - ))(); -export const hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)(); -export const encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)(); diff --git a/node_modules/eventemitter3/LICENSE b/node_modules/tseep/LICENSE old mode 100644 new mode 100755 similarity index 94% rename from node_modules/eventemitter3/LICENSE rename to node_modules/tseep/LICENSE index abcbd54e..1bd70e7e --- a/node_modules/eventemitter3/LICENSE +++ b/node_modules/tseep/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2014 Arnout Kazemier +Copyright (c) 2018 Vladimir Kruzhkov @morglod Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/node_modules/tseep/README.md b/node_modules/tseep/README.md new file mode 100755 index 00000000..93f7c508 --- /dev/null +++ b/node_modules/tseep/README.md @@ -0,0 +1,96 @@ +[![NPM Version](https://badge.fury.io/js/tseep.svg?style=flat)](https://www.npmjs.com/package/tseep) +[![GitHub stars](https://img.shields.io/github/stars/Morglod/tseep.svg?style=social&label=Star)](https://GitHub.com/Morglod/tseep/) + +# tseep + +Because there are N fastest event emitters. And we are fastest (feb 2023) 😏. + +Up to **x12** faster than `eventemitter3` in terms of "classic api event emitters" (currently fastest for not classic too). + +--- + +- Fully typed args of `emit` method based on events map +- Fully implements `NodeJS.EventEmitter` type & standart, provides interface +- Worlds fastest pure-js `EventEmitter` +- Fully tested with eventemitter3 tests +- No external deps + +[how it works](./docs/how_it_works_en.md) + +## Benchmarks + +emit-multiple-listeners: +``` +tseep x 40,569,711 ops/sec <--- +EventEmitter1 x 4,498,223 ops/sec +EventEmitter2 x 4,536,296 ops/sec +EventEmitter3 x 5,852,395 ops/sec +fastemitter x 6,127,215 ops/sec +event-emitter x 3,449,595 ops/sec +contra/emitter x 2,186,002 ops/sec +tsee x 5,231,167 ops/sec +emitix x 6,549,983 ops/sec +Fastest is [ 'tseep' ] +``` + +[benchmarks](./benchmarks/README.md) + +Make an issue to include yours event emitter, lets find the fastest! + +## Install & use + +``` +npm i tseep +``` + +Simple usage: + +```ts +import { EventEmitter } from "tseep"; + +const events = new EventEmitter<{ + foo: (a: number, b: string) => void; +}>(); + +// foo's arguments is fully type checked +events.emit("foo", 123, "hello world"); +``` + +## Api + +`EventEmitter` where `T` extends `{ [eventName]: Call signature }`. + +`EventEmitter.emit`'s args is fully typed based on events map. + +!! **`__proto__`** event name is restricted (type guard exists) !! + +```ts +// Listener = (...args: any[]) => Promise|void +// EventMap extends { [event in (string|symbol)]: Listener } + +class EventEmitter { + readonly maxListeners: number; + readonly _eventsCount: number; + + emit(event: EventKey, ...args: ArgsN): boolean; + on(event: EventKey, listener: EventMap[EventKey]): this; + once(event: EventKey, listener: EventMap[EventKey]): this; + addListener(event: EventKey, listener: EventMap[EventKey], argsNum?: ArgsNum): this; + removeListener(event: EventKey, listener: EventMap[EventKey]): this; + hasListeners(event: EventKey): boolean; + prependListener(event: EventKey, listener: EventMap[EventKey]): this; + prependOnceListener(event: EventKey, listener: EventMap[EventKey]): this; + off(event: EventKey, listener: EventMap[EventKey]): this; + removeAllListeners(event?: EventKey): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: EventKey): EventMap[EventKey][]; + rawListeners(event: EventKey): EventMap[EventKey][]; + eventNames(): Array; + listenerCount(type: EventKey): number; +} +``` + +## License + +MIT diff --git a/node_modules/tseep/lib/ee.d.ts b/node_modules/tseep/lib/ee.d.ts new file mode 100644 index 00000000..3f84a4df --- /dev/null +++ b/node_modules/tseep/lib/ee.d.ts @@ -0,0 +1,31 @@ +import { DefaultEventMap, IEventEmitter } from './index'; +import { TaskCollection } from './task-collection'; +import { ArgsNum } from './utils'; +/** Implemented event emitter */ +export declare class EventEmitter implements IEventEmitter { + events: { + [eventName in keyof EventMap]?: TaskCollection; + }; + onceEvents: { + [eventName in keyof EventMap]?: (EventMap[eventName][]) | EventMap[eventName]; + }; + _symbolKeys: Set; + maxListeners: number; + get _eventsCount(): number; + emit: (event: EventKey, ...args: Parameters) => boolean; + on: (event: EventKey, listener: EventMap[EventKey]) => this; + once: (event: EventKey, listener: EventMap[EventKey]) => this; + addListener: (event: EventKey, listener: EventMap[EventKey], argsNum?: ArgsNum) => this; + removeListener: (event: EventKey, listener: EventMap[EventKey]) => this; + hasListeners: (event: EventKey) => boolean; + prependListener: (event: EventKey, listener: EventMap[EventKey]) => this; + prependOnceListener: (event: EventKey, listener: EventMap[EventKey]) => this; + off: (event: EventKey, listener: EventMap[EventKey]) => this; + removeAllListeners: (event?: EventKey) => this; + setMaxListeners: (n: number) => this; + getMaxListeners: () => number; + listeners: (event: EventKey) => EventMap[EventKey][]; + rawListeners: (event: EventKey) => EventMap[EventKey][]; + eventNames: () => Array; + listenerCount: (type: EventKey) => number; +} diff --git a/node_modules/tseep/lib/ee.js b/node_modules/tseep/lib/ee.js new file mode 100644 index 00000000..9f48c00b --- /dev/null +++ b/node_modules/tseep/lib/ee.js @@ -0,0 +1,254 @@ +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EventEmitter = void 0; +var task_collection_1 = require("./task-collection"); +var utils_1 = require("./utils"); +function emit(event, a, b, c, d, e) { + var ev = this.events[event]; + if (ev) { + if (ev.length === 0) + return false; + if (ev.argsNum < 6) { + ev.call(a, b, c, d, e); + } + else { + ev.call.apply(undefined, arguments); + } + return true; + } + return false; +} +function emitHasOnce(event, a, b, c, d, e) { + var ev = this.events[event]; + if (ev) { + if (ev.length === 0) + return false; + if (ev.argsNum < 6) { + ev.call(a, b, c, d, e); + } + else { + ev.call.apply(undefined, arguments); + } + } + var oev = this.onceEvents[event]; + if (oev) { + if (typeof oev === 'function') { + this.onceEvents[event] = undefined; + if (arguments.length < 6) { + oev(a, b, c, d, e); + } + else { + oev.apply(undefined, arguments); + } + } + else { + var fncs = oev; + this.onceEvents[event] = undefined; + if (arguments.length < 6) { + for (var i = 0; i < fncs.length; ++i) + fncs[i](a, b, c, d, e); + } + else { + for (var i = 0; i < fncs.length; ++i) + fncs[i].apply(undefined, arguments); + } + } + return true; + } + return !!ev; +} +/** Implemented event emitter */ +var EventEmitter = /** @class */ (function () { + function EventEmitter() { + this.events = (0, utils_1.nullObj)(); + this.onceEvents = (0, utils_1.nullObj)(); + this._symbolKeys = new Set; + this.maxListeners = Infinity; + } + Object.defineProperty(EventEmitter.prototype, "_eventsCount", { + get: function () { + return this.eventNames().length; + }, + enumerable: false, + configurable: true + }); + return EventEmitter; +}()); +exports.EventEmitter = EventEmitter; +function once(event, listener) { + if (this.emit === emit) { + this.emit = emitHasOnce; + } + switch (typeof this.onceEvents[event]) { + case 'undefined': + this.onceEvents[event] = listener; + if (typeof event === 'symbol') + this._symbolKeys.add(event); + break; + case 'function': + this.onceEvents[event] = [this.onceEvents[event], listener]; + break; + case 'object': + this.onceEvents[event].push(listener); + } + return this; +} +function addListener(event, listener, argsNum) { + if (argsNum === void 0) { argsNum = listener.length; } + if (typeof listener !== 'function') + throw new TypeError('The listener must be a function'); + var evtmap = this.events[event]; + if (!evtmap) { + this.events[event] = new task_collection_1.TaskCollection(argsNum, true, listener, false); + if (typeof event === 'symbol') + this._symbolKeys.add(event); + } + else { + evtmap.push(listener); + evtmap.growArgsNum(argsNum); + if (this.maxListeners !== Infinity && this.maxListeners <= evtmap.length) + console.warn("Maximum event listeners for \"".concat(String(event), "\" event!")); + } + return this; +} +function removeListener(event, listener) { + var evt = this.events[event]; + if (evt) { + evt.removeLast(listener); + } + var evto = this.onceEvents[event]; + if (evto) { + if (typeof evto === 'function') { + this.onceEvents[event] = undefined; + } + else if (typeof evto === 'object') { + if (evto.length === 1 && evto[0] === listener) { + this.onceEvents[event] = undefined; + } + else { + (0, task_collection_1._fast_remove_single)(evto, evto.lastIndexOf(listener)); + } + } + } + return this; +} +function hasListeners(event) { + return this.events[event] && !!this.events[event].length; +} +function prependListener(event, listener, argsNum) { + if (argsNum === void 0) { argsNum = listener.length; } + if (typeof listener !== 'function') + throw new TypeError('The listener must be a function'); + var evtmap = this.events[event]; + if (!evtmap || !(evtmap instanceof task_collection_1.TaskCollection)) { + evtmap = this.events[event] = new task_collection_1.TaskCollection(argsNum, true, listener, false); + if (typeof event === 'symbol') + this._symbolKeys.add(event); + } + else { + evtmap.insert(0, listener); + evtmap.growArgsNum(argsNum); + if (this.maxListeners !== Infinity && this.maxListeners <= evtmap.length) + console.warn("Maximum event listeners for \"".concat(String(event), "\" event!")); + } + return this; +} +function prependOnceListener(event, listener) { + if (this.emit === emit) { + this.emit = emitHasOnce; + } + var evtmap = this.onceEvents[event]; + if (!evtmap || typeof evtmap !== 'object') { + evtmap = this.onceEvents[event] = [listener]; + if (typeof event === 'symbol') + this._symbolKeys.add(event); + } + else { + // FIXME: + throw new Error('FIXME'); + // evtmap.unshift(listener); + if (this.maxListeners !== Infinity && this.maxListeners <= evtmap.length) + console.warn("Maximum event listeners for \"".concat(String(event), "\" once event!")); + } + return this; +} +function removeAllListeners(event) { + if (event === undefined) { + this.events = (0, utils_1.nullObj)(); + this.onceEvents = (0, utils_1.nullObj)(); + this._symbolKeys = new Set; + } + else { + this.events[event] = undefined; + this.onceEvents[event] = undefined; + if (typeof event === 'symbol') + this._symbolKeys.delete(event); + } + return this; +} +function setMaxListeners(n) { + this.maxListeners = n; + return this; +} +function getMaxListeners() { + return this.maxListeners; +} +function listeners(event) { + if (this.emit === emit) + return this.events[event] ? this.events[event].tasksAsArray().slice() : []; + else { + if (this.events[event] && this.onceEvents[event]) { + return __spreadArray(__spreadArray([], this.events[event].tasksAsArray(), true), (typeof this.onceEvents[event] === 'function' ? [this.onceEvents[event]] : this.onceEvents[event]), true); + } + else if (this.events[event]) + return this.events[event].tasksAsArray(); + else if (this.onceEvents[event]) + return (typeof this.onceEvents[event] === 'function' ? [this.onceEvents[event]] : this.onceEvents[event]); + else + return []; + } +} +function eventNames() { + var _this = this; + if (this.emit === emit) { + var keys = Object.keys(this.events); + return __spreadArray(__spreadArray([], keys, true), Array.from(this._symbolKeys), true).filter(function (x) { return (x in _this.events) && _this.events[x] && _this.events[x].length; }); + } + else { + var keys = Object.keys(this.events).filter(function (x) { return _this.events[x] && _this.events[x].length; }); + var keysO = Object.keys(this.onceEvents).filter(function (x) { return _this.onceEvents[x] && _this.onceEvents[x].length; }); + return __spreadArray(__spreadArray(__spreadArray([], keys, true), keysO, true), Array.from(this._symbolKeys).filter(function (x) { return (((x in _this.events) && _this.events[x] && _this.events[x].length) || + ((x in _this.onceEvents) && _this.onceEvents[x] && _this.onceEvents[x].length)); }), true); + } +} +function listenerCount(type) { + if (this.emit === emit) + return this.events[type] && this.events[type].length || 0; + else + return (this.events[type] && this.events[type].length || 0) + (this.onceEvents[type] && this.onceEvents[type].length || 0); +} +EventEmitter.prototype.emit = emit; +EventEmitter.prototype.on = addListener; +EventEmitter.prototype.once = once; +EventEmitter.prototype.addListener = addListener; +EventEmitter.prototype.removeListener = removeListener; +EventEmitter.prototype.hasListeners = hasListeners; +EventEmitter.prototype.prependListener = prependListener; +EventEmitter.prototype.prependOnceListener = prependOnceListener; +EventEmitter.prototype.off = removeListener; +EventEmitter.prototype.removeAllListeners = removeAllListeners; +EventEmitter.prototype.setMaxListeners = setMaxListeners; +EventEmitter.prototype.getMaxListeners = getMaxListeners; +EventEmitter.prototype.listeners = listeners; +EventEmitter.prototype.eventNames = eventNames; +EventEmitter.prototype.listenerCount = listenerCount; +//# sourceMappingURL=ee.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/ee.js.map b/node_modules/tseep/lib/ee.js.map new file mode 100644 index 00000000..5cae4dd8 --- /dev/null +++ b/node_modules/tseep/lib/ee.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ee.js","sourceRoot":"","sources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,IAAI,CAAC,CAAC;;QACtF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AACpI,CAAC;AAED,YAAY,CAAC,SAAS,CAAC,IAAI,GAAG,IAAW,CAAC;AAC1C,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG,WAAW,CAAC;AACxC,YAAY,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;AACnC,YAAY,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;AACjD,YAAY,CAAC,SAAS,CAAC,cAAc,GAAG,cAAc,CAAC;AACvD,YAAY,CAAC,SAAS,CAAC,YAAY,GAAG,YAAmB,CAAC;AAC1D,YAAY,CAAC,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;AACzD,YAAY,CAAC,SAAS,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;AACjE,YAAY,CAAC,SAAS,CAAC,GAAG,GAAG,cAAc,CAAC;AAC5C,YAAY,CAAC,SAAS,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAC/D,YAAY,CAAC,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;AACzD,YAAY,CAAC,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;AACzD,YAAY,CAAC,SAAS,CAAC,SAAS,GAAG,SAAgB,CAAC;AACpD,YAAY,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;AAC/C,YAAY,CAAC,SAAS,CAAC,aAAa,GAAG,aAAoB,CAAC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/index.d.ts b/node_modules/tseep/lib/index.d.ts new file mode 100644 index 00000000..7329e346 --- /dev/null +++ b/node_modules/tseep/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './ee'; diff --git a/node_modules/tseep/lib/index.js b/node_modules/tseep/lib/index.js new file mode 100644 index 00000000..ee8a7a19 --- /dev/null +++ b/node_modules/tseep/lib/index.js @@ -0,0 +1,19 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./types"), exports); +__exportStar(require("./ee"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/index.js.map b/node_modules/tseep/lib/index.js.map new file mode 100644 index 00000000..212349c9 --- /dev/null +++ b/node_modules/tseep/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,uCAAqB"} \ No newline at end of file diff --git a/node_modules/tseep/lib/opt-playground.d.ts b/node_modules/tseep/lib/opt-playground.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/node_modules/tseep/lib/opt-playground.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/tseep/lib/opt-playground.js b/node_modules/tseep/lib/opt-playground.js new file mode 100644 index 00000000..0be8a656 --- /dev/null +++ b/node_modules/tseep/lib/opt-playground.js @@ -0,0 +1,41 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var tseep = __importStar(require("./")); +var ee = new tseep.EventEmitter(); +function handler(a, b, c) { + if (arguments.length > 10) + throw new Error('aaa'); +} +for (var i = 0; i < 9999999999; ++i) { + for (var j = 0; j < 99999; ++j) { + ee.on('foo', handler); + } + for (var j = 0; j < 99999; ++j) { + ee.off('foo', handler); + } +} +console.log('ok'); +//# sourceMappingURL=opt-playground.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/opt-playground.js.map b/node_modules/tseep/lib/opt-playground.js.map new file mode 100644 index 00000000..03c93230 --- /dev/null +++ b/node_modules/tseep/lib/opt-playground.js.map @@ -0,0 +1 @@ +{"version":3,"file":"opt-playground.js","sourceRoot":"","sources":["../src/opt-playground.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA4B;AAE5B,IAAM,EAAE,GAAG,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;AAEpC,SAAS,OAAO,CAAC,CAAM,EAAC,CAAM,EAAC,CAAM;IACjC,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,EAAE;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE;QAC5B,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACzB;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE;QAC5B,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC1B;CACJ;AAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/patch.d.ts b/node_modules/tseep/lib/patch.d.ts new file mode 100644 index 00000000..d37a4d0e --- /dev/null +++ b/node_modules/tseep/lib/patch.d.ts @@ -0,0 +1,3 @@ +export declare function patchEE3(): void; +export declare function patchEvents(): void; +export declare function patchAll(): void; diff --git a/node_modules/tseep/lib/patch.js b/node_modules/tseep/lib/patch.js new file mode 100644 index 00000000..108b75b4 --- /dev/null +++ b/node_modules/tseep/lib/patch.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.patchAll = exports.patchEvents = exports.patchEE3 = void 0; +var ee_1 = require("./ee"); +function patchEE3() { + try { + var ee3 = require('eventemitter3'); + if (ee3) { + ee3.EventEmitter = ee_1.EventEmitter; + } + } + catch (err) { + console.error(err); + } +} +exports.patchEE3 = patchEE3; +function patchEvents() { + try { + var ee = require('events'); + if (ee) { + ee.EventEmitter = ee_1.EventEmitter; + } + } + catch (err) { + console.error(err); + } +} +exports.patchEvents = patchEvents; +function patchAll() { + patchEE3(); + patchEvents(); +} +exports.patchAll = patchAll; +//# sourceMappingURL=patch.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/patch.js.map b/node_modules/tseep/lib/patch.js.map new file mode 100644 index 00000000..f8f4a295 --- /dev/null +++ b/node_modules/tseep/lib/patch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"patch.js","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":";;;AAAA,2BAAoC;AAEpC,SAAgB,QAAQ;IACpB,IAAI;QACA,IAAM,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;QACrC,IAAI,GAAG,EAAE;YACL,GAAG,CAAC,YAAY,GAAG,iBAAY,CAAC;SACnC;KACJ;IAAC,OAAM,GAAG,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC;AATD,4BASC;AAED,SAAgB,WAAW;IACvB,IAAI;QACA,IAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,EAAE,EAAE;YACJ,EAAE,CAAC,YAAY,GAAG,iBAAY,CAAC;SAClC;KACJ;IAAC,OAAM,GAAG,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC;AATD,kCASC;AAED,SAAgB,QAAQ;IACpB,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;AAClB,CAAC;AAHD,4BAGC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/bake-collection.d.ts b/node_modules/tseep/lib/task-collection/bake-collection.d.ts new file mode 100644 index 00000000..a3f018e7 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/bake-collection.d.ts @@ -0,0 +1,5 @@ +import { ArgsNum } from "../utils"; +export declare const BAKED_EMPTY_FUNC: () => void; +export declare function bakeCollection void>(collection: Func[], fixedArgsNum: ArgsNum): (...args: Parameters) => void; +export declare function bakeCollectionAwait void>(collection: Func[], fixedArgsNum: ArgsNum): (...args: Parameters) => Promise; +export declare function bakeCollectionVariadic void>(collection: Func[]): (...args: Parameters) => void; diff --git a/node_modules/tseep/lib/task-collection/bake-collection.js b/node_modules/tseep/lib/task-collection/bake-collection.js new file mode 100644 index 00000000..1bfe7b18 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/bake-collection.js @@ -0,0 +1,120 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bakeCollectionVariadic = exports.bakeCollectionAwait = exports.bakeCollection = exports.BAKED_EMPTY_FUNC = void 0; +exports.BAKED_EMPTY_FUNC = (function () { }); +var FORLOOP_FALLBACK = 1500; +function generateArgsDefCode(numArgs) { + var argsDefCode = ''; + if (numArgs === 0) + return argsDefCode; + for (var i = 0; i < numArgs - 1; ++i) { + argsDefCode += ('arg' + String(i) + ', '); + } + argsDefCode += ('arg' + String(numArgs - 1)); + return argsDefCode; +} +function generateBodyPartsCode(argsDefCode, collectionLength) { + var funcDefCode = '', funcCallCode = ''; + for (var i = 0; i < collectionLength; ++i) { + funcDefCode += "var f".concat(i, " = collection[").concat(i, "];\n"); + funcCallCode += "f".concat(i, "(").concat(argsDefCode, ")\n"); + } + return { funcDefCode: funcDefCode, funcCallCode: funcCallCode }; +} +function generateBodyPartsVariadicCode(collectionLength) { + var funcDefCode = '', funcCallCode = ''; + for (var i = 0; i < collectionLength; ++i) { + funcDefCode += "var f".concat(i, " = collection[").concat(i, "];\n"); + funcCallCode += "f".concat(i, ".apply(undefined, arguments)\n"); + } + return { funcDefCode: funcDefCode, funcCallCode: funcCallCode }; +} +function bakeCollection(collection, fixedArgsNum) { + if (collection.length === 0) + return exports.BAKED_EMPTY_FUNC; + else if (collection.length === 1) + return collection[0]; + var funcFactoryCode; + if (collection.length < FORLOOP_FALLBACK) { + var argsDefCode = generateArgsDefCode(fixedArgsNum); + var _a = generateBodyPartsCode(argsDefCode, collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode; + funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function(").concat(argsDefCode, ") {\n ").concat(funcCallCode, "\n });\n })"); + } + else { + var argsDefCode = generateArgsDefCode(fixedArgsNum); + // loop unroll + if (collection.length % 10 === 0) { + funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 10) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n collection[i+3](").concat(argsDefCode, ");\n collection[i+4](").concat(argsDefCode, ");\n collection[i+5](").concat(argsDefCode, ");\n collection[i+6](").concat(argsDefCode, ");\n collection[i+7](").concat(argsDefCode, ");\n collection[i+8](").concat(argsDefCode, ");\n collection[i+9](").concat(argsDefCode, ");\n }\n });\n })"); + } + else if (collection.length % 4 === 0) { + funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 4) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n collection[i+3](").concat(argsDefCode, ");\n }\n });\n })"); + } + else if (collection.length % 3 === 0) { + funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 3) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n }\n });\n })"); + } + else { + funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; ++i) {\n collection[i](").concat(argsDefCode, ");\n }\n });\n })"); + } + } + { + // isolate + var bakeCollection_1 = undefined; + var fixedArgsNum_1 = undefined; + var bakeCollectionVariadic_1 = undefined; + var bakeCollectionAwait_1 = undefined; + var funcFactory = eval(funcFactoryCode); + return funcFactory(collection); + } +} +exports.bakeCollection = bakeCollection; +function bakeCollectionAwait(collection, fixedArgsNum) { + if (collection.length === 0) + return exports.BAKED_EMPTY_FUNC; + else if (collection.length === 1) + return collection[0]; + var funcFactoryCode; + if (collection.length < FORLOOP_FALLBACK) { + var argsDefCode = generateArgsDefCode(fixedArgsNum); + var _a = generateBodyPartsCode(argsDefCode, collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode; + funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function(").concat(argsDefCode, ") {\n return Promise.all([ ").concat(funcCallCode, " ]);\n });\n })"); + } + else { + var argsDefCode = generateArgsDefCode(fixedArgsNum); + funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n var promises = Array(collection.length);\n for (var i = 0; i < collection.length; ++i) {\n promises[i] = collection[i](").concat(argsDefCode, ");\n }\n return Promise.all(promises);\n });\n })"); + } + { + // isolate + var bakeCollection_2 = undefined; + var fixedArgsNum_2 = undefined; + var bakeCollectionVariadic_2 = undefined; + var bakeCollectionAwait_2 = undefined; + var funcFactory = eval(funcFactoryCode); + return funcFactory(collection); + } +} +exports.bakeCollectionAwait = bakeCollectionAwait; +function bakeCollectionVariadic(collection) { + if (collection.length === 0) + return exports.BAKED_EMPTY_FUNC; + else if (collection.length === 1) + return collection[0]; + var funcFactoryCode; + if (collection.length < FORLOOP_FALLBACK) { + var _a = generateBodyPartsVariadicCode(collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode; + funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function() {\n ").concat(funcCallCode, "\n });\n })"); + } + else { + funcFactoryCode = "(function(collection) {\n return (function() {\n for (var i = 0; i < collection.length; ++i) {\n collection[i].apply(undefined, arguments);\n }\n });\n })"; + } + { + // isolate + var bakeCollection_3 = undefined; + var fixedArgsNum = undefined; + var bakeCollectionVariadic_3 = undefined; + var bakeCollectionAwait_3 = undefined; + var funcFactory = eval(funcFactoryCode); + return funcFactory(collection); + } +} +exports.bakeCollectionVariadic = bakeCollectionVariadic; +//# sourceMappingURL=bake-collection.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/bake-collection.js.map b/node_modules/tseep/lib/task-collection/bake-collection.js.map new file mode 100644 index 00000000..bda674e9 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/bake-collection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bake-collection.js","sourceRoot":"","sources":["../../src/task-collection/bake-collection.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG,CAAC,cAAW,CAAC,CAAC,CAAC;AAE/C,IAAI,gBAAgB,GAAG,IAAI,CAAC;AAE5B,SAAS,mBAAmB,CAAC,OAAe;IACxC,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAClC,WAAW,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;KAC7C;IACD,WAAW,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,qBAAqB,CAAC,WAAmB,EAAE,gBAAwB;IACxE,IAAI,WAAW,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,EAAE;QACvC,WAAW,IAAI,eAAQ,CAAC,2BAAiB,CAAC,SAAM,CAAC;QACjD,YAAY,IAAI,WAAI,CAAC,cAAI,WAAW,QAAK,CAAC;KAC7C;IACD,OAAO,EAAE,WAAW,aAAA,EAAE,YAAY,cAAA,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,6BAA6B,CAAC,gBAAwB;IAC3D,IAAI,WAAW,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,EAAE;QACvC,WAAW,IAAI,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AM,qBAAmB,GAAG,SAAS,CAAC;QAEtC,IAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;KAClC;AACL,CAAC;AA3CD,kDA2CC;AAED,SAAgB,sBAAsB,CAClC,UAAkB;IAElB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,wBAAgB,CAAC;SAChD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IAEvD,IAAI,eAAuB,CAAC;IAE5B,IAAI,UAAU,CAAC,MAAM,GAAG,gBAAgB,EAAE;QAChC,IAAA,KAAgC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,EAA9E,WAAW,iBAAA,EAAE,YAAY,kBAAqD,CAAC;QAEvF,eAAe,GAAG,+CACZ,WAAW,sGAGP,YAAY,kCAEnB,CAAC;KACP;SAAM;QACH,eAAe,GAAG,0OAMf,CAAC;KACP;IAED;QACI,UAAU;QACV,IAAM,gBAAc,GAAG,SAAS,CAAC;QACjC,IAAM,YAAY,GAAG,SAAS,CAAC;QAC/B,IAAM,wBAAsB,GAAG,SAAS,CAAC;QACzC,IAAM,qBAAmB,GAAG,SAAS,CAAC;QAEtC,IAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;KAClC;AACL,CAAC;AAtCD,wDAsCC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/index.d.ts b/node_modules/tseep/lib/task-collection/index.d.ts new file mode 100644 index 00000000..ddfc0624 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/index.d.ts @@ -0,0 +1 @@ +export * from './task-collection'; diff --git a/node_modules/tseep/lib/task-collection/index.js b/node_modules/tseep/lib/task-collection/index.js new file mode 100644 index 00000000..3752649c --- /dev/null +++ b/node_modules/tseep/lib/task-collection/index.js @@ -0,0 +1,18 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./task-collection"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/index.js.map b/node_modules/tseep/lib/task-collection/index.js.map new file mode 100644 index 00000000..03755cf5 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/task-collection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/task-collection.d.ts b/node_modules/tseep/lib/task-collection/task-collection.d.ts new file mode 100644 index 00000000..5b293a27 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/task-collection.d.ts @@ -0,0 +1,33 @@ +import { ArgsNum } from '../utils'; +export declare function _fast_remove_single(arr: any[], index: number): void; +export declare class TaskCollection void, AwaitTasks extends true | false = false> { + readonly awaitTasks: AwaitTasks; + constructor(argsNum: ArgsNum, autoRebuild?: boolean, initialTasks?: (Func[]) | Func | null, awaitTasks?: AwaitTasks); + /** DO NOT CHANGE DIRECTLY */ + _tasks: (Func[]) | Func | null; + /** cached */ + length: number; + /** auto rebuild on first emit call; otherwise autorebuild on every change */ + firstEmitBuildStrategy: boolean; + readonly argsNum: ArgsNum; + autoRebuild: boolean; + readonly growArgsNum: typeof growArgsNum; + setAutoRebuild: typeof setAutoRebuild; + call: (...args: Parameters) => (AwaitTasks extends true ? Promise : void); + rebuild: () => void; + push: (...func: Func[]) => void; + /** remove last matched task from tasks */ + removeLast: (func: Func) => void; + insert: (index: number, ...func: Func[]) => void; + setTasks: (tasks: Func[]) => void; + tasksAsArray: () => Func[]; + /** this autorebuilds */ + readonly clear: typeof clear; + /** this autorebuilds */ + readonly fastClear: typeof fastClear; +} +declare function fastClear void, AwaitTasks extends true | false = false>(this: TaskCollection): void; +declare function clear void, AwaitTasks extends true | false = false>(this: TaskCollection): void; +declare function growArgsNum void, AwaitTasks extends true | false = false>(this: TaskCollection, argsNum: number): void; +declare function setAutoRebuild void, AwaitTasks extends true | false = false>(this: TaskCollection, newVal: boolean): void; +export {}; diff --git a/node_modules/tseep/lib/task-collection/task-collection.js b/node_modules/tseep/lib/task-collection/task-collection.js new file mode 100644 index 00000000..7a4606b2 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/task-collection.js @@ -0,0 +1,313 @@ +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TaskCollection = exports._fast_remove_single = void 0; +var bake_collection_1 = require("./bake-collection"); +function push_norebuild(a, b /*, ...func: Func[] */) { + var len = this.length; + if (len > 1) { // tasks is array + if (b) { // if multiple args + var _a; + (_a = this._tasks).push.apply(_a, arguments); + this.length += arguments.length; + } + else { // if single arg (most often case) + this._tasks.push(a); + this.length++; + } + } + else { // tasks is (function or null) + if (b) { // if multiple args + if (len === 1) { // if this._tasks is function + var newAr = Array(1 + arguments.length); + newAr.push(newAr); + newAr.push.apply(newAr, arguments); + this._tasks = newAr; + } + else { + var newAr = Array(arguments.length); + newAr.push.apply(newAr, arguments); + this._tasks = newAr; + } + this.length += arguments.length; + } + else { // if single arg (most often case) + if (len === 1) + this._tasks = [this._tasks, a]; + else + this._tasks = a; + this.length++; + } + } +} +function push_rebuild(a, b /*, ...func: Func[] */) { + var len = this.length; + if (len > 1) { // tasks is array + if (b) { // if multiple args + var _a; + (_a = this._tasks).push.apply(_a, arguments); + this.length += arguments.length; + } + else { // if single arg (most often case) + this._tasks.push(a); + this.length++; + } + } + else { // tasks is (function or null) + if (b) { // if multiple args + if (len === 1) { // if this._tasks is function + var newAr = Array(1 + arguments.length); + newAr.push(newAr); + newAr.push.apply(newAr, arguments); + this._tasks = newAr; + } + else { + var newAr = Array(arguments.length); + newAr.push.apply(newAr, arguments); + this._tasks = newAr; + } + this.length += arguments.length; + } + else { // if single arg (most often case) + if (len === 1) + this._tasks = [this._tasks, a]; + else + this._tasks = a; + this.length++; + } + } + if (this.firstEmitBuildStrategy) + this.call = rebuild_on_first_call; + else + this.rebuild(); +} +function _fast_remove_single(arr, index) { + if (index === -1) + return; + if (index === 0) + arr.shift(); + else if (index === arr.length - 1) + arr.length = arr.length - 1; + else + arr.splice(index, 1); +} +exports._fast_remove_single = _fast_remove_single; +function removeLast_norebuild(a) { + if (this.length === 0) + return; + if (this.length === 1) { + if (this._tasks === a) { + this.length = 0; + } + } + else { + _fast_remove_single(this._tasks, this._tasks.lastIndexOf(a)); + if (this._tasks.length === 1) { + this._tasks = this._tasks[0]; + this.length = 1; + } + else + this.length = this._tasks.length; + } +} +function removeLast_rebuild(a) { + if (this.length === 0) + return; + if (this.length === 1) { + if (this._tasks === a) { + this.length = 0; + } + if (this.firstEmitBuildStrategy) { + this.call = bake_collection_1.BAKED_EMPTY_FUNC; + return; + } + else { + this.rebuild(); + return; + } + } + else { + _fast_remove_single(this._tasks, this._tasks.lastIndexOf(a)); + if (this._tasks.length === 1) { + this._tasks = this._tasks[0]; + this.length = 1; + } + else + this.length = this._tasks.length; + } + if (this.firstEmitBuildStrategy) + this.call = rebuild_on_first_call; + else + this.rebuild(); +} +function insert_norebuild(index) { + var _b; + var func = []; + for (var _i = 1; _i < arguments.length; _i++) { + func[_i - 1] = arguments[_i]; + } + if (this.length === 0) { + this._tasks = func; + this.length = 1; + } + else if (this.length === 1) { + func.unshift(this._tasks); + this._tasks = func; + this.length = this._tasks.length; + } + else { + (_b = this._tasks).splice.apply(_b, __spreadArray([index, 0], func, false)); + this.length = this._tasks.length; + } +} +function insert_rebuild(index) { + var _b; + var func = []; + for (var _i = 1; _i < arguments.length; _i++) { + func[_i - 1] = arguments[_i]; + } + if (this.length === 0) { + this._tasks = func; + this.length = 1; + } + else if (this.length === 1) { + func.unshift(this._tasks); + this._tasks = func; + this.length = this._tasks.length; + } + else { + (_b = this._tasks).splice.apply(_b, __spreadArray([index, 0], func, false)); + this.length = this._tasks.length; + } + if (this.firstEmitBuildStrategy) + this.call = rebuild_on_first_call; + else + this.rebuild(); +} +function rebuild_noawait() { + if (this.length === 0) + this.call = bake_collection_1.BAKED_EMPTY_FUNC; + else if (this.length === 1) + this.call = this._tasks; + else + this.call = (0, bake_collection_1.bakeCollection)(this._tasks, this.argsNum); +} +function rebuild_await() { + if (this.length === 0) + this.call = bake_collection_1.BAKED_EMPTY_FUNC; + else if (this.length === 1) + this.call = this._tasks; + else + this.call = (0, bake_collection_1.bakeCollectionAwait)(this._tasks, this.argsNum); +} +function rebuild_on_first_call() { + this.rebuild(); + this.call.apply(undefined, arguments); +} +var TaskCollection = /** @class */ (function () { + function TaskCollection(argsNum, autoRebuild, initialTasks, awaitTasks) { + if (autoRebuild === void 0) { autoRebuild = true; } + if (initialTasks === void 0) { initialTasks = null; } + if (awaitTasks === void 0) { awaitTasks = false; } + this.awaitTasks = awaitTasks; + this.call = bake_collection_1.BAKED_EMPTY_FUNC; + this.argsNum = argsNum; + this.firstEmitBuildStrategy = true; + if (awaitTasks) + this.rebuild = rebuild_await.bind(this); + else + this.rebuild = rebuild_noawait.bind(this); + this.setAutoRebuild(autoRebuild); + if (initialTasks) { + if (typeof initialTasks === 'function') { + this._tasks = initialTasks; + this.length = 1; + } + else { + this._tasks = initialTasks; + this.length = initialTasks.length; + } + } + else { + this._tasks = null; + this.length = 0; + } + if (autoRebuild) + this.rebuild(); + } + return TaskCollection; +}()); +exports.TaskCollection = TaskCollection; +function fastClear() { + this._tasks = null; + this.length = 0; + this.call = bake_collection_1.BAKED_EMPTY_FUNC; +} +function clear() { + this._tasks = null; + this.length = 0; + this.call = bake_collection_1.BAKED_EMPTY_FUNC; +} +function growArgsNum(argsNum) { + if (this.argsNum < argsNum) { + this.argsNum = argsNum; + if (this.firstEmitBuildStrategy) + this.call = rebuild_on_first_call; + else + this.rebuild(); + } +} +function setAutoRebuild(newVal) { + if (newVal) { + this.push = push_rebuild.bind(this); + this.insert = insert_rebuild.bind(this); + this.removeLast = removeLast_rebuild.bind(this); + } + else { + this.push = push_norebuild.bind(this); + this.insert = insert_norebuild.bind(this); + this.removeLast = removeLast_norebuild.bind(this); + } +} +; +function tasksAsArray() { + if (this.length === 0) + return []; + if (this.length === 1) + return [this._tasks]; + return this._tasks; +} +function setTasks(tasks) { + if (tasks.length === 0) { + this.length = 0; + this.call = bake_collection_1.BAKED_EMPTY_FUNC; + } + else if (tasks.length === 1) { + this.length = 1; + this.call = tasks[0]; + this._tasks = tasks[0]; + } + else { + this.length = tasks.length; + this._tasks = tasks; + if (this.firstEmitBuildStrategy) + this.call = rebuild_on_first_call; + else + this.rebuild(); + } +} +TaskCollection.prototype.fastClear = fastClear; +TaskCollection.prototype.clear = clear; +TaskCollection.prototype.growArgsNum = growArgsNum; +TaskCollection.prototype.setAutoRebuild = setAutoRebuild; +TaskCollection.prototype.tasksAsArray = tasksAsArray; +TaskCollection.prototype.setTasks = setTasks; +//# sourceMappingURL=task-collection.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/task-collection.js.map b/node_modules/tseep/lib/task-collection/task-collection.js.map new file mode 100644 index 00000000..a44991de --- /dev/null +++ b/node_modules/tseep/lib/task-collection/task-collection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"task-collection.js","sourceRoot":"","sources":["../../src/task-collection/task-collection.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAA0F;AAG1F,SAAS,cAAc,CAAkE,CAAO,EAAE,CAAQ,CAAC,sBAAsB;IAC7H,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,EAAE,EAAE,iBAAiB;QAC5B,IAAI,CAAC,EAAE,EAAE,mBAAmB;YACxB,IAAI,EAAE,CAAC;YACP,CAAC,EAAE,GAAG,IAAI,CAAC,MAAgB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC;SACnC;aAAM,EAAE,kCAAkC;YACtC,IAAI,CAAC,MAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM,EAAE,CAAC;SACjB;KACJ;SAAM,EAAE,8BAA8B;QACnC,IAAI,CAAC,EAAE,EAAE,mBAAmB;YACxB,IAAI,GAAG,KAAK,CAAC,EAAE,EAAE,6BAA6B;gBAC1C,IAAM,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAClB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;aACvB;iBAAM;gBACH,IAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBACtC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;aAC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AM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,IAAI,CAAC,sBAAsB;YAAE,IAAI,CAAC,IAAI,GAAG,qBAA4B,CAAC;;YACrE,IAAI,CAAC,OAAO,EAAE,CAAC;KACvB;AACL,CAAC;AAEA,cAAc,CAAC,SAAkD,CAAC,SAAS,GAAG,SAAS,CAAC;AACxF,cAAc,CAAC,SAAkD,CAAC,KAAK,GAAG,KAAK,CAAC;AAChF,cAAc,CAAC,SAAkD,CAAC,WAAW,GAAG,WAAW,CAAC;AAC5F,cAAc,CAAC,SAAkD,CAAC,cAAc,GAAG,cAAc,CAAC;AAClG,cAAc,CAAC,SAAkD,CAAC,YAAY,GAAG,YAAY,CAAC;AAC9F,cAAc,CAAC,SAAkD,CAAC,QAAQ,GAAG,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/utils.d.ts b/node_modules/tseep/lib/task-collection/utils.d.ts new file mode 100644 index 00000000..235f0b85 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/utils.d.ts @@ -0,0 +1,5 @@ +export type NoReadonly = { + -readonly [X in keyof T]: T[X]; +}; diff --git a/node_modules/tseep/lib/task-collection/utils.js b/node_modules/tseep/lib/task-collection/utils.js new file mode 100644 index 00000000..ee02fa63 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/utils.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/task-collection/utils.js.map b/node_modules/tseep/lib/task-collection/utils.js.map new file mode 100644 index 00000000..3e935bb7 --- /dev/null +++ b/node_modules/tseep/lib/task-collection/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/task-collection/utils.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/tseep/lib/types.d.ts b/node_modules/tseep/lib/types.d.ts new file mode 100644 index 00000000..3641110e --- /dev/null +++ b/node_modules/tseep/lib/types.d.ts @@ -0,0 +1,27 @@ +export type Listener = (...args: any[]) => Promise | void; +export type DefaultEventMap = { + [event in (string | symbol)]: Listener; +} & { + /** + * __proto__ key not allowed due to implementation + * add prefix, if you want to use this keyword + */ + __proto__?: never; +}; +export interface IEventEmitter { + emit(event: EventKey, ...args: Parameters): boolean; + on(event: EventKey, listener: EventMap[EventKey]): this; + once(event: EventKey, listener: EventMap[EventKey]): this; + addListener(event: EventKey, listener: EventMap[EventKey]): this; + removeListener(event: EventKey, listener: EventMap[EventKey]): this; + prependListener(event: EventKey, listener: EventMap[EventKey]): this; + prependOnceListener(event: EventKey, listener: EventMap[EventKey]): this; + off(event: EventKey, listener: EventMap[EventKey]): this; + removeAllListeners(event?: EventKey): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: EventKey): EventMap[EventKey][]; + rawListeners(event: EventKey): EventMap[EventKey][]; + eventNames(): Array; + listenerCount(type: EventKey): number; +} diff --git a/node_modules/tseep/lib/types.js b/node_modules/tseep/lib/types.js new file mode 100644 index 00000000..11e638d1 --- /dev/null +++ b/node_modules/tseep/lib/types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/types.js.map b/node_modules/tseep/lib/types.js.map new file mode 100644 index 00000000..c768b790 --- /dev/null +++ b/node_modules/tseep/lib/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/tseep/lib/utils.d.ts b/node_modules/tseep/lib/utils.d.ts new file mode 100644 index 00000000..10a8c0a0 --- /dev/null +++ b/node_modules/tseep/lib/utils.d.ts @@ -0,0 +1,2 @@ +export declare function nullObj(): {}; +export type ArgsNum any> = T extends (...args: infer K) => any ? K["length"] : never; diff --git a/node_modules/tseep/lib/utils.js b/node_modules/tseep/lib/utils.js new file mode 100644 index 00000000..105582cd --- /dev/null +++ b/node_modules/tseep/lib/utils.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nullObj = void 0; +function nullObj() { + var x = {}; + x.__proto__ = null; + x.prototype = null; + return x; +} +exports.nullObj = nullObj; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/tseep/lib/utils.js.map b/node_modules/tseep/lib/utils.js.map new file mode 100644 index 00000000..616621be --- /dev/null +++ b/node_modules/tseep/lib/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,SAAgB,OAAO;IACnB,IAAM,CAAC,GAAG,EAAE,CAAC;IACZ,CAAS,CAAC,SAAS,GAAG,IAAI,CAAC;IAC3B,CAAS,CAAC,SAAS,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,CAAC;AACb,CAAC;AALD,0BAKC"} \ No newline at end of file diff --git a/node_modules/tseep/package.json b/node_modules/tseep/package.json new file mode 100755 index 00000000..85b11cfa --- /dev/null +++ b/node_modules/tseep/package.json @@ -0,0 +1,40 @@ +{ + "name": "tseep", + "version": "1.1.3", + "description": "Fastest event emitter in the world", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "test": "jest", + "build": "tsc", + "task_collection_dev_benchmark": "node lib/task-collection/tools/benchmark__bake-collection__num-funcs.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Morglod/tseep.git" + }, + "keywords": [ + "types", + "ts", + "typescript", + "tsargs", + "events", + "eventemitter", + "event-listener", + "eventlistener", + "listener", + "emit" + ], + "author": "morglod", + "license": "MIT", + "bugs": { + "url": "https://github.com/Morglod/tseep/issues" + }, + "homepage": "https://github.com/Morglod/tseep#readme", + "devDependencies": { + "@types/jest": "^29.5.0", + "assume": "^2.2.0", + "jest": "^29.5.0", + "typescript": "^5.0.4" + } +} diff --git a/node_modules/tseep/tsconfig.json b/node_modules/tseep/tsconfig.json new file mode 100755 index 00000000..60014382 --- /dev/null +++ b/node_modules/tseep/tsconfig.json @@ -0,0 +1,60 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "lib": [ "es2018", "dom" ], /* Specify library files to be included in the compilation. */ + "skipLibCheck": true, + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./lib", /* Redirect output structure to the directory. */ + "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + // "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 50bd3471..2886a307 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-ssm": "^3.454.0", "@extractus/feed-extractor": "^7.0.7", - "@nostr-dev-kit/ndk": "^2.0.5", + "@nostr-dev-kit/ndk": "^2.1.1", "bech32-buffer": "^0.2.1", "moment": "^2.29.4", "nostr-tools": "^1.17.0", @@ -638,6 +638,28 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@noble/curves": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", + "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", + "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/hashes": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", @@ -661,40 +683,23 @@ ] }, "node_modules/@nostr-dev-kit/ndk": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nostr-dev-kit/ndk/-/ndk-2.0.5.tgz", - "integrity": "sha512-EvVr43y+4N9lMSZIIe5V8jFWYlKTVkMyyJfbgRaDGCGiBZAm9iy0wcO2Yi+W57awOAlvr3mjT5fAwG9RDb6HSA==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@nostr-dev-kit/ndk/-/ndk-2.1.1.tgz", + "integrity": "sha512-sMD4re3QVpSVMzoyvJAFiftPxJBXkhjRInrK5DcjhSkkPTlJhI+oiVXCpcvCJ3PHT5PilhDgKkg3LyOvv135UQ==", "dependencies": { "@noble/hashes": "^1.3.1", "@noble/secp256k1": "^2.0.0", "@scure/base": "^1.1.1", "debug": "^4.3.4", - "eventemitter3": "^5.0.1", "light-bolt11-decoder": "^3.0.0", "node-fetch": "^3.3.1", "nostr-tools": "^1.15.0", + "tseep": "^1.1.1", "typescript-lru-cache": "^2.0.0", "utf8-buffer": "^1.0.0", "websocket-polyfill": "^0.0.3" } }, - "node_modules/@nostr-dev-kit/ndk/node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "node_modules/@scure/base": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", @@ -716,28 +721,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/@scure/bip32/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@scure/bip39": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", @@ -1305,6 +1288,25 @@ "node-fetch": "^2.6.12" } }, + "node_modules/cross-fetch/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -1371,11 +1373,6 @@ "ext": "^1.1.2" } }, - "node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" - }, "node_modules/ext": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", @@ -1519,22 +1516,20 @@ } }, "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/node-gyp-build": { @@ -1568,17 +1563,6 @@ } } }, - "node_modules/nostr-tools/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/nostr-tools/node_modules/@noble/hashes": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", @@ -1611,6 +1595,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/tseep": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tseep/-/tseep-1.1.3.tgz", + "integrity": "sha512-deBIcIlXUMlr3xaN0UEochqjU/zXGaZGPqHPd1rxo4w6DklBdRM6WQQtsk7bekIF+qY6QTeen3nE6OA7BxL9rg==" + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/package.json b/package.json index 726c8512..2e7b0e9c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "@aws-sdk/client-ssm": "^3.454.0", "@extractus/feed-extractor": "^7.0.7", - "@nostr-dev-kit/ndk": "^2.0.5", + "@nostr-dev-kit/ndk": "^2.1.1", "bech32-buffer": "^0.2.1", "moment": "^2.29.4", "nostr-tools": "^1.17.0", diff --git a/shell.nix b/shell.nix index deb61794..9f822139 100644 --- a/shell.nix +++ b/shell.nix @@ -6,6 +6,7 @@ mkShell { docker localstack nodejs_20 + nodePackages_latest.npm-check-updates ( let my-python-packages = p: with p; [ (