Search in sources :

Example 6 with BlsArtifactSigner

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

the class YamlSignerParserTest method azureSecretMetadataInfoReturnsMetadata.

@Test
void azureSecretMetadataInfoReturnsMetadata() throws IOException {
    final BlsArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.AZURE);
    when(blsArtifactSignerFactory.create(any(AzureSecretSigningMetadata.class))).thenReturn(artifactSigner);
    final Map<String, String> azureMetaDataMap = new HashMap<>();
    azureMetaDataMap.put("type", "azure-secret");
    azureMetaDataMap.put("clientId", "sample-client-id");
    azureMetaDataMap.put("clientSecret", "sample-client-secret");
    azureMetaDataMap.put("tenantId", "sample-tenant-id");
    azureMetaDataMap.put("vaultName", "sample-vault-name");
    azureMetaDataMap.put("secretName", "TEST-KEY");
    azureMetaDataMap.put("keyType", "BLS");
    final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(azureMetaDataMap);
    final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
    assertThat(result).containsOnly(artifactSigner);
    verify(blsArtifactSignerFactory).create(hasCorrectAzureMetadataArguments(AzureAuthenticationMode.CLIENT_SECRET));
}
Also used : BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) ArtifactSigner(tech.pegasys.web3signer.signing.ArtifactSigner) HashMap(java.util.HashMap) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) AzureSecretSigningMetadata(tech.pegasys.web3signer.signing.config.metadata.AzureSecretSigningMetadata) BLSKeyPair(tech.pegasys.teku.bls.BLSKeyPair) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with BlsArtifactSigner

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

the class YamlSignerParserTest method unencryptedMetaDataInfoWithPrivateKeyReturnsMetadata.

@Test
void unencryptedMetaDataInfoWithPrivateKeyReturnsMetadata() throws IOException {
    final ArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.FILE_RAW);
    when(blsArtifactSignerFactory.create(any(FileRawSigningMetadata.class))).thenReturn(artifactSigner);
    final Map<String, String> unencryptedKeyMetadataFile = new HashMap<>();
    unencryptedKeyMetadataFile.put("type", "file-raw");
    unencryptedKeyMetadataFile.put("privateKey", PRIVATE_KEY);
    final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(unencryptedKeyMetadataFile);
    final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
    assertThat(result).containsOnly(artifactSigner);
    verify(blsArtifactSignerFactory).create(hasPrivateKey(PRIVATE_KEY));
}
Also used : BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) ArtifactSigner(tech.pegasys.web3signer.signing.ArtifactSigner) HashMap(java.util.HashMap) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) BLSKeyPair(tech.pegasys.teku.bls.BLSKeyPair) FileRawSigningMetadata(tech.pegasys.web3signer.signing.config.metadata.FileRawSigningMetadata) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with BlsArtifactSigner

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

the class YamlSignerParserTest method keyStoreMetaDataInfoReturnsMetadata.

@Test
void keyStoreMetaDataInfoReturnsMetadata() throws IOException {
    final BlsArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.FILE_KEYSTORE);
    when(blsArtifactSignerFactory.create(any(FileKeyStoreMetadata.class))).thenReturn(artifactSigner);
    final Path keystoreFile = configDir.resolve("keystore.json");
    final Path passwordFile = configDir.resolve("keystore.password");
    final Map<String, String> keystoreMetadataFile = new HashMap<>();
    keystoreMetadataFile.put("type", "file-keystore");
    keystoreMetadataFile.put("keystoreFile", keystoreFile.toString());
    keystoreMetadataFile.put("keystorePasswordFile", passwordFile.toString());
    final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(keystoreMetadataFile);
    final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
    assertThat(result).containsOnly(artifactSigner);
    verify(blsArtifactSignerFactory).create(hasKeystoreAndPasswordFile(keystoreFile, passwordFile));
}
Also used : Path(java.nio.file.Path) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) ArtifactSigner(tech.pegasys.web3signer.signing.ArtifactSigner) HashMap(java.util.HashMap) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) BLSKeyPair(tech.pegasys.teku.bls.BLSKeyPair) FileKeyStoreMetadata(tech.pegasys.web3signer.signing.config.metadata.FileKeyStoreMetadata) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with BlsArtifactSigner

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

the class BlsArtifactSignerFactoryTest method setup.

@BeforeEach
void setup() throws IOException {
    vertx = Vertx.vertx();
    interlockKeyProvider = new InterlockKeyProvider(vertx);
    yubiHsmOpaqueDataProvider = new YubiHsmOpaqueDataProvider();
    awsSecretsManagerProvider = new AwsSecretsManagerProvider(100);
    artifactSignerFactory = new BlsArtifactSignerFactory(configDir, new NoOpMetricsSystem(), new HashicorpConnectionFactory(vertx), interlockKeyProvider, yubiHsmOpaqueDataProvider, awsSecretsManagerProvider, (args) -> new BlsArtifactSigner(args.getKeyPair(), args.getOrigin()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Cipher(tech.pegasys.signers.bls.keystore.model.Cipher) KeyStoreLoader(tech.pegasys.signers.bls.keystore.KeyStoreLoader) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bytes(org.apache.tuweni.bytes.Bytes) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) BLSKeyPair(tech.pegasys.teku.bls.BLSKeyPair) KeyType(tech.pegasys.web3signer.signing.KeyType) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BeforeAll(org.junit.jupiter.api.BeforeAll) CipherFunction(tech.pegasys.signers.bls.keystore.model.CipherFunction) YubiHsmOpaqueDataProvider(tech.pegasys.web3signer.signing.config.metadata.yubihsm.YubiHsmOpaqueDataProvider) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) InterlockKeyProvider(tech.pegasys.web3signer.signing.config.metadata.interlock.InterlockKeyProvider) AwsSecretsManagerProvider(tech.pegasys.signers.aws.AwsSecretsManagerProvider) Path(java.nio.file.Path) KeyStore(tech.pegasys.signers.bls.keystore.KeyStore) Files(java.nio.file.Files) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) HashicorpConnectionFactory(tech.pegasys.signers.hashicorp.HashicorpConnectionFactory) KeyStoreData(tech.pegasys.signers.bls.keystore.model.KeyStoreData) ArtifactSigner(tech.pegasys.web3signer.signing.ArtifactSigner) AssertionsForClassTypes.fail(org.assertj.core.api.AssertionsForClassTypes.fail) SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) TempDir(org.junit.jupiter.api.io.TempDir) Bytes48(org.apache.tuweni.bytes.Bytes48) BLSTestUtil(tech.pegasys.web3signer.BLSTestUtil) YubiHsmOpaqueDataProvider(tech.pegasys.web3signer.signing.config.metadata.yubihsm.YubiHsmOpaqueDataProvider) HashicorpConnectionFactory(tech.pegasys.signers.hashicorp.HashicorpConnectionFactory) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) BlsArtifactSigner(tech.pegasys.web3signer.signing.BlsArtifactSigner) InterlockKeyProvider(tech.pegasys.web3signer.signing.config.metadata.interlock.InterlockKeyProvider) AwsSecretsManagerProvider(tech.pegasys.signers.aws.AwsSecretsManagerProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BlsArtifactSigner (tech.pegasys.web3signer.signing.BlsArtifactSigner)9 BLSKeyPair (tech.pegasys.teku.bls.BLSKeyPair)8 ArtifactSigner (tech.pegasys.web3signer.signing.ArtifactSigner)8 HashMap (java.util.HashMap)6 Test (org.junit.jupiter.api.Test)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Bytes (org.apache.tuweni.bytes.Bytes)3 AzureSecretSigningMetadata (tech.pegasys.web3signer.signing.config.metadata.AzureSecretSigningMetadata)3 Path (java.nio.file.Path)2 AwsSecretsManagerProvider (tech.pegasys.signers.aws.AwsSecretsManagerProvider)2 HashicorpConnectionFactory (tech.pegasys.signers.hashicorp.HashicorpConnectionFactory)2 FileRawSigningMetadata (tech.pegasys.web3signer.signing.config.metadata.FileRawSigningMetadata)2 InterlockKeyProvider (tech.pegasys.web3signer.signing.config.metadata.interlock.InterlockKeyProvider)2 YubiHsmOpaqueDataProvider (tech.pegasys.web3signer.signing.config.metadata.yubihsm.YubiHsmOpaqueDataProvider)2 Vertx (io.vertx.core.Vertx)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Bytes48 (org.apache.tuweni.bytes.Bytes48)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1