Add glwe_normalize_tmp_bytes & update assertion error

This commit is contained in:
Pro7ech
2025-11-12 22:21:32 +01:00
parent b034ea8253
commit b11213c454
2 changed files with 16 additions and 5 deletions

View File

@@ -2,8 +2,8 @@ use poulpy_hal::{
api::{
BivariateTensoring, ModuleN, ScratchTakeBasic, VecZnxAdd, VecZnxAddInplace, VecZnxBigNormalize, VecZnxCopy,
VecZnxIdftApplyConsume, VecZnxMulXpMinusOne, VecZnxMulXpMinusOneInplace, VecZnxNegate, VecZnxNormalize,
VecZnxNormalizeInplace, VecZnxRotate, VecZnxRotateInplace, VecZnxRshInplace, VecZnxSub, VecZnxSubInplace,
VecZnxSubNegateInplace, VecZnxZero,
VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxRotate, VecZnxRotateInplace, VecZnxRshInplace, VecZnxSub,
VecZnxSubInplace, VecZnxSubNegateInplace, VecZnxZero,
},
layouts::{Backend, Module, Scratch, VecZnx, VecZnxBig, ZnxInfos},
reference::vec_znx::vec_znx_rotate_inplace_tmp_bytes,
@@ -389,12 +389,19 @@ impl GLWE<Vec<u8>> {
}
}
impl<BE: Backend> GLWENormalize<BE> for Module<BE> where Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> {}
impl<BE: Backend> GLWENormalize<BE> for Module<BE> where
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> + VecZnxNormalizeTmpBytes
{
}
pub trait GLWENormalize<BE: Backend>
where
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE>,
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> + VecZnxNormalizeTmpBytes,
{
fn glwe_normalize_tmp_bytes(&self) -> usize {
self.vec_znx_normalize_tmp_bytes()
}
fn glwe_normalize<R, A>(&self, res: &mut R, a: &A, scratch: &mut Scratch<BE>)
where
R: GLWEToMut,

View File

@@ -331,7 +331,11 @@ where
let scratch_thread_size = self.fhe_uint_prepare_tmp_bytes(cbt.block_size(), 1, res, bits, key);
assert!(scratch.available() >= threads * scratch_thread_size);
assert!(
scratch.available() >= threads * scratch_thread_size,
"scratch.available():{} < threads:{threads} * scratch_thread_size:{scratch_thread_size}",
scratch.available()
);
let chunk_size: usize = bit_count.div_ceil(threads);