-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
crypto: add generatePublicKey to ECDH, fix corner cases #4124
Conversation
ECDH.generatePublicKey can get the public key using the curve and private key. This allows usage of the crypto module where a developer imports a private key, and then generates a public key without needing it stored. Removed the generated_ boolean from the ECDH class, and stopped checking for it with getPrivateKey() and getPublicKey(). This allows you to import public and private keys without having to generate first, which would just rewrite the generated keys regardless. An error message was changed to accurately reflect what the error was.
Change the function name of generatePublicKey to be generatePublicKey instead of generateKeys.
Would it be possible to implicitly cache the generated keys to avoid repeated calculations? |
@nodejs/crypto |
@mscdex I want to make sure I understand what you're asking. You're talking about basically the same thing as the conversation starting at https://github.com/nodejs/node/pull/1020/files#r25941472 was about, right? It's about how to make sure we don't needlessly go through the work of generating the public key from the private key more than once? |
@Trott Pretty much. |
You guys should check what we've got ready for #3511 to make sure you're not repeating effort. |
@Trott Yep, agreed, exactly what I was thinking. |
FWIW, I just landed #3511. Should this be closed? |
@Trott @bnoordhuis Yep, with the landing of #3511, I believe that this, #4124, and #1020 can now be closed. |
Okay, closing. Thanks. |
This is #1020 rebased against master and with the nits fixed up.
From original PR: