code: public KeyPair generateKeyPair() {
          KeyPair keyPair = null;
          try {
              KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ALGORITHM);
              keyPairGenerator.initialize(KEYLENGTH);
              keyPair = keyPairGenerator.generateKeyPair();
          } catch (NoSuchAlgorithmException e) {
              LOG.error("Failed to create publi/private key pair", e);
          }
          
          return keyPair;
      }
docs: Generate key which contains a pair of private and public key using 4096 bytes
  
  @return key pair