use of com.radixdlt.api.core.openapitools.model.PublicKeyNotSupportedError in project radixdlt by radixdlt.
the class KeySignHandler method handleRequest.
@Override
public KeySignResponse handleRequest(KeySignRequest request) throws CoreApiException {
coreModelMapper.verifyNetwork(request.getNetworkIdentifier());
var pubKey = coreModelMapper.ecPublicKey(request.getPublicKey());
if (!self.equals(pubKey)) {
throw CoreApiException.notSupported(new PublicKeyNotSupportedError().unsupportedPublicKey(request.getPublicKey()).type(PublicKeyNotSupportedError.class.getSimpleName()));
}
// Verify this is a valid transaction and not anything more malicious
var bytes = coreModelMapper.bytes(request.getUnsignedTransaction());
var txn = Txn.create(bytes);
try {
radixEngineProvider.get().getParser().parse(txn);
} catch (TxnParseException e) {
throw coreModelMapper.parseException(e);
}
var builder = TxLowLevelBuilder.newBuilder(bytes);
var hash = builder.hashToSign();
var signature = this.hashSigner.sign(hash);
var signedTransaction = builder.sig(signature).blob();
return new KeySignResponse().signedTransaction(Bytes.toHexString(signedTransaction));
}
Aggregations