6 #ifndef PIVX_BLS_BLS_WORKER_H
7 #define PIVX_BLS_BLS_WORKER_H
72 size_t start,
size_t count,
bool parallel,
75 size_t start,
size_t count,
bool parallel);
77 size_t start = 0,
size_t count = 0,
bool parallel =
true);
85 size_t start,
size_t count,
bool parallel,
88 size_t start,
size_t count,
bool parallel);
92 size_t start,
size_t count,
bool parallel,
95 size_t start,
size_t count,
bool parallel);
99 size_t start,
size_t count,
bool parallel,
102 size_t start,
size_t count,
bool parallel);
116 bool parallel,
bool aggregated, std::function<
void(
const std::vector<bool>&)> doneCallback);
118 bool parallel,
bool aggregated);
120 bool parallel =
true,
bool aggregated =
true);
154 std::map<uint256, std::shared_future<BLSVerificationVectorPtr> >
vvecCache;
182 template <
typename T,
typename Builder>
186 auto it = cache.find(cacheKey);
187 if (it != cache.end()) {
194 cache.emplace(cacheKey, p.get_future());
std::vector< CBLSId > BLSIdVector
std::vector< CBLSPublicKey > BLSVerificationVector
std::vector< CBLSPublicKey > BLSPublicKeyVector
std::shared_ptr< BLSVerificationVector > BLSVerificationVectorPtr
std::vector< CBLSSecretKey > BLSSecretKeyVector
std::vector< CBLSSignature > BLSSignatureVector
BLSVerificationVectorPtr BuildQuorumVerificationVector(const uint256 &cacheKey, const std::vector< BLSVerificationVectorPtr > &vvecs)
std::map< uint256, std::shared_future< BLSVerificationVectorPtr > > vvecCache
CBLSPublicKey BuildPubKeyShare(const uint256 &cacheKey, const BLSVerificationVectorPtr &vvec, const CBLSId &id)
CBLSWorkerCache(CBLSWorker &_worker)
std::map< uint256, std::shared_future< CBLSPublicKey > > publicKeyShareCache
std::map< uint256, std::shared_future< CBLSSecretKey > > secretKeyShareCache
T GetOrBuild(const uint256 &cacheKey, std::map< uint256, std::shared_future< T > > &cache, Builder &&builder)
CBLSSecretKey AggregateSecretKeys(const uint256 &cacheKey, const BLSSecretKeyVector &skShares)
int sigVerifyBatchesInProgress
void AsyncBuildQuorumVerificationVector(const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start, size_t count, bool parallel, std::function< void(const BLSVerificationVectorPtr &)> doneCallback)
CBLSSecretKey AggregateSecretKeys(const BLSSecretKeyVector &secKeys, size_t start=0, size_t count=0, bool parallel=true)
void AsyncAggregatePublicKeys(const BLSPublicKeyVector &pubKeys, size_t start, size_t count, bool parallel, std::function< void(const CBLSPublicKey &)> doneCallback)
bool VerifySecretKeyVector(const BLSSecretKeyVector &secKeys, size_t start=0, size_t count=0)
void AsyncVerifyContributionShares(const CBLSId &forId, const std::vector< BLSVerificationVectorPtr > &vvecs, const BLSSecretKeyVector &skShares, bool parallel, bool aggregated, std::function< void(const std::vector< bool > &)> doneCallback)
bool VerifyContributionShare(const CBLSId &forId, const BLSVerificationVectorPtr &vvec, const CBLSSecretKey &skContribution)
bool IsAsyncVerifyInProgress()
void AsyncSign(const CBLSSecretKey &secKey, const uint256 &msgHash, SignDoneCallback doneCallback)
ctpl::thread_pool workerPool
std::mutex sigVerifyMutex
std::vector< bool > VerifyContributionShares(const CBLSId &forId, const std::vector< BLSVerificationVectorPtr > &vvecs, const BLSSecretKeyVector &skShares, bool parallel=true, bool aggregated=true)
CBLSPublicKey BuildPubKeyShare(const BLSVerificationVectorPtr &vvec, const CBLSId &id)
BLSVerificationVectorPtr BuildQuorumVerificationVector(const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start=0, size_t count=0, bool parallel=true)
void AsyncAggregateSecretKeys(const BLSSecretKeyVector &secKeys, size_t start, size_t count, bool parallel, std::function< void(const CBLSSecretKey &)> doneCallback)
CBLSPublicKey AggregatePublicKeys(const BLSPublicKeyVector &pubKeys, size_t start=0, size_t count=0, bool parallel=true)
bool VerifyVerificationVector(const BLSVerificationVector &vvec, size_t start=0, size_t count=0)
static const int SIG_VERIFY_BATCH_SIZE
std::function< void(const CBLSSignature &)> SignDoneCallback
void AsyncAggregateSigs(const BLSSignatureVector &sigs, size_t start, size_t count, bool parallel, std::function< void(const CBLSSignature &)> doneCallback)
std::vector< SigVerifyJob > sigVerifyQueue
bool VerifyVerificationVectors(const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start=0, size_t count=0)
CBLSSignature AggregateSigs(const BLSSignatureVector &sigs, size_t start=0, size_t count=0, bool parallel=true)
std::future< bool > AsyncVerifyContributionShare(const CBLSId &forId, const BLSVerificationVectorPtr &vvec, const CBLSSecretKey &skContribution)
std::function< bool()> CancelCond
bool VerifySignatureVector(const BLSSignatureVector &sigs, size_t start=0, size_t count=0)
void AsyncVerifySig(const CBLSSignature &sig, const CBLSPublicKey &pubKey, const uint256 &msgHash, SigVerifyDoneCallback doneCallback, CancelCond cancelCond=[] { return false;})
std::function< void(bool)> SigVerifyDoneCallback
void PushSigVerifyBatch()
bool GenerateContributions(int threshold, const BLSIdVector &ids, BLSVerificationVectorPtr &vvecRet, BLSSecretKeyVector &skShares)
#define T(expected, seed, data)
SigVerifyDoneCallback doneCallback
SigVerifyJob(SigVerifyDoneCallback &&_doneCallback, CancelCond &&_cancelCond, const CBLSSignature &_sig, const CBLSPublicKey &_pubKey, const uint256 &_msgHash)