question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance of bip39.mnemonicToSeed

See original GitHub issue

In my JavaScript app (browser) bip39.mnemonicToSeed(seedPhrase) takes about 1500ms.

Is there anyway to improve the speed of this function?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mesqueebcommented, Mar 5, 2019

@junderw I just finished testing. WOW! For me it’s a lot faster!!!

Thank you so much!!

I’m building a browser application and this is the code:

  let t0, t1
  t0 = performance.now()
  const seedOLD = bip39.mnemonicToSeed(seedPhrase) // takes 1000~1500ms
  t1 = performance.now()
  console.log(`create seedOLD took ${(t1 - t0)} ms!`)

  // 🔥 super saiyan mode!!!
  t0 = performance.now()
  const seed = await bip39.mnemonicToSeedAsync(seedPhrase) // takes <10ms
  t1 = performance.now()
  console.log(`create seed took ${(t1 - t0)} ms!`)

This shows this in the console log:

create seedOLD took 1283.4949999814853 ms! create seed took 8.230000006733462 ms!

Also, the first approach completely blocks the UI so the browser window cannot be scrolled or interacted with. The second one doesn’t. AND since it only takes 10 ms, it’s even better!!

Thank you so much for this push! I can’t wait until it goes to master branch and gets pushed to NPM!!! ❤️❤️❤️❤️

1reaction
junderwcommented, Mar 1, 2019

perhaps adding an async function would be fine.

If anyone wants to take a crack I can review and merge. Return a promise is probably best.

leave the sync method as is to keep backwards compat.

I’ll get to it on Monday if no PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the bip39.mnemonicToSeed function in bip39 - Snyk
mnemonicToSeed examples, based on popular ways it is used in public projects. ... t0 = performance.now(); if (this.mnemonic == '') { this.mnemonic =...
Read more >
bip39 - npm
Bitcoin BIP39: Mnemonic code for generating deterministic keys. ... version // mnemonicToSeedSync is less performance oriented bip39.
Read more >
How I checked over 1 trillion mnemonics in 30 hours to win a ...
I wrote a CPU version in Rust to benchmark performance of a CPU solver. ... A BIP-39 mnemonic is generated using words from...
Read more >
Returning a promise node js - javascript - Stack Overflow
Or use the bip39.mnemonicToSeedSync method to avoid the Promise interface - but with lesser performance const bip39 = require('bip39') const ...
Read more >
BITCOIN - Bip39-mnemonic-to-seed
Turn a mnemonic string into a seed. Signature; (bip39-mnemonic-to-seed mnemonic passphrase) → seed; Arguments: mnemonic — Guard ( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found