Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit a0ab929

Browse files
committed
Upgrade to ethereumjs-util 6.0.0
1 parent 93b0fae commit a0ab929

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"aes-js": "^3.1.1",
3636
"bs58check": "^2.1.2",
37-
"ethereumjs-util": "^5.2.0",
37+
"ethereumjs-util": "^6.0.0",
3838
"hdkey": "^1.1.0",
3939
"randombytes": "^2.0.6",
4040
"safe-buffer": "^5.1.2",

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Wallet.prototype.toV3 = function (password, opts) {
142142

143143
var ciphertext = Buffer.concat([ cipher.update(this.privKey), cipher.final() ])
144144

145-
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex') ]))
145+
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex') ]))
146146

147147
return {
148148
version: 3,
@@ -230,13 +230,13 @@ Wallet.fromV1 = function (input, password) {
230230

231231
var ciphertext = Buffer.from(json.Crypto.CipherText, 'hex')
232232

233-
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
233+
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
234234

235235
if (mac.toString('hex') !== json.Crypto.MAC) {
236236
throw new Error('Key derivation failed - possibly wrong passphrase')
237237
}
238238

239-
var decipher = crypto.createDecipheriv('aes-128-cbc', ethUtil.sha3(derivedKey.slice(0, 16)).slice(0, 16), Buffer.from(json.Crypto.IV, 'hex'))
239+
var decipher = crypto.createDecipheriv('aes-128-cbc', ethUtil.keccak256(derivedKey.slice(0, 16)).slice(0, 16), Buffer.from(json.Crypto.IV, 'hex'))
240240
var seed = decipherBuffer(decipher, ciphertext)
241241

242242
return new Wallet(seed)
@@ -271,7 +271,7 @@ Wallet.fromV3 = function (input, password, nonStrict) {
271271

272272
var ciphertext = Buffer.from(json.crypto.ciphertext, 'hex')
273273

274-
var mac = ethUtil.sha3(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
274+
var mac = ethUtil.keccak256(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ]))
275275
if (mac.toString('hex') !== json.crypto.mac) {
276276
throw new Error('Key derivation failed - possibly wrong passphrase')
277277
}
@@ -301,7 +301,7 @@ Wallet.fromEthSale = function (input, password) {
301301
var decipher = crypto.createDecipheriv('aes-128-cbc', derivedKey, encseed.slice(0, 16))
302302
var seed = decipherBuffer(decipher, encseed.slice(16))
303303

304-
var wallet = new Wallet(ethUtil.sha3(seed))
304+
var wallet = new Wallet(ethUtil.keccak256(seed))
305305
if (wallet.getAddress().toString('hex') !== json.ethaddr) {
306306
throw new Error('Decoded key mismatch - possibly wrong passphrase')
307307
}

src/thirdparty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Thirdparty.fromEtherWallet = function (input, password) {
134134
}
135135

136136
Thirdparty.fromEtherCamp = function (passphrase) {
137-
return new Wallet(ethUtil.sha3(Buffer.from(passphrase)))
137+
return new Wallet(ethUtil.keccak256(Buffer.from(passphrase)))
138138
}
139139

140140
Thirdparty.fromKryptoKit = function (entropy, password) {

0 commit comments

Comments
 (0)