ecdh.setPrivateKey(privateKey[, encoding])


设置 EC Diffie-Hellman 私钥。 如果提供了 encoding,则 privateKey 应该是字符串;否则 privateKey 应该是 BufferTypedArrayDataView

如果 privateKey 对于创建 ECDH 对象时指定的曲线无效,则会引发错误。 在设置私钥时,相关的公共点(密钥)也会生成并设置在 ECDH 对象中。

Sets the EC Diffie-Hellman private key. If encoding is provided, privateKey is expected to be a string; otherwise privateKey is expected to be a Buffer, TypedArray, or DataView.

If privateKey is not valid for the curve specified when the ECDH object was created, an error is thrown. Upon setting the private key, the associated public point (key) is also generated and set in the ECDH object.