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
67impl From<EllipticCurveError> for EncryptionError {
68 fn from(e: EllipticCurveError) -> Self {
69 Self::EllipticCurveError(e)
70 }
71}
72
73#[derive(Error, Debug, Clone, PartialEq)]
74pub enum EncryptionError {
76 #[error("AES nonce was missing from the buffer")]
77 MissingNonce,
79 #[error("AES data was missing from the buffer")]
80 MissingData,
82 #[error("AES GCM error {0:?}")]
83 AesGcm(AesGcmError),
85 #[error("Elliptic curve error {0:?}")]
87 EllipticCurveError(EllipticCurveError),
88}
89
90impl From<AesGcmError> for EncryptionError {
91 fn from(e: AesGcmError) -> Self {
92 Self::AesGcm(e)
93 }
94}