From 8d44cbed85c0e912121c1abeadd661467482802f Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Mon, 24 May 2021 12:14:55 +0200 Subject: [PATCH 1/3] elliptic -> eccrypto to support browsers keygen --- package-lock.json | 94 +++++++++++++++++++++++++++++++++++ package.json | 2 + src/lib/Keys.ts | 19 ++++--- test/lib/CasperClient.test.ts | 1 + 4 files changed, 106 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 610e86971..02f905c18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -514,6 +514,15 @@ "@types/node": "*" } }, + "@types/eccrypto": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/eccrypto/-/eccrypto-1.1.2.tgz", + "integrity": "sha512-qmB/iGIoqDdCMHAcJiOKI4ZBI1Z3kBQGYQCkgNP/Z9ge5w/EVx5uxQYkGOFpllm6l2N/B3qXcn9vjqXGaV1vRQ==", + "requires": { + "@types/expect": "^1.20.4", + "@types/node": "*" + } + }, "@types/elliptic": { "version": "6.4.12", "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.12.tgz", @@ -545,6 +554,11 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.47.tgz", "integrity": "sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg==" }, + "@types/expect": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/@types/expect/-/expect-1.20.4.tgz", + "integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==" + }, "@types/express": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.11.tgz", @@ -1189,6 +1203,24 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "optional": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, "blakejs": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", @@ -1830,12 +1862,58 @@ } } }, + "drbg.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", + "integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", + "optional": true, + "requires": { + "browserify-aes": "^1.0.6", + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4" + } + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", "dev": true }, + "eccrypto": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/eccrypto/-/eccrypto-1.1.6.tgz", + "integrity": "sha512-d78ivVEzu7Tn0ZphUUaL43+jVPKTMPFGtmgtz1D0LrFn7cY3K8CdrvibuLz2AAkHBLKZtR8DMbB2ukRYFk987A==", + "requires": { + "acorn": "7.1.1", + "elliptic": "6.5.4", + "es6-promise": "4.2.8", + "nan": "2.14.0", + "secp256k1": "3.7.1" + }, + "dependencies": { + "acorn": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==" + }, + "secp256k1": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "bip66": "^1.1.5", + "bn.js": "^4.11.8", + "create-hash": "^1.2.0", + "drbg.js": "^1.0.1", + "elliptic": "^6.4.1", + "nan": "^2.14.0", + "safe-buffer": "^5.1.2" + } + } + } + }, "electron-to-chromium": { "version": "1.3.719", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.719.tgz", @@ -1976,6 +2054,11 @@ "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=", "dev": true }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -2304,6 +2387,12 @@ "flat-cache": "^3.0.4" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "optional": true + }, "filename-reserved-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", @@ -4129,6 +4218,11 @@ } } }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", diff --git a/package.json b/package.json index 1ec685cb4..fc236dd83 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,10 @@ "@ethersproject/bytes": "^5.0.5", "@ethersproject/constants": "^5.0.5", "@open-rpc/client-js": "^1.6.2", + "@types/eccrypto": "^1.1.2", "axios": "^0.21.1", "blakejs": "^1.1.0", + "eccrypto": "^1.1.6", "ethereum-cryptography": "^0.1.3", "glob": "^7.1.6", "humanize-duration": "^3.24.0", diff --git a/src/lib/Keys.ts b/src/lib/Keys.ts index 49a225ccd..76016f364 100644 --- a/src/lib/Keys.ts +++ b/src/lib/Keys.ts @@ -5,14 +5,15 @@ import { decodeBase64 } from 'tweetnacl-util'; import { encodeBase16, encodeBase64 } from '../index'; import { PublicKey } from '../lib/index'; import { byteHash } from './Contracts'; -import { ec as EC } from 'elliptic'; +import eccrypto from "eccrypto"; +// import { ec as EC } from 'elliptic'; import * as secp256k1 from 'ethereum-cryptography/secp256k1'; import KeyEncoder from 'key-encoder'; import { sha256 } from 'ethereum-cryptography/sha256'; import { CasperHDKey } from './CasperHDKey'; const keyEncoder = new KeyEncoder('secp256k1'); -const ec = new EC('secp256k1'); +// const ec = new EC('secp256k1'); const ED25519_PEM_SECRET_KEY_TAG = 'PRIVATE KEY'; const ED25519_PEM_PUBLIC_KEY_TAG = 'PUBLIC KEY'; @@ -317,9 +318,9 @@ export class Secp256K1 extends AsymmetricKey { * Generating a new Secp256K1 key pair */ public static new() { - const keyPair = ec.genKeyPair(); - const publicKey = Uint8Array.from(keyPair.getPublic(true, 'array')); - const privateKey = keyPair.getPrivate().toBuffer(); + // const keyPair = ec.genKeyPair(); + const privateKey = eccrypto.generatePrivate(); + const publicKey = Uint8Array.from(eccrypto.getPublicCompressed(privateKey)); return new Secp256K1(publicKey, privateKey); } @@ -388,10 +389,8 @@ export class Secp256K1 extends AsymmetricKey { } else { rawKeyHex = encodeBase16(bytes); } - const privateKey = ec - .keyFromPrivate(rawKeyHex, 'hex') - .getPrivate() - .toBuffer(); + + const privateKey = Buffer.from(rawKeyHex, 'hex'); return privateKey; } @@ -407,7 +406,7 @@ export class Secp256K1 extends AsymmetricKey { } const publicKey = Uint8Array.from( - ec.keyFromPublic(rawKeyHex, 'hex').getPublic(true, 'array') + Buffer.from(rawKeyHex, 'hex') ); return publicKey; } diff --git a/test/lib/CasperClient.test.ts b/test/lib/CasperClient.test.ts index 3570e1b73..78af7b294 100644 --- a/test/lib/CasperClient.test.ts +++ b/test/lib/CasperClient.test.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; + import { CasperClient } from '../../src/lib/CasperClient'; import { Deploy } from '../../src/lib/DeployUtil'; import * as fs from 'fs'; From eeafdcf0256b7bae0adc28e98c4fbdf1ec42cf4d Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Mon, 24 May 2021 12:35:51 +0200 Subject: [PATCH 2/3] version bump --- CHANGELOG.md | 9 ++- package-lock.json | 163 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- webpack.config.js | 1 + 4 files changed, 174 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6182c6ffb..7ca8fa2ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,18 @@ All notable changes to casper-client-sdk. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.3.3 + +## Fixed + +- `Keys.SECP256K1.new()` and other SECP256K1 releated methods now can work in a browser environment. + ## 1.3.2 ## Added + - `DeployUtil.deployToBytes(deploy)` returns an `Uint8Array`, which is a byte representation of a deploy. - + ## 1.3.1 ### Changed diff --git a/package-lock.json b/package-lock.json index 02f905c18..a6d247966 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1307,6 +1307,72 @@ "safe-buffer": "^5.0.1" } }, + "browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "browserify-rsa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "dev": true, + "requires": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + }, + "dependencies": { + "bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", + "dev": true + } + } + }, + "browserify-sign": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", + "dev": true, + "requires": { + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", + "dev": true + } + } + }, "browserslist": { "version": "4.16.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.4.tgz", @@ -1698,6 +1764,16 @@ "yaml": "^1.10.0" } }, + "create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, "create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", @@ -1734,6 +1810,25 @@ "which": "^2.0.1" } }, + "crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + } + }, "crypto-random-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", @@ -1821,12 +1916,33 @@ "object-keys": "^1.0.12" } }, + "des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -3813,6 +3929,16 @@ "picomatch": "^2.2.3" } }, + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, "mime-db": { "version": "1.47.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", @@ -4680,6 +4806,19 @@ "callsites": "^3.0.0" } }, + "parse-asn1": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "dev": true, + "requires": { + "asn1.js": "^5.2.0", + "browserify-aes": "^1.0.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, "parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -5061,6 +5200,20 @@ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", "dev": true }, + "public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -5109,6 +5262,16 @@ "safe-buffer": "^5.1.0" } }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "requires": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", diff --git a/package.json b/package.json index fc236dd83..cf18222e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "casper-client-sdk", - "version": "1.3.2", + "version": "1.3.3", "license": "Apache 2.0", "description": "SDK to interact with the Casper blockchain", "main": "dist/lib.node.js", @@ -47,6 +47,7 @@ "buffer": "^6.0.3", "chai": "^4.2.0", "concurrently": "^6.0.0", + "crypto-browserify": "^3.12.0", "eslint": "^7.21.0", "eslint-config-prettier": "^8.1.0", "eslint-plugin-jsdoc": "^32.2.0", diff --git a/webpack.config.js b/webpack.config.js index dba649811..44600dfb9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -35,6 +35,7 @@ const clientConfig = { resolve: { ...common.resolve, fallback: { + crypto: require.resolve('crypto-browserify'), stream: require.resolve('stream-browserify'), asert: require.resolve('assert'), fs: false From 8d9a80f8431b2ebfc73afbf3f977ca3404184d2d Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Mon, 24 May 2021 12:42:18 +0200 Subject: [PATCH 3/3] removed comments --- src/lib/Keys.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/Keys.ts b/src/lib/Keys.ts index 76016f364..d3897e602 100644 --- a/src/lib/Keys.ts +++ b/src/lib/Keys.ts @@ -6,14 +6,12 @@ import { encodeBase16, encodeBase64 } from '../index'; import { PublicKey } from '../lib/index'; import { byteHash } from './Contracts'; import eccrypto from "eccrypto"; -// import { ec as EC } from 'elliptic'; import * as secp256k1 from 'ethereum-cryptography/secp256k1'; import KeyEncoder from 'key-encoder'; import { sha256 } from 'ethereum-cryptography/sha256'; import { CasperHDKey } from './CasperHDKey'; const keyEncoder = new KeyEncoder('secp256k1'); -// const ec = new EC('secp256k1'); const ED25519_PEM_SECRET_KEY_TAG = 'PRIVATE KEY'; const ED25519_PEM_PUBLIC_KEY_TAG = 'PUBLIC KEY'; @@ -318,7 +316,6 @@ export class Secp256K1 extends AsymmetricKey { * Generating a new Secp256K1 key pair */ public static new() { - // const keyPair = ec.genKeyPair(); const privateKey = eccrypto.generatePrivate(); const publicKey = Uint8Array.from(eccrypto.getPublicCompressed(privateKey)); return new Secp256K1(publicKey, privateKey);