Consensys / eth-lightwallet

Lightweight JS Wallet for Node and the browser
MIT License
1.47k stars 503 forks source link

Bug: lightwallet.keystore.createVault and vault.keyFromPassword very slow #200

Open Tschuck opened 6 years ago

Tschuck commented 6 years ago

Hi,

We use lightwallet 3.0.1 in our progressive web application. In some cases, the two functions

take an incredibly long time to deliver a result. On a desktop browser, maximum peaks of 3s - 5s can be detected. On mobile devices, be it Chrome / Safari IOS or Chrome Android, times of up to 40 - 80s can be recorded.

After a page reload, this seems to worsen. Within Angular 5 and Ionic 3 on an IOS device, the behavior deteriorates after each side reload within the application. After reloading the page 5 - 10 times and creating new vaults, the IOS device stops the application completely and restarts the app.

After some debugging i think it could be a problem with the following lines within the keystore.js file.

Here's a fiddle-JS to investigate the problem. Please test on mobile devices, there the problem can be simulated better. A qr-code to scan it directly on your mobile device is attached too. For single testing of createVault, comment out lines 43 - 45.

https://jsfiddle.net/654b5yez qr-code-fiddle

Here some images of our tests on several devices:

Thank you for your support in advance. Notify me, if i can help you.

Tschuck commented 6 years ago

Its a problem with the scrypt-async-js library. We have created a pull request to handle the issue scrypt-async-js pull request.

Tschuck commented 6 years ago

Its not a problem with the scrypt-async-js library itself, its a problem the configuration of this library. By using an interruptStep of 200, to many setTimeouts are used.

I tested around a bit and a value of 1000 - 2000 should improve the behavior significantly.