Skip to content

Commit 1924f25

Browse files
kovanclaude
andcommitted
doc: clarify diffieHellman.generateKeys recomputes same key
Clarify that calling generateKeys() after a private key has been set recomputes the same public key deterministically, rather than implying the public key changes. The public key is fully determined by the private key, so the result is identical unless the private key was changed via setPrivateKey(). Fixes: #56990 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3bbed16 commit 1924f25

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doc/api/crypto.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,10 @@ If `encoding` is provided a string is returned; otherwise a
11211121
[`Buffer`][] is returned.
11221122

11231123
This function is a thin wrapper around [`DH_generate_key()`][]. In particular,
1124-
once a private key has been generated or set, calling this function only updates
1125-
the public key but does not generate a new private key.
1124+
once a private key has been generated or set, calling this function only
1125+
recomputes the public key from the existing private key. Since the public key is
1126+
determined by the private key, the result will be the same unless the private key
1127+
has been changed via [`diffieHellman.setPrivateKey()`][].
11261128

11271129
### `diffieHellman.getGenerator([encoding])`
11281130

@@ -6572,6 +6574,7 @@ See the [list of SSL OP Flags][] for details.
65726574
[`decipher.final()`]: #decipherfinaloutputencoding
65736575
[`decipher.update()`]: #decipherupdatedata-inputencoding-outputencoding
65746576
[`diffieHellman.generateKeys()`]: #diffiehellmangeneratekeysencoding
6577+
[`diffieHellman.setPrivateKey()`]: #diffiehellmansetprivatekeyprivatekey-encoding
65756578
[`diffieHellman.setPublicKey()`]: #diffiehellmansetpublickeypublickey-encoding
65766579
[`ecdh.generateKeys()`]: #ecdhgeneratekeysencoding-format
65776580
[`ecdh.setPrivateKey()`]: #ecdhsetprivatekeyprivatekey-encoding

0 commit comments

Comments
 (0)