Add glwe tensoiring

This commit is contained in:
Pro7ech
2025-10-26 19:03:15 +01:00
parent 6e9cef5ecd
commit 41ca5aafcc
9 changed files with 199 additions and 138 deletions

View File

@@ -29,6 +29,7 @@ where
self.glwe_to_glwe_blind_rotation_tmp_bytes(res_infos, k_infos)
}
#[allow(clippy::too_many_arguments)]
/// res <- a * X^{((k>>bit_rsh) % 2^bit_mask) << bit_lsh}.
fn ggsw_to_ggsw_blind_rotation<R, A, K>(
&self,
@@ -74,6 +75,7 @@ where
self.glwe_to_glwe_blind_rotation_tmp_bytes(res_infos, k_infos) + GLWE::bytes_of_from_infos(res_infos)
}
#[allow(clippy::too_many_arguments)]
fn scalar_to_ggsw_blind_rotation<R, S, K>(
&self,
res: &mut R,
@@ -143,6 +145,7 @@ where
self.cmux_tmp_bytes(res_infos, res_infos, k_infos) + GLWE::bytes_of_from_infos(res_infos)
}
#[allow(clippy::too_many_arguments)]
/// res <- a * X^{((k>>bit_rsh) % 2^bit_mask) << bit_lsh}.
fn glwe_to_glwe_blind_rotation<R, A, K>(
&self,
@@ -162,6 +165,7 @@ where
assert!(bit_rsh + bit_mask <= T::WORD_SIZE);
let mut res: GLWE<&mut [u8]> = res.to_mut();
let a: &GLWE<&[u8]> = &a.to_ref();
let (mut tmp_res, scratch_1) = scratch.take_glwe(&res);

View File

@@ -3,7 +3,7 @@ use poulpy_backend::FFT64Ref;
use crate::tfhe::{
bdd_arithmetic::tests::test_suite::{
test_bdd_add, test_bdd_and, test_bdd_or, test_bdd_prepare, test_bdd_sll, test_bdd_slt, test_bdd_sltu, test_bdd_sra,
test_bdd_srl, test_bdd_sub, test_bdd_xor, test_scalar_to_ggsw_blind_rotation, test_glwe_to_glwe_blind_rotation,
test_bdd_srl, test_bdd_sub, test_bdd_xor, test_glwe_to_glwe_blind_rotation, test_scalar_to_ggsw_blind_rotation,
},
blind_rotation::CGGI,
};

View File

@@ -70,12 +70,8 @@ where
data.iter_mut().enumerate().for_each(|(i, x)| *x = i as i64);
test_glwe.encode_vec_i64(&data, base2k.as_usize().into());
println!("pt: {}", test_glwe);
let k: u32 = source.next_u32();
println!("k: {k}");
let mut k_enc_prep: FheUintBlocksPrepared<Vec<u8>, u32, BE> =
FheUintBlocksPrepared::<Vec<u8>, u32, BE>::alloc(&module, &ggsw_infos);
k_enc_prep.encrypt_sk(