vsss_rs_std/
error.rs

1/*
2    Copyright Michael Lodder. All Rights Reserved.
3    SPDX-License-Identifier: Apache-2.0
4*/
5use thiserror::Error;
6
7/// Errors during secret sharing
8#[derive(Error, Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
9pub enum Error {
10    /// Error when threshold is less than 2
11    #[error("Threshold cannot be less than 2")]
12    SharingMinThreshold,
13    /// Error when limit is less than threshold
14    #[error("Limit is less than threshold")]
15    SharingLimitLessThanThreshold,
16    /// Invalid share identifier
17    #[error("An invalid share detected")]
18    SharingInvalidIdentifier,
19    /// Duplicate identifier when combining
20    #[error("Duplicate share detected")]
21    SharingDuplicateIdentifier,
22    /// The maximum number of shares to be made when splitting
23    #[error("The maximum number of shares to be made when splitting was reached")]
24    SharingMaxRequest,
25    /// An invalid share was supplied for verification or combine
26    #[error("An invalid share was supplied for verification or combine")]
27    InvalidShare,
28    /// An invalid secret was supplied for split
29    #[error("An invalid secret was supplied for split")]
30    InvalidSecret,
31    /// A share cannot be converted to a group or field element
32    #[error("A share cannot be converted to a group or field element")]
33    InvalidShareConversion,
34    /// A specific function is not implemented
35    #[error("Not implemented")]
36    NotImplemented,
37}
38
39/// Results returned by this crate
40pub type VsssResult<T> = anyhow::Result<T, Error>;