Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
28294924
Unverified
Commit
28294924
authored
Sep 08, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added function stubs
parent
1f00f276
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
15 deletions
+145
-15
SGXWalletServer.cpp
SGXWalletServer.cpp
+29
-4
abstractstubserver.h
abstractstubserver.h
+27
-3
spec.json
spec.json
+41
-3
stubclient.h
stubclient.h
+48
-5
No files found.
SGXWalletServer.cpp
View file @
28294924
...
...
@@ -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
""
;
}
abstractstubserver.h
View file @
28294924
...
...
@@ -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
;
...
...
spec.json
View file @
28294924
...
...
@@ -2,13 +2,51 @@
{
"name"
:
"importBLSKeyShare"
,
"params"
:
{
"
name"
:
"Peter
"
,
"
keyShareName"
:
"key1
"
,
"n"
:
2
,
"t"
:
2
,
"index"
:
2
,
"
hexK
eyShare"
:
"1122334455"
"
k
eyShare"
:
"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"
},
...
...
stubclient.h
View file @
28294924
...
...
@@ -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
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment