pub mod modular;
pub mod ntt;
pub mod params;
pub mod poly;
pub mod rlwe;
pub mod sampling;
#[derive(Debug)]
pub enum FheError {
EncryptionError(String),
DecryptionError(String),
Unsupported(String),
KeyError(String),
ParamsMismatch(String),
}
impl std::fmt::Display for FheError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FheError::EncryptionError(msg) => write!(f, "encryption error: {msg}"),
FheError::DecryptionError(msg) => write!(f, "decryption error: {msg}"),
FheError::Unsupported(msg) => write!(f, "unsupported: {msg}"),
FheError::KeyError(msg) => write!(f, "key error: {msg}"),
FheError::ParamsMismatch(msg) => write!(f, "params mismatch: {msg}"),
}
}
}
impl std::error::Error for FheError {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn error_display() {
let err = FheError::Unsupported("not yet implemented".into());
assert_eq!(format!("{err}"), "unsupported: not yet implemented");
}
#[test]
fn key_error_display() {
let err = FheError::KeyError("missing party 3".into());
assert_eq!(format!("{err}"), "key error: missing party 3");
}
}