Web3.js: Decrypting a keystore fails on 1.2.9 (browser / React )

Created on 11 Jun 2020  路  5Comments  路  Source: ChainSafe/web3.js

1.2.9 broke web3.eth.accounts.wallet.decrypt (works fine in 1.2.8):

Expected behavior

in the browser (chromium) I can decrypt an encrypted wallet keystore structure.

Actual behavior

it shows me an the error TypeError: "list" argument must be an Array of Buffers

Steps to reproduce the behavior

call web3.eth.accounts.wallet.decrypt(jsonKeystore, password);

_I've put a demo repo here:_
https://github.com/cod1ng-earth/demo-web3-129-breaks-keystore-decryption

Environment

node 13 / 14 for building, chrome 83

Background

I debugged until the failing call that occurs on 1.2.9 on web3-eth-accounts, Line 384: https://github.com/ethereum/web3.js/commit/2f366c7a7925be59d6de8cadafa21a441d8b08ae#diff-7bb2a20126193b9ecfe4723f83429c49R384

The result of the newly introduced derivedKey = scrypt.syncScrypt seems to be related somehow, even though [derivedKey.slice(16, 32), ciphertext] is actually an array of two Uint8 arrays ([Uint8Array(16), Uint8Array(32)]). After having a look at the scrypt line (https://github.com/ricmoo/scrypt-js/blob/master/scrypt.js#L462) I'm absolutely not sure what could go wrong here, so I leave it up to you guys :(

Screenshot from 2020-06-11 16-52-01

1.x Stale bug

Most helpful comment

This just got merged in an hour ago @wendydv1989 @elmariachi111 If you'd like you can check the 1.x branch for the fix, otherwise hold tight for the next release!

All 5 comments

I have the same issue but with web3.eth.accounts.encrypt(privkey, passw);

This just got merged in an hour ago @wendydv1989 @elmariachi111 If you'd like you can check the 1.x branch for the fix, otherwise hold tight for the next release!

yep, tested that with my demo repo and 1.x fixes the issue :heart:

Awesome, will close this out once we cut a release :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

Was this page helpful?
0 / 5 - 0 ratings