| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
There was a problem hiding this comment.
I think the function name here needs to be changed from generateKeys to generatePublicKey
Sorry, something went wrong.
Change the function name of generatePublicKey to be generatePublicKey instead of generateKeys.
|
cc'ing @iojs/crypto |
Sorry, something went wrong.
There was a problem hiding this comment.
Style: space after 'if' (here and below.)
Sorry, something went wrong.
|
LGTM sans nits. |
Sorry, something went wrong.
There was a problem hiding this comment.
Why?
Sorry, something went wrong.
There was a problem hiding this comment.
I mean, perhaps it should be set from GeneratePublicKey too? Or be a flag field with two possible flags: GeneratedPrivate and GeneratedPublic?
Sorry, something went wrong.
There was a problem hiding this comment.
If I have something like the following code sample, getPrivateKey() will return an error if you haven't generated the keys, which is a pain for imported keys. I'd have to generate a keypair, then overwrite the keys (wasting a keypair just to toggle the bool).
var ecdh = crypto.createECDH(curve); ecdh.setPrivateKey(privateKey); ecdh.setPublicKey(publicKey); ecdh.getPrivateKey(); // error
I could also import only the private key then use generatePublicKey to toggle the bool, but the getPrivateKey/getPublicKey functionality with the bool initially can be unexpected behavior.
Perhaps computeSecret could just check for the private key and throw an error based on that?
Sorry, something went wrong.
There was a problem hiding this comment.
Ok, if setPrivateKey will set both Private and Public flag - will that work?
Sorry, something went wrong.
|
Reiterating, @mbullington if you could make the requested changes, I could try and get this merged in soon! |
Sorry, something went wrong.
|
This PR is getting stale. @mbullington Can you update the PR based on the feedback provided? |
Sorry, something went wrong.
|
I'll update the PR based on master and the feedback provided. Thank you for being patient, I'm very sorry if having this PR open for this long caused any inconvenience. |
Sorry, something went wrong.
|
No worries. I just want to make sure you get your contributions in and that they aren't forgotten. :) |
Sorry, something went wrong.
|
@nodejs/crypto Anyone want to update and retarget this? |
Sorry, something went wrong.
|
@mbullington could you make a new PR against master? Thanks! |
Sorry, something went wrong.
|
Please see #3511. It's a little different, but solves many of the same things. |
Sorry, something went wrong.
|
I rebased against master (only conflicts were in the markdown file), fixed up the nits (except for the ecdh->generated_ = true; removal that @indutny calls out) as well as some linting errors and re-animated this in #4124. Hope that's OK (and happy to close it if it's not for some reason). |
Sorry, something went wrong.
|
Closing, obsolete now that #3511 has landed. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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.