use of org.hyperledger.besu.plugin.services.metrics.OperationTimer.TimingContext in project web3signer by ConsenSys.
the class BlsArtifactSignerFactory method create.
@Override
public ArtifactSigner create(final AwsKeySigningMetadata awsKeySigningMetadata) {
try (final TimingContext ignored = privateKeyRetrievalTimer.labels("aws").startTimer()) {
final Bytes32 keyBytes = Bytes32.wrap(extractBytesFromSecretsManager(awsKeySigningMetadata));
final BLSKeyPair keyPair = new BLSKeyPair(BLSSecretKey.fromBytes(keyBytes));
return signerFactory.apply(new BlsArtifactSignerArgs(keyPair, SignerOrigin.AWS));
}
}
use of org.hyperledger.besu.plugin.services.metrics.OperationTimer.TimingContext in project web3signer by ConsenSys.
the class BlsArtifactSignerFactory method create.
@Override
public ArtifactSigner create(final HashicorpSigningMetadata hashicorpMetadata) {
try (final TimingContext ignored = privateKeyRetrievalTimer.labels("hashicorp").startTimer()) {
final Bytes privateKeyBytes = extractBytesFromVault(hashicorpMetadata);
final BLSKeyPair keyPair = new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.wrap(privateKeyBytes)));
return signerFactory.apply(new BlsArtifactSignerArgs(keyPair, SignerOrigin.HASHICORP));
}
}
use of org.hyperledger.besu.plugin.services.metrics.OperationTimer.TimingContext in project web3signer by ConsenSys.
the class Eth1SignForIdentifierHandler method handle.
@Override
public void handle(final RoutingContext routingContext) {
try (final TimingContext ignored = metrics.getSigningTimer().startTimer()) {
final RequestParameters params = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
final String identifier = params.pathParameter("identifier").toString();
final Bytes data;
try {
data = getDataToSign(params);
} catch (final IllegalArgumentException e) {
metrics.getMalformedRequestCounter().inc();
LOG.debug("Invalid signing request", e);
routingContext.fail(400);
return;
}
signerForIdentifier.sign(normaliseIdentifier(identifier), data).ifPresentOrElse(signature -> {
respondWithSignature(routingContext, signature);
}, () -> {
LOG.trace("Identifier not found {}", identifier);
metrics.getMissingSignerCounter().inc();
routingContext.fail(404);
});
}
}
use of org.hyperledger.besu.plugin.services.metrics.OperationTimer.TimingContext in project web3signer by ConsenSys.
the class Eth2SignForIdentifierHandler method handle.
@Override
public void handle(final RoutingContext routingContext) {
try (final TimingContext ignored = httpMetrics.getSigningTimer().startTimer()) {
LOG.trace("{} || {}", routingContext.normalizedPath(), routingContext.getBody());
final RequestParameters params = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
final String identifier = params.pathParameter("identifier").toString();
final Eth2SigningRequestBody eth2SigningRequestBody;
try {
eth2SigningRequestBody = getSigningRequest(params);
} catch (final IllegalArgumentException | JsonProcessingException e) {
handleInvalidRequest(routingContext, e);
return;
}
final Bytes signingRoot = computeSigningRoot(eth2SigningRequestBody);
if (eth2SigningRequestBody.getSigningRoot() != null) {
checkArgument(eth2SigningRequestBody.getSigningRoot().equals(signingRoot), "Signing root %s must match signing computed signing root %s from data", eth2SigningRequestBody.getSigningRoot(), signingRoot);
}
final String normalisedIdentifier = normaliseIdentifier(identifier);
if (slashingProtection.isPresent()) {
handleSigning(routingContext, signingRoot, normalisedIdentifier, signature -> signWithSlashingProtection(routingContext, identifier, eth2SigningRequestBody, signingRoot, signature));
} else {
handleSigning(routingContext, signingRoot, normalisedIdentifier, signature -> respondWithSignature(routingContext, signature));
}
}
}
use of org.hyperledger.besu.plugin.services.metrics.OperationTimer.TimingContext in project web3signer by ConsenSys.
the class BlsArtifactSignerFactory method create.
@Override
public ArtifactSigner create(final InterlockSigningMetadata interlockSigningMetadata) {
try (final TimingContext ignored = privateKeyRetrievalTimer.labels("interlock").startTimer()) {
final Bytes32 keyBytes = Bytes32.wrap(extractBytesFromInterlock(interlockSigningMetadata));
final BLSKeyPair keyPair = new BLSKeyPair(BLSSecretKey.fromBytes(keyBytes));
return signerFactory.apply(new BlsArtifactSignerArgs(keyPair, SignerOrigin.INTERLOCK));
}
}
Aggregations