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
d2e6f8ca
Unverified
Commit
d2e6f8ca
authored
May 21, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-1880-fix-ecdsa
parent
7bf43a09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
ECDSACrypto.cpp
ECDSACrypto.cpp
+18
-9
Signature.c
secure_enclave/Signature.c
+2
-0
No files found.
ECDSACrypto.cpp
View file @
d2e6f8ca
...
...
@@ -135,9 +135,10 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
return
pubKey
;
}
void
verifyECDSASig
(
string
&
pubKeyStr
,
const
char
*
hashHex
,
const
char
*
signatureR
,
bool
verifyECDSASig
(
string
&
pubKeyStr
,
const
char
*
hashHex
,
const
char
*
signatureR
,
const
char
*
signatureS
)
{
bool
result
=
false
;
signature
sig
=
signature_init
();
...
...
@@ -158,12 +159,15 @@ void verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur
}
signature_set_str
(
sig
,
signatureR
,
signatureS
,
16
);
point_set_hex
(
publicKey
,
r
.
c_str
(),
s
.
c_str
());
if
(
!
signature_verify
(
msgMpz
,
sig
,
publicKey
,
curve
))
{
spdlog
::
error
(
"ECDSA sig not verified"
);
goto
clean
;
}
result
=
true
;
clean
:
mpz_clear
(
msgMpz
);
...
...
@@ -171,10 +175,12 @@ void verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur
point_clear
(
publicKey
);
signature_free
(
sig
);
return
result
;
}
vector
<
string
>
ecdsaSignHash
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
int
base
)
{
vector
<
string
>
signature
_vect
(
3
);
vector
<
string
>
signature
Vector
(
3
);
vector
<
char
>
errMsg
(
1024
,
0
);
int
errStatus
=
0
;
...
...
@@ -219,18 +225,21 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
exception
=
make_shared
<
SGXException
>
(
666
,
"failed to sign"
);
goto
clean
;
}
signature
_vect
.
at
(
0
)
=
to_string
(
signatureV
);
signature
Vector
.
at
(
0
)
=
to_string
(
signatureV
);
if
(
base
==
16
)
{
signature
_vect
.
at
(
1
)
=
"0x"
+
string
(
signatureR
.
data
());
signature
_vect
.
at
(
2
)
=
"0x"
+
string
(
signatureS
.
data
());
signature
Vector
.
at
(
1
)
=
"0x"
+
string
(
signatureR
.
data
());
signature
Vector
.
at
(
2
)
=
"0x"
+
string
(
signatureS
.
data
());
}
else
{
signature
_vect
.
at
(
1
)
=
string
(
signatureR
.
data
());
signature
_vect
.
at
(
2
)
=
string
(
signatureS
.
data
());
signature
Vector
.
at
(
1
)
=
string
(
signatureR
.
data
());
signature
Vector
.
at
(
2
)
=
string
(
signatureS
.
data
());
}
/* Now verify signature */
verifyECDSASig
(
pubKeyStr
,
hashHex
,
signatureR
.
data
(),
signatureS
.
data
());
if
(
!
verifyECDSASig
(
pubKeyStr
,
hashHex
,
signatureR
.
data
(),
signatureS
.
data
()))
{
exception
=
make_shared
<
SGXException
>
(
667
,
"ECDSA did not verify"
);
goto
clean
;
}
clean
:
...
...
@@ -238,5 +247,5 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
if
(
exception
)
throw
*
exception
;
return
signature
_vect
;
return
signature
Vector
;
}
\ No newline at end of file
secure_enclave/Signature.c
View file @
d2e6f8ca
...
...
@@ -256,3 +256,5 @@ bool signature_verify(mpz_t message, signature sig, point public_key, domain_par
return
result
;
}
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