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/

60
package-lock.json generated

@ -1,12 +1,12 @@
{ {
"name": "ethers", "name": "ethers",
"version": "6.11.0", "version": "6.12.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ethers", "name": "ethers",
"version": "6.11.0", "version": "6.12.0",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@ -20,8 +20,8 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@adraffy/ens-normalize": "1.10.1", "@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2", "@noble/hashes": "1.3.2",
"@tornado/noble-curves": "1.4.0",
"@types/node": "18.15.13", "@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5", "aes-js": "4.0.0-beta.5",
"tslib": "2.4.0", "tslib": "2.4.0",
@ -87,17 +87,6 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": { "node_modules/@noble/hashes": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
@ -156,6 +145,26 @@
} }
} }
}, },
"node_modules/@tornado/noble-curves": {
"version": "1.4.0",
"resolved": "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fnoble-curves/-/1.4.0/noble-curves-1.4.0.tgz",
"integrity": "sha512-1PgP5PoSaC+rA+kb+UMe8Ilv01xyMQ0XOvxdSdgAaAKKNg4ypk5cmDUPbbcNh5W9kDSGSB1KwPOMsloFjCVmqw==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.4.0"
}
},
"node_modules/@tornado/noble-curves/node_modules/@noble/hashes": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz",
"integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@types/estree": { "node_modules/@types/estree": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz",
@ -1603,14 +1612,6 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"requires": {
"@noble/hashes": "1.3.2"
}
},
"@noble/hashes": { "@noble/hashes": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
@ -1641,6 +1642,21 @@
"picomatch": "^2.3.1" "picomatch": "^2.3.1"
} }
}, },
"@tornado/noble-curves": {
"version": "1.4.0",
"resolved": "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fnoble-curves/-/1.4.0/noble-curves-1.4.0.tgz",
"integrity": "sha512-1PgP5PoSaC+rA+kb+UMe8Ilv01xyMQ0XOvxdSdgAaAKKNg4ypk5cmDUPbbcNh5W9kDSGSB1KwPOMsloFjCVmqw==",
"requires": {
"@noble/hashes": "1.4.0"
},
"dependencies": {
"@noble/hashes": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz",
"integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg=="
}
}
},
"@types/estree": { "@types/estree": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz",

@ -10,7 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@adraffy/ens-normalize": "1.10.1", "@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0", "@tornado/noble-curves": "1.4.0",
"@noble/hashes": "1.3.2", "@noble/hashes": "1.3.2",
"@types/node": "18.15.13", "@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5", "aes-js": "4.0.0-beta.5",
@ -103,7 +103,7 @@
"license": "MIT", "license": "MIT",
"main": "./lib.commonjs/index.js", "main": "./lib.commonjs/index.js",
"module": "./lib.esm/index.js", "module": "./lib.esm/index.js",
"name": "ethers", "name": "@tornado/ethers",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"tag": "latest" "tag": "latest"

@ -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);
} }
} }

@ -5,10 +5,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"importHelpers": true, "importHelpers": true,
"lib": [ "lib": ["es2020", "es5"],
"es2020",
"es5"
],
"moduleResolution": "node16", "moduleResolution": "node16",
"noEmitOnError": true, "noEmitOnError": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
@ -22,10 +19,8 @@
"rootDir": "./src.ts", "rootDir": "./src.ts",
"strict": true, "strict": true,
"sourceMap": true, "sourceMap": true,
"target": "es2022" "target": "ES2015"
}, },
"exclude": [ ], "exclude": [],
"include": [ "include": ["./src.ts/**/*.ts"]
"./src.ts/**/*.ts"
],
} }

@ -1,7 +1,5 @@
{ {
"exclude": [ "exclude": ["src.ts/_admin/**"],
"src.ts/_admin/**"
],
"extends": "./tsconfig.base.json", "extends": "./tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "module": "commonjs",