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

Signing session takes 20+ seconds on Node v21 #33

Open
simonmcallister0210 opened this issue Mar 26, 2024 · 5 comments
Open

Signing session takes 20+ seconds on Node v21 #33

simonmcallister0210 opened this issue Mar 26, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@simonmcallister0210
Copy link
Owner

After updating the test matrix to include Node v21 I noticed signing takes ages, causing tests to fail. Maybe this is something to do with the fact I'm still using CryptoJS? I'm not sure...

I think for now we should look into moving over to the built-in crypto functions. Might improve performance and should have the added benefit of reducing the package size

@simonmcallister0210 simonmcallister0210 added the bug Something isn't working label Mar 26, 2024
@ryanwalters
Copy link

Also worth noting, crypto-js was discontinued as of October 2023. I'm not an expert on crypto stuff, but this issue might be useful for migrating over to the node:crypto equivalents of crypto-js functionality.

@simonmcallister0210
Copy link
Owner Author

Yes it's been at the back of my mind for a while and I've been thinking about how to approach it. I definitely want to move over to the standard crypto library very soon

I wasn't aware of this issue. Some useful info in there that'll come in handy. Thanks! If you (or anyone else) find any more useful guides or discussions feel free to drop them here. It'll make my life a lot easier when we eventually do make the transition 😁

@rhoberman
Copy link

rhoberman commented Nov 8, 2024

I'm using React Native with Hermes and I was experiencing 5+ second waits on an iPhone 16.

I'm using the buffer polyfill. I did some profiling on both buffer and crypto-js and neither seemed to be the problem. Rather it seems it is jsbn. Replacing its BigInteger with the in-built BigInt gives me pretty good performance (around 6 times faster).

See my fork.

I know using BigInt may not work for everyone. If not, would it be possible to make the BigInteger library configurable?

@simonmcallister0210
Copy link
Owner Author

simonmcallister0210 commented Nov 25, 2024

I'm using the buffer polyfill. I did some profiling on both buffer and crypto-js and neither seemed to be the problem. Rather it seems it is jsbn. Replacing its BigInteger with the in-built BigInt gives me pretty good performance (around 6 times faster).

Ah good spot! Thats really useful to know

I know using BigInt may not work for everyone. If not, would it be possible to make the BigInteger library configurable?

Maybe yeah.. I'm thinking we could create a layer of abstraction for large numbers, then swap out the underlying library based on config. Wouldn't need to install any new dependencies since BigInt is built-in. Shouldn't cause any interference for existing users

I'm a bit stuck on how we'd specify that config. Our library's all functions so we're limited in what we can do. We could use environment variable, a package level config object, more function params... I'll give it some thought

Should be do-able though. I'll put together a solution soon. Feel free to open a PR if you feel like it, always happy to collaborate

@rhoberman
Copy link

rhoberman commented Dec 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants