Unverified Commit 755886fb authored by kladko's avatar kladko

SKALE-2678-BLS-test-vectors

parent ee569dda
...@@ -536,7 +536,8 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares test", "[dkg-aes- ...@@ -536,7 +536,8 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares test", "[dkg-aes-
void doDKG(StubClient &c, int n, int t) { void doDKG(StubClient &c, int n, int t, vector<string>& _blsPrivateKeyNames,
int schainID, int dkgID) {
Json::Value ethKeys[n]; Json::Value ethKeys[n];
Json::Value verifVects[n]; Json::Value verifVects[n];
...@@ -547,8 +548,10 @@ void doDKG(StubClient &c, int n, int t) { ...@@ -547,8 +548,10 @@ void doDKG(StubClient &c, int n, int t) {
vector<string> pubShares(n); vector<string> pubShares(n);
vector<string> polyNames(n); vector<string> polyNames(n);
int schainID = TestUtils::randGen(); _blsPrivateKeyNames.clear();
int dkgID = TestUtils::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();
CHECK_STATE(ethKeys[i]["status"] == 0); CHECK_STATE(ethKeys[i]["status"] == 0);
...@@ -617,6 +620,7 @@ void doDKG(StubClient &c, int n, int t) { ...@@ -617,6 +620,7 @@ void doDKG(StubClient &c, int n, int t) {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
string endName = polyNames[i].substr(4); string endName = polyNames[i].substr(4);
string blsName = "BLS_KEY" + polyNames[i].substr(4); string blsName = "BLS_KEY" + polyNames[i].substr(4);
_blsPrivateKeyNames.push_back(blsName);
string secretShare = secretShares[i]["secretShare"].asString(); string secretShare = secretShares[i]["secretShare"].asString();
auto response = c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t, auto response = c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], t,
...@@ -647,17 +651,34 @@ void doDKG(StubClient &c, int n, int t) { ...@@ -647,17 +651,34 @@ void doDKG(StubClient &c, int n, int t) {
} }
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 blsPublicKey(make_shared<map<size_t, shared_ptr<BLSPublicKeyShare >>>(coeffsPubKeysMap), t,
n); n);
CHECK_STATE(common_public.VerifySigWithHelper(hash_arr, commonSig, t, n)); CHECK_STATE(blsPublicKey.VerifySigWithHelper(hash_arr, commonSig, t, n));
for (auto&& i : _blsPrivateKeyNames)
cerr << i << endl;
} }
TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
doDKG(c, 4, 1);
doDKG(c, 16, 5); vector<string> blsKeyNames;
int schainID = TestUtils::randGen();
int dkgID = TestUtils::randGen();
doDKG(c, 4, 1, blsKeyNames, schainID, dkgID);
REQUIRE(blsKeyNames.size() == 4);
schainID = TestUtils::randGen();
dkgID = TestUtils::randGen();
doDKG(c, 16, 5, blsKeyNames, schainID, dkgID);
} }
......
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