Skip to content

Commit 4026ea2

Browse files
committed
Implement VerifyRecoveredSig to allow verifcation of sigs found in P2P messages
1 parent 9f211ef commit 4026ea2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/llmq/quorums_signing.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,17 @@ bool CSigningManager::IsConflicting(Consensus::LLMQType llmqType, const uint256&
548548
return false;
549549
}
550550

551+
bool CSigningManager::VerifyRecoveredSig(Consensus::LLMQType llmqType, const uint256& signedAtTip, const uint256& id, const uint256& msgHash, const CBLSSignature& sig)
552+
{
553+
auto& llmqParams = Params().GetConsensus().llmqs.at(Params().GetConsensus().llmqTypeForChainLocks);
554+
555+
auto quorum = quorumManager->SelectQuorum(llmqParams.type, signedAtTip, id);
556+
if (!quorum) {
557+
return false;
558+
}
559+
560+
uint256 signHash = CLLMQUtils::BuildSignHash(llmqParams.type, quorum->quorumHash, id, msgHash);
561+
return sig.VerifyInsecure(quorum->quorumPublicKey, signHash);
562+
}
563+
551564
}

src/llmq/quorums_signing.h

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class CSigningManager
146146
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id);
147147
bool HasRecoveredSigForSession(const uint256& signHash);
148148
bool IsConflicting(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
149+
150+
// Verifies a recovered sig that was signed while the chain tip was at signedAtTip
151+
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const uint256& signedAtTip, const uint256& id, const uint256& msgHash, const CBLSSignature& sig);
149152
};
150153

151154
extern CSigningManager* quorumSigningManager;

0 commit comments

Comments
 (0)