Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
delegation.h
Go to the documentation of this file.
1// Copyright (c) 2020 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_AVALANCHE_DELEGATION_H
6#define BITCOIN_AVALANCHE_DELEGATION_H
7
9#include <avalanche/proofid.h>
10#include <key.h>
11#include <pubkey.h>
12#include <serialize.h>
13
14#include <vector>
15
16struct bilingual_str;
17
18namespace avalanche {
19
26constexpr size_t MAX_DELEGATION_LEVELS{20};
27
28class DelegationState;
29class Proof;
30
34
37
44
45 std::vector<Level> levels;
46
47 friend class DelegationBuilder;
53
54public:
55 explicit Delegation() {}
56
57 static bool FromHex(Delegation &dg, const std::string &dgHex,
59
60 const DelegationId &getId() const { return dgid; }
62 const CPubKey &getProofMaster() const { return proofMaster; }
63 const CPubKey &getDelegatedPubkey() const;
64 const std::vector<Level> &getLevels() const { return levels; }
65
66 ProofId getProofId() const;
67
69 READWRITE(obj.limitedProofid, obj.proofMaster, obj.levels);
70 SER_READ(obj, obj.dgid = obj.computeDelegationId());
71 }
72
73 bool verify(DelegationState &state, CPubKey &auth) const;
74};
75
76} // namespace avalanche
77
78#endif // BITCOIN_AVALANCHE_DELEGATION_H
An encapsulated public key.
Definition pubkey.h:31
ProofId getProofId() const
DelegationId dgid
Definition delegation.h:35
const std::vector< Level > & getLevels() const
Definition delegation.h:64
static bool FromHex(Delegation &dg, const std::string &dgHex, bilingual_str &errorOut)
bool verify(DelegationState &state, CPubKey &auth) const
const CPubKey & getProofMaster() const
Definition delegation.h:62
std::vector< Level > levels
Definition delegation.h:45
LimitedProofId limitedProofid
Definition delegation.h:32
Delegation(const LimitedProofId &limitedProofid_, const CPubKey &proofMaster_, const DelegationId &dgid_, std::vector< Level > levels_)
Definition delegation.h:48
const DelegationId & getId() const
Definition delegation.h:60
const CPubKey & getDelegatedPubkey() const
SERIALIZE_METHODS(Delegation, obj)
Definition delegation.h:68
const LimitedProofId & getLimitedProofId() const
Definition delegation.h:61
DelegationId computeDelegationId() const
std::array< uint8_t, CPubKey::SCHNORR_SIZE > SchnorrSig
a Schnorr signature
Definition key.h:25
constexpr size_t MAX_DELEGATION_LEVELS
The maximum number of delegation levels we are willing to verify.
Definition delegation.h:26
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition rcu.h:259
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define SER_READ(obj, code)
Definition serialize.h:169
#define READWRITE(...)
Definition serialize.h:166
Bilingual messages:
Definition translation.h:17