use thiserror::Error;
use crate::{frost::Identifier, Ciphersuite};
#[non_exhaustive]
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
pub enum Error<C: Ciphersuite> {
#[error("min_signers must be at least 2 and not larger than max_signers")]
InvalidMinSigners,
#[error("max_signers must be at least 2")]
InvalidMaxSigners,
#[error("coefficients must have min_signers-1 elements")]
InvalidCoefficients,
#[error("Malformed identifier is unserializable.")]
MalformedIdentifier,
#[error("Malformed signing key encoding.")]
MalformedSigningKey,
#[error("Malformed verifying key encoding.")]
MalformedVerifyingKey,
#[error("Malformed signature encoding.")]
MalformedSignature,
#[error("Invalid signature.")]
InvalidSignature,
#[error("Duplicated shares provided.")]
DuplicatedShares,
#[error("Incorrect number of shares.")]
IncorrectNumberOfShares,
#[error("Commitment equals the identity.")]
IdentityCommitment,
#[error("Invalid signature share.")]
InvalidSignatureShare {
signer: Identifier<C>,
},
#[error("Invalid secret share.")]
InvalidSecretShare {
identifier: Identifier<C>,
},
#[error("Round 1 package not found for Round 2 participant.")]
PackageNotFound,
#[error("Incorrect number of packages.")]
IncorrectNumberOfPackages,
#[error("The incorrect package was specified.")]
IncorrectPackage,
#[error("The ciphersuite does not support DKG.")]
DKGNotSupported,
#[error("The proof of knowledge is not valid.")]
InvalidProofOfKnowledge {
sender: Identifier<C>,
},
#[error("Error in scalar Field.")]
FieldError(#[from] FieldError),
#[error("Error in elliptic curve Group.")]
GroupError(#[from] GroupError),
#[error("Invalid coefficient")]
InvalidCoefficient,
}
#[non_exhaustive]
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
pub enum FieldError {
#[error("Malformed scalar encoding.")]
MalformedScalar,
#[error("Invalid for this scalar to be zero.")]
InvalidZeroScalar,
}
#[non_exhaustive]
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
pub enum GroupError {
#[error("Malformed group element encoding.")]
MalformedElement,
#[error("Invalid for this element to be the identity.")]
InvalidIdentityElement,
#[error("Invalid for this element to not have large prime order.")]
InvalidNonPrimeOrderElement,
}