SKALE-2002 refactoring

parent 1390120c
...@@ -757,7 +757,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -757,7 +757,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
secretShares[i] = c.getSecretShare(polyNames[i], pubEthKeys, t, n); secretShares[i] = c.getSecretShare(polyNames[i], pubEthKeys, t, n);
cout << secretShares[i] << endl;
REQUIRE(secretShares[i]["status"] == 0); REQUIRE(secretShares[i]["status"] == 0);
for (uint8_t k = 0; k < t; k++) { for (uint8_t k = 0; k < t; k++) {
for (uint8_t j = 0; j < 4; j++) { for (uint8_t j = 0; j < 4; j++) {
...@@ -768,7 +767,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -768,7 +767,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
} }
} }
int k = 0; int k = 0;
vector <string> secShares(n); vector <string> secShares(n);
...@@ -794,17 +792,14 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -794,17 +792,14 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
BLSSigShareSet sigShareSet(t, n); BLSSigShareSet sigShareSet(t, n);
string hash = SAMPLE_HASH; string hash = SAMPLE_HASH;
auto hash_arr = make_shared < array < uint8_t, auto hash_arr = make_shared < array < uint8_t, 32 >> ();
32 >> ();
uint64_t binLen; uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) { if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) {
throw SGXException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffsPubKeysMap; map <size_t, shared_ptr<BLSPublicKeyShare>> coeffsPubKeysMap;
for (int i = 0; i < t; i++) { for (int i = 0; i < t; i++) {
...@@ -812,9 +807,12 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -812,9 +807,12 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
string blsName = "BLS_KEY" + polyNames[i].substr(4); string blsName = "BLS_KEY" + polyNames[i].substr(4);
string secretShare = secretShares[i]["secretShare"].asString(); string secretShare = secretShares[i]["secretShare"].asString();
c.createBLSPrivateKey(blsName, etnKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t, n); auto response = c.createBLSPrivateKey(blsName, etnKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t, n);
REQUIRE(response["status"] == 0);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName); pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
REQUIRE(pubBLSKeys[i]["status"] == 0);
blsSigShares[i] = c.blsSignMessageHash(blsName, hash, t, n, i + 1); blsSigShares[i] = c.blsSignMessageHash(blsName, hash, t, n, i + 1);
REQUIRE(blsSigShares[i]["status"] == 0);
shared_ptr <string> sig_share_ptr = make_shared<string>(blsSigShares[i]["signatureShare"].asString()); shared_ptr <string> sig_share_ptr = make_shared<string>(blsSigShares[i]["signatureShare"].asString());
BLSSigShare sig(sig_share_ptr, i + 1, t, n); BLSSigShare sig(sig_share_ptr, i + 1, t, n);
sigShareSet.addSigShare(make_shared<BLSSigShare>(sig)); sigShareSet.addSigShare(make_shared<BLSSigShare>(sig));
...@@ -829,7 +827,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -829,7 +827,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
coeffsPubKeysMap[i + 1] = make_shared<BLSPublicKeyShare>(pubKey); coeffsPubKeysMap[i + 1] = make_shared<BLSPublicKeyShare>(pubKey);
} }
shared_ptr <BLSSignature> commonSig = sigShareSet.merge(); shared_ptr <BLSSignature> commonSig = sigShareSet.merge();
BLSPublicKey common_public(make_shared < map < size_t, shared_ptr < BLSPublicKeyShare >> > (coeffsPubKeysMap), t, BLSPublicKey common_public(make_shared < map < size_t, shared_ptr < BLSPublicKeyShare >> > (coeffsPubKeysMap), t,
n); n);
...@@ -1051,14 +1048,12 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") { ...@@ -1051,14 +1048,12 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") {
REQUIRE(status == 0); REQUIRE(status == 0);
REQUIRE( errStatus == 0 ); REQUIRE( errStatus == 0 );
vector<char> decr_key(BUF_LEN, 0); vector<char> decr_key(BUF_LEN, 0);
status = trustedDecryptKeyAES(eid, &errStatus, errMsg.data(), encrypted_key.data(), encLen, decr_key.data()); status = trustedDecryptKeyAES(eid, &errStatus, errMsg.data(), encrypted_key.data(), encLen, decr_key.data());
REQUIRE(status == 0); REQUIRE(status == 0);
REQUIRE( errStatus == 0 ); REQUIRE( errStatus == 0 );
REQUIRE(key.compare(decr_key.data()) == 0); REQUIRE(key.compare(decr_key.data()) == 0);
} }
TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") { TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") {
...@@ -1073,7 +1068,6 @@ TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") { ...@@ -1073,7 +1068,6 @@ TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") {
REQUIRE(status == 0); REQUIRE(status == 0);
REQUIRE( errStatus == 0 ); REQUIRE( errStatus == 0 );
vector<char> decr_key(BUF_LEN, 0); vector<char> decr_key(BUF_LEN, 0);
status = trustedDecryptKey(eid, &errStatus, errMsg.data(), encrypted_key.data(), encLen, decr_key.data()); status = trustedDecryptKey(eid, &errStatus, errMsg.data(), encrypted_key.data(), encLen, decr_key.data());
......
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