Repository navigation
ecdh.setPublicKey is actually useful and should be undeprecated #18977
Description
Activity
- addedcryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.
on Feb 24, 2018 /cc @nodejs/crypto
Technically correct but it's probably better to add an explicit conversion method instead of undeprecating
ECDH#setPublicKey().@skerit When does this come up? I'd expect most applications to be agnostic to the point format.
Ah well, this is related to my comment on issue #18147 "Signing with a ecdh type private key":
Since
crypto'sSign#signmethod needs a valid ASN.1 wrapper, but currently there is no built-in way of generating this, I'm using the jsrsasign module to do the signing, and that requires an uncompressed key.But yeah, an new method for converting the compressed key would be better :)
- addedc++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Feb 26, 2018 Okay, I've added labels. Pull request welcome and happy to answer questions.
Reacted by Jelle De Loecker@bnoordhuis Can I pick this up? I think it'll be a good first issue :)
@wuweiweiwu Sure thing.
Reacted by wei-wei@bnoordhuis I was thinking of adding another method
uncompressKeyin theECDHclass in https://github.com/nodejs/node/blob/master/src/node_crypto.ccIs that a good place to start?
Thank you
@wuweiweiwu I'd make it a static method (i.e. on
ECDH, notECDH.prototype) and you should name it something likeconvertKey()because the conversion goes both ways.(Three ways actually because node can also convert to a hybrid format.)
@bnoordhuis sounds good! I will work on the compress and uncompress. Where can I find more information on the hybrid format?
And is it ok if I put the tests in
test/parallel?It's the
'hybrid'option toECDH.prototype.getPublicKey.And is it ok if I put the tests in test/parallel?
Yep.
Just a question about converting buffer to point. Currently I have
ConvertKeyinnode_crypto.ccas a static method. I was planning on usingECDH::BufferToPointto convert the input key toEC_POINTHowever that function is a protected function in ECDH class.Should I declare
ConvertKeyas protected function of ECDH as well and then just bind it as a static method indiffiehellman.jsor should I figure out a way without using the ECDH member functions sinceConvertKeyis going to be a static method?Perhaps using
EC_GROUP_new_by_curve_name(nid)and have the user input the ECDH curve name associated with the key?Thank you!
I'd probably move the shared logic into a static ECDH member function. It doesn't matter if it's not a member, as long as there isn't code duplication.
Sounds good! On it
- added a commit that references this issue
on Mar 10, 2018 - added a commit that references this issue
on Apr 12, 2018 - added a commit that references this issue
on Jul 27, 2026
So
ecdh.setPublicKeyhas been deprecated since v5.2.0, but there is a certain use case where it is very useful: when you need to uncompress a compressed public key.Here's how I would uncompress such a public key:
If
ecdh.setPublicKeywhere to disappear I would require another library just for this simple task.