Unverified Commit 0aedc499 authored by kladko's avatar kladko

Fixed docs

parent 6428536a
...@@ -73,7 +73,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -73,7 +73,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "testw.h" #include "testw.h"
using namespace jsonrpc; using namespace jsonrpc;
using namespace std; using namespace std;
...@@ -189,7 +188,6 @@ libff::alt_bn128_G2 vectStringToG2(const vector <string> &G2_str_vect) { ...@@ -189,7 +188,6 @@ libff::alt_bn128_G2 vectStringToG2(const vector <string> &G2_str_vect) {
} }
void sendRPCRequest() { void sendRPCRequest() {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
...@@ -197,31 +195,31 @@ void sendRPCRequest() { ...@@ -197,31 +195,31 @@ void sendRPCRequest() {
int n = 16, t = 16; int n = 16, t = 16;
Json::Value EthKeys[n]; Json::Value ethKeys[n];
Json::Value verifVects[n]; Json::Value verifVects[n];
Json::Value pubEthKeys; Json::Value pubEthKeys;
Json::Value secretShares[n]; Json::Value secretShares[n];
Json::Value pubBLSKeys[n]; Json::Value pubBLSKeys[n];
Json::Value blsSigShares[n]; Json::Value blsSigShares[n];
vector <string> pubShares(n); vector <string> pubShares(n);
vector <string> poly_names(n); vector <string> polyNames(n);
int schainID = randGen(); int schainID = randGen();
int dkgID = randGen(); int dkgID = randGen();
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
EthKeys[i] = c.generateECDSAKey(); ethKeys[i] = c.generateECDSAKey();
string polyName = string polyName =
"POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID); "POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID);
c.generateDKGPoly(polyName, t); c.generateDKGPoly(polyName, t);
poly_names[i] = polyName; polyNames[i] = polyName;
verifVects[i] = c.getVerificationVector(polyName, t, n); verifVects[i] = c.getVerificationVector(polyName, t, n);
REQUIRE(verifVects[i]["status"] == 0); REQUIRE(verifVects[i]["status"] == 0);
pubEthKeys.append(EthKeys[i]["publicKey"]); pubEthKeys.append(ethKeys[i]["publicKey"]);
} }
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n); secretShares[i] = c.getSecretShare(polyNames[i], pubEthKeys, t, n);
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++) {
string pubShare = verifVects[i]["Verification Vector"][k][j].asString(); string pubShare = verifVects[i]["Verification Vector"][k][j].asString();
...@@ -233,14 +231,14 @@ void sendRPCRequest() { ...@@ -233,14 +231,14 @@ void sendRPCRequest() {
int k = 0; int k = 0;
vector <string> secShares_vect(n); vector <string> secShares(n);
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192); string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192);
secShares_vect[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192); secShares[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192);
Json::Value verif = c.dkgVerification(pubShares[i], EthKeys[j]["keyName"].asString(), secretShare, t, n, j); Json::Value verif = c.dkgVerification(pubShares[i], ethKeys[j]["keyName"].asString(), secretShare, t, n, j);
k++; k++;
...@@ -262,11 +260,11 @@ void sendRPCRequest() { ...@@ -262,11 +260,11 @@ void sendRPCRequest() {
for (int i = 0; i < t; i++) { for (int i = 0; i < t; i++) {
string endName = poly_names[i].substr(4); string endName = polyNames[i].substr(4);
string blsName = "BLS_KEY" + poly_names[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, EthKeys[i]["keyName"].asString(), poly_names[i], secShares_vect[i], t, c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t,
n); n);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName); pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
...@@ -282,8 +280,7 @@ void sendRPCRequest() { ...@@ -282,8 +280,7 @@ void sendRPCRequest() {
} }
shared_ptr <BLSSignature> commonSig = sigShareSet.merge(); shared_ptr <BLSSignature> commonSig = sigShareSet.merge();
} }
...@@ -341,13 +338,13 @@ TEST_CASE_METHOD(FixtureResetDB, "ECDSA keygen and signature test", "[ecdsa-key- ...@@ -341,13 +338,13 @@ TEST_CASE_METHOD(FixtureResetDB, "ECDSA keygen and signature test", "[ecdsa-key-
string hex = SAMPLE_HEX_HASH; string hex = SAMPLE_HEX_HASH;
vector<char> signature_r(BUF_LEN, 0); vector<char> signatureR(BUF_LEN, 0);
vector<char> signature_s(BUF_LEN, 0); vector<char> signatureS(BUF_LEN, 0);
uint8_t signature_v = 0; uint8_t signatureV = 0;
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen, (unsigned char *) hex.data(), status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen, (unsigned char *) hex.data(),
signature_r.data(), signatureR.data(),
signature_s.data(), &signature_v, 16); signatureS.data(), &signatureV, 16);
REQUIRE(status == SGX_SUCCESS); REQUIRE(status == SGX_SUCCESS);
} }
...@@ -666,7 +663,6 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -666,7 +663,6 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") {
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
int n = 16, t = 16; int n = 16, t = 16;
Json::Value etnKeys[n]; Json::Value etnKeys[n];
Json::Value verifVects[n]; Json::Value verifVects[n];
...@@ -707,7 +703,7 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -707,7 +703,7 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") {
int k = 0; int k = 0;
vector <string> secShares_vect(n); vector <string> secShares(n);
vector <string> pSharesBad(pubShares); vector <string> pSharesBad(pubShares);
...@@ -716,7 +712,7 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -716,7 +712,7 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") {
string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192); string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192);
secShares_vect[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192); secShares[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192);
bool res = c.dkgVerification(pubShares[i], etnKeys[j]["keyName"].asString(), secretShare, t, n, bool res = c.dkgVerification(pubShares[i], etnKeys[j]["keyName"].asString(), secretShare, t, n,
j)["result"].asBool(); j)["result"].asBool();
k++; k++;
...@@ -751,7 +747,7 @@ TEST_CASE_METHOD(Fixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -751,7 +747,7 @@ TEST_CASE_METHOD(Fixture, "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_vect[i], t, n); c.createBLSPrivateKey(blsName, etnKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t, n);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName); pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
blsSigShares[i] = c.blsSignMessageHash(blsName, hash, t, n, i + 1); blsSigShares[i] = c.blsSignMessageHash(blsName, hash, t, n, i + 1);
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());
...@@ -786,9 +782,6 @@ TEST_CASE_METHOD(FixtureResetDB, "Get ServerStatus", "[get-server-status]") { ...@@ -786,9 +782,6 @@ TEST_CASE_METHOD(FixtureResetDB, "Get ServerStatus", "[get-server-status]") {
} }
TEST_CASE_METHOD(FixtureResetDB, "DKG API test", "[dkg-api]") { TEST_CASE_METHOD(FixtureResetDB, "DKG API test", "[dkg-api]") {
...@@ -883,31 +876,31 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") { ...@@ -883,31 +876,31 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
int n = 2, t = 2; int n = 2, t = 2;
Json::Value EthKeys[n]; Json::Value ethKeys[n];
Json::Value verifVects[n]; Json::Value verifVects[n];
Json::Value pubEthKeys; Json::Value pubEthKeys;
Json::Value secretShares[n]; Json::Value secretShares[n];
Json::Value pubBLSKeys[n]; Json::Value pubBLSKeys[n];
Json::Value blsSigShares[n]; Json::Value blsSigShares[n];
vector <string> pubShares(n); vector <string> pubShares(n);
vector <string> poly_names(n); vector <string> polyNames(n);
int schainID = randGen(); int schainID = randGen();
int dkgID = randGen(); int dkgID = randGen();
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
EthKeys[i] = c.generateECDSAKey(); ethKeys[i] = c.generateECDSAKey();
string polyName = string polyName =
"POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID); "POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID);
REQUIRE(EthKeys[i]["status"] == 0); REQUIRE(ethKeys[i]["status"] == 0);
c.generateDKGPoly(polyName, t); c.generateDKGPoly(polyName, t);
poly_names[i] = polyName; polyNames[i] = polyName;
verifVects[i] = c.getVerificationVector(polyName, t, n); verifVects[i] = c.getVerificationVector(polyName, t, n);
pubEthKeys.append(EthKeys[i]["publicKey"]); pubEthKeys.append(ethKeys[i]["publicKey"]);
} }
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n); secretShares[i] = c.getSecretShare(polyNames[i], pubEthKeys, t, n);
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++)
...@@ -919,21 +912,21 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") { ...@@ -919,21 +912,21 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
} }
int k = 0; int k = 0;
vector <string> secShares_vect(n); vector <string> secShares(n);
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192); string secretShare = secretShares[i]["secretShare"].asString().substr(192 * j, 192);
secShares_vect[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192); secShares[i] += secretShares[j]["secretShare"].asString().substr(192 * i, 192);
Json::Value verif = c.dkgVerification(pubShares[i], EthKeys[j]["keyName"].asString(), secretShare, t, n, j); Json::Value verif = c.dkgVerification(pubShares[i], ethKeys[j]["keyName"].asString(), secretShare, t, n, j);
bool res = verif["result"].asBool(); bool res = verif["result"].asBool();
k++; k++;
REQUIRE(res); REQUIRE(res);
} }
Json::Value complaintResponse = c.complaintResponse(poly_names[1], 0); Json::Value complaintResponse = c.complaintResponse(polyNames[1], 0);
REQUIRE(complaintResponse["status"] == 0); REQUIRE(complaintResponse["status"] == 0);
...@@ -941,7 +934,8 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") { ...@@ -941,7 +934,8 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
string hash = SAMPLE_HASH; string hash = SAMPLE_HASH;
auto hash_arr = make_shared < array < uint8_t, 32 >> (); auto hash_arr = make_shared < array < uint8_t,
32 >> ();
uint64_t binLen; uint64_t binLen;
...@@ -953,9 +947,9 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") { ...@@ -953,9 +947,9 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map; map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map;
for (int i = 0; i < t; i++) { for (int i = 0; i < t; i++) {
string endName = poly_names[i].substr(4); string endName = polyNames[i].substr(4);
string blsName = "BLS_KEY" + poly_names[i].substr(4); string blsName = "BLS_KEY" + polyNames[i].substr(4);
c.createBLSPrivateKey(blsName, EthKeys[i]["keyName"].asString(), poly_names[i], secShares_vect[i], t, n); c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t, n);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName); pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
REQUIRE(pubBLSKeys[i]["status"] == 0); REQUIRE(pubBLSKeys[i]["status"] == 0);
...@@ -1011,7 +1005,6 @@ TEST_CASE_METHOD(FixtureResetDB, "AES encrypt/decrypt", "[AES-encrypt-decrypt]") ...@@ -1011,7 +1005,6 @@ TEST_CASE_METHOD(FixtureResetDB, "AES encrypt/decrypt", "[AES-encrypt-decrypt]")
} }
TEST_CASE_METHOD(Fixture, "Many threads ecdsa dkg bls", "[many-threads-ecdsa-dkg-bls]") { TEST_CASE_METHOD(Fixture, "Many threads ecdsa dkg bls", "[many-threads-ecdsa-dkg-bls]") {
vector <thread> threads; vector <thread> threads;
......
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