ecdh.setPrivateKey(privateKey[, encoding])


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

【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.】

如果 privateKeyECDH 对象创建时指定的曲线无效,将会抛出错误。在设置私钥时,相关的公钥点也会生成并设置在 ECDH 对象中。

【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.】