PIVX Core  5.6.99
P2P Digital Currency
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CBLSWorker Class Reference

#include <bls_worker.h>

Collaboration diagram for CBLSWorker:
[legend]

Classes

struct  SigVerifyJob
 

Public Types

typedef std::function< void(const CBLSSignature &)> SignDoneCallback
 
typedef std::function< void(bool)> SigVerifyDoneCallback
 
typedef std::function< bool()> CancelCond
 

Public Member Functions

 CBLSWorker ()
 
 ~CBLSWorker ()
 
void Start ()
 
void Stop ()
 
bool GenerateContributions (int threshold, const BLSIdVector &ids, BLSVerificationVectorPtr &vvecRet, BLSSecretKeyVector &skShares)
 
void AsyncBuildQuorumVerificationVector (const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start, size_t count, bool parallel, std::function< void(const BLSVerificationVectorPtr &)> doneCallback)
 
std::future< BLSVerificationVectorPtrAsyncBuildQuorumVerificationVector (const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start, size_t count, bool parallel)
 
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)
 
std::future< CBLSSecretKeyAsyncAggregateSecretKeys (const BLSSecretKeyVector &secKeys, size_t start, size_t count, bool parallel)
 
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)
 
std::future< CBLSPublicKeyAsyncAggregatePublicKeys (const BLSPublicKeyVector &pubKeys, size_t start, size_t count, bool parallel)
 
CBLSPublicKey AggregatePublicKeys (const BLSPublicKeyVector &pubKeys, size_t start=0, size_t count=0, bool parallel=true)
 
void AsyncAggregateSigs (const BLSSignatureVector &sigs, size_t start, size_t count, bool parallel, std::function< void(const CBLSSignature &)> doneCallback)
 
std::future< CBLSSignatureAsyncAggregateSigs (const BLSSignatureVector &sigs, size_t start, size_t count, bool parallel)
 
CBLSSignature AggregateSigs (const BLSSignatureVector &sigs, size_t start=0, size_t count=0, bool parallel=true)
 
CBLSPublicKey BuildPubKeyShare (const BLSVerificationVectorPtr &vvec, const CBLSId &id)
 
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)
 
std::future< std::vector< bool > > AsyncVerifyContributionShares (const CBLSId &forId, const std::vector< BLSVerificationVectorPtr > &vvecs, const BLSSecretKeyVector &skShares, bool parallel, bool aggregated)
 
std::vector< bool > VerifyContributionShares (const CBLSId &forId, const std::vector< BLSVerificationVectorPtr > &vvecs, const BLSSecretKeyVector &skShares, bool parallel=true, bool aggregated=true)
 
std::future< bool > AsyncVerifyContributionShare (const CBLSId &forId, const BLSVerificationVectorPtr &vvec, const CBLSSecretKey &skContribution)
 
bool VerifyContributionShare (const CBLSId &forId, const BLSVerificationVectorPtr &vvec, const CBLSSecretKey &skContribution)
 
bool VerifyVerificationVector (const BLSVerificationVector &vvec, size_t start=0, size_t count=0)
 
bool VerifyVerificationVectors (const std::vector< BLSVerificationVectorPtr > &vvecs, size_t start=0, size_t count=0)
 
bool VerifySecretKeyVector (const BLSSecretKeyVector &secKeys, size_t start=0, size_t count=0)
 
bool VerifySignatureVector (const BLSSignatureVector &sigs, size_t start=0, size_t count=0)
 
void AsyncSign (const CBLSSecretKey &secKey, const uint256 &msgHash, SignDoneCallback doneCallback)
 
std::future< CBLSSignatureAsyncSign (const CBLSSecretKey &secKey, const uint256 &msgHash)
 
void AsyncVerifySig (const CBLSSignature &sig, const CBLSPublicKey &pubKey, const uint256 &msgHash, SigVerifyDoneCallback doneCallback, CancelCond cancelCond=[] { return false;})
 
std::future< bool > AsyncVerifySig (const CBLSSignature &sig, const CBLSPublicKey &pubKey, const uint256 &msgHash, CancelCond cancelCond=[] { return false;})
 
bool IsAsyncVerifyInProgress ()
 

Private Member Functions

void PushSigVerifyBatch ()
 

Private Attributes

ctpl::thread_pool workerPool
 
std::mutex sigVerifyMutex
 
int sigVerifyBatchesInProgress {0}
 
std::vector< SigVerifyJobsigVerifyQueue
 

Static Private Attributes

static const int SIG_VERIFY_BATCH_SIZE = 8
 

Detailed Description

Definition at line 19 of file bls_worker.h.

Member Typedef Documentation

◆ CancelCond

typedef std::function<bool()> CBLSWorker::CancelCond

Definition at line 24 of file bls_worker.h.

◆ SignDoneCallback

typedef std::function<void(const CBLSSignature&)> CBLSWorker::SignDoneCallback

Definition at line 22 of file bls_worker.h.

◆ SigVerifyDoneCallback

typedef std::function<void(bool)> CBLSWorker::SigVerifyDoneCallback

Definition at line 23 of file bls_worker.h.

Constructor & Destructor Documentation

◆ CBLSWorker()

CBLSWorker::CBLSWorker ( )

Definition at line 54 of file bls_worker.cpp.

◆ ~CBLSWorker()

CBLSWorker::~CBLSWorker ( )

Definition at line 58 of file bls_worker.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ AggregatePublicKeys()

CBLSPublicKey CBLSWorker::AggregatePublicKeys ( const BLSPublicKeyVector pubKeys,
size_t  start = 0,
size_t  count = 0,
bool  parallel = true 
)

Definition at line 696 of file bls_worker.cpp.

◆ AggregateSecretKeys()

CBLSSecretKey CBLSWorker::AggregateSecretKeys ( const BLSSecretKeyVector secKeys,
size_t  start = 0,
size_t  count = 0,
bool  parallel = true 
)

Definition at line 675 of file bls_worker.cpp.

Here is the caller graph for this function:

◆ AggregateSigs()

CBLSSignature CBLSWorker::AggregateSigs ( const BLSSignatureVector sigs,
size_t  start = 0,
size_t  count = 0,
bool  parallel = true 
)

Definition at line 717 of file bls_worker.cpp.

◆ AsyncAggregatePublicKeys() [1/2]

std::future< CBLSPublicKey > CBLSWorker::AsyncAggregatePublicKeys ( const BLSPublicKeyVector pubKeys,
size_t  start,
size_t  count,
bool  parallel 
)

Definition at line 688 of file bls_worker.cpp.

◆ AsyncAggregatePublicKeys() [2/2]

void CBLSWorker::AsyncAggregatePublicKeys ( const BLSPublicKeyVector pubKeys,
size_t  start,
size_t  count,
bool  parallel,
std::function< void(const CBLSPublicKey &)>  doneCallback 
)

Definition at line 681 of file bls_worker.cpp.

◆ AsyncAggregateSecretKeys() [1/2]

std::future< CBLSSecretKey > CBLSWorker::AsyncAggregateSecretKeys ( const BLSSecretKeyVector secKeys,
size_t  start,
size_t  count,
bool  parallel 
)

Definition at line 667 of file bls_worker.cpp.

◆ AsyncAggregateSecretKeys() [2/2]

void CBLSWorker::AsyncAggregateSecretKeys ( const BLSSecretKeyVector secKeys,
size_t  start,
size_t  count,
bool  parallel,
std::function< void(const CBLSSecretKey &)>  doneCallback 
)

Definition at line 660 of file bls_worker.cpp.

◆ AsyncAggregateSigs() [1/2]

std::future< CBLSSignature > CBLSWorker::AsyncAggregateSigs ( const BLSSignatureVector sigs,
size_t  start,
size_t  count,
bool  parallel 
)

Definition at line 709 of file bls_worker.cpp.

◆ AsyncAggregateSigs() [2/2]

void CBLSWorker::AsyncAggregateSigs ( const BLSSignatureVector sigs,
size_t  start,
size_t  count,
bool  parallel,
std::function< void(const CBLSSignature &)>  doneCallback 
)

Definition at line 702 of file bls_worker.cpp.

◆ AsyncBuildQuorumVerificationVector() [1/2]

std::future< BLSVerificationVectorPtr > CBLSWorker::AsyncBuildQuorumVerificationVector ( const std::vector< BLSVerificationVectorPtr > &  vvecs,
size_t  start,
size_t  count,
bool  parallel 
)

Definition at line 625 of file bls_worker.cpp.

◆ AsyncBuildQuorumVerificationVector() [2/2]

void CBLSWorker::AsyncBuildQuorumVerificationVector ( const std::vector< BLSVerificationVectorPtr > &  vvecs,
size_t  start,
size_t  count,
bool  parallel,
std::function< void(const BLSVerificationVectorPtr &)>  doneCallback 
)

Definition at line 605 of file bls_worker.cpp.

◆ AsyncSign() [1/2]

std::future< CBLSSignature > CBLSWorker::AsyncSign ( const CBLSSecretKey secKey,
const uint256 msgHash 
)

Definition at line 839 of file bls_worker.cpp.

Here is the call graph for this function:

◆ AsyncSign() [2/2]

void CBLSWorker::AsyncSign ( const CBLSSecretKey secKey,
const uint256 msgHash,
CBLSWorker::SignDoneCallback  doneCallback 
)

Definition at line 832 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AsyncVerifyContributionShare()

std::future< bool > CBLSWorker::AsyncVerifyContributionShare ( const CBLSId forId,
const BLSVerificationVectorPtr vvec,
const CBLSSecretKey skContribution 
)

Definition at line 759 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AsyncVerifyContributionShares() [1/2]

std::future< std::vector< bool > > CBLSWorker::AsyncVerifyContributionShares ( const CBLSId forId,
const std::vector< BLSVerificationVectorPtr > &  vvecs,
const BLSSecretKeyVector skShares,
bool  parallel,
bool  aggregated 
)

Definition at line 745 of file bls_worker.cpp.

Here is the call graph for this function:

◆ AsyncVerifyContributionShares() [2/2]

void CBLSWorker::AsyncVerifyContributionShares ( const CBLSId forId,
const std::vector< BLSVerificationVectorPtr > &  vvecs,
const BLSSecretKeyVector skShares,
bool  parallel,
bool  aggregated,
std::function< void(const std::vector< bool > &)>  doneCallback 
)

Definition at line 731 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AsyncVerifySig() [1/2]

std::future< bool > CBLSWorker::AsyncVerifySig ( const CBLSSignature sig,
const CBLSPublicKey pubKey,
const uint256 msgHash,
CancelCond  cancelCond = [] { return false; } 
)

Definition at line 876 of file bls_worker.cpp.

Here is the call graph for this function:

◆ AsyncVerifySig() [2/2]

void CBLSWorker::AsyncVerifySig ( const CBLSSignature sig,
const CBLSPublicKey pubKey,
const uint256 msgHash,
CBLSWorker::SigVerifyDoneCallback  doneCallback,
CancelCond  cancelCond = [] { return false; } 
)

Definition at line 846 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildPubKeyShare()

CBLSPublicKey CBLSWorker::BuildPubKeyShare ( const BLSVerificationVectorPtr vvec,
const CBLSId id 
)

Definition at line 724 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildQuorumVerificationVector()

BLSVerificationVectorPtr CBLSWorker::BuildQuorumVerificationVector ( const std::vector< BLSVerificationVectorPtr > &  vvecs,
size_t  start = 0,
size_t  count = 0,
bool  parallel = true 
)

Definition at line 633 of file bls_worker.cpp.

Here is the caller graph for this function:

◆ GenerateContributions()

bool CBLSWorker::GenerateContributions ( int  threshold,
const BLSIdVector ids,
BLSVerificationVectorPtr vvecRet,
BLSSecretKeyVector skShares 
)

Definition at line 77 of file bls_worker.cpp.

Here is the caller graph for this function:

◆ IsAsyncVerifyInProgress()

bool CBLSWorker::IsAsyncVerifyInProgress ( )

Definition at line 883 of file bls_worker.cpp.

◆ PushSigVerifyBatch()

void CBLSWorker::PushSigVerifyBatch ( )
private
Todo:
this could be improved if we would cache pairing results in some way as the previous aggregated verification already calculated all the pairings for the hashes

Definition at line 890 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

void CBLSWorker::Start ( )

Definition at line 63 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stop()

void CBLSWorker::Stop ( )

Definition at line 71 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyContributionShare()

bool CBLSWorker::VerifyContributionShare ( const CBLSId forId,
const BLSVerificationVectorPtr vvec,
const CBLSSecretKey skContribution 
)

Definition at line 775 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyContributionShares()

std::vector< bool > CBLSWorker::VerifyContributionShares ( const CBLSId forId,
const std::vector< BLSVerificationVectorPtr > &  vvecs,
const BLSSecretKeyVector skShares,
bool  parallel = true,
bool  aggregated = true 
)

Definition at line 753 of file bls_worker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifySecretKeyVector()

bool CBLSWorker::VerifySecretKeyVector ( const BLSSecretKeyVector secKeys,
size_t  start = 0,
size_t  count = 0 
)

Definition at line 822 of file bls_worker.cpp.

◆ VerifySignatureVector()

bool CBLSWorker::VerifySignatureVector ( const BLSSignatureVector sigs,
size_t  start = 0,
size_t  count = 0 
)

Definition at line 827 of file bls_worker.cpp.

◆ VerifyVerificationVector()

bool CBLSWorker::VerifyVerificationVector ( const BLSVerificationVector vvec,
size_t  start = 0,
size_t  count = 0 
)

Definition at line 787 of file bls_worker.cpp.

Here is the caller graph for this function:

◆ VerifyVerificationVectors()

bool CBLSWorker::VerifyVerificationVectors ( const std::vector< BLSVerificationVectorPtr > &  vvecs,
size_t  start = 0,
size_t  count = 0 
)

Definition at line 792 of file bls_worker.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ SIG_VERIFY_BATCH_SIZE

const int CBLSWorker::SIG_VERIFY_BATCH_SIZE = 8
staticprivate

Definition at line 29 of file bls_worker.h.

◆ sigVerifyBatchesInProgress

int CBLSWorker::sigVerifyBatchesInProgress {0}
private

Definition at line 47 of file bls_worker.h.

◆ sigVerifyMutex

std::mutex CBLSWorker::sigVerifyMutex
private

Definition at line 46 of file bls_worker.h.

◆ sigVerifyQueue

std::vector<SigVerifyJob> CBLSWorker::sigVerifyQueue
private

Definition at line 48 of file bls_worker.h.

◆ workerPool

ctpl::thread_pool CBLSWorker::workerPool
private

Definition at line 27 of file bls_worker.h.


The documentation for this class was generated from the following files: