The class for creating EC Diffie-Hellman key exchanges.

Returned by Crypto.createECDH.

Methods

computeSecret(other_public_key:Buffer):Buffer

computeSecret(other_public_key:String, input_encoding:String, output_encoding:String):String

computeSecret(other_public_key:String, input_encoding:String):Buffer

Computes the shared secret using other_public_key as the other party's public key and returns the computed shared secret. Supplied key is interpreted using specified input_encoding, and secret is encoded using specified output_encoding.

Encodings can be 'binary', 'hex', or 'base64'.

If the input encoding is not provided, then a buffer is expected. If no output encoding is given, then a buffer is returned.

generateKeys(?encoding:String, ?format:ECDHFormat):EitherType<String, Buffer>

Generates private and public EC Diffie-Hellman key values, and returns the public key in the specified format and encoding. This key should be transferred to the other party.

Format specifies point encoding and can be 'compressed', 'uncompressed', or 'hybrid'. If no format is provided - the point will be returned in 'uncompressed' format.

Encoding can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

getPrivateKey(encoding:String):String

getPrivateKey():Buffer

Returns the EC Diffie-Hellman private key in the specified encoding, which can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

getPublicKey(?encoding:String, ?format:ECDHFormat):EitherType<String, Buffer>

Returns the EC Diffie-Hellman public key in the specified encoding and format.

Format specifies point encoding and can be 'compressed', 'uncompressed', or 'hybrid'. If no format is provided - the point will be returned in 'uncompressed' format.

Encoding can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

setPrivateKey(private_key:String, encoding:String):Void

setPrivateKey(private_key:Buffer):Void

Sets the EC Diffie-Hellman private key.

Key encoding can be 'binary', 'hex' or 'base64'. If no encoding is provided, then a buffer is expected.

setPublicKey(public_key:String, encoding:String):Void

setPublicKey(public_key:Buffer):Void

Sets the EC Diffie-Hellman public key.

Key encoding can be 'binary', 'hex' or 'base64'. If no encoding is provided, then a buffer is expected.