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
d3d3523c
Unverified
Commit
d3d3523c
authored
Nov 13, 2019
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-1779 Fix read ECDSA keys from db
parent
66fc7fba
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
12 deletions
+9
-12
ECDSACrypto.cpp
ECDSACrypto.cpp
+1
-0
SGXWalletServer.cpp
SGXWalletServer.cpp
+5
-9
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-1
testw.cpp
testw.cpp
+2
-2
No files found.
ECDSACrypto.cpp
View file @
d3d3523c
...
...
@@ -30,6 +30,7 @@ std::vector<std::string> gen_ecdsa_key(){
std
::
default_random_engine
rand_gen
((
unsigned
int
)
time
(
0
));
unsigned
long
seed
=
rand_gen
();
std
::
cerr
<<
"seed is "
<<
seed
<<
std
::
endl
;
gmp_randstate_t
state
;
gmp_randinit_default
(
state
);
...
...
SGXWalletServer.cpp
View file @
d3d3523c
...
...
@@ -192,15 +192,11 @@ Json::Value renameESDSAKeyImpl(const std::string& KeyName, const std::string& te
throw
RPCException
(
UNKNOWN_ERROR
,
""
);
}
prefix
=
KeyName
.
substr
(
0
,
5
);
if
(
prefix
!=
"NODE_"
)
{
throw
RPCException
(
UNKNOWN_ERROR
,
""
);
}
std
::
string
chain_str
=
"CHAIN_"
;
if
(
KeyName
.
find
(
chain_str
)
==
std
::
string
::
npos
){
if
(
prefix
!=
"NEK_NODE_ID:"
)
{
throw
RPCException
(
UNKNOWN_ERROR
,
""
);
}
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
tempKeyName
,
""
);
//readECDSAKey(_keyName
);
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
tempKeyName
);
writeDataToDB
(
KeyName
,
*
key_ptr
);
levelDb
->
deleteTempNEK
(
tempKeyName
);
...
...
@@ -374,7 +370,7 @@ Json::Value DKGVerificationImpl(const std::string& publicShares, const std::stri
try
{
//std::string keyName = polyName + "_" + std::to_string(ind);
//std::shared_ptr<std::string> encryptedKeyHex_ptr = readFromDb(EthKeyName, "");
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
read
ECDSAKey
(
EthKeyName
);
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
read
FromDb
(
EthKeyName
);
if
(
!
VerifyShares
(
publicShares
.
c_str
(),
SecretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
t
,
n
,
ind
)){
...
...
@@ -421,7 +417,7 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
//std::cerr << sshares << std::endl;
//std::cerr << "length is " << strlen(sshares);
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
readECDSAKey
(
EthKeyName
);
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
read
FromDb
(
EthKeyName
);
//read
ECDSAKey(EthKeyName);
bool
res
=
CreateBLSShare
(
BLSKeyName
,
sshares
,
encryptedKeyHex_ptr
->
c_str
());
if
(
res
){
...
...
@@ -666,7 +662,7 @@ void writeDataToDB(const string & Name, const string &value) {
auto
key
=
Name
;
if
(
levelDb
->
readString
(
Name
)
!=
nullptr
)
{
std
::
cerr
<<
"already exists"
<<
std
::
endl
;
std
::
cerr
<<
"
name "
<<
Name
<<
"
already exists"
<<
std
::
endl
;
throw
new
RPCException
(
KEY_SHARE_ALREADY_EXISTS
,
"Data with this name already exists"
);
}
...
...
SGXWalletServer.hpp
View file @
d3d3523c
...
...
@@ -39,7 +39,7 @@ public:
};
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
);
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
);
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
);
void
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
value
,
int
index
,
int
n
,
int
t
);
...
...
testw.cpp
View file @
d3d3523c
...
...
@@ -724,7 +724,7 @@ TEST_CASE("API test", "[api_test]") {
//levelDb->deleteOlegKey("1");
cout
<<
c
.
generateECDSAKey
()
<<
endl
;
//
cout << c.generateECDSAKey() << endl;
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
//cout<<c.getPublicECDSAKey("test_key1");
//cout << c.ecdsaSignMessageHash(16, "known_key1","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
...
...
@@ -743,7 +743,7 @@ TEST_CASE("API test", "[api_test]") {
Json
::
Value
publicKeys
;
publicKeys
.
append
(
"505f55a38f9c064da744f217d1cb993a17705e9839801958cda7c884e08ab4dad7fd8d22953d3ac7f0913de24fd67d7ed36741141b8a3da152d7ba954b0f14e2"
);
publicKeys
.
append
(
"378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e"
);
//
cout << c.getSecretShare("p2", publicKeys, 2, 2);
cout
<<
c
.
getSecretShare
(
"p2"
,
publicKeys
,
2
,
2
);
// cout << c.generateDKGPoly("p3", 3);
// cout << c.getSecretShare("p3",
// "669aa790e1c5f5199af82ab0b6f1965c382d23a2ebdda581454adba3fd082a30edab62b545f78f1e402ceef7340a0364a7046633d6151fe7e657d8b8a6352378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e9d43f1c88581f53af993da1654c9f91829c1fe5344c4452ef8d2d8675c6a051c19029f6e4f82b035fb3552058cf22c5bbafd9e6456d579634987281765d130b0",
...
...
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