2022-05-16 13:53:17 -07:00
|
|
|
//! FROST Error types
|
|
|
|
|
|
|
|
use thiserror::Error;
|
|
|
|
|
2022-12-12 14:04:10 -08:00
|
|
|
use crate::{frost::Identifier, Ciphersuite};
|
|
|
|
|
2022-05-16 13:53:17 -07:00
|
|
|
/// An error related to FROST.
|
|
|
|
#[non_exhaustive]
|
|
|
|
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
|
2022-12-12 14:04:10 -08:00
|
|
|
pub enum Error<C: Ciphersuite> {
|
2022-10-28 13:01:03 -07:00
|
|
|
/// min_signers is invalid
|
|
|
|
#[error("min_signers must be at least 2 and not larger than max_signers")]
|
|
|
|
InvalidMinSigners,
|
|
|
|
/// max_signers is invalid
|
|
|
|
#[error("max_signers must be at least 2")]
|
|
|
|
InvalidMaxSigners,
|
|
|
|
/// max_signers is invalid
|
|
|
|
#[error("coefficients must have min_signers-1 elements")]
|
|
|
|
InvalidCoefficients,
|
2022-05-16 13:53:17 -07:00
|
|
|
/// This identifier is unserializable.
|
|
|
|
#[error("Malformed identifier is unserializable.")]
|
|
|
|
MalformedIdentifier,
|
|
|
|
/// The encoding of a signing key was malformed.
|
|
|
|
#[error("Malformed signing key encoding.")]
|
|
|
|
MalformedSigningKey,
|
|
|
|
/// The encoding of a verifying key was malformed.
|
|
|
|
#[error("Malformed verifying key encoding.")]
|
|
|
|
MalformedVerifyingKey,
|
|
|
|
/// The encoding of a signature was malformed.
|
|
|
|
#[error("Malformed signature encoding.")]
|
|
|
|
MalformedSignature,
|
|
|
|
/// Signature verification failed.
|
|
|
|
#[error("Invalid signature.")]
|
|
|
|
InvalidSignature,
|
2022-10-28 13:01:03 -07:00
|
|
|
/// Duplicated shares provided
|
|
|
|
#[error("Duplicated shares provided.")]
|
|
|
|
DuplicatedShares,
|
|
|
|
/// Commitment equals the identity
|
|
|
|
#[error("Commitment equals the identity.")]
|
|
|
|
IdentityCommitment,
|
|
|
|
/// Signature share verification failed.
|
|
|
|
#[error("Invalid signature share.")]
|
2022-12-12 14:04:10 -08:00
|
|
|
InvalidSignatureShare {
|
|
|
|
/// The identifier of the signer whose share validation failed.
|
|
|
|
signer: Identifier<C>,
|
|
|
|
},
|
2022-10-28 13:01:03 -07:00
|
|
|
/// Secret share verification failed.
|
|
|
|
#[error("Invalid secret share.")]
|
|
|
|
InvalidSecretShare,
|
|
|
|
/// Round 1 package not found for Round 2 participant.
|
|
|
|
#[error("Round 1 package not found for Round 2 participant.")]
|
|
|
|
PackageNotFound,
|
|
|
|
/// Incorrect number of packages.
|
|
|
|
#[error("Incorrect number of packages.")]
|
|
|
|
IncorrectNumberOfPackages,
|
|
|
|
/// The incorrect package was specified.
|
|
|
|
#[error("The incorrect package was specified.")]
|
|
|
|
IncorrectPackage,
|
|
|
|
/// The ciphersuite does not support DKG.
|
|
|
|
#[error("The ciphersuite does not support DKG.")]
|
|
|
|
DKGNotSupported,
|
|
|
|
/// The proof of knowledge is not valid.
|
|
|
|
#[error("The proof of knowledge is not valid.")]
|
|
|
|
InvalidProofOfKnowledge,
|
2022-12-12 14:04:10 -08:00
|
|
|
/// Error in scalar Field.
|
|
|
|
#[error("Error in scalar Field.")]
|
|
|
|
FieldError(#[from] FieldError),
|
|
|
|
/// Error in elliptic curve Group.
|
|
|
|
#[error("Error in elliptic curve Group.")]
|
|
|
|
GroupError(#[from] GroupError),
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An error related to a scalar Field.
|
|
|
|
#[non_exhaustive]
|
|
|
|
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
|
|
|
|
pub enum FieldError {
|
|
|
|
/// The encoding of a group scalar was malformed.
|
|
|
|
#[error("Malformed scalar encoding.")]
|
|
|
|
MalformedScalar,
|
|
|
|
/// This scalar MUST NOT be zero.
|
|
|
|
#[error("Invalid for this scalar to be zero.")]
|
|
|
|
InvalidZeroScalar,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An error related to a Group (usually an elliptic curve or constructed from one) or one of its Elements.
|
|
|
|
#[non_exhaustive]
|
|
|
|
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
|
|
|
|
pub enum GroupError {
|
|
|
|
/// The encoding of a group element was malformed.
|
|
|
|
#[error("Malformed group element encoding.")]
|
|
|
|
MalformedElement,
|
|
|
|
/// This element MUST NOT be the identity.
|
|
|
|
#[error("Invalid for this element to be the identity.")]
|
|
|
|
InvalidIdentityElement,
|
|
|
|
/// This element MUST have (large) prime order.
|
|
|
|
#[error("Invalid for this element to not have large prime order.")]
|
|
|
|
InvalidNonPrimeOrderElement,
|
2022-05-16 13:53:17 -07:00
|
|
|
}
|