PIVX Core  5.6.99
P2P Digital Currency
quorums_commitment.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2019 The Dash Core developers
2 // Copyright (c) 2021 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_LLMQ_QUORUMS_COMMITMENT_H
7 #define PIVX_LLMQ_QUORUMS_COMMITMENT_H
8 
9 #include "bls/bls_wrapper.h"
10 #include "consensus/params.h"
11 
12 #include <univalue.h>
13 
14 class CBlockIndex;
15 class CValidationState;
16 class CTransaction;
17 
18 namespace llmq
19 {
20 
21 // This message is an aggregation of all received premature commitments and only valid if
22 // enough (>=threshold) premature commitments were aggregated
23 // This is mined on-chain as part of LLMQCOMM payload.
25 {
26 public:
27  static const uint16_t CURRENT_VERSION = 1;
28 
32  std::vector<bool> signers;
33  std::vector<bool> validMembers;
34 
37 
38  CBLSSignature quorumSig; // recovered threshold sig of blockHash+validMembers+pubKeyHash+vvecHash
39  CBLSSignature membersSig; // aggregated member sig of blockHash+validMembers+pubKeyHash+vvecHash
40 
41 public:
42  CFinalCommitment() = default;
43  CFinalCommitment(const Consensus::LLMQParams& params, const uint256& _quorumHash);
44 
45  int CountSigners() const { return (int)std::count(signers.begin(), signers.end(), true); }
46  int CountValidMembers() const { return (int)std::count(validMembers.begin(), validMembers.end(), true); }
47 
48  bool IsNull() const;
49  void ToJson(UniValue& obj) const;
50 
51  bool Verify(const std::vector<CBLSPublicKey>& allkeys, const Consensus::LLMQParams& params) const;
52  bool VerifySizes(const Consensus::LLMQParams& params) const;
53 
55  {
56  READWRITE(obj.nVersion);
57  READWRITE(obj.llmqType);
58  READWRITE(obj.quorumHash);
59  READWRITE(DYNBITSET(obj.signers));
60  READWRITE(DYNBITSET(obj.validMembers));
61  READWRITE(obj.quorumPublicKey);
62  READWRITE(obj.quorumVvecHash);
63  READWRITE(obj.quorumSig);
64  READWRITE(obj.membersSig);
65  }
66 };
67 
69 {
70 public:
71  static const uint16_t CURRENT_VERSION = 1;
72 
73 public:
75  uint32_t nHeight{(uint32_t)-1};
77 
78 public:
80  {
81  READWRITE(obj.nVersion);
82  READWRITE(obj.nHeight);
83  READWRITE(obj.commitment);
84  }
85 
86  void ToJson(UniValue& obj) const;
87 };
88 
89 } // namespace llmq
90 
91 #endif // PIVX_LLMQ_QUORUMS_COMMITMENT_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:139
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:244
Capture information about block/transaction validation.
Definition: validation.h:24
static const uint16_t CURRENT_VERSION
SERIALIZE_METHODS(CFinalCommitment, obj)
void ToJson(UniValue &obj) const
bool Verify(const std::vector< CBLSPublicKey > &allkeys, const Consensus::LLMQParams &params) const
std::vector< bool > validMembers
std::vector< bool > signers
bool VerifySizes(const Consensus::LLMQParams &params) const
SERIALIZE_METHODS(LLMQCommPL, obj)
static const uint16_t CURRENT_VERSION
void ToJson(UniValue &obj) const
CFinalCommitment commitment
256-bit opaque blob.
Definition: uint256.h:138
@ LLMQ_NONE
Definition: params.h:91
Definition: quorums.cpp:26
#define DYNBITSET(obj)
Definition: serialize.h:533
#define READWRITE(...)
Definition: serialize.h:183