Skip to content

"crypto/rsa" SignPKCS1v15 is 300 times slower than native #526

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

Open
idupree opened this issue Sep 25, 2016 · 3 comments
Open

"crypto/rsa" SignPKCS1v15 is 300 times slower than native #526

idupree opened this issue Sep 25, 2016 · 3 comments

Comments

@idupree
Copy link

idupree commented Sep 25, 2016

"crypto/rsa" SignPKCS1v15() completes in about 0.01 second on non-gopherjs x86_64 but 3 seconds in gopherjs on the same machine, which is 300 times slower. Can we do better? This affects things like macgyver's ChromeStorageBackend[1].

Test code/instructions here: https://github.com/idupree/slow-gopherjs-crypto

[1] https://github.com/stripe/macgyver

@paralin
Copy link
Contributor

paralin commented Sep 25, 2016

https://github.com/digitalbazaar/forge#pki

Javascript implementation of PKI, I don't know if they have v15 though.

@idupree
Copy link
Author

idupree commented Sep 26, 2016

That's a good comment.

golang has a library that implements the ssh-agent protocol, while forge doesn't, which makes it hard to use forge for macgyver's use case.

It's possible to use golang's ssh library with a non-golang RSA implementation. Which could be forge, web crypto, or other. I am likely to do this.

I mainly submitted this issue in case gopherjs is interested in improving the situation (or even just documenting why it's slow for anyone googling to find out why).

@nevkontakte
Copy link
Member

I think this could be a good test case for GopherJS performance improvements (as well as the slow-running tests in the crypto/x509 package). A while ago I attempted to profile these and determined that it was due to GopherJS's inefficient array access operations. One particular suspect is the range check GopherJS inserts on every array/slice element access.

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

3 participants