Ethers.js: React Native : Wallet.createRandom()._mnemonic(); function took 5 min for Android 6.0.1

Created on 23 Apr 2021  Â·  6Comments  Â·  Source: ethers-io/ethers.js

Describe the bug
I am working latest application for using ethers.io for my react native application and this should work on major android and ios

Reproduction steps
Just create a release build and use the function inside your code

Wallet.createRandom()._mnemonic();

Environment:
Android - v6.0.1
Kernal 3.10.49

Regards,
Ashish

investigate

Most helpful comment

yeah, it calls Wallet.fromMnemonic() which calls HDNode.fromMnemonic() which at some point calls mnemonicToSeed() which uses pbkdf2

All 6 comments

I've seen many devs facing slow performance on React Native with crypto utils. You can see: https://github.com/ethers-io/ethers.js/issues/946, https://github.com/ethers-io/ethers.js/issues/390#issuecomment-491759810, #323, #287, #210, #49.

Can you try the solution mentioned in https://github.com/ethers-io/ethers.js/issues/612#issuecomment-535617874

I'm tracing the slowness to pbkdf2 which seems to be blazingly slow on android (in react-native).
I imagine that in react-native it's rerouted to a JS implementation that is much slower than a native one.
I haven't figured out yet how this rerouting happens to be able to suggest a workaround.

Best to use web3j and web3swift.

Regards,
Ashish

On Tue, 8 Jun 2021 at 14:53, Mircea Nistor @.*> wrote:

I'm tracing the slowness to pbkdf2 which seems to be blazingly slow on
android (in react-native).
I imagine that in react-native it's rerouted to a JS implementation that
is much slower than a native one.
I haven't figured out yet how this rerouting happens to be able to suggest
a workaround.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ethers-io/ethers.js/issues/1503#issuecomment-856609854,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB6CBG77RZWP2IDXRDIGYTLTRXORBANCNFSM43O7PTLQ
.

>

[image: photo]
Ashish Kumar Patel
Founder & CEO, APPXBUILD TECHNOLOGIES PVT LTD

+91-98606-77800 | @.*

http://www.appxbuild.com
B401, Shree Ganesh Apartment, Kotwal Nagar , Khamla Sq. Nagpur
http://facebook.com/ashish%5C.onmobile
http://us.linkedin.com/in/ashishkumarpatel
http://twitter.com/ashishonmobile
Create your own email signature
https://www.wisestamp.com/create-own-signature/?utm_source=promotion&utm_medium=signature&utm_campaign=create_your_own&srcid=
‌

yeah.. sure.. but that's not the point.

Wallet.createRandom() will derive keys from a mnemonic that is based on a generated seed.
Deriving keys from a mnemonic is the bit that takes super long because of pbkdf2.
If you just need the mnemonic, then it should be easy to generate some randomness and then call 'entropyToMnemonic' from the hdnode package.

Are you sure pbkdf2 is used in Wallet.createRandom()? Can you point me to it if it's the case. AFAIK the kdfs are only used while keystore encrypting and ethers uses scrypt by default.

yeah, it calls Wallet.fromMnemonic() which calls HDNode.fromMnemonic() which at some point calls mnemonicToSeed() which uses pbkdf2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dev1644 picture dev1644  Â·  42Comments

282931 picture 282931  Â·  42Comments

pointtoken picture pointtoken  Â·  24Comments

elenadimitrova picture elenadimitrova  Â·  28Comments

Levino picture Levino  Â·  35Comments