Skip to content

Commit b6e2440

Browse files
committed
Replace vendored secp256k1 v3 for secp256k1 v4
1 parent 063ba25 commit b6e2440

File tree

11 files changed

+22
-163
lines changed

11 files changed

+22
-163
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "packages/ethereum-cryptography/secp256k1-node"]
2-
path = packages/ethereum-cryptography/secp256k1-node
3-
url = https://github.com/cryptocoinjs/secp256k1-node.git
41
[submodule "packages/ethereum-cryptography/scryptsy"]
52
path = packages/ethereum-cryptography/scryptsy
63
url = https://github.com/cryptocoinjs/scryptsy.git

packages/ethereum-cryptography/elliptic-secp256k1-config/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ethereum-cryptography/elliptic-secp256k1-config/rollup.config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ethereum-cryptography/package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"browser": {
5252
"./scrypt.js": "./pure/scrypt.js",
5353
"./ripemd160.js": "./pure/ripemd160.js",
54-
"./secp256k1.js": "./pure/secp256k1.js",
5554
"./sha256.js": "./pure/sha256.js",
5655
"./hdkey.js": "./pure/hdkey.js",
5756
"./blake2b.js": "./pure/blake2b.js",
@@ -60,9 +59,9 @@
6059
"sideEffects": false,
6160
"scripts": {
6261
"prepare": "npm run build",
63-
"build": "npm-run-all build:tsc elliptic-secp256k1:build elliptic-secp256k1:copy scryptsy-without-crypto:build scryptsy-without-crypto:copy hdkey-without-crypto:build hdkey-without-crypto:copy bip39-without-wordlists:build bip39-without-wordlists:copy",
62+
"build": "npm-run-all build:tsc scryptsy-without-crypto:build scryptsy-without-crypto:copy hdkey-without-crypto:build hdkey-without-crypto:copy bip39-without-wordlists:build bip39-without-wordlists:copy",
6463
"build:tsc": "tsc --project tsconfig.prod.json",
65-
"test": "npm-run-all elliptic-secp256k1:build scryptsy-without-crypto:build hdkey-without-crypto:build bip39-without-wordlists:build test:node",
64+
"test": "npm-run-all scryptsy-without-crypto:build hdkey-without-crypto:build bip39-without-wordlists:build test:node",
6665
"test:node": "mocha",
6766
"clean": "rimraf vendor test-builds pure shims scryptsy-without-crypto-build hdkey-without-crypto-build bip39-without-wordlists-build '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'",
6867
"lint": "tslint --project tsconfig.json",
@@ -74,8 +73,6 @@
7473
"browser-tests:test-browserify": "karma start --single-run --browsers ChromeHeadless test/karma.browserify.conf.js",
7574
"browser-tests:test-webpack": "karma start --single-run --browsers ChromeHeadless test/karma.webpack.conf.js",
7675
"browser-tests:test-rollup": "karma start --single-run --browsers ChromeHeadless test/karma.rollup.conf.js",
77-
"elliptic-secp256k1:build": "rollup -c elliptic-secp256k1-config/rollup.config.js",
78-
"elliptic-secp256k1:copy": "mkdir -p vendor && cp src/vendor/elliptic-secp256k1.js ./vendor",
7976
"scryptsy-without-crypto:build": "bash -x scripts/build-scryptsy-without-crypto.sh",
8077
"scryptsy-without-crypto:copy": "mkdir -p vendor && cp src/vendor/scryptsy-without-crypto.js ./vendor",
8178
"hdkey-without-crypto:build": "bash -x scripts/build-hdkey-without-crypto.sh",
@@ -117,20 +114,18 @@
117114
},
118115
"dependencies": {
119116
"@types/pbkdf2": "^3.0.0",
120-
"@types/secp256k1": "3.5.0",
121-
"bip66": "^1.1.5",
122-
"blakejs": "^1.1.0",
123-
"bn.js": "^4.11.8",
124-
"browserify-aes": "^1.2.0",
117+
"@types/secp256k1": "^4.0.1",
125118
"bs58check": "^2.1.2",
119+
"safe-buffer": "^5.1.2",
126120
"create-hash": "^1.2.0",
121+
"pbkdf2": "^3.0.17",
127122
"create-hmac": "^1.1.7",
128-
"elliptic": "^6.4.1",
123+
"blakejs": "^1.1.0",
124+
"browserify-aes": "^1.2.0",
129125
"hash.js": "^1.1.7",
130126
"keccak": "^3.0.0",
131-
"pbkdf2": "^3.0.17",
132127
"randombytes": "^2.1.0",
133-
"safe-buffer": "^5.1.2",
128+
"secp256k1": "^4.0.1",
134129
"setimmediate": "^1.0.5"
135130
}
136131
}

packages/ethereum-cryptography/scripts/build-browser-tests.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ set -e
33
echo "Building tests with TypeScript"
44
npx tsc --project tsconfig.json
55

6-
echo "Building elliptic shim"
7-
npm run elliptic-secp256k1:build
8-
mkdir -p test-builds/tsc/src/vendor
9-
cp src/vendor/elliptic-secp256k1.js test-builds/tsc/src/vendor
10-
116
echo "Building scryptsy-without-crypto"
127
npm run scryptsy-without-crypto:build
138
mkdir -p test-builds/tsc/src/vendor
Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ethereum-cryptography/src/pure/secp256k1.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1 @@
1-
import * as secp256k1Pure from "./pure/secp256k1";
2-
3-
let secp256k1Module: typeof secp256k1Pure;
4-
5-
try {
6-
// tslint:disable-next-line no-implicit-dependencies
7-
secp256k1Module = require("ethereum-cryptography-native/secp256k1");
8-
} catch {
9-
secp256k1Module = require("./pure/secp256k1");
10-
}
11-
12-
export const privateKeyVerify = secp256k1Module.privateKeyVerify;
13-
export const privateKeyExport = secp256k1Module.privateKeyExport;
14-
export const privateKeyImport = secp256k1Module.privateKeyImport;
15-
export const privateKeyNegate = secp256k1Module.privateKeyNegate;
16-
export const privateKeyModInverse = secp256k1Module.privateKeyModInverse;
17-
export const privateKeyTweakAdd = secp256k1Module.privateKeyTweakAdd;
18-
export const privateKeyTweakMul = secp256k1Module.privateKeyTweakMul;
19-
export const publicKeyCreate = secp256k1Module.publicKeyCreate;
20-
export const publicKeyConvert = secp256k1Module.publicKeyConvert;
21-
export const publicKeyVerify = secp256k1Module.publicKeyVerify;
22-
export const publicKeyTweakAdd = secp256k1Module.publicKeyTweakAdd;
23-
export const publicKeyTweakMul = secp256k1Module.publicKeyTweakMul;
24-
export const publicKeyCombine = secp256k1Module.publicKeyCombine;
25-
export const signatureNormalize = secp256k1Module.signatureNormalize;
26-
export const signatureExport = secp256k1Module.signatureExport;
27-
export const signatureImport = secp256k1Module.signatureImport;
28-
export const signatureImportLax = secp256k1Module.signatureImportLax;
29-
export const sign = secp256k1Module.sign;
30-
export const verify = secp256k1Module.verify;
31-
export const recover = secp256k1Module.recover;
32-
export const ecdh = secp256k1Module.ecdh;
33-
export const ecdhUnsafe = secp256k1Module.ecdhUnsafe;
1+
export * from "secp256k1";
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { publicKeyConvert, recover, sign } from "../../src/secp256k1";
1+
import { ecdsaRecover, ecdsaSign, publicKeyConvert } from "../../src/secp256k1";
22
import { createTests } from "../test-vectors/secp256k1";
33

4-
createTests(sign, recover, publicKeyConvert);
4+
createTests(ecdsaSign, ecdsaRecover, publicKeyConvert);

packages/ethereum-cryptography/test/pure/secp256k1.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)