qFixed

parent c485fc72
...@@ -41,11 +41,11 @@ public: ...@@ -41,11 +41,11 @@ public:
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 std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t); virtual Json::Value 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 Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash);
virtual std::string importECDSAKey(const std::string& key, const std::string& keyName); virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName);
virtual std::string generateECDSAKey(const std::string& keyName); virtual Json::Value generateECDSAKey(const std::string& keyName);
virtual std::string ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash); virtual Json::Value ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash);
...@@ -100,18 +100,35 @@ int init_server() { ...@@ -100,18 +100,35 @@ int init_server() {
std::string SGXWalletServer::importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) { Json::Value SGXWalletServer::importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) {
return ""; Json::Value result;
result["name"] = 1;
result["year"] = 1;
return result;
} }
std::string SGXWalletServer::blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) { Json::Value SGXWalletServer::blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) {
return ""; Json::Value result;
result["name"] = 1;
result["year"] = 1;
return result;
} }
std::string SGXWalletServer::importECDSAKey(const std::string& key, const std::string& keyName) {
return ""; Json::Value SGXWalletServer::importECDSAKey(const std::string& key, const std::string& keyName) {
Json::Value result;
result["name"] = 1;
result["year"] = 1;
return result;
} }
std::string SGXWalletServer::generateECDSAKey(const std::string& keyName) {
return ""; Json::Value SGXWalletServer::generateECDSAKey(const std::string& keyName) {
Json::Value result;
result["name"] = 1;
result["year"] = 1;
return result;
} }
std::string SGXWalletServer::ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) { Json::Value SGXWalletServer::ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) {
return ""; Json::Value result;
result["name"] = 1;
result["year"] = 1;
return result;
} }
...@@ -12,11 +12,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -12,11 +12,11 @@ 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_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("importBLSKeyShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "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("blsSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "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("importECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "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("generateECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "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("ecdsaSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "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->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);
...@@ -76,11 +76,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -76,11 +76,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
(void)request; (void)request;
response = this->methodWithoutParameters(); response = this->methodWithoutParameters();
} }
virtual std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) = 0; virtual Json::Value 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 Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0;
virtual std::string importECDSAKey(const std::string& key, const std::string& keyName) = 0; virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName) = 0;
virtual std::string generateECDSAKey(const std::string& keyName) = 0; virtual Json::Value generateECDSAKey(const std::string& keyName) = 0;
virtual std::string ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0; virtual Json::Value ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 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;
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
"index" : 2, "index" : 2,
"keyShare": "1122334455" "keyShare": "1122334455"
}, },
"returns": "encryptedKeyShare" "returns": {
"status": 0,
"errorMessage": "12345",
"encryptedKeyShare": "12345"
}
}, },
{ {
...@@ -17,7 +21,12 @@ ...@@ -17,7 +21,12 @@
"keyShareName": "key1", "keyShareName": "key1",
"messageHash": "1122334455" "messageHash": "1122334455"
}, },
"returns": "blsSignatureShare" "returns": {
"status": 0,
"errorMessage": "12345",
"blsSignatureShare": "12345"
}
}, },
{ {
...@@ -26,7 +35,11 @@ ...@@ -26,7 +35,11 @@
"keyName": "key1", "keyName": "key1",
"key": "1122334455" "key": "1122334455"
}, },
"returns": "encryptedKey" "returns": {
"status": 0,
"errorMessage": "12345",
"encryptedKey": "12345"
}
}, },
...@@ -35,7 +48,11 @@ ...@@ -35,7 +48,11 @@
"params": { "params": {
"keyName": "key1" "keyName": "key1"
}, },
"returns": "encryptedKey" "returns": {
"status": 0,
"errorMessage": "12345",
"encryptedKey": "12345"
}
}, },
...@@ -46,7 +63,11 @@ ...@@ -46,7 +63,11 @@
"keyShareName": "key1", "keyShareName": "key1",
"messageHash": "1122334455" "messageHash": "1122334455"
}, },
"returns": "ecdsaSignature" "returns": {
"status": 0,
"errorMessage": "12345",
"ecdsaSignature": "12345"
}
}, },
......
...@@ -12,7 +12,7 @@ class StubClient : public jsonrpc::Client ...@@ -12,7 +12,7 @@ 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) {}
std::string importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) throw (jsonrpc::JsonRpcException) Json::Value importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p["index"] = index; p["index"] = index;
...@@ -21,51 +21,51 @@ class StubClient : public jsonrpc::Client ...@@ -21,51 +21,51 @@ class StubClient : public jsonrpc::Client
p["n"] = n; p["n"] = n;
p["t"] = t; p["t"] = t;
Json::Value result = this->CallMethod("importBLSKeyShare",p); Json::Value result = this->CallMethod("importBLSKeyShare",p);
if (result.isString()) if (result.isObject())
return result.asString(); return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); 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 blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p["keyShareName"] = keyShareName; p["keyShareName"] = keyShareName;
p["messageHash"] = messageHash; p["messageHash"] = messageHash;
Json::Value result = this->CallMethod("blsSignMessageHash",p); Json::Value result = this->CallMethod("blsSignMessageHash",p);
if (result.isString()) if (result.isObject())
return result.asString(); return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); 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 importECDSAKey(const std::string& key, const std::string& keyName) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p["key"] = key; p["key"] = key;
p["keyName"] = keyName; p["keyName"] = keyName;
Json::Value result = this->CallMethod("importECDSAKey",p); Json::Value result = this->CallMethod("importECDSAKey",p);
if (result.isString()) if (result.isObject())
return result.asString(); return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
std::string generateECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException) Json::Value generateECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p["keyName"] = keyName; p["keyName"] = keyName;
Json::Value result = this->CallMethod("generateECDSAKey",p); Json::Value result = this->CallMethod("generateECDSAKey",p);
if (result.isString()) if (result.isObject())
return result.asString(); return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); 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 ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p["keyShareName"] = keyShareName; p["keyShareName"] = keyShareName;
p["messageHash"] = messageHash; p["messageHash"] = messageHash;
Json::Value result = this->CallMethod("ecdsaSignMessageHash",p); Json::Value result = this->CallMethod("ecdsaSignMessageHash",p);
if (result.isString()) if (result.isObject())
return result.asString(); return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); 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