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

Keypair functions taking too much time #1833

Open
amany9000 opened this issue May 23, 2023 · 2 comments
Open

Keypair functions taking too much time #1833

amany9000 opened this issue May 23, 2023 · 2 comments

Comments

@amany9000
Copy link

I am running polkadot.js over IOS using react-native. keypair.toJson and keypair.unlock each take almost 60 seconds. Same code I run in a browser extension and it works fine.

The numbers while creating the keyPair:
• cryptoWaitReady 67.58516716957092 milliseconds.
• naclDecrypt 2.701167106628418 milliseconds.
• new Keyring 0.1640000343322754 milliseconds.
• keyring.addFromUri 2326.9085409641266 milliseconds.
• keyPair.toJson 53572.15112495422 milliseconds.

While trying to signAndSend():
• cryptoWaitReady 0.061165809631347656 milliseconds.
• new Keyring 0.009291887283325195 milliseconds.
• keyring.addFromJson 3.1981661319732666 milliseconds.
• keypair.unlock 56587.29391694069 milliseconds.

@amany9000
Copy link
Author

@jacogr

@jacogr
Copy link
Member

jacogr commented May 23, 2023

RN is a best-effort.

To make it work we have to compile the normal JS WASM functions to ASM.js (everything else uses WASM - so this is the happy path), which is not optimal at all. We also cannot use pure JS for those functions (where available, e.g. non-sr25519) since BigInt support is spotty at best and the used underlying libs only use bn.

Any PRs to optimize the RN paths would certainly be appreciated.

(This is not a platform I can actually look at myself, I have never worked in that environment and previous efforts to even get a test app running has been fruitless, so it really is as stated - "best effort, assuming it works", hence "any PRs" above.)

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

2 participants