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
301f585f
Unverified
Commit
301f585f
authored
Feb 22, 2022
by
Oleh Nikolaiev
Committed by
GitHub
Feb 22, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into bug/fix-0x-bls-sign
parents
5d8506fa
513ec71a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
104 additions
and
50 deletions
+104
-50
SGXWalletServer.cpp
SGXWalletServer.cpp
+17
-9
SGXWalletServer.hpp
SGXWalletServer.hpp
+2
-2
abstractstubserver.h
abstractstubserver.h
+4
-4
common.h
common.h
+1
-1
secure_enclave.config.xml.sim
secure_enclave/secure_enclave.config.xml.sim
+3
-3
stubclient.h
stubclient.h
+3
-3
testw.cpp
testw.cpp
+66
-22
ReqMessage.cpp
zmq_src/ReqMessage.cpp
+2
-2
RspMessage.h
zmq_src/RspMessage.h
+1
-1
ZMQClient.cpp
zmq_src/ZMQClient.cpp
+2
-2
ZMQClient.h
zmq_src/ZMQClient.h
+1
-1
ZMQServer.cpp
zmq_src/ZMQServer.cpp
+2
-0
No files found.
SGXWalletServer.cpp
View file @
301f585f
...
@@ -982,7 +982,7 @@ SGXWalletServer::createBLSPrivateKeyV2Impl(const string &_blsKeyName, const stri
...
@@ -982,7 +982,7 @@ SGXWalletServer::createBLSPrivateKeyV2Impl(const string &_blsKeyName, const stri
RETURN_SUCCESS
(
result
);
RETURN_SUCCESS
(
result
);
}
}
Json
::
Value
SGXWalletServer
::
getDecryptionShare
Impl
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
publicDecryptionValue
)
{
Json
::
Value
SGXWalletServer
::
getDecryptionShare
sImpl
(
const
std
::
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
...
@@ -991,6 +991,13 @@ Json::Value SGXWalletServer::getDecryptionShareImpl(const std::string& blsKeyNam
...
@@ -991,6 +991,13 @@ Json::Value SGXWalletServer::getDecryptionShareImpl(const std::string& blsKeyNam
throw
SGXException
(
BLS_SIGN_INVALID_KS_NAME
,
string
(
__FUNCTION__
)
+
":Invalid BLSKey name"
);
throw
SGXException
(
BLS_SIGN_INVALID_KS_NAME
,
string
(
__FUNCTION__
)
+
":Invalid BLSKey name"
);
}
}
if
(
!
publicDecryptionValues
.
isArray
())
{
throw
SGXException
(
INVALID_DECRYPTION_VALUE_FORMAT
,
string
(
__FUNCTION__
)
+
":Public decryption values should be an array"
);
}
for
(
int
i
=
0
;
i
<
publicDecryptionValues
.
size
();
++
i
)
{
std
::
string
publicDecryptionValue
=
publicDecryptionValues
[
i
].
asString
();
if
(
publicDecryptionValue
.
length
()
<
7
||
publicDecryptionValue
.
length
()
>
78
*
4
)
{
if
(
publicDecryptionValue
.
length
()
<
7
||
publicDecryptionValue
.
length
()
>
78
*
4
)
{
throw
SGXException
(
INVALID_DECRYPTION_VALUE_FORMAT
,
string
(
__FUNCTION__
)
+
":Invalid publicDecryptionValue format"
);
throw
SGXException
(
INVALID_DECRYPTION_VALUE_FORMAT
,
string
(
__FUNCTION__
)
+
":Invalid publicDecryptionValue format"
);
}
}
...
@@ -998,8 +1005,9 @@ Json::Value SGXWalletServer::getDecryptionShareImpl(const std::string& blsKeyNam
...
@@ -998,8 +1005,9 @@ Json::Value SGXWalletServer::getDecryptionShareImpl(const std::string& blsKeyNam
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
blsKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
blsKeyName
);
vector
<
string
>
decryptionValueVector
=
calculateDecryptionShare
(
encryptedKeyHex_ptr
->
c_str
(),
publicDecryptionValue
);
vector
<
string
>
decryptionValueVector
=
calculateDecryptionShare
(
encryptedKeyHex_ptr
->
c_str
(),
publicDecryptionValue
);
for
(
uint8_t
i
=
0
;
i
<
4
;
++
i
)
{
for
(
uint8_t
j
=
0
;
j
<
4
;
++
j
)
{
result
[
"decryptionShare"
][
i
]
=
decryptionValueVector
.
at
(
i
);
result
[
"decryptionShares"
][
i
][
j
]
=
decryptionValueVector
.
at
(
j
);
}
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
...
@@ -1106,8 +1114,8 @@ SGXWalletServer::createBLSPrivateKeyV2(const string &blsKeyName, const string &e
...
@@ -1106,8 +1114,8 @@ SGXWalletServer::createBLSPrivateKeyV2(const string &blsKeyName, const string &e
return
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
return
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
}
}
Json
::
Value
SGXWalletServer
::
getDecryptionShare
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
publicDecryptionValue
)
{
Json
::
Value
SGXWalletServer
::
getDecryptionShare
s
(
const
std
::
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
)
{
return
getDecryptionShare
Impl
(
blsKeyName
,
publicDecryptionValue
);
return
getDecryptionShare
sImpl
(
blsKeyName
,
publicDecryptionValues
);
}
}
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
...
...
SGXWalletServer.hpp
View file @
301f585f
...
@@ -113,7 +113,7 @@ public:
...
@@ -113,7 +113,7 @@ public:
virtual
Json
::
Value
createBLSPrivateKeyV2
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
createBLSPrivateKeyV2
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
getDecryptionShare
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
publicDecryptionValue
);
virtual
Json
::
Value
getDecryptionShare
s
(
const
std
::
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
);
static
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
);
static
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
);
...
@@ -173,7 +173,7 @@ public:
...
@@ -173,7 +173,7 @@ public:
static
Json
::
Value
createBLSPrivateKeyV2Impl
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
static
Json
::
Value
createBLSPrivateKeyV2Impl
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
static
Json
::
Value
getDecryptionShare
Impl
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
publicDecryptionValue
);
static
Json
::
Value
getDecryptionShare
sImpl
(
const
std
::
string
&
KeyName
,
const
Json
::
Value
&
publicDecryptionValues
);
static
void
printDB
();
static
void
printDB
();
...
...
abstractstubserver.h
View file @
301f585f
...
@@ -63,7 +63,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -63,7 +63,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"dkgVerificationV2"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"publicShares"
,
jsonrpc
::
JSON_STRING
,
"ethKeyName"
,
jsonrpc
::
JSON_STRING
,
"secretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
"index"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
dkgVerificationV2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"dkgVerificationV2"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"publicShares"
,
jsonrpc
::
JSON_STRING
,
"ethKeyName"
,
jsonrpc
::
JSON_STRING
,
"secretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
"index"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
dkgVerificationV2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"createBLSPrivateKeyV2"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"blsKeyName"
,
jsonrpc
::
JSON_STRING
,
"ethKeyName"
,
jsonrpc
::
JSON_STRING
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"secretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
createBLSPrivateKeyV2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"createBLSPrivateKeyV2"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"blsKeyName"
,
jsonrpc
::
JSON_STRING
,
"ethKeyName"
,
jsonrpc
::
JSON_STRING
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"secretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
createBLSPrivateKeyV2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getDecryptionShare
"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"blsKeyName"
,
jsonrpc
::
JSON_STRING
,
"publicDecryptionValue"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
getDecryptionShare
I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getDecryptionShare
s"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"blsKeyName"
,
jsonrpc
::
JSON_STRING
,
"publicDecryptionValues"
,
jsonrpc
::
JSON_ARRAY
,
NULL
),
&
AbstractStubServer
::
getDecryptionShares
I
);
}
}
inline
virtual
void
importBLSKeyShareI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
inline
virtual
void
importBLSKeyShareI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
...
@@ -163,9 +163,9 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -163,9 +163,9 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
response
=
this
->
createBLSPrivateKeyV2
(
request
[
"blsKeyName"
].
asString
(),
request
[
"ethKeyName"
].
asString
(),
request
[
"polyName"
].
asString
(),
request
[
"secretShare"
].
asString
(),
request
[
"t"
].
asInt
(),
request
[
"n"
].
asInt
());
response
=
this
->
createBLSPrivateKeyV2
(
request
[
"blsKeyName"
].
asString
(),
request
[
"ethKeyName"
].
asString
(),
request
[
"polyName"
].
asString
(),
request
[
"secretShare"
].
asString
(),
request
[
"t"
].
asInt
(),
request
[
"n"
].
asInt
());
}
}
inline
virtual
void
getDecryptionShareI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
inline
virtual
void
getDecryptionShare
s
I
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
{
response
=
this
->
getDecryptionShare
(
request
[
"blsKeyName"
].
asString
(),
request
[
"publicDecryptionValue"
].
asString
()
);
response
=
this
->
getDecryptionShare
s
(
request
[
"blsKeyName"
].
asString
(),
request
[
"publicDecryptionValues"
]
);
}
}
virtual
Json
::
Value
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
)
=
0
;
virtual
Json
::
Value
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
)
=
0
;
...
@@ -194,7 +194,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -194,7 +194,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual
Json
::
Value
dkgVerificationV2
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
=
0
;
virtual
Json
::
Value
dkgVerificationV2
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
=
0
;
virtual
Json
::
Value
createBLSPrivateKeyV2
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
=
0
;
virtual
Json
::
Value
createBLSPrivateKeyV2
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
=
0
;
virtual
Json
::
Value
getDecryptionShare
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
publicDecryptionValue
)
=
0
;
virtual
Json
::
Value
getDecryptionShare
s
(
const
std
::
string
&
KeyName
,
const
Json
::
Value
&
publicDecryptionValues
)
=
0
;
};
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
common.h
View file @
301f585f
...
@@ -121,7 +121,7 @@ string __ERR_STRING__ = string("SGX enclave call to ") + \
...
@@ -121,7 +121,7 @@ string __ERR_STRING__ = string("SGX enclave call to ") + \
__FUNCTION__ + " failed with status:" \
__FUNCTION__ + " failed with status:" \
+ to_string(__STATUS__) + \
+ to_string(__STATUS__) + \
" Err message:" + __ERR_MSG__; \
" Err message:" + __ERR_MSG__; \
BOOST_THROW_EXCEPTION(SGXException(-102, string(__ERR_
MS
G__))); \
BOOST_THROW_EXCEPTION(SGXException(-102, string(__ERR_
STRIN
G__))); \
}\
}\
\
\
if (__ERR_STATUS__ != 0) {\
if (__ERR_STATUS__ != 0) {\
...
...
secure_enclave/secure_enclave.config.xml.sim
View file @
301f585f
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
<ISVSVN>3</ISVSVN>
<ISVSVN>3</ISVSVN>
<StackMaxSize>0x200000</StackMaxSize>
<StackMaxSize>0x200000</StackMaxSize>
<HeapMaxSize>0x200000</HeapMaxSize>
<HeapMaxSize>0x200000</HeapMaxSize>
<TCSNum>2
0
</TCSNum>
<TCSNum>2
5
</TCSNum>
<TCSMaxNum>2
0
</TCSMaxNum>
<TCSMaxNum>2
5
</TCSMaxNum>
<TCSMinPool>2
0
</TCSMinPool>
<TCSMinPool>2
5
</TCSMinPool>
<TCSPolicy>0</TCSPolicy>
<TCSPolicy>0</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<DisableDebug>0</DisableDebug>
...
...
stubclient.h
View file @
301f585f
...
@@ -214,13 +214,13 @@ class StubClient : public jsonrpc::Client
...
@@ -214,13 +214,13 @@ class StubClient : public jsonrpc::Client
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
getDecryptionShare
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
publicDecryptionValue
)
Json
::
Value
getDecryptionShare
s
(
const
std
::
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"blsKeyName"
]
=
blsKeyName
;
p
[
"blsKeyName"
]
=
blsKeyName
;
p
[
"publicDecryptionValue
"
]
=
publicDecryptionValue
;
p
[
"publicDecryptionValue
s"
]
=
publicDecryptionValues
[
"publicDecryptionValues"
]
;
Json
::
Value
result
=
this
->
CallMethod
(
"getDecryptionShare"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"getDecryptionShare
s
"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
...
...
testw.cpp
View file @
301f585f
...
@@ -1248,21 +1248,43 @@ TEST_CASE_METHOD(TestFixture, "Test decryption share for threshold encryption",
...
@@ -1248,21 +1248,43 @@ TEST_CASE_METHOD(TestFixture, "Test decryption share for threshold encryption",
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
libff
::
alt_bn128_G2
decryption_value
=
libff
::
alt_bn128_G2
::
random_element
();
libff
::
alt_bn128_G2
decryption_value
1
=
libff
::
alt_bn128_G2
::
random_element
();
decryption_value
.
to_affine_coordinates
();
libff
::
alt_bn128_G2
decryption_value2
=
libff
::
alt_bn128_G2
::
random_element
();
auto
decrytion_value_str
=
convertG2ToString
(
decryption_value
,
':'
);
decryption_value1
.
to_affine_coordinates
(
);
auto
decryption_share
=
c
.
getDecryptionShare
(
name
,
decrytion_value_str
)[
"decryptionShare"
]
;
decryption_value2
.
to_affine_coordinates
()
;
libff
::
alt_bn128_G2
share
;
auto
decrytion_value_str1
=
convertG2ToString
(
decryption_value1
,
':'
)
;
share
.
Z
=
libff
::
alt_bn128_Fq2
::
one
(
);
auto
decrytion_value_str2
=
convertG2ToString
(
decryption_value2
,
':'
);
share
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share
[
0
].
asCString
()
);
Json
::
Value
publicDecryptionValues
;
share
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share
[
1
].
asCString
()
);
publicDecryptionValues
[
"publicDecryptionValues"
][
0
]
=
decrytion_value_str1
;
share
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share
[
2
].
asCString
()
);
publicDecryptionValues
[
"publicDecryptionValues"
][
1
]
=
decrytion_value_str2
;
share
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share
[
3
].
asCString
()
);
REQUIRE
(
share
==
key
*
decryption_value
);
auto
decryptionShares
=
c
.
getDecryptionShares
(
name
,
publicDecryptionValues
);
auto
decryption_share1
=
decryptionShares
[
"decryptionShares"
][
0
];
auto
decryption_share2
=
decryptionShares
[
"decryptionShares"
][
1
];
libff
::
alt_bn128_G2
share1
;
share1
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
share1
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
0
].
asCString
()
);
share1
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
1
].
asCString
()
);
share1
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
2
].
asCString
()
);
share1
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
3
].
asCString
()
);
REQUIRE
(
share1
==
key
*
decryption_value1
);
libff
::
alt_bn128_G2
share2
;
share2
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
share2
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
0
].
asCString
()
);
share2
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
1
].
asCString
()
);
share2
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
2
].
asCString
()
);
share2
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
3
].
asCString
()
);
REQUIRE
(
share2
==
key
*
decryption_value2
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"Test decryption share for threshold encryption via zmq"
,
"[te-decryption-share-zmq]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"Test decryption share for threshold encryption via zmq"
,
"[te-decryption-share-zmq]"
)
{
...
@@ -1277,21 +1299,43 @@ TEST_CASE_METHOD(TestFixture, "Test decryption share for threshold encryption vi
...
@@ -1277,21 +1299,43 @@ TEST_CASE_METHOD(TestFixture, "Test decryption share for threshold encryption vi
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
libff
::
alt_bn128_G2
decryption_value
=
libff
::
alt_bn128_G2
::
random_element
();
libff
::
alt_bn128_G2
decryption_value1
=
libff
::
alt_bn128_G2
::
random_element
();
decryption_value
.
to_affine_coordinates
();
libff
::
alt_bn128_G2
decryption_value2
=
libff
::
alt_bn128_G2
::
random_element
();
decryption_value1
.
to_affine_coordinates
();
decryption_value2
.
to_affine_coordinates
();
auto
decrytion_value_str1
=
convertG2ToString
(
decryption_value1
,
':'
);
auto
decrytion_value_str2
=
convertG2ToString
(
decryption_value2
,
':'
);
Json
::
Value
publicDecryptionValues
;
publicDecryptionValues
[
"publicDecryptionValues"
][
0
]
=
decrytion_value_str1
;
publicDecryptionValues
[
"publicDecryptionValues"
][
1
]
=
decrytion_value_str2
;
auto
decryptionShares
=
client
->
getDecryptionShares
(
name
,
publicDecryptionValues
);
auto
decryption_share1
=
decryptionShares
[
0
];
auto
decryption_share2
=
decryptionShares
[
1
];
libff
::
alt_bn128_G2
share1
;
share1
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
share1
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
0
].
asCString
()
);
share1
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
1
].
asCString
()
);
share1
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
2
].
asCString
()
);
share1
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share1
[
3
].
asCString
()
);
auto
decrytion_value_str
=
convertG2ToString
(
decryption_value
,
':'
);
REQUIRE
(
share1
==
key
*
decryption_value1
);
auto
decryption_share
=
client
->
getDecryptionShare
(
name
,
decrytion_value_str
);
libff
::
alt_bn128_G2
share
;
libff
::
alt_bn128_G2
share
2
;
share
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
share
2
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
share
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share
[
0
].
asCString
()
);
share
2
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
0
].
asCString
()
);
share
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share
[
1
].
asCString
()
);
share
2
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
1
].
asCString
()
);
share
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share
[
2
].
asCString
()
);
share
2
.
Y
.
c0
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
2
].
asCString
()
);
share
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share
[
3
].
asCString
()
);
share
2
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
decryption_share2
[
3
].
asCString
()
);
REQUIRE
(
share
==
key
*
decryption_value
);
REQUIRE
(
share
2
==
key
*
decryption_value2
);
}
}
TEST_CASE_METHOD
(
TestFixtureZMQSign
,
"ZMQ-ecdsa"
,
"[zmq-ecdsa]"
)
{
TEST_CASE_METHOD
(
TestFixtureZMQSign
,
"ZMQ-ecdsa"
,
"[zmq-ecdsa]"
)
{
...
...
zmq_src/ReqMessage.cpp
View file @
301f585f
...
@@ -265,11 +265,11 @@ Json::Value deleteBLSKeyReqMessage::process() {
...
@@ -265,11 +265,11 @@ Json::Value deleteBLSKeyReqMessage::process() {
Json
::
Value
GetDecryptionShareReqMessage
::
process
()
{
Json
::
Value
GetDecryptionShareReqMessage
::
process
()
{
auto
blsKeyName
=
getStringRapid
(
"blsKeyName"
);
auto
blsKeyName
=
getStringRapid
(
"blsKeyName"
);
auto
publicDecryptionValue
=
getStringRapid
(
"publicDecryptionValue
"
);
auto
publicDecryptionValue
s
=
getJsonValueRapid
(
"publicDecryptionValues
"
);
if
(
checkKeyOwnership
&&
!
isKeyByOwner
(
blsKeyName
,
getStringRapid
(
"cert"
)))
{
if
(
checkKeyOwnership
&&
!
isKeyByOwner
(
blsKeyName
,
getStringRapid
(
"cert"
)))
{
throw
std
::
invalid_argument
(
"Only owner of the key can access it"
);
throw
std
::
invalid_argument
(
"Only owner of the key can access it"
);
}
}
auto
result
=
SGXWalletServer
::
getDecryptionShare
Impl
(
blsKeyName
,
publicDecryptionValue
);
auto
result
=
SGXWalletServer
::
getDecryptionShare
sImpl
(
blsKeyName
,
publicDecryptionValues
);
result
[
"type"
]
=
ZMQMessage
::
GET_DECRYPTION_SHARE_RSP
;
result
[
"type"
]
=
ZMQMessage
::
GET_DECRYPTION_SHARE_RSP
;
return
result
;
return
result
;
}
}
zmq_src/RspMessage.h
View file @
301f585f
...
@@ -255,7 +255,7 @@ public:
...
@@ -255,7 +255,7 @@ public:
virtual
Json
::
Value
process
();
virtual
Json
::
Value
process
();
Json
::
Value
getShare
()
{
Json
::
Value
getShare
()
{
return
getJsonValueRapid
(
"decryptionShare"
);
return
getJsonValueRapid
(
"decryptionShare
s
"
);
}
}
};
};
...
...
zmq_src/ZMQClient.cpp
View file @
301f585f
...
@@ -496,11 +496,11 @@ bool ZMQClient::deleteBLSKey(const string& blsKeyName) {
...
@@ -496,11 +496,11 @@ bool ZMQClient::deleteBLSKey(const string& blsKeyName) {
return
result
->
isSuccessful
();
return
result
->
isSuccessful
();
}
}
Json
::
Value
ZMQClient
::
getDecryptionShare
(
const
string
&
blsKeyName
,
const
string
&
publicDecryptionValue
)
{
Json
::
Value
ZMQClient
::
getDecryptionShare
s
(
const
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
)
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"type"
]
=
ZMQMessage
::
GET_DECRYPTION_SHARE_REQ
;
p
[
"type"
]
=
ZMQMessage
::
GET_DECRYPTION_SHARE_REQ
;
p
[
"blsKeyName"
]
=
blsKeyName
;
p
[
"blsKeyName"
]
=
blsKeyName
;
p
[
"publicDecryptionValue
"
]
=
publicDecryptionValue
;
p
[
"publicDecryptionValue
s"
]
=
publicDecryptionValues
[
"publicDecryptionValues"
]
;
auto
result
=
dynamic_pointer_cast
<
GetDecryptionShareRspMessage
>
(
doRequestReply
(
p
));
auto
result
=
dynamic_pointer_cast
<
GetDecryptionShareRspMessage
>
(
doRequestReply
(
p
));
CHECK_STATE
(
result
);
CHECK_STATE
(
result
);
CHECK_STATE
(
result
->
getStatus
()
==
0
);
CHECK_STATE
(
result
->
getStatus
()
==
0
);
...
...
zmq_src/ZMQClient.h
View file @
301f585f
...
@@ -122,7 +122,7 @@ public:
...
@@ -122,7 +122,7 @@ public:
bool
deleteBLSKey
(
const
string
&
blsKeyName
);
bool
deleteBLSKey
(
const
string
&
blsKeyName
);
Json
::
Value
getDecryptionShare
(
const
string
&
blsKeyName
,
const
string
&
publicDecryptionValue
);
Json
::
Value
getDecryptionShare
s
(
const
string
&
blsKeyName
,
const
Json
::
Value
&
publicDecryptionValues
);
};
};
...
...
zmq_src/ZMQServer.cpp
View file @
301f585f
...
@@ -233,6 +233,7 @@ pair <string, shared_ptr<zmq::message_t>> ZMQServer::receiveMessage() {
...
@@ -233,6 +233,7 @@ pair <string, shared_ptr<zmq::message_t>> ZMQServer::receiveMessage() {
}
}
auto
result
=
string
((
char
*
)
reqMsg
->
data
(),
reqMsg
->
size
());
auto
result
=
string
((
char
*
)
reqMsg
->
data
(),
reqMsg
->
size
());
spdlog
::
debug
(
"Received request via ZMQ server: {}"
,
result
);
return
{
result
,
identity
};
return
{
result
,
identity
};
}
}
...
@@ -255,6 +256,7 @@ void ZMQServer::sendToClient(Json::Value &_result, shared_ptr <zmq::message_t> &
...
@@ -255,6 +256,7 @@ void ZMQServer::sendToClient(Json::Value &_result, shared_ptr <zmq::message_t> &
if
(
!
s_send
(
*
socket
,
replyStr
))
{
if
(
!
s_send
(
*
socket
,
replyStr
))
{
exit
(
-
16
);
exit
(
-
16
);
}
}
spdlog
::
debug
(
"Send response to client: {}"
,
replyStr
);
}
catch
(
ExitRequestedException
)
{
}
catch
(
ExitRequestedException
)
{
throw
;
throw
;
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
...
...
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