Upgrade to ethereumjs-util 6.0.0
This commit is contained in:
parent
93b0fae5f9
commit
a0ab9292dc
|
@ -34,7 +34,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"aes-js": "^3.1.1",
|
"aes-js": "^3.1.1",
|
||||||
"bs58check": "^2.1.2",
|
"bs58check": "^2.1.2",
|
||||||
"ethereumjs-util": "^5.2.0",
|
"ethereumjs-util": "^6.0.0",
|
||||||
"hdkey": "^1.1.0",
|
"hdkey": "^1.1.0",
|
||||||
"randombytes": "^2.0.6",
|
"randombytes": "^2.0.6",
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
|
|
10
src/index.js
10
src/index.js
|
@ -142,7 +142,7 @@ Wallet.prototype.toV3 = function (password, opts) {
|
||||||
|
|
||||||
var ciphertext = Buffer.concat([ cipher.update(this.privKey), cipher.final() ])
|
var ciphertext = Buffer.concat([ cipher.update(this.privKey), cipher.final() ])
|
||||||
|
|
||||||
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex') ]))
|
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex') ]))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: 3,
|
version: 3,
|
||||||
|
@ -230,13 +230,13 @@ Wallet.fromV1 = function (input, password) {
|
||||||
|
|
||||||
var ciphertext = Buffer.from(json.Crypto.CipherText, 'hex')
|
var ciphertext = Buffer.from(json.Crypto.CipherText, 'hex')
|
||||||
|
|
||||||
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
|
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
|
||||||
|
|
||||||
if (mac.toString('hex') !== json.Crypto.MAC) {
|
if (mac.toString('hex') !== json.Crypto.MAC) {
|
||||||
throw new Error('Key derivation failed - possibly wrong passphrase')
|
throw new Error('Key derivation failed - possibly wrong passphrase')
|
||||||
}
|
}
|
||||||
|
|
||||||
var decipher = crypto.createDecipheriv('aes-128-cbc', ethUtil.sha3(derivedKey.slice(0, 16)).slice(0, 16), Buffer.from(json.Crypto.IV, 'hex'))
|
var decipher = crypto.createDecipheriv('aes-128-cbc', ethUtil.keccak256(derivedKey.slice(0, 16)).slice(0, 16), Buffer.from(json.Crypto.IV, 'hex'))
|
||||||
var seed = decipherBuffer(decipher, ciphertext)
|
var seed = decipherBuffer(decipher, ciphertext)
|
||||||
|
|
||||||
return new Wallet(seed)
|
return new Wallet(seed)
|
||||||
|
@ -271,7 +271,7 @@ Wallet.fromV3 = function (input, password, nonStrict) {
|
||||||
|
|
||||||
var ciphertext = Buffer.from(json.crypto.ciphertext, 'hex')
|
var ciphertext = Buffer.from(json.crypto.ciphertext, 'hex')
|
||||||
|
|
||||||
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
|
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
|
||||||
if (mac.toString('hex') !== json.crypto.mac) {
|
if (mac.toString('hex') !== json.crypto.mac) {
|
||||||
throw new Error('Key derivation failed - possibly wrong passphrase')
|
throw new Error('Key derivation failed - possibly wrong passphrase')
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ Wallet.fromEthSale = function (input, password) {
|
||||||
var decipher = crypto.createDecipheriv('aes-128-cbc', derivedKey, encseed.slice(0, 16))
|
var decipher = crypto.createDecipheriv('aes-128-cbc', derivedKey, encseed.slice(0, 16))
|
||||||
var seed = decipherBuffer(decipher, encseed.slice(16))
|
var seed = decipherBuffer(decipher, encseed.slice(16))
|
||||||
|
|
||||||
var wallet = new Wallet(ethUtil.sha3(seed))
|
var wallet = new Wallet(ethUtil.keccak256(seed))
|
||||||
if (wallet.getAddress().toString('hex') !== json.ethaddr) {
|
if (wallet.getAddress().toString('hex') !== json.ethaddr) {
|
||||||
throw new Error('Decoded key mismatch - possibly wrong passphrase')
|
throw new Error('Decoded key mismatch - possibly wrong passphrase')
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ Thirdparty.fromEtherWallet = function (input, password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Thirdparty.fromEtherCamp = function (passphrase) {
|
Thirdparty.fromEtherCamp = function (passphrase) {
|
||||||
return new Wallet(ethUtil.sha3(Buffer.from(passphrase)))
|
return new Wallet(ethUtil.keccak256(Buffer.from(passphrase)))
|
||||||
}
|
}
|
||||||
|
|
||||||
Thirdparty.fromKryptoKit = function (entropy, password) {
|
Thirdparty.fromKryptoKit = function (entropy, password) {
|
||||||
|
|
Loading…
Reference in New Issue