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
use thiserror::Error;

/// Errors that can occur when using the SSKR library.
#[derive(Debug, Error)]
pub enum SSKRError {
    #[error("When combining shares, the provided shares contained a duplicate member index")]
    DuplicateMemberIndex,

    #[error("When creating a split spec, the group count is invalid")]
    GroupCountInvalid,

    #[error("SSKR group threshold is invalid")]
    GroupThresholdInvalid,

    #[error("SSKR member count is invalid")]
    MemberCountInvalid,

    #[error("SSKR member threshold is invalid")]
    MemberThresholdInvalid,

    #[error("SSKR shares did not contain enough groups")]
    NotEnoughGroups,

    #[error("SSKR secret is not of even length")]
    SecretLengthNotEven,

    #[error("SSKR secret is too long")]
    SecretTooLong,

    #[error("SSKR secret is too short")]
    SecretTooShort,

    #[error("SSKR shares did not contain enough serialized bytes")]
    ShareLengthInvalid,

    #[error("SSKR shares contained invalid reserved bits")]
    ShareReservedBitsInvalid,

    #[error("SSKR shares were empty")]
    SharesEmpty,

    #[error("SSKR shares were invalid")]
    ShareSetInvalid,

    #[error("SSKR Shamir error: {0}")]
    ShamirError(bc_shamir::Error),
}

impl From<bc_shamir::Error> for SSKRError {
    fn from(err: bc_shamir::Error) -> Self {
        SSKRError::ShamirError(err)
    }
}