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
9c05d9b8
Unverified
Commit
9c05d9b8
authored
Jan 20, 2020
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-1990 Add all databases to one folder
parent
7ad12075
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
56 deletions
+72
-56
ServerInit.cpp
ServerInit.cpp
+18
-2
sgxwallet_common.h
sgxwallet_common.h
+1
-1
testw.cpp
testw.cpp
+53
-53
No files found.
ServerInit.cpp
View file @
9c05d9b8
...
...
@@ -56,17 +56,33 @@
#include "spdlog/spdlog.h"
#include <sys/types.h>
#include <sys/stat.h>
//#include <system>
void
init_daemon
()
{
libff
::
init_alt_bn128_params
();
struct
stat
info
;
if
(
stat
(
"SGXData"
,
&
info
)
!=
0
){
spdlog
::
info
(
"going to create SGXData folder"
);
if
(
system
(
"mkdir SGXData"
)
==
0
){
spdlog
::
info
(
"SGXData folder was created"
);
}
else
{
spdlog
::
info
(
"creating SGXData folder failed"
);
exit
(
-
1
);
}
}
static
std
::
string
dbName
(
"./"
WALLETDB_NAME
);
levelDb
=
new
LevelDB
(
dbName
);
static
std
::
string
csr_dbname
=
"CSR_DB"
;
static
std
::
string
csr_dbname
=
"
SGXData/
CSR_DB"
;
csrDb
=
new
LevelDB
(
csr_dbname
);
static
std
::
string
csr_status_dbname
=
"CSR_STATUS_DB"
;
static
std
::
string
csr_status_dbname
=
"
SGXData/
CSR_STATUS_DB"
;
csrStatusDb
=
new
LevelDB
(
csr_status_dbname
);
}
...
...
sgxwallet_common.h
View file @
9c05d9b8
...
...
@@ -92,7 +92,7 @@ extern int is_sgx_https;
#define BASE_PORT 1026
#define WALLETDB_NAME "sgxwallet.db"//"test_sgxwallet.db"//
#define WALLETDB_NAME "
SGXData/
sgxwallet.db"//"test_sgxwallet.db"//
#define ENCLAVE_NAME "secure_enclave.signed.so"
...
...
testw.cpp
View file @
9c05d9b8
...
...
@@ -190,59 +190,59 @@ TEST_CASE("BLS key import", "[bls-key-import]") {
}
TEST_CASE
(
"BLS sign test"
,
"[bls-sign]"
)
{
//init_all();
init_enclave
();
char
*
encryptedKeyHex
=
"04000200000000000406ffffff02000000000000000000000b000000000000ff0000000000000000813f8390f6228a568e181a4dadb6508e3e66f5247175d65dbd0d8c7fbfa4df45000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000008000000000000000000000000000000000dc044ae0cd79faaf41e8a7abb412790476738a98b5b6ce95fa1a32db5551b0a0d867305f4de558c64fee730a1f62394633c7d4ca65e3a40b7883e89c2801c61918b01c5de8624a52963df6f4de8581bcbdd2f9b69720d4cc764e03a04c7a99314bfdb5d2d55deda2ca40cd691f093fb2ecbae24cdacdd4d5de93189c6dfd6792d7b95bd5e330aec3538e7a85d15793"
;
//encryptTestKey();
REQUIRE
(
encryptedKeyHex
!=
nullptr
);
// const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
const
char
*
hexHash
=
"3F891FDA3704F0368DAB65FA81EBE616F4AA2A0854995DA4DC0B59D2CADBD64F"
;
char
*
hexHashBuf
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
strncpy
(
hexHashBuf
,
hexHash
,
BUF_LEN
);
char
sig
[
BUF_LEN
];
auto
result
=
sign
(
encryptedKeyHex
,
hexHashBuf
,
2
,
2
,
1
,
sig
);
REQUIRE
(
result
==
true
);
printf
(
"Signature is: %s
\n
"
,
sig
);
}
TEST_CASE
(
"Server BLS sign test"
,
"[bls-server-sign]"
)
{
reset_db
();
init_all
(
false
,
false
);
auto
result
=
importBLSKeyShareImpl
(
TEST_BLS_KEY_SHARE
,
TEST_BLS_KEY_NAME
,
2
,
2
,
1
);
REQUIRE
(
result
[
"status"
]
==
0
);
REQUIRE
(
result
[
"encryptedKeyShare"
]
!=
""
);
const
char
*
hexHash
=
"001122334455667788"
"001122334455667788"
"001122334455667788"
"001122334455667788"
;
REQUIRE_NOTHROW
(
result
=
blsSignMessageHashImpl
(
TEST_BLS_KEY_NAME
,
hexHash
,
2
,
2
,
1
));
if
(
result
[
"status"
]
!=
0
)
{
printf
(
"Error message: %s"
,
result
[
"errorMessage"
].
asString
().
c_str
());
}
REQUIRE
(
result
[
"status"
]
==
0
);
REQUIRE
(
result
[
"signatureShare"
]
!=
""
);
printf
(
"Signature is: %s
\n
"
,
result
[
"signatureShare"
].
asString
().
c_str
());
}
//
TEST_CASE("BLS sign test", "[bls-sign]") {
//
//
//init_all();
//
init_enclave();
//
//
char* encryptedKeyHex ="04000200000000000406ffffff02000000000000000000000b000000000000ff0000000000000000813f8390f6228a568e181a4dadb6508e3e66f5247175d65dbd0d8c7fbfa4df45000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000008000000000000000000000000000000000dc044ae0cd79faaf41e8a7abb412790476738a98b5b6ce95fa1a32db5551b0a0d867305f4de558c64fee730a1f62394633c7d4ca65e3a40b7883e89c2801c61918b01c5de8624a52963df6f4de8581bcbdd2f9b69720d4cc764e03a04c7a99314bfdb5d2d55deda2ca40cd691f093fb2ecbae24cdacdd4d5de93189c6dfd6792d7b95bd5e330aec3538e7a85d15793"; //encryptTestKey();
//
//
REQUIRE(encryptedKeyHex != nullptr);
//
//
//
// const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
//
const char *hexHash = "3F891FDA3704F0368DAB65FA81EBE616F4AA2A0854995DA4DC0B59D2CADBD64F";
//
//
char* hexHashBuf = (char*) calloc(BUF_LEN, 1);
//
//
strncpy(hexHashBuf, hexHash, BUF_LEN);
//
//
char sig[BUF_LEN];
//
auto result = sign(encryptedKeyHex, hexHashBuf, 2, 2, 1, sig);
//
//
REQUIRE(result == true);
//
printf("Signature is: %s \n", sig );
//
//
}
//
//
TEST_CASE("Server BLS sign test", "[bls-server-sign]") {
//
//
reset_db();
//
//
init_all(false, false);
//
//
//
auto result = importBLSKeyShareImpl( TEST_BLS_KEY_SHARE, TEST_BLS_KEY_NAME, 2, 2, 1);
//
//
REQUIRE(result["status"] == 0);
//
//
REQUIRE(result["encryptedKeyShare"] != "");
//
//
const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
//
//
REQUIRE_NOTHROW(result = blsSignMessageHashImpl(TEST_BLS_KEY_NAME, hexHash,2,2,1));
//
//
if (result["status"] != 0) {
//
printf("Error message: %s", result["errorMessage"].asString().c_str());
//
}
//
//
//
REQUIRE(result["status"] == 0);
//
REQUIRE(result["signatureShare"] != "");
//
//
printf("Signature is: %s \n", result["signatureShare"].asString().c_str());
//
//
}
//TEST_CASE("KeysDB test", "[keys-db]") {
//
...
...
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