1use aes_gcm::Error as AesGcmError;
2use core::num::TryFromIntError;
3use elliptic_curve::Error as EllipticCurveError;
4use serde::{Deserialize, Serialize};
5use thiserror::Error;
6
7use crate::curve::{point::Error as PointError, scalar::Scalar};
8
9#[derive(Error, Debug, Clone, Serialize, Deserialize, PartialEq)]
10pub enum DkgError {
12 #[error("missing public shares from {0:?}")]
13 MissingPublicShares(Vec<u32>),
15 #[error("missing private shares for/from {0:?}")]
16 MissingPrivateShares(Vec<(u32, u32)>),
18 #[error("bad public shares {0:?}")]
19 BadPublicShares(Vec<u32>),
21 #[error("bad private shares {0:?}")]
22 BadPrivateShares(Vec<u32>),
24 #[error("point error {0:?}")]
25 Point(#[from] PointError),
27 #[error("integer conversion error")]
28 TryFromInt,
30}
31
32impl From<TryFromIntError> for DkgError {
33 fn from(_e: TryFromIntError) -> Self {
34 Self::TryFromInt
35 }
36}
37
38#[derive(Error, Debug, Clone, Serialize, Deserialize, PartialEq)]
39pub enum AggregatorError {
41 #[error("bad poly commitments {0:?}")]
42 BadPolyCommitments(Vec<Scalar>),
44 #[error("bad nonce length (expected {0} got {1}")]
45 BadNonceLen(usize, usize),
47 #[error("bad party keys from {0:?}")]
48 BadPartyKeys(Vec<u32>),
50 #[error("bad party sigs from {0:?}")]
51 BadPartySigs(Vec<u32>),
53 #[error("bad group sig")]
54 BadGroupSig,
56 #[error("integer conversion error")]
57 TryFromInt,
59}
60
61impl From<TryFromIntError> for AggregatorError {
62 fn from(_e: TryFromIntError) -> Self {
63 Self::TryFromInt
64 }
65}
66
67#[derive(Error, Debug, Clone, PartialEq)]
68pub enum EncryptionError {
70 #[error("AES nonce was missing from the buffer")]
71 MissingNonce,
73 #[error("AES data was missing from the buffer")]
74 MissingData,
76 #[error("AES GCM error {0:?}")]
77 AesGcm(AesGcmError),
79 #[error("Elliptic curve error {0:?}")]
81 EllipticCurveError(EllipticCurveError),
82}
83
84impl From<AesGcmError> for EncryptionError {
85 fn from(e: AesGcmError) -> Self {
86 Self::AesGcm(e)
87 }
88}
89
90impl From<EllipticCurveError> for EncryptionError {
91 fn from(e: EllipticCurveError) -> Self {
92 Self::EllipticCurveError(e)
93 }
94}