feat: add missing into/from_raw_parts functions for compressed KSK material

This commit is contained in:
Arthur Meyre
2025-08-08 16:45:44 +02:00
parent 37ed32cf4f
commit e31333b2c7
2 changed files with 35 additions and 0 deletions

View File

@@ -223,6 +223,19 @@ impl CompressedKeySwitchingKeyMaterial {
material: self.material.decompress(),
}
}
pub fn from_raw_parts(
material: crate::shortint::key_switching_key::CompressedKeySwitchingKeyMaterial,
) -> Self {
Self { material }
}
pub fn into_raw_parts(
self,
) -> crate::shortint::key_switching_key::CompressedKeySwitchingKeyMaterial {
let Self { material } = self;
material
}
}
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)]

View File

@@ -843,6 +843,28 @@ impl CompressedKeySwitchingKeyMaterial {
destination_key: self.destination_key,
}
}
pub fn from_raw_parts(
key_switching_key: SeededLweKeyswitchKeyOwned<u64>,
cast_rshift: i8,
destination_key: EncryptionKeyChoice,
) -> Self {
Self {
key_switching_key,
cast_rshift,
destination_key,
}
}
pub fn into_raw_parts(self) -> (SeededLweKeyswitchKeyOwned<u64>, i8, EncryptionKeyChoice) {
let Self {
key_switching_key,
cast_rshift,
destination_key,
} = self;
(key_switching_key, cast_rshift, destination_key)
}
}
// This is used to have the ability to build a keyswitching key without owning the ServerKey