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();
}
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);
}
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);
}
Aggregations