-
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.
refactor(integer): add compression key types
- Loading branch information
1 parent
3f318a2
commit 1f55d61
Showing
10 changed files
with
164 additions
and
25 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
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
30 changes: 30 additions & 0 deletions
30
tfhe/src/integer/backward_compatibility/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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::integer::compression_keys::{ | ||
CompressedCompressionKey, CompressedDecompressionKey, CompressionKey, CompressionPrivateKeys, | ||
DecompressionKey, | ||
}; | ||
use tfhe_versionable::VersionsDispatch; | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum CompressionKeyVersions { | ||
V0(CompressionKey), | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum DecompressionKeyVersions { | ||
V0(DecompressionKey), | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum CompressedCompressionKeyVersions { | ||
V0(CompressedCompressionKey), | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum CompressedDecompressionKeyVersions { | ||
V0(CompressedDecompressionKey), | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
pub enum CompressionPrivateKeysVersions { | ||
V0(CompressionPrivateKeys), | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use super::ClientKey; | ||
use crate::integer::backward_compatibility::list_compression::*; | ||
use serde::{Deserialize, Serialize}; | ||
use tfhe_versionable::Versionize; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressionPrivateKeysVersions)] | ||
pub struct CompressionPrivateKeys(pub crate::shortint::list_compression::CompressionPrivateKeys); | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressionKeyVersions)] | ||
pub struct CompressionKey(pub crate::shortint::list_compression::CompressionKey); | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(DecompressionKeyVersions)] | ||
pub struct DecompressionKey(pub crate::shortint::list_compression::DecompressionKey); | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressedCompressionKeyVersions)] | ||
pub struct CompressedCompressionKey( | ||
pub crate::shortint::list_compression::CompressedCompressionKey, | ||
); | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressedDecompressionKeyVersions)] | ||
pub struct CompressedDecompressionKey( | ||
pub crate::shortint::list_compression::CompressedDecompressionKey, | ||
); | ||
|
||
impl CompressedCompressionKey { | ||
pub fn decompress(&self) -> CompressionKey { | ||
CompressionKey(self.0.decompress()) | ||
} | ||
} | ||
|
||
impl CompressedDecompressionKey { | ||
pub fn decompress(&self) -> DecompressionKey { | ||
DecompressionKey(self.0.decompress()) | ||
} | ||
} | ||
|
||
impl ClientKey { | ||
pub fn new_compressed_compression_decompression_keys( | ||
&self, | ||
private_compression_key: &CompressionPrivateKeys, | ||
) -> (CompressedCompressionKey, CompressedDecompressionKey) { | ||
let (comp_key, decomp_key) = self | ||
.key | ||
.new_compressed_compression_decompression_keys(&private_compression_key.0); | ||
|
||
( | ||
CompressedCompressionKey(comp_key), | ||
CompressedDecompressionKey(decomp_key), | ||
) | ||
} | ||
} |
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