From fc34f08181a0e19b1f372f20748df1882d5599bc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 26 Apr 2016 15:14:37 +0100 Subject: [PATCH] Use importPublic and isValidPublic from ethereumjs-util 4.4.0 --- index.js | 9 +++------ package.json | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 1de86c7..3e1abb0 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ var ethUtil = require('ethereumjs-util') var crypto = require('crypto') var scryptsy = require('scrypt.js') var uuid = require('uuid') -var secp256k1 = require('secp256k1') var bs58check = require('bs58check') function assert (val, msg) { @@ -24,7 +23,7 @@ var Wallet = function (priv, pub) { throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)') } - if (pub && pub.length !== 64) { + if (pub && !ethUtil.isValidPublic(pub)) { throw new Error('Invalid public key') } @@ -171,11 +170,9 @@ Wallet.prototype.toV3String = function (password, opts) { } Wallet.fromPublicKey = function (pub, nonStrict) { - // FIXME: duplicate from ethUtil.publicToAddress(), maybe it could be factored out? - if ((pub.length !== 64) && nonStrict) { - pub = secp256k1.publicKeyConvert(pub, false).slice(1) + if (nonStrict) { + pub = ethUtil.importPublic(pub) } - assert(pub.length === 64, 'Invalid public key') return new Wallet(null, pub) } diff --git a/package.json b/package.json index 7e2b7e4..d3ce718 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,9 @@ "dependencies": { "aes-js": "^0.2.3", "bs58check": "^1.0.8", - "ethereumjs-util": "^4.3.0", + "ethereumjs-util": "^4.4.0", "hdkey": "^0.7.0", "scrypt.js": "^0.2.0", - "secp256k1": "^3.0.1", "uuid": "^2.0.1", "utf8": "^2.1.1" },