Unverified Commit 8bb6847a authored by Oleh's avatar Oleh

SKALE-3334 add verificationVectorMult to response

parent e075e5eb
......@@ -182,15 +182,39 @@ vector <vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
vector <string> g2Strings = splitString(pubShares.data(), ',');
vector <vector<string>> pubSharesVect;
vector <vector<string>> pubSharesVect(t);
for (uint64_t i = 0; i < g2Strings.size(); i++) {
vector <string> coeffStr = splitString(g2Strings.at(i).c_str(), ':');
pubSharesVect.push_back(coeffStr);
pubSharesVect[i] = coeffStr;
}
return pubSharesVect;
}
vector <vector<string>> getVerificationVectorMult(const std::string& encryptedPolyHex, int t, int n, size_t ind) {
auto verificationVector = get_verif_vect(encryptedPolyHex.c_str(), t, n);
vector<vector<string>> result(t);
for (size_t i = 0; i < t; ++i) {
libff::alt_bn128_G2 current_coefficient;
current_coefficient.X.c0 = libff::alt_bn128_Fq(verificationVector[i][0]);
current_coefficient.X.c1 = libff::alt_bn128_Fq(verificationVector[i][1]);
current_coefficient.Y.c0 = libff::alt_bn128_Fq(verificationVector[i][2]);
current_coefficient.Y.c1 = libff::alt_bn128_Fq(verificationVector[i][3]);
current_coefficient.Z = libff::alt_bn128_Fq2::one();
current_coefficient = current_coefficient * libff::power(libff::alt_bn128_Fr(ind + 1), i);
current_coefficient.to_affine_coordinates();
auto g2_str = convertG2ToString(current_coefficient);
result[i] = splitString(g2_str.c_str(), ':');
}
return result;
}
string
getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const vector <string> &_publicKeys,
int _t,
......
......@@ -35,6 +35,8 @@ string gen_dkg_poly( int _t);
vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int n);
vector <vector<string>> getVerificationVectorMult(const std::string& encryptedPolyHex, int t, int n, size_t ind);
vector<string> splitString(const char* coeffs, const char symbol);
string getSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n);
......
......@@ -388,7 +388,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
shared_ptr <string> encrPoly = readFromDb(_polyName);
verifVector = get_verif_vect(encrPoly->c_str(), _t, _n);
verifVector = get_verif_vect(encrPoly.get(), _t, _n);
for (int i = 0; i < _t; i++) {
vector <string> currentCoef = verifVector.at(i);
......@@ -603,6 +603,17 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result["share*G2"] = *shareG2_ptr;
result["dhKey"] = DHKey;
shared_ptr <string> encrPoly = readFromDb(_polyName);
verificationVectorMult = getVerificationVectorMult(encrPoly->c_str(), _t, _n, ind);
for (int i = 0; i < _t; i++) {
vector <string> currentCoef = verifVector.at(i);
for (int j = 0; j < 4; j++) {
result["verificationVectorMult"][i][j] = currentCoef.at(j);
}
}
// TODO: delete dh keys
// for (int i = 0; i < _n; i++) {
// string name = _polyName + "_" + to_string(i) + ":";
......
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