-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shortint): add ciphertext_modulus_after_packing_ks to compression…
… parameters
- Loading branch information
1 parent
a668112
commit fd554e7
Showing
6 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 54 additions & 3 deletions
57
tfhe/src/shortint/backward_compatibility/parameters/list_compression.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,59 @@ | ||
use tfhe_versionable::VersionsDispatch; | ||
|
||
use super::parameters::list_compression::CompressionParameters; | ||
use super::CiphertextModulus; | ||
use crate::core_crypto::prelude::{CiphertextModulusLog, LweCiphertextCount}; | ||
use crate::shortint::parameters::{ | ||
DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, GlweDimension, | ||
PolynomialSize, | ||
}; | ||
use std::convert::Infallible; | ||
use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; | ||
|
||
#[derive(Version)] | ||
pub struct CompressionParametersV0 { | ||
pub br_level: DecompositionLevelCount, | ||
pub br_base_log: DecompositionBaseLog, | ||
pub packing_ks_level: DecompositionLevelCount, | ||
pub packing_ks_base_log: DecompositionBaseLog, | ||
pub packing_ks_polynomial_size: PolynomialSize, | ||
pub packing_ks_glwe_dimension: GlweDimension, | ||
pub lwe_per_glwe: LweCiphertextCount, | ||
pub storage_log_modulus: CiphertextModulusLog, | ||
pub packing_ks_key_noise_distribution: DynamicDistribution<u64>, | ||
} | ||
|
||
impl Upgrade<CompressionParameters> for CompressionParametersV0 { | ||
type Error = Infallible; | ||
|
||
fn upgrade(self) -> Result<CompressionParameters, Self::Error> { | ||
let Self { | ||
br_level, | ||
br_base_log, | ||
packing_ks_level, | ||
packing_ks_base_log, | ||
packing_ks_polynomial_size, | ||
packing_ks_glwe_dimension, | ||
lwe_per_glwe, | ||
storage_log_modulus, | ||
packing_ks_key_noise_distribution, | ||
} = self; | ||
|
||
Ok(CompressionParameters { | ||
br_level, | ||
br_base_log, | ||
packing_ks_level, | ||
packing_ks_base_log, | ||
packing_ks_polynomial_size, | ||
packing_ks_glwe_dimension, | ||
lwe_per_glwe, | ||
storage_log_modulus, | ||
packing_ks_key_noise_distribution, | ||
ciphertext_modulus_after_packing_ks: CiphertextModulus::new_native(), | ||
}) | ||
} | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum CompressionParametersVersions { | ||
V0(CompressionParameters), | ||
V0(CompressionParametersV0), | ||
V1(CompressionParameters), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters