Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tschuck opened this issue May 9, 2018 · 2 comments
Open

Comments

@Tschuck
Copy link

Tschuck commented May 9, 2018

Hi,

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

  • lightwallet.keystore.createVault
  • vault.keyFromPassword

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.

  • Line: 86 - 89
var hdRoot = new Mnemonic(mnemonic).toHDPrivateKey().xprivkey;
var hdRootKey = new bitcore.HDPrivateKey(hdRoot);
var hdPathKey = hdRootKey.derive(hdPathString).xprivkey;
this.encHdRootPriv = encryptString(hdPathKey, pwDerivedKey);
  • Line: 355
scrypt(password, salt, logN, r, dkLen, interruptStep, cb, null);

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:

  • Desktop Chrome
    desktop-chrome

  • Desktop Firefox
    desktop-firefox

  • Nexus 5X Android Chrome
    nexus5x-android-chrome

  • IPAD Air IOS Safari
    ipad air safari

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

@Tschuck
Copy link
Author

Tschuck commented May 9, 2018

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
Copy link
Author

Tschuck commented May 15, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant