Skip to content

Commit

Permalink
refactor: use more structured bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Dec 26, 2024
1 parent 2bd4703 commit fb0b5ac
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/llmq/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,22 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
pubKeys.reserve(messages.size());
messageHashes.reserve(messages.size());
bool first = true;
for (const auto& p : messages ) {
const auto& msg = *p.second;

auto member = session.GetMember(msg.proTxHash);
for (const auto& [nodeId, msg] : messages) {
auto member = session.GetMember(msg->proTxHash);
if (!member) {
// should not happen as it was verified before
ret.emplace(p.first);
ret.emplace(nodeId);
continue;
}

if (first) {
aggSig = msg.sig;
aggSig = msg->sig;
} else {
aggSig.AggregateInsecure(msg.sig);
aggSig.AggregateInsecure(msg->sig);
}
first = false;

auto msgHash = msg.GetSignHash();
auto msgHash = msg->GetSignHash();
if (!messageHashesSet.emplace(msgHash).second) {
// can only happen in 2 cases:
// 1. Someone sent us the same message twice but with differing signature, meaning that at least one of them
Expand Down Expand Up @@ -418,16 +416,15 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
// different nodes, let's figure out who are the bad ones
}

for (const auto& p : messages) {
if (ret.count(p.first)) {
for (const auto& [nodeId, msg] : messages) {
if (ret.count(nodeId)) {
continue;
}

const auto& msg = *p.second;
auto member = session.GetMember(msg.proTxHash);
bool valid = msg.sig.VerifyInsecure(member->dmn->pdmnState->pubKeyOperator.Get(), msg.GetSignHash());
auto member = session.GetMember(msg->proTxHash);
bool valid = msg->sig.VerifyInsecure(member->dmn->pdmnState->pubKeyOperator.Get(), msg->GetSignHash());
if (!valid) {
ret.emplace(p.first);
ret.emplace(nodeId);
}
}
return ret;
Expand Down

0 comments on commit fb0b5ac

Please sign in to comment.