arcanum_threshold/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ThresholdError {
8 #[error("threshold must be at least 1, got {threshold}")]
10 ThresholdTooLow {
11 threshold: usize,
13 },
14
15 #[error("threshold ({threshold}) cannot exceed total shares ({total})")]
17 ThresholdExceedsTotal {
18 threshold: usize,
20 total: usize,
22 },
23
24 #[error("invalid threshold: need {threshold} of {total} shares, but {threshold} > {total}")]
26 InvalidThreshold {
27 threshold: usize,
29 total: usize,
31 },
32
33 #[error("insufficient shares: need {required}, got {provided}")]
35 InsufficientShares {
36 required: usize,
38 provided: usize,
40 },
41
42 #[error("invalid share index: {index} (valid range: 1-{max})")]
44 InvalidShareIndex {
45 index: usize,
47 max: usize,
49 },
50
51 #[error("duplicate share index: {index}")]
53 DuplicateShareIndex {
54 index: usize,
56 },
57
58 #[error("share verification failed for participant {participant}")]
60 ShareVerificationFailed {
61 participant: u16,
63 },
64
65 #[error("invalid share format")]
67 InvalidShareFormat,
68
69 #[error("invalid share data: {reason}")]
71 InvalidShare {
72 reason: String,
74 },
75
76 #[error("invalid commitment")]
78 InvalidCommitment,
79
80 #[error("DKG protocol error: {0}")]
82 DkgError(String),
83
84 #[error("signing protocol error: {0}")]
86 SigningError(String),
87
88 #[error("invalid participant identifier: {0}")]
90 InvalidParticipant(u16),
91
92 #[error("missing participant {0} in round")]
94 MissingParticipant(u16),
95
96 #[error("invalid signature")]
98 InvalidSignature,
99
100 #[error("serialization error: {0}")]
102 SerializationError(String),
103
104 #[error("internal error: {0}")]
106 InternalError(String),
107}
108
109pub type Result<T> = std::result::Result<T, ThresholdError>;