SKALE-3951 add req methods

parent 877c416a
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file BLSSignReqMessage.cpp
@author Stan Kladko
@date 2021
*/
#include "BLSSignReqMessage.h"
#include "SGXWalletServer.hpp"
Json::Value BLSSignReqMessage::process() {
auto keyName = getStringRapid("keyShareName");
auto hash = getStringRapid("messageHash");
auto t = getUint64Rapid("t");
auto n = getUint64Rapid("n");
auto result = SGXWalletServer::blsSignMessageHashImpl(keyName, hash, t, n);
result["type"] = ZMQMessage::BLS_SIGN_RSP;
return result;
}
\ No newline at end of file
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file BLSReqSignMessage.h
@author Stan Kladko
@date 2020
*/
#ifndef SGXWALLET_BLSSIGNREQMSG_H
#define SGXWALLET_BLSSIGNREQMSG_H
#include "ZMQMessage.h"
class BLSSignReqMessage : public ZMQMessage {
public:
BLSSignReqMessage(shared_ptr<rapidjson::Document>& _d) : ZMQMessage(_d) {};
virtual Json::Value process();
};
#endif //SGXWALLET_BLSSIGNREQMSG_H
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ECDSASignReqMessage.cpp
@author Stan Kladko
@date 2020
*/
#include "SGXWalletServer.hpp"
#include "ECDSASignReqMessage.h"
Json::Value ECDSASignReqMessage::process() {
auto base = getUint64Rapid("base");
auto keyName = getStringRapid("keyName");
auto hash = getStringRapid("messageHash");
auto result = SGXWalletServer::ecdsaSignMessageHashImpl(base, keyName, hash);
result["type"] = ZMQMessage::ECDSA_SIGN_RSP;
return result;
}
\ No newline at end of file
/*
Copyright (C) 2018- SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ECDSAReqSignMessage.h
@author Stan Kladko
@date 2020
*/
#ifndef SGXWALLET_ECDSASIGNREQMESSAGE_H
#define SGXWALLET_ECDSASIGNREQMESSAGE_H
#include "ZMQMessage.h"
class ECDSASignReqMessage : public ZMQMessage {
public:
ECDSASignReqMessage(shared_ptr <rapidjson::Document> &_d) : ZMQMessage(_d) {};
virtual Json::Value process();
};
#endif //SGXWALLET_ECDSASIGNREQMESSAGE_H
......@@ -33,9 +33,8 @@
#include "sgxwallet_common.h"
#include "common.h"
#include "BLSCrypto.h"
#include "BLSSignReqMessage.h"
#include "ReqMessage.h"
#include "BLSSignRspMessage.h"
#include "ECDSASignReqMessage.h"
#include "ECDSASignRspMessage.h"
#include "ZMQClient.h"
......
......@@ -29,9 +29,8 @@
#include "ZMQClient.h"
#include "SGXWalletServer.hpp"
#include "BLSSignReqMessage.h"
#include "ReqMessage.h"
#include "BLSSignRspMessage.h"
#include "ECDSASignReqMessage.h"
#include "ECDSASignRspMessage.h"
#include "ZMQMessage.h"
......@@ -44,6 +43,14 @@ uint64_t ZMQMessage::getUint64Rapid(const char *_name) {
return a.GetUint64();
};
Json::Value ZMQMessage::getJsonArray(const char *_name) {
CHECK_STATE(_name);
CHECK_STATE(d->HasMember(_name));
const rapidjson::Value &a = (*d)[_name];
CHECK_STATE(a.IsArray());
return a.GetUint64();
}
string ZMQMessage::getStringRapid(const char *_name) {
CHECK_STATE(_name);
CHECK_STATE(d->HasMember(_name));
......@@ -155,55 +162,55 @@ shared_ptr <ZMQMessage> ZMQMessage::buildRequest(string &_type, shared_ptr <rapi
ret = make_shared<ECDSASignReqMessage>(_d);
break;
case ENUM_IMPORT_BLS_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<importBLSReqMessage>(_d);
break;
case ENUM_IMPORT_ECDSA_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<importECDSAReqMessage>(_d);
break;
case ENUM_GENERATE_ECDSA_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<generateECDSAReqMessage>(_d);
break;
case ENUM_GET_PUBLIC_ECDSA_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getPublicECDSAReqMessage>(_d);
break;
case ENUM_GENERATE_DKG_POLY_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<generateDKGPolyReqMessage>(_d);
break;
case ENUM_GET_VV_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getVerificationVectorReqMessage>(_d);
break;
case ENUM_GET_SECRET_SHARE_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getSecretShareReqMessage>(_d);
break;
case ENUM_DKG_VERIFY_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<dkgVerificationReqMessage>(_d);
break;
case ENUM_CREATE_BLS_PRIVATE_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<createBLSPrivateKeyReqMessage>(_d);
break;
case ENUM_GET_BLS_PUBLIC_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getBLSPublicReqMessage>(_d);
break;
case ENUM_GET_ALL_BLS_PUBLIC_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getAllBLSPublicKeysReqMessage>(_d);
break;
case ENUM_COMPLAINT_RESPONSE_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<complaintResponseReqMessage>(_d);
break;
case ENUM_MULT_G2_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<multG2ReqMessage>(_d);
break;
case ENUM_IS_POLY_EXISTS_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<isPolyExistsReqMessage>(_d);
break;
case ENUM_GET_SERVER_STATUS_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getServerStatusReqMessage>(_d);
break;
case ENUM_GET_SERVER_VERSION_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<getServerVersionReqMessage>(_d);
break;
case ENUM_DELETE_BLS_KEY_REQ:
ret = make_shared<ECDSASignReqMessage>(_d);
ret = make_shared<deleteBLSKeyReqMessage>(_d);
break;
default:
break;
......
......@@ -49,7 +49,6 @@ class ZMQMessage {
shared_ptr<rapidjson::Document> d;
static cache::lru_cache<string, pair<EVP_PKEY*, X509*>> verifiedCerts;
public:
......@@ -111,6 +110,8 @@ public:
uint64_t getUint64Rapid(const char *_name);
Json::Value getJsonArray(const char *_name);
uint64_t getStatus() {
return getUint64Rapid("status");
}
......
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