Search in sources :

Example 1 with SignerIdentifier

use of tech.pegasys.signers.secp256k1.api.SignerIdentifier in project signers by ConsenSys.

the class MultiKeySignerProviderTest method signerIsNotReturnedIfFileContainsPublicKeyDifferentToRequest.

@Test
void signerIsNotReturnedIfFileContainsPublicKeyDifferentToRequest() throws URISyntaxException {
    final FileBasedSigningMetadataFile capitalisedMetadata = new FileBasedSigningMetadataFile(LOWERCASE_ADDRESS + ".toml", new FileSignerConfig(Path.of(Resources.getResource("metadata-toml-configs").toURI()).resolve(KEY_FILENAME), Path.of(Resources.getResource("metadata-toml-configs").toURI()).resolve(PASSWORD_FILENAME)));
    when(loader.loadMetadata(any())).thenReturn(Optional.of(capitalisedMetadata));
    final PublicKeySignerIdentifier signerIdentifier = new PublicKeySignerIdentifier(EthPublicKeyUtils.createPublicKey(Bytes.fromHexString("A".repeat(128))));
    final Optional<Signer> signer = signerFactory.getSigner(signerIdentifier);
    assertThat(signer).isEmpty();
}
Also used : Signer(tech.pegasys.signers.secp256k1.api.Signer) FileSignerConfig(tech.pegasys.signers.secp256k1.filebased.FileSignerConfig) FileBasedSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile) PublicKeySignerIdentifier(tech.pegasys.signers.secp256k1.common.PublicKeySignerIdentifier) Test(org.junit.jupiter.api.Test)

Example 2 with SignerIdentifier

use of tech.pegasys.signers.secp256k1.api.SignerIdentifier in project signers by ConsenSys.

the class MultiKeySignerProviderTest method getSignerForAvailableMetadataReturnsSigner.

@Test
void getSignerForAvailableMetadataReturnsSigner() {
    when(loader.loadMetadata(any())).thenReturn(Optional.of(metadataFile));
    final PublicKeySignerIdentifier signerIdentifier = new PublicKeySignerIdentifier(EthPublicKeyUtils.createPublicKey(Bytes.fromHexString(LOWER_CASE_PUBLIC_KEY)));
    final Optional<Signer> signer = signerFactory.getSigner(signerIdentifier);
    assertThat(signer).isNotEmpty();
    assertThat(EthPublicKeyUtils.toHexString(signer.get().getPublicKey())).isEqualTo("0x" + LOWER_CASE_PUBLIC_KEY);
    final ArgumentCaptor<SignerIdentifier> captor = ArgumentCaptor.forClass(PublicKeySignerIdentifier.class);
    verify(publicKeyFileSelector).getConfigFilesFilter(captor.capture());
    assertThat(captor.getValue().toStringIdentifier()).isEqualTo(LOWER_CASE_PUBLIC_KEY);
}
Also used : Signer(tech.pegasys.signers.secp256k1.api.Signer) PublicKeySignerIdentifier(tech.pegasys.signers.secp256k1.common.PublicKeySignerIdentifier) SignerIdentifier(tech.pegasys.signers.secp256k1.api.SignerIdentifier) PublicKeySignerIdentifier(tech.pegasys.signers.secp256k1.common.PublicKeySignerIdentifier) Test(org.junit.jupiter.api.Test)

Example 3 with SignerIdentifier

use of tech.pegasys.signers.secp256k1.api.SignerIdentifier in project signers by ConsenSys.

the class MultiKeySignerProvider method create.

public static MultiKeySignerProvider create(final Path rootDir, final FileSelector<Void> allConfigFilesSelector, final FileSelector<SignerIdentifier> signerIdentifierConfigFileSelector) {
    final SigningMetadataTomlConfigLoader signingMetadataTomlConfigLoader = new SigningMetadataTomlConfigLoader(rootDir);
    final HashicorpSignerFactory hashicorpSignerFactory = new HashicorpSignerFactory(Vertx.vertx());
    return new MultiKeySignerProvider(signingMetadataTomlConfigLoader, hashicorpSignerFactory, allConfigFilesSelector, signerIdentifierConfigFileSelector);
}
Also used : HashicorpSignerFactory(tech.pegasys.signers.secp256k1.hashicorp.HashicorpSignerFactory)

Aggregations

Test (org.junit.jupiter.api.Test)2 Signer (tech.pegasys.signers.secp256k1.api.Signer)2 PublicKeySignerIdentifier (tech.pegasys.signers.secp256k1.common.PublicKeySignerIdentifier)2 SignerIdentifier (tech.pegasys.signers.secp256k1.api.SignerIdentifier)1 FileSignerConfig (tech.pegasys.signers.secp256k1.filebased.FileSignerConfig)1 HashicorpSignerFactory (tech.pegasys.signers.secp256k1.hashicorp.HashicorpSignerFactory)1 FileBasedSigningMetadataFile (tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile)1