Skip to content
Merged
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
62 changes: 35 additions & 27 deletions src/llmq/signing_shares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,47 +1645,55 @@ void CSigSharesManager::SignPendingSigShares()
}
}

std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorum& quorum, const uint256& id, const uint256& msgHash) const
std::optional<CSigShare> CSigSharesManager::CreateSigShareForSingleMember(const CQuorum& quorum, const uint256& id, const uint256& msgHash) const
{
cxxtimer::Timer t(true);
auto activeMasterNodeProTxHash = m_mn_activeman.GetProTxHash();

if (!quorum.IsValidMember(activeMasterNodeProTxHash)) {
int memberIdx = quorum.GetMemberIndex(activeMasterNodeProTxHash);
if (memberIdx == -1) {
// this should really not happen (IsValidMember gave true)
return std::nullopt;
}

if (quorum.params.is_single_member()) {
int memberIdx = quorum.GetMemberIndex(activeMasterNodeProTxHash);
if (memberIdx == -1) {
// this should really not happen (IsValidMember gave true)
return std::nullopt;
}
CSigShare sigShare(quorum.params.type, quorum.qc->quorumHash, id, msgHash, uint16_t(memberIdx), {});
uint256 signHash = sigShare.buildSignHash().Get();

CSigShare sigShare(quorum.params.type, quorum.qc->quorumHash, id, msgHash, uint16_t(memberIdx), {});
uint256 signHash = sigShare.buildSignHash().Get();
// TODO: This one should be SIGN by QUORUM key, not by OPERATOR key
// see TODO in CDKGSession::FinalizeSingleCommitment for details
auto bls_scheme = bls::bls_legacy_scheme.load();
sigShare.sigShare.Set(m_mn_activeman.Sign(signHash, bls_scheme), bls_scheme);

// TODO: This one should be SIGN by QUORUM key, not by OPERATOR key
// see TODO in CDKGSession::FinalizeSingleCommitment for details
auto bls_scheme = bls::bls_legacy_scheme.load();
sigShare.sigShare.Set(m_mn_activeman.Sign(signHash, bls_scheme), bls_scheme);
if (!sigShare.sigShare.Get().IsValid()) {
LogPrintf("CSigSharesManager::%s -- failed to sign sigShare. signHash=%s, id=%s, msgHash=%s, time=%s\n",
__func__, signHash.ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(),
t.count());
return std::nullopt;
}

if (!sigShare.sigShare.Get().IsValid()) {
LogPrintf("CSigSharesManager::%s -- failed to sign sigShare. signHash=%s, id=%s, msgHash=%s, time=%s\n",
__func__, signHash.ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(),
t.count());
return std::nullopt;
}
sigShare.UpdateKey();

LogPrint(BCLog::LLMQ_SIGS, /* Continued */
"CSigSharesManager::%s -- created sigShare. signHash=%s, id=%s, msgHash=%s, llmqType=%d, quorum=%s, "
"time=%s\n",
__func__, signHash.ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(),
ToUnderlying(quorum.params.type), quorum.qc->quorumHash.ToString(), t.count());

sigShare.UpdateKey();
return sigShare;
}

LogPrint(BCLog::LLMQ_SIGS, /* Continued */
"CSigSharesManager::%s -- created sigShare. signHash=%s, id=%s, msgHash=%s, llmqType=%d, quorum=%s, "
"time=%s\n",
__func__, signHash.ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(),
ToUnderlying(quorum.params.type), quorum.qc->quorumHash.ToString(), t.count());
std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorum& quorum, const uint256& id, const uint256& msgHash) const
{
auto activeMasterNodeProTxHash = m_mn_activeman.GetProTxHash();

return sigShare;
if (!quorum.IsValidMember(activeMasterNodeProTxHash)) {
return std::nullopt;
}

if (quorum.params.is_single_member()) {
return CreateSigShareForSingleMember(quorum, id, msgHash);
}
cxxtimer::Timer t(true);
const CBLSSecretKey& skShare = quorum.GetSkShare();
if (!skShare.IsValid()) {
LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::%s -- we don't have our skShare for quorum %s\n", __func__, quorum.qc->quorumHash.ToString());
Expand Down
2 changes: 2 additions & 0 deletions src/llmq/signing_shares.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ class CSigSharesManager : public CRecoveredSigsListener
void NotifyRecoveredSig(const std::shared_ptr<const CRecoveredSig>& sig) const EXCLUSIVE_LOCKS_REQUIRED(!cs);

private:
std::optional<CSigShare> CreateSigShareForSingleMember(const CQuorum& quorum, const uint256& id, const uint256& msgHash) const;

// all of these return false when the currently processed message should be aborted (as each message actually contains multiple messages)
bool ProcessMessageSigSesAnn(const CNode& pfrom, const CSigSesAnn& ann) EXCLUSIVE_LOCKS_REQUIRED(!cs);
bool ProcessMessageSigSharesInv(const CNode& pfrom, const CSigSharesInv& inv) EXCLUSIVE_LOCKS_REQUIRED(!cs);
Expand Down
Loading