Added function stubs

parent 1f00f276
......@@ -34,7 +34,15 @@ public:
virtual bool isEqual(const std::string &str1, const std::string &str2);
virtual Json::Value buildObject(const std::string &name, int age);
virtual std::string methodWithoutParameters();
virtual bool importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t);
virtual std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t);
virtual std::string blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash);
virtual std::string importECDSAKey(const std::string& key, const std::string& keyName);
virtual std::string generateECDSAKey(const std::string& keyName);
virtual std::string ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash);
};
SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
......@@ -59,9 +67,9 @@ bool SGXWalletServer::isEqual(const string &str1, const string &str2) {
return str1 == str2;
}
bool SGXWalletServer::importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t) {
return false;
}
Json::Value SGXWalletServer::buildObject(const string &name, int age) {
......@@ -84,3 +92,20 @@ int init_server() {
return 0;
}
std::string SGXWalletServer::importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) {
return "";
}
std::string SGXWalletServer::blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) {
return "";
}
std::string SGXWalletServer::importECDSAKey(const std::string& key, const std::string& keyName) {
return "";
}
std::string SGXWalletServer::generateECDSAKey(const std::string& keyName) {
return "";
}
std::string SGXWalletServer::ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) {
return "";
}
......@@ -12,7 +12,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
public:
AbstractStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractStubServer>(conn, type)
{
this->bindAndAddMethod(jsonrpc::Procedure("importBLSKeyShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_BOOLEAN, "hexKeyShare",jsonrpc::JSON_STRING,"index",jsonrpc::JSON_INTEGER,"n",jsonrpc::JSON_INTEGER,"name",jsonrpc::JSON_STRING,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::importBLSKeyShareI);
this->bindAndAddMethod(jsonrpc::Procedure("importBLSKeyShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "index",jsonrpc::JSON_INTEGER,"keyShare",jsonrpc::JSON_STRING,"keyShareName",jsonrpc::JSON_STRING,"n",jsonrpc::JSON_INTEGER,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::importBLSKeyShareI);
this->bindAndAddMethod(jsonrpc::Procedure("blsSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "keyShareName",jsonrpc::JSON_STRING,"messageHash",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::blsSignMessageHashI);
this->bindAndAddMethod(jsonrpc::Procedure("importECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "key",jsonrpc::JSON_STRING,"keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::importECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("generateECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::generateECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("ecdsaSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "keyShareName",jsonrpc::JSON_STRING,"messageHash",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::ecdsaSignMessageHashI);
this->bindAndAddMethod(jsonrpc::Procedure("sayHello", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "name",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::sayHelloI);
this->bindAndAddNotification(jsonrpc::Procedure("notifyServer", jsonrpc::PARAMS_BY_NAME, NULL), &AbstractStubServer::notifyServerI);
this->bindAndAddMethod(jsonrpc::Procedure("addNumbers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::addNumbersI);
......@@ -24,7 +28,23 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
inline virtual void importBLSKeyShareI(const Json::Value &request, Json::Value &response)
{
response = this->importBLSKeyShare(request["hexKeyShare"].asString(), request["index"].asInt(), request["n"].asInt(), request["name"].asString(), request["t"].asInt());
response = this->importBLSKeyShare(request["index"].asInt(), request["keyShare"].asString(), request["keyShareName"].asString(), request["n"].asInt(), request["t"].asInt());
}
inline virtual void blsSignMessageHashI(const Json::Value &request, Json::Value &response)
{
response = this->blsSignMessageHash(request["keyShareName"].asString(), request["messageHash"].asString());
}
inline virtual void importECDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->importECDSAKey(request["key"].asString(), request["keyName"].asString());
}
inline virtual void generateECDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->generateECDSAKey(request["keyName"].asString());
}
inline virtual void ecdsaSignMessageHashI(const Json::Value &request, Json::Value &response)
{
response = this->ecdsaSignMessageHash(request["keyShareName"].asString(), request["messageHash"].asString());
}
inline virtual void sayHelloI(const Json::Value &request, Json::Value &response)
{
......@@ -56,7 +76,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
(void)request;
response = this->methodWithoutParameters();
}
virtual bool importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t) = 0;
virtual std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) = 0;
virtual std::string blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0;
virtual std::string importECDSAKey(const std::string& key, const std::string& keyName) = 0;
virtual std::string generateECDSAKey(const std::string& keyName) = 0;
virtual std::string ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0;
virtual std::string sayHello(const std::string& name) = 0;
virtual void notifyServer() = 0;
virtual int addNumbers(int param1, int param2) = 0;
......
......@@ -2,13 +2,51 @@
{
"name": "importBLSKeyShare",
"params": {
"name": "Peter",
"keyShareName": "key1",
"n": 2,
"t": 2,
"index" : 2,
"hexKeyShare": "1122334455"
"keyShare": "1122334455"
},
"returns": false
"returns": "encryptedKeyShare"
},
{
"name": "blsSignMessageHash",
"params": {
"keyShareName": "key1",
"messageHash": "1122334455"
},
"returns": "blsSignatureShare"
},
{
"name": "importECDSAKey",
"params": {
"keyName": "key1",
"key": "1122334455"
},
"returns": "encryptedKey"
},
{
"name": "generateECDSAKey",
"params": {
"keyName": "key1"
},
"returns": "encryptedKey"
},
{
"name": "ecdsaSignMessageHash",
"params": {
"keyShareName": "key1",
"messageHash": "1122334455"
},
"returns": "ecdsaSignature"
},
......
......@@ -12,17 +12,60 @@ class StubClient : public jsonrpc::Client
public:
StubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {}
bool importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t) throw (jsonrpc::JsonRpcException)
std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["hexKeyShare"] = hexKeyShare;
p["index"] = index;
p["keyShare"] = keyShare;
p["keyShareName"] = keyShareName;
p["n"] = n;
p["name"] = name;
p["t"] = t;
Json::Value result = this->CallMethod("importBLSKeyShare",p);
if (result.isBool())
return result.asBool();
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["keyShareName"] = keyShareName;
p["messageHash"] = messageHash;
Json::Value result = this->CallMethod("blsSignMessageHash",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string importECDSAKey(const std::string& key, const std::string& keyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["key"] = key;
p["keyName"] = keyName;
Json::Value result = this->CallMethod("importECDSAKey",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string generateECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["keyName"] = keyName;
Json::Value result = this->CallMethod("generateECDSAKey",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["keyShareName"] = keyShareName;
p["messageHash"] = messageHash;
Json::Value result = this->CallMethod("ecdsaSignMessageHash",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
......
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