use core::fmt;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AnnihilationError {
InvalidPair,
PointRecovery,
PointMismatch,
ConstraintMismatch,
UnsatisfiedConstraint,
}
impl fmt::Display for AnnihilationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AnnihilationError::InvalidPair => {
write!(f, "annihilative pair has only keys or antikeys")
}
AnnihilationError::PointRecovery => {
write!(f, "unable to recover shared base curve point")
}
AnnihilationError::PointMismatch => {
write!(f, "recovered base curve points do not match")
}
AnnihilationError::ConstraintMismatch => {
write!(f, "key and antikey constraints do not match")
}
AnnihilationError::UnsatisfiedConstraint => {
write!(f, "XOR hash does not satisfy the constraint")
}
}
}
}
#[test]
fn error_display() {
assert_eq!(
AnnihilationError::InvalidPair.to_string(),
"annihilative pair has only keys or antikeys"
);
assert_eq!(
AnnihilationError::PointRecovery.to_string(),
"unable to recover shared base curve point"
);
assert_eq!(
AnnihilationError::PointMismatch.to_string(),
"recovered base curve points do not match"
);
assert_eq!(
AnnihilationError::ConstraintMismatch.to_string(),
"key and antikey constraints do not match"
);
assert_eq!(
AnnihilationError::UnsatisfiedConstraint.to_string(),
"XOR hash does not satisfy the constraint"
);
}