Search in sources :

Example 1 with BlsArtifactSignature

use of tech.pegasys.web3signer.core.signing.BlsArtifactSignature in project web3signer by ConsenSys.

the class FilecoinVerifyTest method verifiesBlsSignatureWasSignedWithKey.

@Test
void verifiesBlsSignatureWasSignedWithKey() {
    final Bytes message = Bytes.fromBase64String(DATA);
    final BlsArtifactSignature artifactSignature = new BlsArtifactSignature(BLSSignature.fromBytesCompressed(Bytes.fromBase64String(BLS_SIGNATURE)));
    final FilecoinAddress filecoinAddress = FilecoinAddress.fromString("t3sjhgtrk5fdio52k5lzanh7yy4mj4rqbiowd6odddzprrxejgbjbl2irr3gmpbf7epigf45oy7asljj3v3lva");
    assertThat(FilecoinVerify.verify(filecoinAddress, message, artifactSignature)).isTrue();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) BlsArtifactSignature(tech.pegasys.web3signer.core.signing.BlsArtifactSignature) Test(org.junit.jupiter.api.Test)

Example 2 with BlsArtifactSignature

use of tech.pegasys.web3signer.core.signing.BlsArtifactSignature in project web3signer by ConsenSys.

the class Eth2Runner method registerEth2Routes.

private void registerEth2Routes(final RouterBuilder routerBuilder, final ArtifactSignerProvider blsSignerProvider, final LogErrorHandler errorHandler, final MetricsSystem metricsSystem, final Optional<SlashingProtection> slashingProtection) {
    final ObjectMapper objectMapper = SigningObjectMapperFactory.createObjectMapper();
    // security handler for keymanager endpoints
    routerBuilder.securityHandler("bearerAuth", context -> {
        // TODO Auth token security logic
        final boolean authorized = true;
        if (authorized) {
            context.next();
        } else {
            context.response().setStatusCode(401).end("{ message: \"permission denied\" }");
        }
    });
    addPublicKeysListHandler(routerBuilder, blsSignerProvider, ETH2_LIST.name(), errorHandler);
    final SignerForIdentifier<BlsArtifactSignature> blsSigner = new SignerForIdentifier<>(blsSignerProvider, this::formatBlsSignature, BLS);
    routerBuilder.operation(ETH2_SIGN.name()).handler(new BlockingHandlerDecorator(new Eth2SignForIdentifierHandler(blsSigner, new HttpApiMetrics(metricsSystem, BLS), new SlashingProtectionMetrics(metricsSystem), slashingProtection, objectMapper, eth2Spec), false)).failureHandler(errorHandler);
    addReloadHandler(routerBuilder, blsSignerProvider, RELOAD.name(), errorHandler);
    if (isKeyManagerApiEnabled) {
        routerBuilder.operation(KEYMANAGER_LIST.name()).handler(new BlockingHandlerDecorator(new ListKeystoresHandler(blsSignerProvider, objectMapper), false)).failureHandler(errorHandler);
        routerBuilder.operation(KEYMANAGER_IMPORT.name()).handler(new BlockingHandlerDecorator(new ImportKeystoresHandler(objectMapper, config.getKeyConfigPath(), slashingProtection, blsSignerProvider), false)).failureHandler(errorHandler);
        routerBuilder.operation(KEYMANAGER_DELETE.name()).handler(new BlockingHandlerDecorator(new DeleteKeystoresHandler(objectMapper, new KeystoreFileManager(config.getKeyConfigPath()), slashingProtection, blsSignerProvider), false)).failureHandler(errorHandler);
    }
}
Also used : KeystoreFileManager(tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.KeystoreFileManager) ListKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.list.ListKeystoresHandler) DeleteKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.DeleteKeystoresHandler) SlashingProtectionMetrics(tech.pegasys.web3signer.core.metrics.SlashingProtectionMetrics) SignerForIdentifier(tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier) BlockingHandlerDecorator(io.vertx.ext.web.impl.BlockingHandlerDecorator) BlsArtifactSignature(tech.pegasys.web3signer.core.signing.BlsArtifactSignature) ImportKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.imports.ImportKeystoresHandler) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Eth2SignForIdentifierHandler(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SignForIdentifierHandler) HttpApiMetrics(tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics)

Aggregations

BlsArtifactSignature (tech.pegasys.web3signer.core.signing.BlsArtifactSignature)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BlockingHandlerDecorator (io.vertx.ext.web.impl.BlockingHandlerDecorator)1 Bytes (org.apache.tuweni.bytes.Bytes)1 Test (org.junit.jupiter.api.Test)1 SlashingProtectionMetrics (tech.pegasys.web3signer.core.metrics.SlashingProtectionMetrics)1 DeleteKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.DeleteKeystoresHandler)1 KeystoreFileManager (tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.KeystoreFileManager)1 ImportKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.imports.ImportKeystoresHandler)1 ListKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.list.ListKeystoresHandler)1 SignerForIdentifier (tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier)1 Eth2SignForIdentifierHandler (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SignForIdentifierHandler)1 HttpApiMetrics (tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics)1