ecdh.setPrivateKey(privateKey[, encoding])
-
privateKey
<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>
设置 EC Diffie-Hellman 私钥。如果提供了 encoding
,则 privateKey
应该是一个字符串;否则 privateKey
应为 Buffer
、TypedArray
或 DataView
。
¥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
.
如果 privateKey
对于创建 ECDH
对象时指定的曲线无效,则会引发错误。在设置私钥时,相关的公共点(密钥)也会生成并设置在 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.