code: public OpenPgpV4Fingerprint generateAndImportKeyPair(BareJid ourJid)
              throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchProviderException,
              PGPException, IOException {
  
          throwIfNoProviderSet();
          OpenPgpStore store = provider.getStore();
          PGPKeyRing keys = store.generateKeyRing(ourJid);
          try {
              store.importSecretKey(ourJid, keys.getSecretKeys());
              store.importPublicKey(ourJid, keys.getPublicKeys());
          } catch (MissingUserIdOnKeyException e) {
              // This should never throw, since we set our jid literally one line above this comment.
              throw new AssertionError(e);
          }
  
          OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(keys.getSecretKeys());
  
          store.setTrust(ourJid, fingerprint, OpenPgpTrustStore.Trust.trusted);
  
          return fingerprint;
      }
docs: Generate a fresh OpenPGP key pair and import it.
  
  @param ourJid our {@link BareJid}.
  @return {@link OpenPgpV4Fingerprint} of the generated key.
  @throws NoSuchAlgorithmException if the JVM doesn't support one of the used algorithms.
  @throws InvalidAlgorithmParameterException if the used algorithm parameters are invalid.
  @throws NoSuchProviderException if we are missing a cryptographic provider.
  @throws PGPException PGP is brittle.
  @throws IOException IO is dangerous.