-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Labels
c++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++.cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Description
So ecdh.setPublicKey
has 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:
const crypto = require('crypto');
let ecdh = crypto.createECDH('secp256k1');
ecdh.generateKeys();
let private_key_compressed = ecdh.getPrivateKey(null, 'compressed');
let public_key_compressed = ecdh.getPublicKey(null, 'compressed');
// Public key is a buffer of 33 bytes
console.log('Compressed public key:', public_key_compressed.length, public_key_compressed);
// Create a new ecdh object
ecdh = crypto.createECDH('secp256k1')
// Use the compressed public key to set the public key
ecdh.setPublicKey(public_key_compressed);
// Get the uncompressed get
let public_key_uncompressed = ecdh.getPublicKey();
// The returned key is a buffer of 66 bytes long
console.log('Uncomrpessed public key:', public_key_uncompressed.length, public_key_uncompressed);
If ecdh.setPublicKey
where to disappear I would require another library just for this simple task.
yackermann
Metadata
Metadata
Assignees
Labels
c++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++.cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.