use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub struct PartialGlweSecretKeyRandomCoefCount(pub usize);
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub struct GlweSecretKeySharedCoefCount(pub usize);
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub struct LweSecretKeySharedCoefCount(pub usize);
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub struct LweSecretKeyUnsharedCoefCount(pub usize);
impl crate::core_crypto::commons::parameters::LweDimension {
#[track_caller]
pub fn shared_coef_count_from(
&self,
unshared_coef_count: LweSecretKeyUnsharedCoefCount,
) -> LweSecretKeySharedCoefCount {
assert!(
unshared_coef_count.0 <= self.0,
"unshared_coef_count {unshared_coef_count:?} must be smaller than self {:?}",
*self
);
LweSecretKeySharedCoefCount(self.0 - unshared_coef_count.0)
}
#[track_caller]
pub fn unshared_coef_count_from(
&self,
shared_coef_count: LweSecretKeySharedCoefCount,
) -> LweSecretKeyUnsharedCoefCount {
assert!(
shared_coef_count.0 <= self.0,
"shared_coef_count {shared_coef_count:?} must be smaller than self {:?}",
*self
);
LweSecretKeyUnsharedCoefCount(self.0 - shared_coef_count.0)
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct CmLweCiphertextCount(pub usize);
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
pub struct CmDimension(pub usize);
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub struct LweBootstrapExtensionFactor(usize);
impl LweBootstrapExtensionFactor {
pub const fn new(value: usize) -> Self {
assert!(
value > 1,
"An LweBootstrapExtensionFactor <= 1 makes no sense."
);
assert!(
value.is_power_of_two(),
"LweBootstrapExtensionFactor needs to be a power of 2"
);
Self(value)
}
pub const fn get(&self) -> usize {
self.0
}
}