-
Notifications
You must be signed in to change notification settings - Fork 150
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
93ff699
commit c0d9839
Showing
14 changed files
with
215 additions
and
45 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
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,66 @@ | ||
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) key: crate::shortint::list_compression::CompressionPrivateKeys, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressionKeyVersions)] | ||
pub struct CompressionKey { | ||
pub(crate) key: crate::shortint::list_compression::CompressionKey, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(DecompressionKeyVersions)] | ||
pub struct DecompressionKey { | ||
pub(crate) key: crate::shortint::list_compression::DecompressionKey, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressedCompressionKeyVersions)] | ||
pub struct CompressedCompressionKey { | ||
pub(crate) key: crate::shortint::list_compression::CompressedCompressionKey, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)] | ||
#[versionize(CompressedDecompressionKeyVersions)] | ||
pub struct CompressedDecompressionKey { | ||
pub(crate) key: crate::shortint::list_compression::CompressedDecompressionKey, | ||
} | ||
|
||
impl CompressedCompressionKey { | ||
pub fn decompress(&self) -> CompressionKey { | ||
CompressionKey { | ||
key: self.key.decompress(), | ||
} | ||
} | ||
} | ||
|
||
impl CompressedDecompressionKey { | ||
pub fn decompress(&self) -> DecompressionKey { | ||
DecompressionKey { | ||
key: self.key.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.key); | ||
|
||
( | ||
CompressedCompressionKey { key: comp_key }, | ||
CompressedDecompressionKey { key: decomp_key }, | ||
) | ||
} | ||
} |
Oops, something went wrong.