use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Error {
Length {
expected: usize,
actual: usize,
},
PbkdfOutputLength {
actual: usize,
},
InvalidPoint,
InvalidScalar,
DegenerateShare,
ConfirmationFailed,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Length { expected, actual } => {
write!(f, "expected {expected} bytes, got {actual}")
}
Self::PbkdfOutputLength { actual } => {
write!(
f,
"a PBKDF output of {actual} bytes is not two equal halves of a usable length"
)
}
Self::InvalidPoint => f.write_str("not an encoded point of the group"),
Self::InvalidScalar => {
f.write_str("a scalar that is zero or not below the group order")
}
Self::DegenerateShare => f.write_str("a share that cancels the password's mask"),
Self::ConfirmationFailed => f.write_str("the key confirmation does not match"),
}
}
}
impl core::error::Error for Error {}