Skip to content

Commit 67e6404

Browse files
kovanclaude
authored 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> PR-URL: #62205 Fixes: #56990 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent b4fce60 commit 67e6404

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

doc/api/crypto.md

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

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

10861088
### `diffieHellman.getGenerator([encoding])`
10871089

@@ -6185,6 +6187,7 @@ See the [list of SSL OP Flags][] for details.
61856187
[`decipher.final()`]: #decipherfinaloutputencoding
61866188
[`decipher.update()`]: #decipherupdatedata-inputencoding-outputencoding
61876189
[`diffieHellman.generateKeys()`]: #diffiehellmangeneratekeysencoding
6190+
[`diffieHellman.setPrivateKey()`]: #diffiehellmansetprivatekeyprivatekey-encoding
61886191
[`diffieHellman.setPublicKey()`]: #diffiehellmansetpublickeypublickey-encoding
61896192
[`ecdh.generateKeys()`]: #ecdhgeneratekeysencoding-format
61906193
[`ecdh.setPrivateKey()`]: #ecdhsetprivatekeyprivatekey-encoding

0 commit comments

Comments
 (0)