use crate::AlgorithmError;
use crypto_core::Algorithm;
use zeroize::Zeroizing;
pub struct XWing768Algo;
impl XWing768Algo {
pub const ALG: Algorithm = Algorithm::XWing768;
pub fn generate_keypair() -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError> {
crypto_x_wing::generate_x_wing_768_keypair().map_err(AlgorithmError::from)
}
pub fn derive_keypair(secret: &[u8]) -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError> {
crypto_x_wing::generate_x_wing_768_keypair_derand(secret).map_err(AlgorithmError::from)
}
pub fn encapsulate(public_key: &[u8]) -> Result<(Zeroizing<Vec<u8>>, Vec<u8>), AlgorithmError> {
let (ciphertext, shared_secret) =
crypto_x_wing::x_wing_768_encapsulate(public_key).map_err(AlgorithmError::from)?;
Ok((shared_secret, ciphertext))
}
pub fn decapsulate(
ciphertext: &[u8],
secret_key: &[u8],
) -> Result<Zeroizing<Vec<u8>>, AlgorithmError> {
crypto_x_wing::x_wing_768_decapsulate(ciphertext, secret_key).map_err(AlgorithmError::from)
}
}