Skip to content

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

@Tschuck

Description

@Tschuck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions