static void storeKeyPair(final KeyPair keyPair, final File file) throws IOException {
    final File privateKeyDir = file.getParentFile();
    privateKeyDir.mkdirs();
    final Path tempPath = Files.createTempFile(privateKeyDir.toPath(), ".tmp", "");
    Files.write(
        tempPath,
        keyPair.getPrivateKey().getEncodedBytes().toString().getBytes(StandardCharsets.UTF_8));
    Files.move(tempPath, file.toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
  }
Store key pair.

@param keyPair the key pair
@param file the file
@throws IOException the io exception
crypto/algorithms/src/main/java/org/hyperledger/besu/crypto/KeyPairUtil.java