Search in sources :

Example 1 with BlsKeystoreBulkLoader

use of tech.pegasys.web3signer.signing.BlsKeystoreBulkLoader in project web3signer by ConsenSys.

the class Eth2Runner method createArtifactSignerProvider.

@Override
protected ArtifactSignerProvider createArtifactSignerProvider(final Vertx vertx, final MetricsSystem metricsSystem) {
    return new DefaultArtifactSignerProvider(() -> {
        final List<ArtifactSigner> signers = Lists.newArrayList();
        final HashicorpConnectionFactory hashicorpConnectionFactory = new HashicorpConnectionFactory(vertx);
        try (final InterlockKeyProvider interlockKeyProvider = new InterlockKeyProvider(vertx);
            final YubiHsmOpaqueDataProvider yubiHsmOpaqueDataProvider = new YubiHsmOpaqueDataProvider();
            final AwsSecretsManagerProvider awsSecretsManagerProvider = new AwsSecretsManagerProvider(awsCacheMaximumSize)) {
            final AbstractArtifactSignerFactory artifactSignerFactory = new BlsArtifactSignerFactory(config.getKeyConfigPath(), metricsSystem, hashicorpConnectionFactory, interlockKeyProvider, yubiHsmOpaqueDataProvider, awsSecretsManagerProvider, (args) -> new BlsArtifactSigner(args.getKeyPair(), args.getOrigin(), args.getPath()));
            signers.addAll(new SignerLoader().load(config.getKeyConfigPath(), "yaml", new YamlSignerParser(List.of(artifactSignerFactory))));
        }
        if (azureKeyVaultParameters.isAzureKeyVaultEnabled()) {
            signers.addAll(loadAzureSigners());
        }
        if (keystoresParameters.isEnabled()) {
            final BlsKeystoreBulkLoader blsKeystoreBulkLoader = new BlsKeystoreBulkLoader();
            final Collection<ArtifactSigner> keystoreSigners = keystoresParameters.hasKeystoresPasswordsPath() ? blsKeystoreBulkLoader.loadKeystoresUsingPasswordDir(keystoresParameters.getKeystoresPath(), keystoresParameters.getKeystoresPasswordsPath()) : blsKeystoreBulkLoader.loadKeystoresUsingPasswordFile(keystoresParameters.getKeystoresPath(), keystoresParameters.getKeystoresPasswordFile());
            signers.addAll(keystoreSigners);
        }
        final List<Bytes> validators = signers.stream().map(ArtifactSigner::getIdentifier).map(Bytes::fromHexString).collect(Collectors.toList());
        if (validators.isEmpty()) {
            LOG.warn("No BLS keys loaded. Check that the key store has BLS key config files");
        } else {
            slashingProtectionContext.ifPresent(context -> context.getRegisteredValidators().registerValidators(validators));
        }
        return signers;
    });
}
Also used : BlsKeystoreBulkLoader(tech.pegasys.web3signer.signing.BlsKeystoreBulkLoader) HashicorpConnectionFactory(tech.pegasys.signers.hashicorp.HashicorpConnectionFactory) YamlSignerParser(tech.pegasys.web3signer.signing.config.metadata.parser.YamlSignerParser) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) AbstractArtifactSignerFactory(tech.pegasys.web3signer.signing.config.metadata.AbstractArtifactSignerFactory) SignerLoader(tech.pegasys.web3signer.signing.config.SignerLoader) InterlockKeyProvider(tech.pegasys.web3signer.signing.config.metadata.interlock.InterlockKeyProvider) AwsSecretsManagerProvider(tech.pegasys.signers.aws.AwsSecretsManagerProvider) YubiHsmOpaqueDataProvider(tech.pegasys.web3signer.signing.config.metadata.yubihsm.YubiHsmOpaqueDataProvider) Bytes(org.apache.tuweni.bytes.Bytes) ArtifactSigner(tech.pegasys.web3signer.signing.ArtifactSigner) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) DefaultArtifactSignerProvider(tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider) BlsArtifactSignerFactory(tech.pegasys.web3signer.signing.config.metadata.BlsArtifactSignerFactory)

Aggregations

Bytes (org.apache.tuweni.bytes.Bytes)1 AwsSecretsManagerProvider (tech.pegasys.signers.aws.AwsSecretsManagerProvider)1 HashicorpConnectionFactory (tech.pegasys.signers.hashicorp.HashicorpConnectionFactory)1 ArtifactSigner (tech.pegasys.web3signer.signing.ArtifactSigner)1 BlsArtifactSigner (tech.pegasys.web3signer.signing.BlsArtifactSigner)1 BlsKeystoreBulkLoader (tech.pegasys.web3signer.signing.BlsKeystoreBulkLoader)1 DefaultArtifactSignerProvider (tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider)1 SignerLoader (tech.pegasys.web3signer.signing.config.SignerLoader)1 AbstractArtifactSignerFactory (tech.pegasys.web3signer.signing.config.metadata.AbstractArtifactSignerFactory)1 BlsArtifactSignerFactory (tech.pegasys.web3signer.signing.config.metadata.BlsArtifactSignerFactory)1 InterlockKeyProvider (tech.pegasys.web3signer.signing.config.metadata.interlock.InterlockKeyProvider)1 YamlSignerParser (tech.pegasys.web3signer.signing.config.metadata.parser.YamlSignerParser)1 YubiHsmOpaqueDataProvider (tech.pegasys.web3signer.signing.config.metadata.yubihsm.YubiHsmOpaqueDataProvider)1