Unverified Commit 8f08f2af authored by Oleh Nikolaiev's avatar Oleh Nikolaiev Committed by GitHub

Merge pull request #129 from skalenetwork/bug/SKALE-2830-tests-fail-after-longrun

Bug/skale 2830 tests fail after longrun
parents 135dd788 f5d217ae
......@@ -233,6 +233,9 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
strncpy(_sig, sig.c_str(), BUF_LEN);
delete xStr;
delete yStr;
return true;
}
......
......@@ -176,6 +176,9 @@ std::string BLSPrivateKeyShareSGX::signWithHelperSGXstr(
sig.append(":");
sig.append(hint);
delete xStr;
delete yStr;
return sig;
}
......
......@@ -35,8 +35,6 @@
#include "third_party/spdlog/spdlog.h"
#include "common.h"
#define DKG_MAX_SEALED_LEN 3100
vector<string> splitString(const char *coeffs, const char symbol) {
string str(coeffs);
string delim;
......@@ -95,8 +93,7 @@ string gen_dkg_poly(int _t) {
throw SGXException(-666, errMsg.data());
}
uint64_t length = DKG_MAX_SEALED_LEN;
length = enc_len;
uint64_t length = enc_len;;
vector<char> hexEncrPoly(2 * length + 1, 0);
CHECK_STATE(encrypted_dkg_secret.size() >= length);
......
......@@ -37,5 +37,5 @@ RUN apt update && \
cd .. && rm -rf dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \
cd /usr/src/sdk && \
./autoconf.bash && \
./configure && \
./configure && \
bash -c "make -j$(nproc)"
......@@ -89,7 +89,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
vector<char> errMsg(BUF_LEN, 0);
vector<char> pubKeyX(BUF_LEN, 0);
vector<char> pubKeyY(BUF_LEN, 0);
vector <uint8_t> encrPrKey(BUF_LEN, 0);
vector<uint8_t> encrPrKey(BUF_LEN, 0);
int errStatus = 0;
uint64_t enc_len = 0;
......@@ -102,6 +102,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
if (errStatus != 0) {
spdlog::error("failed to get ECDSA public key {}", status);
throw SGXException(-666, errMsg.data());
}
......@@ -109,8 +110,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
spdlog::error("failed to get ECDSA public key {}", status);
throw SGXException(666, "failed to get ECDSA public key");
}
string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());//concatPubKeyWith0x(pub_key_x, pub_key_y);//
string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());
if (pubKey.size() != 128) {
spdlog::error("Incorrect pub key size", status);
......@@ -182,8 +182,6 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
goto clean;
}
pubKeyStr = getECDSAPubKey(encryptedKeyHex);
status = trustedEcdsaSignAES(eid, &errStatus,
errMsg.data(), encryptedKey.data(), decLen, (unsigned char *) hashHex,
signatureR.data(),
......@@ -210,6 +208,8 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
/* Now verify signature */
pubKeyStr = getECDSAPubKey(encryptedKeyHex);
if (!verifyECDSASig(pubKeyStr, hashHex, signatureR.data(), signatureS.data(), base)) {
exception = make_shared<SGXException>(667, "ECDSA did not verify");
goto clean;
......
......@@ -59,7 +59,6 @@
void initUserSpace() {
libff::inhibit_profiling_counters = true;
libff::inhibit_profiling_info = true;
libff::init_alt_bn128_params();
......
......@@ -115,6 +115,8 @@ bool enclave_sign(const char *_keyString, const char *_hashXString, const char *
libff::alt_bn128_G1 sign = key->as_bigint() * hash;
delete key;
sign.to_affine_coordinates();
auto r = stringFromG1(&sign);
......
......@@ -36,7 +36,7 @@
#define ADD_ENTROPY_SIZE 32
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_BUFER_LENGTH 2496//3060
#define DKG_MAX_SEALED_LEN 3100
#define SECRET_SHARE_NUM_BYTES 96
......
......@@ -93,8 +93,7 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
//message must not have a bit length longer than that of n
//see: Guide to Elliptic Curve Cryptography, section 4.4.1.
for (int i = 0; i < 1; i++ ) {
{
assert(mpz_sizeinbase(message, 2) <= mpz_sizeinbase(curve->n, 2));
point Q = point_init();
......@@ -128,10 +127,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_mod(k, seed, curve->p);
//mpz_set_str(k, "49a0d7b786ec9cde0d0721d72804befd06571c974b191efb42ecf322ba9ddd9a", 16);
// mpz_set_str(k, "DC87789C4C1A09C97FF4DE72C0D0351F261F10A2B9009C80AEE70DDEC77201A0", 16);
//mpz_set_str(k,"29932781130098090011281004827843485745127563886526054275935615017309884975795",10);
//Calculate x
point_multiplication(Q, k, curve->G, curve);
mpz_set(x, Q->x);
......@@ -193,7 +188,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_clear(seed);
mpz_clear(n_div_2);
mpz_clear(s_mul_2);
}
}
......
......@@ -1091,7 +1091,7 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
for (int i = 0; i < n_zeroes; i++) {
pub_key_y[i] = '0';
}
strncpy(pub_key_y + n_zeroes, arr_y, 1024 - n_zeroes); // ??????????????????????????????????? SIGSEGV
strncpy(pub_key_y + n_zeroes, arr_y, 1024 - n_zeroes);
mpz_clear(privateKeyMpz);
domain_parameters_clear(curve);
......
This diff is collapsed.
......@@ -111,13 +111,10 @@ TEST_CASE_METHOD(TestFixture, "ECDSA keygen and signature test", "[ecdsa-key-sig
vector<char> signatureS(BUF_LEN, 0);
uint8_t signatureV = 0;
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,
(unsigned char *) hex.data(),
signatureR.data(),
signatureS.data(), &signatureV, 16);
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,
(unsigned char *) hex.data(),
signatureR.data(),
signatureS.data(), &signatureV, 16);
REQUIRE(status == SGX_SUCCESS);
......@@ -138,7 +135,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes
REQUIRE(status == SGX_SUCCESS);
REQUIRE(errStatus == SGX_SUCCESS);
string hex = SAMPLE_HEX_HASH;
vector<char> signatureR(BUF_LEN, 0);
vector<char> signatureS(BUF_LEN, 0);
......
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