code: protected KeyPair generateKeyPair() {
          KeyPair keyPair = null;
          DHParameterSpec keySpec = new DHParameterSpec(DH_MODULUS, DH_BASE);
          try {
              KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
              keyGen.initialize(keySpec);
              keyPair = keyGen.generateKeyPair();
              keyAgreement = KeyAgreement.getInstance("DH");
              // key agreement is initialized with "this" ends private key
              keyAgreement.init(keyPair.getPrivate());
          } catch (Exception e) {
              log.error("Error generating keypair", e);
          }
          return keyPair;
      }
docs: Creates a Diffie-Hellman key pair.
  
  @return dh keypair