simonmcallister0210 / cognito-srp-helper

A helper for SRP authentication in AWS Cognito
Apache License 2.0
12 stars 3 forks source link

Signing session takes 20+ seconds on Node v21 #33

Open simonmcallister0210 opened 8 months ago

simonmcallister0210 commented 8 months ago

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

ryanwalters commented 3 months ago

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 commented 3 months ago

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 commented 2 weeks ago

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?