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
use crate::Role;
#[derive(Debug)]
pub enum CounterSigningError {
AgentIndexOutOfBounds,
MissingResponse,
CounterSigningSessionResponsesLength(usize, usize),
CounterSigningSessionResponsesOrder(u8, usize),
EnzymeMismatch(
Option<(holo_hash::AgentPubKey, Vec<Role>)>,
Option<(holo_hash::AgentPubKey, Vec<Role>)>,
),
NonEnzymaticOptionalSigners,
AgentsLength(usize),
OptionalAgentsLength(u8, usize),
MinOptionalAgents(u8, usize),
AgentsDupes(Vec<holo_hash::AgentPubKey>),
CounterSigningSessionTimes(crate::CounterSigningSessionTimes),
}
impl std::error::Error for CounterSigningError {}
impl core::fmt::Display for CounterSigningError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CounterSigningError::AgentIndexOutOfBounds => {
write!(f, "Agent index is out of bounds for the signing session.")
}
CounterSigningError::MissingResponse => write!(
f,
"Attempted to build CounterSigningSessionData with an empty response vector."
),
CounterSigningError::CounterSigningSessionResponsesLength(resp, num_agents) => {
write!(f,
"The countersigning session responses ({}) did not match the number of signing agents ({})",
resp,
num_agents
)
}
CounterSigningError::CounterSigningSessionResponsesOrder(index, pos) => write!(f,
"The countersigning session response with agent index {} was found in index position {}",
index, pos
),
CounterSigningError::EnzymeMismatch(required_signer, optional_signer) => write!(f,
"The enzyme is mismatche for required signer {:?} and optional signer {:?}",
required_signer, optional_signer
),
CounterSigningError::NonEnzymaticOptionalSigners => write!(f, "There are optional signers without an enzyme."),
CounterSigningError::AgentsLength(len) => {
write!(f, "The signing agents list is too long or short {}", len)
},
CounterSigningError::OptionalAgentsLength(min, len) => {
write!(f, "The optional signing agents list length is {} which is less than the minimum {} required to sign", len, min)
},
CounterSigningError::MinOptionalAgents(min, len) => {
write!(f, "The minimum optional agents {} is not a majority of {}", min, len)
},
CounterSigningError::AgentsDupes(agents) => write!(
f,
"The signing agents list contains duplicates {:?}",
agents
),
CounterSigningError::CounterSigningSessionTimes(times) => write!(
f,
"The countersigning session times were not valid {:?}",
times
),
}
}
}