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
10 changes: 6 additions & 4 deletions src/bench/bls_dkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ struct DKG

DKG(int quorumSize)
{
members.resize(quorumSize);
ids.resize(quorumSize);
members.reserve(quorumSize);
ids.reserve(quorumSize);

for (int i = 0; i < quorumSize; i++) {
members[i].id.SetInt(i + 1);
ids[i] = members[i].id;
uint256 id;
WriteLE64(id.begin(), i + 1);
members.push_back({id, {}, {}});
ids.emplace_back(id);
}

for (int i = 0; i < quorumSize; i++) {
Expand Down
25 changes: 2 additions & 23 deletions src/bls/bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,13 @@
#include <assert.h>
#include <string.h>

void CBLSId::SetInt(int x)
CBLSId::CBLSId(const uint256& nHash) : CBLSWrapper<CBLSIdImplicit, BLS_CURVE_ID_SIZE, CBLSId>()
{
impl.SetHex(strprintf("%x", x));
impl = nHash;
fValid = true;
UpdateHash();
}

void CBLSId::SetHash(const uint256& hash)
{
impl = hash;
fValid = true;
UpdateHash();
}

CBLSId CBLSId::FromInt(int64_t i)
{
CBLSId id;
id.SetInt(i);
return id;
}

CBLSId CBLSId::FromHash(const uint256& hash)
{
CBLSId id;
id.SetHash(hash);
return id;
}

void CBLSSecretKey::AggregateInsecure(const CBLSSecretKey& o)
{
assert(IsValid() && o.IsValid());
Expand Down
7 changes: 1 addition & 6 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,7 @@ class CBLSId : public CBLSWrapper<CBLSIdImplicit, BLS_CURVE_ID_SIZE, CBLSId>
using CBLSWrapper::operator!=;

CBLSId() {}

void SetInt(int x);
void SetHash(const uint256& hash);

static CBLSId FromInt(int64_t i);
static CBLSId FromHash(const uint256& hash);
CBLSId(const uint256& nHash);
};

class CBLSSecretKey : public CBLSWrapper<bls::PrivateKey, BLS_CURVE_SECKEY_SIZE, CBLSSecretKey>
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CBLSPublicKey CQuorum::GetPubKeyShare(size_t memberIdx) const
return CBLSPublicKey();
}
auto& m = members[memberIdx];
return blsCache.BuildPubKeyShare(m->proTxHash, quorumVvec, CBLSId::FromHash(m->proTxHash));
return blsCache.BuildPubKeyShare(m->proTxHash, quorumVvec, CBLSId(m->proTxHash));
}

CBLSSecretKey CQuorum::GetSkShare() const
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CDKGPrematureCommitment::CDKGPrematureCommitment(const Consensus::LLMQParams& pa
CDKGMember::CDKGMember(CDeterministicMNCPtr _dmn, size_t _idx) :
dmn(_dmn),
idx(_idx),
id(CBLSId::FromHash(_dmn->proTxHash))
id(_dmn->proTxHash)
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_signing_shares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
for (auto it = sigShares->begin(); it != sigShares->end() && sigSharesForRecovery.size() < quorum->params.threshold; ++it) {
auto& sigShare = it->second;
sigSharesForRecovery.emplace_back(sigShare.sigShare.Get());
idsForRecovery.emplace_back(CBLSId::FromHash(quorum->members[sigShare.quorumMember]->proTxHash));
idsForRecovery.emplace_back(quorum->members[sigShare.quorumMember]->proTxHash);
}

// check if we can recover the final signature
Expand Down