Distinguish between gglwe_to_ggsw key and tensor_key + update key repreentation

This commit is contained in:
Pro7ech
2025-10-27 11:28:53 +01:00
parent 41ca5aafcc
commit 8d4c19a304
59 changed files with 2812 additions and 1596 deletions

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
};
use poulpy_core::{
GGSWFromGGLWE, GLWEDecrypt, GLWEPacking, GLWETrace, ScratchTakeCore,
GGSWFromGGLWE, GLWEDecrypt, GLWEPacking, GLWERotate, GLWETrace, ScratchTakeCore,
layouts::{
Dsize, GGLWELayout, GGSWInfos, GGSWToMut, GLWEInfos, GLWESecretPreparedFactory, GLWEToMut, GLWEToRef, LWEInfos, LWEToRef,
},
@@ -115,7 +115,8 @@ where
+ GLWEPacking<BE>
+ GGSWFromGGLWE<BE>
+ GLWESecretPreparedFactory<BE>
+ GLWEDecrypt<BE>,
+ GLWEDecrypt<BE>
+ GLWERotate<BE>,
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
@@ -216,7 +217,9 @@ pub fn circuit_bootstrap_core<R, L, D, M, BRA: BlindRotationAlgo, BE: Backend>(
+ GLWEPacking<BE>
+ GGSWFromGGLWE<BE>
+ GLWESecretPreparedFactory<BE>
+ GLWEDecrypt<BE>,
+ GLWEDecrypt<BE>
+ GLWERotate<BE>
+ ModuleLogN,
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
@@ -332,7 +335,7 @@ fn post_process<R, A, M, BE: Backend>(
) where
R: GLWEToMut,
A: GLWEToRef,
M: ModuleLogN + GLWETrace<BE> + GLWEPacking<BE>,
M: ModuleLogN + GLWETrace<BE> + GLWEPacking<BE> + GLWERotate<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();

View File

@@ -1,8 +1,8 @@
use poulpy_core::{
Distribution, GLWEAutomorphismKeyEncryptSk, GLWETensorKeyEncryptSk, GetDistribution, ScratchTakeCore,
Distribution, GGLWEToGGSWKeyEncryptSk, GLWEAutomorphismKeyEncryptSk, GetDistribution, ScratchTakeCore,
layouts::{
GGLWEInfos, GGSWInfos, GLWEAutomorphismKey, GLWEAutomorphismKeyLayout, GLWEInfos, GLWESecretPreparedFactory,
GLWESecretToRef, GLWETensorKey, GLWETensorKeyLayout, LWEInfos, LWESecretToRef, prepared::GLWESecretPrepared,
GGLWEInfos, GGLWEToGGSWKey, GGSWInfos, GLWEAutomorphismKey, GLWEAutomorphismKeyLayout, GLWEInfos,
GLWESecretPreparedFactory, GLWESecretToRef, GLWETensorKeyLayout, LWEInfos, LWESecretToRef, prepared::GLWESecretPrepared,
},
trace_galois_elements,
};
@@ -81,14 +81,14 @@ impl<BRA: BlindRotationAlgo> CircuitBootstrappingKey<Vec<u8>, BRA> {
(gal_el, key)
})
.collect(),
tsk: GLWETensorKey::alloc_from_infos(trk_infos),
tsk: GGLWEToGGSWKey::alloc_from_infos(trk_infos),
}
}
}
pub struct CircuitBootstrappingKey<D: Data, BRA: BlindRotationAlgo> {
pub(crate) brk: BlindRotationKey<D, BRA>,
pub(crate) tsk: GLWETensorKey<Vec<u8>>,
pub(crate) tsk: GGLWEToGGSWKey<Vec<u8>>,
pub(crate) atk: HashMap<i64, GLWEAutomorphismKey<Vec<u8>>>,
}
@@ -112,7 +112,7 @@ impl<D: DataMut, BRA: BlindRotationAlgo> CircuitBootstrappingKey<D, BRA> {
impl<BRA: BlindRotationAlgo, BE: Backend> CircuitBootstrappingKeyEncryptSk<BRA, BE> for Module<BE>
where
Self: GLWETensorKeyEncryptSk<BE>
Self: GGLWEToGGSWKeyEncryptSk<BE>
+ BlindRotationKeyEncryptSk<BRA, BE>
+ GLWEAutomorphismKeyEncryptSk<BE>
+ GLWESecretPreparedFactory<BE>,

View File

@@ -1,8 +1,8 @@
use poulpy_core::{
layouts::{
GGLWEInfos, GGSWInfos, GLWEAutomorphismKeyLayout, GLWEAutomorphismKeyPreparedFactory, GLWEInfos, GLWETensorKeyLayout,
GLWETensorKeyPreparedFactory, LWEInfos,
prepared::{GLWEAutomorphismKeyPrepared, GLWETensorKeyPrepared},
GGLWEInfos, GGLWEToGGSWKeyPrepared, GGLWEToGGSWKeyPreparedFactory, GGSWInfos, GLWEAutomorphismKeyLayout,
GLWEAutomorphismKeyPreparedFactory, GLWEInfos, GLWETensorKeyLayout, GLWETensorKeyPreparedFactory, LWEInfos,
prepared::GLWEAutomorphismKeyPrepared,
},
trace_galois_elements,
};
@@ -50,7 +50,7 @@ pub trait CircuitBootstrappingKeyPreparedFactory<BRA: BlindRotationAlgo, BE: Bac
where
Self: Sized
+ BlindRotationKeyPreparedFactory<BRA, BE>
+ GLWETensorKeyPreparedFactory<BE>
+ GGLWEToGGSWKeyPreparedFactory<BE>
+ GLWEAutomorphismKeyPreparedFactory<BE>,
{
fn circuit_bootstrapping_key_prepared_alloc_from_infos<A>(
@@ -65,7 +65,7 @@ where
CircuitBootstrappingKeyPrepared {
brk: BlindRotationKeyPrepared::alloc(self, &infos.brk_infos()),
tsk: GLWETensorKeyPrepared::alloc_from_infos(self, &infos.tsk_infos()),
tsk: GGLWEToGGSWKeyPrepared::alloc_from_infos(self, &infos.tsk_infos()),
atk: gal_els
.iter()
.map(|&gal_el| {
@@ -81,7 +81,7 @@ where
A: CircuitBootstrappingKeyInfos,
{
self.blind_rotation_key_prepare_tmp_bytes(&infos.brk_infos())
.max(self.prepare_tensor_key_tmp_bytes(&infos.tsk_infos()))
.max(self.prepare_gglwe_to_ggsw_key_tmp_bytes(&infos.tsk_infos()))
.max(self.prepare_glwe_automorphism_key_tmp_bytes(&infos.atk_infos()))
}
@@ -105,7 +105,7 @@ where
pub struct CircuitBootstrappingKeyPrepared<D: Data, BRA: BlindRotationAlgo, B: Backend> {
pub(crate) brk: BlindRotationKeyPrepared<D, BRA, B>,
pub(crate) tsk: GLWETensorKeyPrepared<Vec<u8>, B>,
pub(crate) tsk: GGLWEToGGSWKeyPrepared<Vec<u8>, B>,
pub(crate) atk: HashMap<i64, GLWEAutomorphismKeyPrepared<Vec<u8>, B>>,
}