class KeystoresValidatorKeyProvider implements ValidatorKeyProvider {

  @Override
  public List<BLSKeyPair> loadValidatorKeys() {
    final List<Pair<Path, Path>> keystorePasswordFilePairs =
        config.getValidatorKeystorePasswordFilePairs();
    checkNotNull(keystorePasswordFilePairs, "validator keystore and password pairs cannot be null");

    final int totalValidatorCount = keystorePasswordFilePairs.size();
    StatusLogger.STATUS_LOG.loadingValidators(totalValidatorCount);
    // return distinct loaded key pairs

    final ExecutorService executorService =
        Executors.newFixedThreadPool(Math.min(4, Runtime.getRuntime().availableProcessors()));
    try {
      final AtomicInteger numberOfLoadedKeys = new AtomicInteger(0);
      final List<Future<Bytes32>> futures =
          keystorePasswordFilePairs.stream()
              .map(
                  pair ->
                      executorService.submit(
                          () -> {
                            Bytes32 privateKey =
                                loadBLSPrivateKey(pair.getLeft(), loadPassword(pair.getRight()));
                            int loadedValidatorCount = numberOfLoadedKeys.incrementAndGet();
                            if (loadedValidatorCount % 10 == 0) {
                              StatusLogger.STATUS_LOG.atLoadedValidatorNumber(
                                  loadedValidatorCount, totalValidatorCount);
                            }
                            return privateKey;
                          }))
              .collect(toList());

      Set<Bytes32> result = new HashSet<>();
      for (Future<Bytes32> future : futures) {
        result.add(future.get());
      }
      return result.stream()
          .map(privKey -> new BLSKeyPair(BLSSecretKey.fromBytes(privKey)))
          .collect(toList());
    } catch (InterruptedException e) {
      throw new RuntimeException("Interrupted while attempting to load validator key files", e);
    } catch (ExecutionException e) {
      if (e.getCause() instanceof RuntimeException) {
        throw (RuntimeException) e.getCause();
      }
      throw new RuntimeException("Unable to load validator key files", e);
    } finally {
      executorService.shutdownNow();
    }
  }

  public  KeystoresValidatorKeyProvider(
      final KeystoreLocker keystoreLocker, final ValidatorConfig config);

}