Added importBLSKeyShare

parent d1b8fd5c
...@@ -34,6 +34,7 @@ public: ...@@ -34,6 +34,7 @@ public:
virtual bool isEqual(const std::string &str1, const std::string &str2); virtual bool isEqual(const std::string &str1, const std::string &str2);
virtual Json::Value buildObject(const std::string &name, int age); virtual Json::Value buildObject(const std::string &name, int age);
virtual std::string methodWithoutParameters(); virtual std::string methodWithoutParameters();
virtual bool importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t);
}; };
SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector, SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
...@@ -58,6 +59,11 @@ bool SGXWalletServer::isEqual(const string &str1, const string &str2) { ...@@ -58,6 +59,11 @@ bool SGXWalletServer::isEqual(const string &str1, const string &str2) {
return str1 == 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) { Json::Value SGXWalletServer::buildObject(const string &name, int age) {
Json::Value result; Json::Value result;
result["name"] = name; result["name"] = name;
...@@ -65,6 +71,9 @@ Json::Value SGXWalletServer::buildObject(const string &name, int age) { ...@@ -65,6 +71,9 @@ Json::Value SGXWalletServer::buildObject(const string &name, int age) {
return result; return result;
} }
string SGXWalletServer::methodWithoutParameters() { return "Test"; } string SGXWalletServer::methodWithoutParameters() { return "Test"; }
int init_server() { int init_server() {
......
...@@ -12,6 +12,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -12,6 +12,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
public: public:
AbstractStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractStubServer>(conn, type) 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("sayHello", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "name",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::sayHelloI); 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->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); this->bindAndAddMethod(jsonrpc::Procedure("addNumbers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::addNumbersI);
...@@ -21,6 +22,10 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -21,6 +22,10 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("methodWithoutParameters", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractStubServer::methodWithoutParametersI); this->bindAndAddMethod(jsonrpc::Procedure("methodWithoutParameters", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractStubServer::methodWithoutParametersI);
} }
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());
}
inline virtual void sayHelloI(const Json::Value &request, Json::Value &response) inline virtual void sayHelloI(const Json::Value &request, Json::Value &response)
{ {
response = this->sayHello(request["name"].asString()); response = this->sayHello(request["name"].asString());
...@@ -51,6 +56,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -51,6 +56,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
(void)request; (void)request;
response = this->methodWithoutParameters(); response = this->methodWithoutParameters();
} }
virtual bool importBLSKeyShare(const std::string& hexKeyShare, int index, int n, const std::string& name, int t) = 0;
virtual std::string sayHello(const std::string& name) = 0; virtual std::string sayHello(const std::string& name) = 0;
virtual void notifyServer() = 0; virtual void notifyServer() = 0;
virtual int addNumbers(int param1, int param2) = 0; virtual int addNumbers(int param1, int param2) = 0;
......
[ [
{
"name": "importBLSKeyShare",
"params": {
"name": "Peter",
"n": 2,
"t": 2,
"index" : 2,
"hexKeyShare": "1122334455"
},
"returns": false
},
{ {
"name": "sayHello", "name": "sayHello",
"params": { "params": {
...@@ -45,7 +58,7 @@ ...@@ -45,7 +58,7 @@
} }
}, },
{ {
"name" : "methodWithoutParameters", "name": "methodWithoutParameters",
"returns": "String" "returns": "String"
} }
] ]
\ No newline at end of file
...@@ -12,6 +12,20 @@ class StubClient : public jsonrpc::Client ...@@ -12,6 +12,20 @@ class StubClient : public jsonrpc::Client
public: public:
StubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} 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)
{
Json::Value p;
p["hexKeyShare"] = hexKeyShare;
p["index"] = index;
p["n"] = n;
p["name"] = name;
p["t"] = t;
Json::Value result = this->CallMethod("importBLSKeyShare",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string sayHello(const std::string& name) throw (jsonrpc::JsonRpcException) std::string sayHello(const std::string& name) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
......
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