@@ -142,7 +142,7 @@ Wallet.prototype.toV3 = function (password, opts) {
142
142
143
143
var ciphertext = Buffer . concat ( [ cipher . update ( this . privKey ) , cipher . final ( ) ] )
144
144
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' ) ] ) )
146
146
147
147
return {
148
148
version : 3 ,
@@ -230,13 +230,13 @@ Wallet.fromV1 = function (input, password) {
230
230
231
231
var ciphertext = Buffer . from ( json . Crypto . CipherText , 'hex' )
232
232
233
- var mac = ethUtil . sha3 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , ciphertext ] ) )
233
+ var mac = ethUtil . keccak256 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , ciphertext ] ) )
234
234
235
235
if ( mac . toString ( 'hex' ) !== json . Crypto . MAC ) {
236
236
throw new Error ( 'Key derivation failed - possibly wrong passphrase' )
237
237
}
238
238
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' ) )
240
240
var seed = decipherBuffer ( decipher , ciphertext )
241
241
242
242
return new Wallet ( seed )
@@ -271,7 +271,7 @@ Wallet.fromV3 = function (input, password, nonStrict) {
271
271
272
272
var ciphertext = Buffer . from ( json . crypto . ciphertext , 'hex' )
273
273
274
- var mac = ethUtil . sha3 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , ciphertext ] ) )
274
+ var mac = ethUtil . keccak256 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , ciphertext ] ) )
275
275
if ( mac . toString ( 'hex' ) !== json . crypto . mac ) {
276
276
throw new Error ( 'Key derivation failed - possibly wrong passphrase' )
277
277
}
@@ -301,7 +301,7 @@ Wallet.fromEthSale = function (input, password) {
301
301
var decipher = crypto . createDecipheriv ( 'aes-128-cbc' , derivedKey , encseed . slice ( 0 , 16 ) )
302
302
var seed = decipherBuffer ( decipher , encseed . slice ( 16 ) )
303
303
304
- var wallet = new Wallet ( ethUtil . sha3 ( seed ) )
304
+ var wallet = new Wallet ( ethUtil . keccak256 ( seed ) )
305
305
if ( wallet . getAddress ( ) . toString ( 'hex' ) !== json . ethaddr ) {
306
306
throw new Error ( 'Decoded key mismatch - possibly wrong passphrase' )
307
307
}
0 commit comments