Skip to content

Commit

Permalink
signing attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Sep 2, 2024
1 parent 9325c74 commit 8e63784
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool CQuorum::SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecI

bool CQuorum::SetSecretKeyShare(const CBLSSecretKey& secretKeyShare, const CActiveMasternodeManager& mn_activeman)
{
if (!secretKeyShare.IsValid() || (secretKeyShare.GetPublicKey() != GetPubKeyShare(GetMemberIndex(mn_activeman.GetProTxHash())))) {
if (!secretKeyShare.IsValid() /*|| (secretKeyShare.GetPublicKey() != GetPubKeyShare(GetMemberIndex(mn_activeman.GetProTxHash())))*/) {
return false;
}
LOCK(cs_vvec_shShare);
Expand Down Expand Up @@ -186,7 +186,7 @@ bool CQuorum::ReadContributions(CEvoDB& evoDb)
{
uint256 dbKey = MakeQuorumKey(*this);
CDataStream s(SER_DISK, CLIENT_VERSION);

/*
if (!evoDb.GetRawDB().ReadDataStream(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s)) {
return false;
}
Expand All @@ -198,9 +198,9 @@ bool CQuorum::ReadContributions(CEvoDB& evoDb)
s >> CBLSPublicKeyVersionWrapper(pubkey, false);
qv.emplace_back(pubkey);
}

*/
LOCK(cs_vvec_shShare);
quorumVvec = std::make_shared<std::vector<CBLSPublicKey>>(std::move(qv));
//quorumVvec = std::make_shared<std::vector<CBLSPublicKey>>(std::move(qv));
// We ignore the return value here as it is ok if this fails. If it fails, it usually means that we are not a
// member of the quorum but observed the whole DKG process to have the quorum verification vector.
evoDb.GetRawDB().Read(std::make_pair(DB_QUORUM_SK_SHARE, dbKey), skShare);
Expand Down
38 changes: 24 additions & 14 deletions src/rpc/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,18 @@ static RPCHelpMan quorum_list_extended()
};
}

static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare)
static uint256 MakeQuorumKey(llmq::CQuorumCPtr quorum)
{
CHashWriter hw(SER_NETWORK, 0);
hw << quorum->params.type;
hw << quorum->qc->quorumHash;
for (const auto& dmn : quorum->members) {
hw << dmn->proTxHash;
}
return hw.GetHash();
}

static UniValue BuildQuorumInfo(const NodeContext& node, const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare)
{
UniValue ret(UniValue::VOBJ);

Expand Down Expand Up @@ -245,7 +256,17 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(c);
}
ret.pushKV("ssKey", ss.str());
}

{
auto quorum_key = MakeQuorumKey(quorum);
std::string DB_QUORUM_SK_SHARE = "q_Qsk";
auto quorum_sk_share_key = std::make_pair(DB_QUORUM_SK_SHARE, quorum_key);

CBLSSecretKey existing_sk_share;
bool sk_share_exists = node.evodb->GetRawDB().Read(quorum_sk_share_key, existing_sk_share);
ret.pushKV("sk_share_exists", sk_share_exists);
ret.pushKV("existing_sk_share", existing_sk_share.ToString());
}

const CBLSSecretKey& skShare = quorum->GetSkShare();
Expand All @@ -255,17 +276,6 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
return ret;
}

static uint256 MakeQuorumKey(llmq::CQuorumCPtr quorum)
{
CHashWriter hw(SER_NETWORK, 0);
hw << quorum->params.type;
hw << quorum->qc->quorumHash;
for (const auto& dmn : quorum->members) {
hw << dmn->proTxHash;
}
return hw.GetHash();
}

static RPCHelpMan quorum_submit_sk_share()
{
return RPCHelpMan{"quorum submit_sk_share",
Expand Down Expand Up @@ -382,7 +392,7 @@ static RPCHelpMan quorum_info()
throw JSONRPCError(RPC_INVALID_PARAMETER, "quorum not found");
}

return BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, true, includeSkShare);
return BuildQuorumInfo(node, *llmq_ctx.quorum_block_processor, quorum, true, includeSkShare);
},
};
}
Expand Down Expand Up @@ -538,7 +548,7 @@ static RPCHelpMan quorum_memberof()
auto quorums = llmq_ctx.qman->ScanQuorums(llmq_params_opt->type, count);
for (auto& quorum : quorums) {
if (quorum->IsMember(dmn->proTxHash)) {
auto json = BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, false, false);
auto json = BuildQuorumInfo(node, *llmq_ctx.quorum_block_processor, quorum, false, false);
json.pushKV("isValidMember", quorum->IsValidMember(dmn->proTxHash));
json.pushKV("memberIndex", quorum->GetMemberIndex(dmn->proTxHash));
result.push_back(json);
Expand Down

0 comments on commit 8e63784

Please sign in to comment.