Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bls/bls_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ CBLSPublicKey CBLSWorker::BuildPubKeyShare(const BLSVerificationVectorPtr& vvec,
void CBLSWorker::AsyncVerifyContributionShares(const CBLSId& forId, const std::vector<BLSVerificationVectorPtr>& vvecs, const BLSSecretKeyVector& skShares,
bool parallel, bool aggregated, std::function<void(const std::vector<bool>&)> doneCallback)
{
if (vvecs.empty()) {
doneCallback(std::vector<bool>{});
return;
}
if (!forId.IsValid() || !VerifyVerificationVectors(vvecs)) {
std::vector<bool> result;
result.assign(vvecs.size(), false);
Expand Down
5 changes: 5 additions & 0 deletions src/llmq/quorums_dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ void CDKGSession::VerifyPendingContributions()
skContributions.emplace_back(receivedSkContributions[idx]);
}

// All pending members may have been marked bad after they were enqueued.
if (memberIndexes.empty()) {
return;
}

auto result = blsWorker.VerifyContributionShares(myId, vvecs, skContributions);
if (result.size() != memberIndexes.size()) {
logger.Batch("VerifyContributionShares returned result of size %d but size %d was expected, something is wrong", result.size(), memberIndexes.size());
Expand Down
25 changes: 25 additions & 0 deletions src/test/bls_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "bls/bls.h"
#include "bls/bls_batchverifier.h"
#include "bls/bls_worker.h"
#include "test/test_bitcoin.h"

#include <boost/test/unit_test.hpp>
Expand Down Expand Up @@ -154,4 +155,28 @@ BOOST_AUTO_TEST_CASE(batch_verifier_tests)
Verify(msgs);
}

BOOST_AUTO_TEST_CASE(bls_verify_contribution_shares_empty_vvecs_tests)
{
CBLSWorker worker;
worker.Start();

const CBLSId id{uint256S("1")};
BOOST_REQUIRE(id.IsValid());

const std::vector<BLSVerificationVectorPtr> vvecs;
const BLSSecretKeyVector skShares;

for (const bool aggregated : {true, false}) {
bool completed = false;
worker.AsyncVerifyContributionShares(id, vvecs, skShares, true, aggregated,
[&](const std::vector<bool>& result) {
BOOST_CHECK(result.empty());
completed = true;
});
BOOST_CHECK(completed);
}

worker.Stop();
}

BOOST_AUTO_TEST_SUITE_END()