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

Commit 744a79d

Browse files
authored
Merge pull request #135 from torusresearch/master
Fix issue with buffer concatenation while using scrypt
2 parents 0681d67 + 9b5f5fe commit 744a79d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export default class Wallet {
430430
}
431431

432432
const ciphertext = Buffer.from(json.crypto.ciphertext, 'hex')
433-
const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), ciphertext]))
433+
const mac = keccak256(Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), ciphertext]))
434434
if (mac.toString('hex') !== json.crypto.mac) {
435435
throw new Error('Key derivation failed - possibly wrong passphrase')
436436
}
@@ -599,7 +599,7 @@ export default class Wallet {
599599
}
600600

601601
const ciphertext = runCipherBuffer(cipher, this.privKey)
602-
const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), Buffer.from(ciphertext)]))
602+
const mac = keccak256(Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), Buffer.from(ciphertext)]))
603603

604604
return {
605605
version: 3,

0 commit comments

Comments
 (0)