code: public static PrivateKey deserializePrivateKey(byte[] keyData, String algorithm) {
          LOGGER.trace("deserialize private key from data using algorithm \"{}\"", algorithm);
          PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(keyData);
          try {
              KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
              return keyFactory.generatePrivate(privSpec);
          } catch (GeneralSecurityException e) {
              throw new IllegalArgumentException("provided data could not be converted to a PrivateKey for algorithm "
                      + algorithm, e);
          }
      }
docs: converts a byte[] that originally was created using {@link PrivateKey#getEncoded()} back to the corresponding
  instance.
  
  Example: CipherUtils.deserializePrivateKey(data, "RSA")