@@ -12,8 +12,8 @@ function assert (val, msg) {
12
12
}
13
13
}
14
14
15
- function decipherBuffer ( decipher , data ) {
16
- return Buffer . concat ( [ decipher . update ( data ) , decipher . final ( ) ] )
15
+ function runCipherBuffer ( cipher , data ) {
16
+ return Buffer . concat ( [ cipher . update ( data ) , cipher . final ( ) ] )
17
17
}
18
18
19
19
var Wallet = function ( priv , pub ) {
@@ -140,7 +140,7 @@ Wallet.prototype.toV3 = function (password, opts) {
140
140
throw new Error ( 'Unsupported cipher' )
141
141
}
142
142
143
- var ciphertext = Buffer . concat ( [ cipher . update ( this . privKey ) , cipher . final ( ) ] )
143
+ var ciphertext = runCipherBuffer ( cipher , this . privKey )
144
144
145
145
var mac = ethUtil . keccak256 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , Buffer . from ( ciphertext , 'hex' ) ] ) )
146
146
@@ -237,7 +237,7 @@ Wallet.fromV1 = function (input, password) {
237
237
}
238
238
239
239
var decipher = crypto . createDecipheriv ( 'aes-128-cbc' , ethUtil . keccak256 ( derivedKey . slice ( 0 , 16 ) ) . slice ( 0 , 16 ) , Buffer . from ( json . Crypto . IV , 'hex' ) )
240
- var seed = decipherBuffer ( decipher , ciphertext )
240
+ var seed = runCipherBuffer ( decipher , ciphertext )
241
241
242
242
return new Wallet ( seed )
243
243
}
@@ -277,7 +277,7 @@ Wallet.fromV3 = function (input, password, nonStrict) {
277
277
}
278
278
279
279
var decipher = crypto . createDecipheriv ( json . crypto . cipher , derivedKey . slice ( 0 , 16 ) , Buffer . from ( json . crypto . cipherparams . iv , 'hex' ) )
280
- var seed = decipherBuffer ( decipher , ciphertext )
280
+ var seed = runCipherBuffer ( decipher , ciphertext )
281
281
282
282
return new Wallet ( seed )
283
283
}
@@ -299,7 +299,7 @@ Wallet.fromEthSale = function (input, password) {
299
299
// NOTE: crypto (derived from openssl) when used with aes-*-cbc will handle PKCS#7 padding internally
300
300
// see also http://stackoverflow.com/a/31614770/4964819
301
301
var decipher = crypto . createDecipheriv ( 'aes-128-cbc' , derivedKey , encseed . slice ( 0 , 16 ) )
302
- var seed = decipherBuffer ( decipher , encseed . slice ( 16 ) )
302
+ var seed = runCipherBuffer ( decipher , encseed . slice ( 16 ) )
303
303
304
304
var wallet = new Wallet ( ethUtil . keccak256 ( seed ) )
305
305
if ( wallet . getAddress ( ) . toString ( 'hex' ) !== json . ethaddr ) {
0 commit comments