Change to @tornado/ethers and use @tornado/noble-curves
Some checks failed
Generate Documentation / Generate Documentation (push) Has been cancelled
Browser Tests / Run Browser Tests (push) Has been cancelled
CI Tests / Run Node.js Tests (18.x, commonjs) (push) Has been cancelled
CI Tests / Run Node.js Tests (18.x, esm) (push) Has been cancelled
CI Tests / Run Node.js Tests (20.x, commonjs) (push) Has been cancelled
CI Tests / Run Node.js Tests (20.x, esm) (push) Has been cancelled
CI Tests / Generate Coverage Report (push) Has been cancelled
Environment Tests / Test TypeScript Environments (commonjs, node) (push) Has been cancelled
Environment Tests / Test TypeScript Environments (commonjs, node16) (push) Has been cancelled
Environment Tests / Test TypeScript Environments (commonjs, nodenext) (push) Has been cancelled
Environment Tests / Test TypeScript Environments (es2020, node) (push) Has been cancelled
Environment Tests / Test TypeScript Environments (es2020, node16) (push) Has been cancelled
Environment Tests / Test TypeScript Environments (es2020, nodenext) (push) Has been cancelled
Environment Tests / Test Angular Environment (push) Has been cancelled

This commit is contained in:
Theo 2024-04-18 20:05:00 -07:00
parent b553b1bc43
commit 053ca44133
6 changed files with 2826 additions and 2815 deletions

1
.npmrc Normal file

@ -0,0 +1 @@
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

5294
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,135 +1,135 @@
{ {
"author": "Richard Moore <me@ricmoo.com>", "author": "Richard Moore <me@ricmoo.com>",
"browser": { "browser": {
"./lib.esm/crypto/crypto.js": "./lib.esm/crypto/crypto-browser.js", "./lib.esm/crypto/crypto.js": "./lib.esm/crypto/crypto-browser.js",
"./lib.esm/providers/provider-ipcsocket.js": "./lib.esm/providers/provider-ipcsocket-browser.js", "./lib.esm/providers/provider-ipcsocket.js": "./lib.esm/providers/provider-ipcsocket-browser.js",
"./lib.esm/providers/ws.js": "./lib.esm/providers/ws-browser.js", "./lib.esm/providers/ws.js": "./lib.esm/providers/ws-browser.js",
"./lib.esm/utils/base64.js": "./lib.esm/utils/base64-browser.js", "./lib.esm/utils/base64.js": "./lib.esm/utils/base64-browser.js",
"./lib.esm/utils/geturl.js": "./lib.esm/utils/geturl-browser.js", "./lib.esm/utils/geturl.js": "./lib.esm/utils/geturl-browser.js",
"./lib.esm/wordlists/wordlists.js": "./lib.esm/wordlists/wordlists-browser.js" "./lib.esm/wordlists/wordlists.js": "./lib.esm/wordlists/wordlists-browser.js"
},
"dependencies": {
"@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5",
"tslib": "2.4.0",
"ws": "8.5.0"
},
"description": "A complete and compact Ethereum library, for dapps, wallets and any other tools.",
"devDependencies": {
"@rollup/plugin-node-resolve": "15.0.2",
"@types/mocha": "9.1.1",
"@types/semver": "7.5.0",
"c8": "7.12.0",
"mocha": "10.0.0",
"rollup": "3.21.5",
"semver": "7.5.4",
"typescript": "5.0.4",
"uglify-js": "3.17.0"
},
"engines": {
"node": ">=14.0.0"
},
"ethereum": "donations.ethers.eth",
"exports": {
".": {
"import": "./lib.esm/index.js",
"default": "./lib.commonjs/index.js"
}, },
"./abi": { "dependencies": {
"import": "./lib.esm/abi/index.js", "@adraffy/ens-normalize": "1.10.1",
"default": "./lib.commonjs/abi/index.js" "@tornado/noble-curves": "1.4.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5",
"tslib": "2.4.0",
"ws": "8.5.0"
}, },
"./address": { "description": "A complete and compact Ethereum library, for dapps, wallets and any other tools.",
"import": "./lib.esm/address/index.js", "devDependencies": {
"default": "./lib.commonjs/address/index.js" "@rollup/plugin-node-resolve": "15.0.2",
"@types/mocha": "9.1.1",
"@types/semver": "7.5.0",
"c8": "7.12.0",
"mocha": "10.0.0",
"rollup": "3.21.5",
"semver": "7.5.4",
"typescript": "5.0.4",
"uglify-js": "3.17.0"
}, },
"./constants": { "engines": {
"import": "./lib.esm/constants/index.js", "node": ">=14.0.0"
"default": "./lib.commonjs/constants/index.js"
}, },
"./contract": { "ethereum": "donations.ethers.eth",
"import": "./lib.esm/contract/index.js", "exports": {
"default": "./lib.commonjs/contract/index.js" ".": {
"import": "./lib.esm/index.js",
"default": "./lib.commonjs/index.js"
},
"./abi": {
"import": "./lib.esm/abi/index.js",
"default": "./lib.commonjs/abi/index.js"
},
"./address": {
"import": "./lib.esm/address/index.js",
"default": "./lib.commonjs/address/index.js"
},
"./constants": {
"import": "./lib.esm/constants/index.js",
"default": "./lib.commonjs/constants/index.js"
},
"./contract": {
"import": "./lib.esm/contract/index.js",
"default": "./lib.commonjs/contract/index.js"
},
"./crypto": {
"import": "./lib.esm/crypto/index.js",
"default": "./lib.commonjs/crypto/index.js"
},
"./hash": {
"import": "./lib.esm/hash/index.js",
"default": "./lib.commonjs/hash/index.js"
},
"./providers": {
"import": "./lib.esm/providers/index.js",
"default": "./lib.commonjs/providers/index.js"
},
"./transaction": {
"import": "./lib.esm/transaction/index.js",
"default": "./lib.commonjs/transaction/index.js"
},
"./utils": {
"import": "./lib.esm/utils/index.js",
"default": "./lib.commonjs/utils/index.js"
},
"./wallet": {
"import": "./lib.esm/wallet/index.js",
"default": "./lib.commonjs/wallet/index.js"
},
"./wordlists": {
"import": "./lib.esm/wordlists/index.js",
"default": "./lib.commonjs/wordlists/index.js"
}
}, },
"./crypto": { "funding": [
"import": "./lib.esm/crypto/index.js", {
"default": "./lib.commonjs/crypto/index.js" "type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"gitHead": "b4aaab8d39fe47f8a1a296fa442f0856f84faf03",
"homepage": "https://ethers.org",
"keywords": [
"ethereum",
"ethers",
"ethersjs"
],
"license": "MIT",
"main": "./lib.commonjs/index.js",
"module": "./lib.esm/index.js",
"name": "@tornado/ethers",
"publishConfig": {
"access": "public",
"tag": "latest"
}, },
"./hash": { "repository": {
"import": "./lib.esm/hash/index.js", "type": "git",
"default": "./lib.commonjs/hash/index.js" "url": "git://github.com/ethers-io/ethers.js.git"
}, },
"./providers": { "scripts": {
"import": "./lib.esm/providers/index.js", "_build-dist": "rollup -c && uglifyjs ./dist/ethers.js -o ./dist/ethers.min.js && uglifyjs ./dist/ethers.umd.js -o ./dist/ethers.umd.min.js && uglifyjs ./dist/wordlists-extra.js -o ./dist/wordlists-extra.min.js",
"default": "./lib.commonjs/providers/index.js" "_dist-stats": "gzip -k9f -S '.gz' ./dist/ethers.min.js && gzip -k9f -S '.gz' ./dist/ethers.umd.min.js && gzip -k9f -S '.gz' ./dist/wordlists-extra.min.js && du -hs ./dist/*.gz && echo '' && du -hs ./dist/*.js",
"auto-build": "npm run build -- -w",
"build": "tsc --project tsconfig.esm.json",
"build-all": "npm run build && npm run build-commonjs",
"build-clean": "npm run clean && npm run build && node lib.esm/_admin/update-version.js && node lib.esm/_admin/update-changelog.js && npm run build-all && npm run _build-dist && npm run _dist-stats",
"build-commonjs": "tsc --project tsconfig.commonjs.json",
"build-dist": "npm run build && npm run _build-dist && npm run _dist-stats",
"clean": "rm -rf dist lib.esm lib.commonjs && cp -r misc/basedirs/* .",
"postpublish": "node lib.esm/_admin/create-release.js",
"stats": "echo 'Dependencies' && npm ls --all --omit=dev",
"test": "npm run test-esm",
"test-browser": "node lib.esm/_admin/test-browser",
"test-commonjs": "mocha --reporter ./reporter.cjs ./lib.commonjs/_tests/test-*.js",
"test-coverage": "c8 -o output -r lcov -r text mocha --no-color --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js | tee output/summary.txt",
"test-esm": "mocha --trace-warnings --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js"
}, },
"./transaction": { "sideEffects": false,
"import": "./lib.esm/transaction/index.js", "version": "6.12.0"
"default": "./lib.commonjs/transaction/index.js"
},
"./utils": {
"import": "./lib.esm/utils/index.js",
"default": "./lib.commonjs/utils/index.js"
},
"./wallet": {
"import": "./lib.esm/wallet/index.js",
"default": "./lib.commonjs/wallet/index.js"
},
"./wordlists": {
"import": "./lib.esm/wordlists/index.js",
"default": "./lib.commonjs/wordlists/index.js"
}
},
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"gitHead": "b4aaab8d39fe47f8a1a296fa442f0856f84faf03",
"homepage": "https://ethers.org",
"keywords": [
"ethereum",
"ethers",
"ethersjs"
],
"license": "MIT",
"main": "./lib.commonjs/index.js",
"module": "./lib.esm/index.js",
"name": "ethers",
"publishConfig": {
"access": "public",
"tag": "latest"
},
"repository": {
"type": "git",
"url": "git://github.com/ethers-io/ethers.js.git"
},
"scripts": {
"_build-dist": "rollup -c && uglifyjs ./dist/ethers.js -o ./dist/ethers.min.js && uglifyjs ./dist/ethers.umd.js -o ./dist/ethers.umd.min.js && uglifyjs ./dist/wordlists-extra.js -o ./dist/wordlists-extra.min.js",
"_dist-stats": "gzip -k9f -S '.gz' ./dist/ethers.min.js && gzip -k9f -S '.gz' ./dist/ethers.umd.min.js && gzip -k9f -S '.gz' ./dist/wordlists-extra.min.js && du -hs ./dist/*.gz && echo '' && du -hs ./dist/*.js",
"auto-build": "npm run build -- -w",
"build": "tsc --project tsconfig.esm.json",
"build-all": "npm run build && npm run build-commonjs",
"build-clean": "npm run clean && npm run build && node lib.esm/_admin/update-version.js && node lib.esm/_admin/update-changelog.js && npm run build-all && npm run _build-dist && npm run _dist-stats",
"build-commonjs": "tsc --project tsconfig.commonjs.json",
"build-dist": "npm run build && npm run _build-dist && npm run _dist-stats",
"clean": "rm -rf dist lib.esm lib.commonjs && cp -r misc/basedirs/* .",
"postpublish": "node lib.esm/_admin/create-release.js",
"stats": "echo 'Dependencies' && npm ls --all --omit=dev",
"test": "npm run test-esm",
"test-browser": "node lib.esm/_admin/test-browser",
"test-commonjs": "mocha --reporter ./reporter.cjs ./lib.commonjs/_tests/test-*.js",
"test-coverage": "c8 -o output -r lcov -r text mocha --no-color --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js | tee output/summary.txt",
"test-esm": "mocha --trace-warnings --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js"
},
"sideEffects": false,
"version": "6.12.0"
} }

@ -4,12 +4,9 @@
* @_subsection: api/crypto:Signing [about-signing] * @_subsection: api/crypto:Signing [about-signing]
*/ */
import { secp256k1 } from "@noble/curves/secp256k1"; import { secp256k1 } from "@tornado/noble-curves/secp256k1";
import { import { concat, dataLength, getBytes, getBytesCopy, hexlify, toBeHex, assertArgument } from "../utils/index.js";
concat, dataLength, getBytes, getBytesCopy, hexlify, toBeHex,
assertArgument
} from "../utils/index.js";
import { Signature } from "./signature.js"; import { Signature } from "./signature.js";
@ -17,7 +14,6 @@ import type { BytesLike } from "../utils/index.js";
import type { SignatureLike } from "./index.js"; import type { SignatureLike } from "./index.js";
/** /**
* A **SigningKey** provides high-level access to the elliptic curve * A **SigningKey** provides high-level access to the elliptic curve
* cryptography (ECC) operations and key management. * cryptography (ECC) operations and key management.
@ -36,7 +32,9 @@ export class SigningKey {
/** /**
* The private key. * The private key.
*/ */
get privateKey(): string { return this.#privateKey; } get privateKey(): string {
return this.#privateKey;
}
/** /**
* The uncompressed public key. * The uncompressed public key.
@ -44,7 +42,9 @@ export class SigningKey {
* This will always begin with the prefix ``0x04`` and be 132 * This will always begin with the prefix ``0x04`` and be 132
* characters long (the ``0x`` prefix and 130 hexadecimal nibbles). * characters long (the ``0x`` prefix and 130 hexadecimal nibbles).
*/ */
get publicKey(): string { return SigningKey.computePublicKey(this.#privateKey); } get publicKey(): string {
return SigningKey.computePublicKey(this.#privateKey);
}
/** /**
* The compressed public key. * The compressed public key.
@ -53,7 +53,9 @@ export class SigningKey {
* and be 68 characters long (the ``0x`` prefix and 33 hexadecimal * and be 68 characters long (the ``0x`` prefix and 33 hexadecimal
* nibbles) * nibbles)
*/ */
get compressedPublicKey(): string { return SigningKey.computePublicKey(this.#privateKey, true); } get compressedPublicKey(): string {
return SigningKey.computePublicKey(this.#privateKey, true);
}
/** /**
* Return the signature of the signed %%digest%%. * Return the signature of the signed %%digest%%.
@ -62,13 +64,13 @@ export class SigningKey {
assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest); assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest);
const sig = secp256k1.sign(getBytesCopy(digest), getBytesCopy(this.#privateKey), { const sig = secp256k1.sign(getBytesCopy(digest), getBytesCopy(this.#privateKey), {
lowS: true lowS: true,
}); });
return Signature.from({ return Signature.from({
r: toBeHex(sig.r, 32), r: toBeHex(sig.r, 32),
s: toBeHex(sig.s, 32), s: toBeHex(sig.s, 32),
v: (sig.recovery ? 0x1c: 0x1b) v: sig.recovery ? 0x1c : 0x1b,
}); });
} }
@ -168,7 +170,7 @@ export class SigningKey {
const sig = Signature.from(signature); const sig = Signature.from(signature);
let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat([ sig.r, sig.s ]))); let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat([sig.r, sig.s])));
secpSig = secpSig.addRecoveryBit(sig.yParity); secpSig = secpSig.addRecoveryBit(sig.yParity);
const pubKey = secpSig.recoverPublicKey(getBytesCopy(digest)); const pubKey = secpSig.recoverPublicKey(getBytesCopy(digest));
@ -190,7 +192,6 @@ export class SigningKey {
static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string { static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string {
const pub0 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p0).substring(2)); const pub0 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p0).substring(2));
const pub1 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p1).substring(2)); const pub1 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p1).substring(2));
return "0x" + pub0.add(pub1).toHex(!!compressed) return "0x" + pub0.add(pub1).toHex(!!compressed);
} }
} }

@ -1,31 +1,26 @@
{ {
"compilerOptions": { "compilerOptions": {
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"esModuleInterop": true, "esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"importHelpers": true, "importHelpers": true,
"lib": [ "lib": ["es2020", "es5"],
"es2020", "moduleResolution": "node16",
"es5" "noEmitOnError": true,
], "noFallthroughCasesInSwitch": true,
"moduleResolution": "node16", "noImplicitAny": true,
"noEmitOnError": true, "noImplicitReturns": true,
"noFallthroughCasesInSwitch": true, "noImplicitThis": true,
"noImplicitAny": true, "noUnusedLocals": true,
"noImplicitReturns": true, "preserveSymlinks": true,
"noImplicitThis": true, "preserveWatchOutput": true,
"noUnusedLocals": true, "pretty": false,
"preserveSymlinks": true, "rootDir": "./src.ts",
"preserveWatchOutput": true, "strict": true,
"pretty": false, "sourceMap": true,
"rootDir": "./src.ts", "target": "ES2015"
"strict": true, },
"sourceMap": true, "exclude": [],
"target": "es2022" "include": ["./src.ts/**/*.ts"]
},
"exclude": [ ],
"include": [
"./src.ts/**/*.ts"
],
} }

@ -1,10 +1,8 @@
{ {
"exclude": [ "exclude": ["src.ts/_admin/**"],
"src.ts/_admin/**" "extends": "./tsconfig.base.json",
], "compilerOptions": {
"extends": "./tsconfig.base.json", "module": "commonjs",
"compilerOptions": { "outDir": "./lib.commonjs"
"module": "commonjs", }
"outDir": "./lib.commonjs"
}
} }