Unverified Commit 16756736 authored by kladko's avatar kladko

SKALE-2879-faster-ecdsa

parent e37be46c
......@@ -175,11 +175,8 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
string pubKeyStr = "";
shared_ptr<SGXException> exception = NULL;
if (!hex2carray(encryptedKeyHex, &decLen, encryptedKey.data())) {
exception = make_shared<SGXException>(INVALID_HEX, "Invalid encryptedKeyHex");
goto clean;
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
}
status = trustedEcdsaSignAES(eid, &errStatus,
......@@ -188,14 +185,12 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
signatureS.data(), &signatureV, base);
if (errStatus != 0) {
exception = make_shared<SGXException>(666, errMsg.data());
goto clean;
throw SGXException(666, errMsg.data());
}
if (status != SGX_SUCCESS) {
spdlog::error("failed to sign {}", status);
exception = make_shared<SGXException>(666, "failed to sign");
goto clean;
throw SGXException(666, "failed to sign");
}
signatureVector.at(0) = to_string(signatureV);
if (base == 16) {
......@@ -211,14 +206,8 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
pubKeyStr = getECDSAPubKey(encryptedKeyHex);
if (!verifyECDSASig(pubKeyStr, hashHex, signatureR.data(), signatureS.data(), base)) {
exception = make_shared<SGXException>(667, "ECDSA did not verify");
goto clean;
throw SGXException(667, "ECDSA did not verify");
}
clean:
if (exception)
throw *exception;
return signatureVector;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment