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
2ed572aa
Unverified
Commit
2ed572aa
authored
Aug 15, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up
parent
dd4e9d36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
29 deletions
+40
-29
DKGUtils.cpp
secure_enclave/DKGUtils.cpp
+40
-29
No files found.
secure_enclave/DKGUtils.cpp
View file @
2ed572aa
...
...
@@ -258,9 +258,6 @@ void calc_secret_shares(const char *decrypted_coeffs,
CHECK_ARG_CLEAN
(
_n
>
0
);
CHECK_ARG_CLEAN
(
_t
<=
_n
);
try
{
vector
<
libff
::
alt_bn128_Fr
>
poly
=
SplitStringToFr
(
decrypted_coeffs
,
symbol
);
...
...
@@ -326,8 +323,6 @@ int calc_secret_share(const char *decrypted_coeffs, char *s_share,
int
calc_secret_shareG2
(
const
char
*
s_share
,
char
*
s_shareG2
)
{
int
result
=
1
;
mpz_t
share
;
...
...
@@ -416,43 +411,45 @@ int calc_public_shares(const char *decrypted_coeffs, char *public_shares,
string
ConvertHexToDec
(
string
hex_str
)
{
try
{
mpz_t
dec
;
mpz_init
(
dec
);
string
ret
=
""
;
mpz_t
dec
;
mpz_init
(
dec
);
try
{
if
(
mpz_set_str
(
dec
,
hex_str
.
c_str
(),
16
)
==
-
1
)
{
mpz_clear
(
dec
);
return
""
;
goto
clean
;
}
char
arr
[
mpz_sizeinbase
(
dec
,
10
)
+
2
];
char
*
result
=
mpz_get_str
(
arr
,
10
,
dec
);
mpz_clear
(
dec
);
return
result
;
CHECK_ARG_CLEAN
(
result
);
ret
=
result
;
}
catch
(
exception
&
e
)
{
LOG_ERROR
(
e
.
what
());
return
""
;
goto
clean
;
}
catch
(...)
{
LOG_ERROR
(
"Unknown throwable"
);
return
""
;
goto
clean
;
}
clean
:
mpz_clear
(
dec
);
return
ret
;
}
int
Verification
(
char
*
public_shares
,
mpz_t
decr_secret_share
,
int
_t
,
int
ind
)
{
try
{
string
pub_shares_str
=
public_shares
;
vector
<
libff
::
alt_bn128_G2
>
pub_shares
;
uint64_t
share_length
=
256
;
uint8_t
coord_length
=
64
;
int
ret
=
0
;
CHECK_ARG_CLEAN
(
public_shares
);
string
pub_shares_str
=
public_shares
;
vector
<
libff
::
alt_bn128_G2
>
pub_shares
;
uint64_t
share_length
=
256
;
uint8_t
coord_length
=
64
;
try
{
for
(
size_t
i
=
0
;
i
<
_t
;
++
i
)
{
libff
::
alt_bn128_G2
pub_share
;
...
...
@@ -463,7 +460,8 @@ int Verification(char *public_shares, mpz_t decr_secret_share, int _t, int ind)
string
y_c0_str
=
ConvertHexToDec
(
pub_shares_str
.
substr
(
pos0
+
2
*
coord_length
,
coord_length
));
string
y_c1_str
=
ConvertHexToDec
(
pub_shares_str
.
substr
(
pos0
+
3
*
coord_length
,
coord_length
));
if
(
x_c0_str
==
""
||
x_c1_str
==
""
||
y_c0_str
==
""
||
y_c1_str
==
""
)
{
return
2
;
ret
=
2
;
goto
clean
;
}
pub_share
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
x_c0_str
.
c_str
());
pub_share
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
x_c1_str
.
c_str
());
...
...
@@ -496,22 +494,31 @@ int Verification(char *public_shares, mpz_t decr_secret_share, int _t, int ind)
strncpy
(
public_shares
+
ConvertToString
(
val
.
X
.
c0
).
length
()
+
1
,
ConvertToString
(
val2
.
X
.
c0
).
c_str
(),
ConvertToString
(
val2
.
X
.
c0
).
length
());
ret
urn
(
val
==
sshare
*
libff
::
alt_bn128_G2
::
one
());
ret
=
(
val
==
sshare
*
libff
::
alt_bn128_G2
::
one
());
}
catch
(
exception
&
e
)
{
LOG_ERROR
(
e
.
what
());
return
0
;
goto
clean
;
}
catch
(...)
{
LOG_ERROR
(
"Unknown throwable"
);
return
0
;
goto
clean
;
}
clean
:
return
ret
;
}
int
calc_bls_public_key
(
char
*
skey_hex
,
char
*
pub_key
)
{
mpz_t
skey
;
mpz_init
(
skey
);
int
ret
=
1
;
CHECK_ARG_CLEAN
(
skey_hex
);
try
{
mpz_t
skey
;
mpz_init
(
skey
);
if
(
mpz_set_str
(
skey
,
skey_hex
,
16
)
==
-
1
)
{
mpz_clear
(
skey
);
return
1
;
...
...
@@ -540,4 +547,8 @@ int calc_bls_public_key(char *skey_hex, char *pub_key) {
LOG_ERROR
(
"Unknown throwable"
);
return
1
;
}
clean
:
mpz_clear
(
skey
);
return
ret
;
}
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