Implement VerifyRecoveredSig to allow verifcation of sigs found in P2P messages

This commit is contained in:
Alexander Block 2019-01-22 14:12:47 +01:00
parent 9f211ef12d
commit 4026ea203b
2 changed files with 16 additions and 0 deletions

View File

@ -548,4 +548,17 @@ bool CSigningManager::IsConflicting(Consensus::LLMQType llmqType, const uint256&
return false; return false;
} }
bool CSigningManager::VerifyRecoveredSig(Consensus::LLMQType llmqType, const uint256& signedAtTip, const uint256& id, const uint256& msgHash, const CBLSSignature& sig)
{
auto& llmqParams = Params().GetConsensus().llmqs.at(Params().GetConsensus().llmqTypeForChainLocks);
auto quorum = quorumManager->SelectQuorum(llmqParams.type, signedAtTip, id);
if (!quorum) {
return false;
}
uint256 signHash = CLLMQUtils::BuildSignHash(llmqParams.type, quorum->quorumHash, id, msgHash);
return sig.VerifyInsecure(quorum->quorumPublicKey, signHash);
}
} }

View File

@ -146,6 +146,9 @@ public:
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id); bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id);
bool HasRecoveredSigForSession(const uint256& signHash); bool HasRecoveredSigForSession(const uint256& signHash);
bool IsConflicting(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash); bool IsConflicting(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
// Verifies a recovered sig that was signed while the chain tip was at signedAtTip
bool VerifyRecoveredSig(Consensus::LLMQType llmqType, const uint256& signedAtTip, const uint256& id, const uint256& msgHash, const CBLSSignature& sig);
}; };
extern CSigningManager* quorumSigningManager; extern CSigningManager* quorumSigningManager;