@@ -12,8 +12,8 @@ function assert (val, msg) {
1212 }
1313}
1414
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 ( ) ] )
1717}
1818
1919var Wallet = function ( priv , pub ) {
@@ -140,7 +140,7 @@ Wallet.prototype.toV3 = function (password, opts) {
140140 throw new Error ( 'Unsupported cipher' )
141141 }
142142
143- var ciphertext = Buffer . concat ( [ cipher . update ( this . privKey ) , cipher . final ( ) ] )
143+ var ciphertext = runCipherBuffer ( cipher , this . privKey )
144144
145145 var mac = ethUtil . keccak256 ( Buffer . concat ( [ derivedKey . slice ( 16 , 32 ) , Buffer . from ( ciphertext , 'hex' ) ] ) )
146146
@@ -237,7 +237,7 @@ Wallet.fromV1 = function (input, password) {
237237 }
238238
239239 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 )
241241
242242 return new Wallet ( seed )
243243}
@@ -277,7 +277,7 @@ Wallet.fromV3 = function (input, password, nonStrict) {
277277 }
278278
279279 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 )
281281
282282 return new Wallet ( seed )
283283}
@@ -299,7 +299,7 @@ Wallet.fromEthSale = function (input, password) {
299299 // NOTE: crypto (derived from openssl) when used with aes-*-cbc will handle PKCS#7 padding internally
300300 // see also http://stackoverflow.com/a/31614770/4964819
301301 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 ) )
303303
304304 var wallet = new Wallet ( ethUtil . keccak256 ( seed ) )
305305 if ( wallet . getAddress ( ) . toString ( 'hex' ) !== json . ethaddr ) {
0 commit comments