#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[non_exhaustive]
pub enum KyberLibError {
InvalidInput,
InvalidKey,
InvalidLength,
Decapsulation,
RandomBytesGeneration,
}
impl core::fmt::Display for KyberLibError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
KyberLibError::InvalidInput => write!(f, "Function input is of incorrect length"),
KyberLibError::Decapsulation => write!(
f,
"Decapsulation Failure, unable to obtain shared secret from ciphertext"
),
KyberLibError::RandomBytesGeneration => {
write!(f, "Random bytes generation function failed")
}
KyberLibError::InvalidKey => {
write!(f, "The secret and public key given does not match.")
},
KyberLibError::InvalidLength => {
write!(f, "The length of the input buffer is invalid.")
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for KyberLibError {}