Either generates a DH instance from scratch or by
reading already existing DH parameters from
string. Note that when reading a DH
instance from data that was encoded from a DH
instance by using #to_pem or #to_der the result will
not contain a public/private key pair yet. This needs to
be generated using #generate_key! first.

Generates a private and public key unless a private key already exists. If
this DH instance was generated from public DH parameters (e.g. by encoding the result of #public_key), then this method needs
to be called first in order to generate the per-session keys before
performing the actual key exchange.

Returns a new DH instance that carries just the
public information, i.e. the prime p and the generator
g, but no public/private key yet. Such a pair may be generated
using #generate_key!. The
“public key” needed for a key exchange with #compute_key is considered as
per-session information and may be retrieved with DH#pub_key once a key
pair has been generated. If the current instance already contains private
information (and thus a valid public/private key pair), this information
will no longer be present in the new instance generated by #public_key. This feature is helpful
for publishing the Diffie-Hellman parameters without leaking any of the
private per-session information.