Unverified Commit ed546ca9 authored by kladko's avatar kladko

SKALE-3087

parent d0c753aa
Subproject commit f980b79f086b27b187bb696de1d7b99a0988859b
Subproject commit 8dc9f547c612010ea0b6257d86bcbd4ff7149565
Subproject commit 6c863ecc15eb5580e469f6b7f59817fdd08da1d1
Subproject commit 78ea56c3b5251e9d840ef65705bb2c5f8f193662
Subproject commit b0a445ba09e96e1d0507487e5c496485a9cf3742
Subproject commit 95eaa6f6693cd86c35e10a22b4f8e483373c987c
......@@ -43,7 +43,7 @@ uint8_t *getThreadLocalDecryptedDkgPoly() {
}
string *stringFromKey(libff::alt_bn128_Fr *_key) {
string* stringFromKey(libff::alt_bn128_Fr *_key) {
string* ret = nullptr;
mpz_t t;
mpz_init(t);
......@@ -55,8 +55,11 @@ string *stringFromKey(libff::alt_bn128_Fr *_key) {
char *tmp = mpz_get_str(arr, 10, t);
if (!tmp) {
LOG_ERROR("stringFromKey: mpz_get_str failed");
goto clean;
}
ret = new string(tmp);
goto clean;
} catch (exception &e) {
LOG_ERROR(e.what());
goto clean;
......@@ -78,9 +81,7 @@ string *stringFromFq(libff::alt_bn128_Fq *_fq) {
SAFE_CHAR_BUF(arr, BUF_LEN);
try {
_fq->as_bigint().to_mpz(t);
char *tmp = mpz_get_str(arr, 10, t);
ret = new string(tmp);
} catch (exception &e) {
......@@ -98,27 +99,43 @@ string *stringFromFq(libff::alt_bn128_Fq *_fq) {
string *stringFromG1(libff::alt_bn128_G1 *_g1) {
string* sX = nullptr;
string* sY = nullptr;
string* ret = nullptr;
try {
_g1->to_affine_coordinates();
auto sX = stringFromFq(&_g1->X);
auto sY = stringFromFq(&_g1->Y);
auto sG1 = new string(*sX + ":" + *sY);
if (!sX) {
goto clean;
}
delete (sX);
delete (sY);
auto sY = stringFromFq(&_g1->Y);
return sG1;
if (!sY) {
goto clean;
}
ret = new string(*sX + ":" + *sY);
} catch (exception &e) {
LOG_ERROR(e.what());
return nullptr;
goto clean;
} catch (...) {
LOG_ERROR("Unknown throwable");
return nullptr;
goto clean;
}
clean:
SAFE_FREE(sX);
SAFE_FREE(sY);
return ret;
}
libff::alt_bn128_Fr *keyFromString(const char *_keyStringHex) {
......
......@@ -64,7 +64,7 @@ extern unsigned char* globalRandom;
extern domain_parameters curve;
#define SAFE_FREE(__X__) if (!__X__) {free(__X__); __X__ = NULL;}
#define SAFE_FREE(__X__) if (__X__) {free(__X__); __X__ = NULL;}
#define SAFE_CHAR_BUF(__X__, __Y__) ;char __X__ [ __Y__ ]; memset(__X__, 0, __Y__);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment