1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use super::{plain_message::PlainMessage, section::NodeState, signed::Signed};
use crate::{MessageId, SectionAuthorityProvider};
use ed25519_dalek::{PublicKey, Signature};
use hex_fmt::HexFmt;
use secured_linked_list::SecuredLinkedList;
use serde::{Deserialize, Serialize};
use std::{
borrow::Borrow,
collections::BTreeSet,
fmt::{self, Debug, Formatter},
};
use threshold_crypto::PublicKey as BlsPublicKey;
use xor_name::{Prefix, XorName};
pub type Digest256 = [u8; 32];
#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct DkgKey {
pub hash: Digest256,
pub generation: u64,
}
impl Debug for DkgKey {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "DkgKey({:10}/{})", HexFmt(&self.hash), self.generation)
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct DkgFailureSigned {
pub public_key: PublicKey,
pub signature: Signature,
}
#[derive(Default, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct DkgFailureSignedSet {
pub signeds: Vec<DkgFailureSigned>,
pub non_participants: BTreeSet<XorName>,
}
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct SectionSigned<T: Serialize> {
pub value: T,
pub signed: Signed,
}
impl<T> Borrow<Prefix> for SectionSigned<T>
where
T: Borrow<Prefix> + Serialize,
{
fn borrow(&self) -> &Prefix {
self.value.borrow()
}
}
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
#[allow(clippy::large_enum_variant)]
pub enum Proposal {
Online {
node_state: NodeState,
previous_name: Option<XorName>,
destination_key: Option<BlsPublicKey>,
},
Offline(NodeState),
SectionInfo(SectionAuthorityProvider),
OurElders(SectionSigned<SectionAuthorityProvider>),
AccumulateAtSrc {
message: Box<PlainMessage>,
proof_chain: SecuredLinkedList,
},
JoinsAllowed((MessageId, bool)),
}