add test for GLWEBlindRotation

This commit is contained in:
Pro7ech
2025-10-25 17:58:34 +02:00
parent 6d6d00e9e4
commit 98208d5e67
13 changed files with 286 additions and 26 deletions

View File

@@ -8,6 +8,12 @@ pub trait VecZnxNormalizeTmpBytes {
fn vec_znx_normalize_tmp_bytes(&self) -> usize;
}
pub trait VecZnxZero {
fn vec_znx_zero<R>(&self, res: &mut R, res_col: usize)
where
R: VecZnxToMut;
}
pub trait VecZnxNormalize<B: Backend> {
#[allow(clippy::too_many_arguments)]
/// Normalizes the selected column of `a` and stores the result into the selected column of `res`.

View File

@@ -6,7 +6,7 @@ use crate::{
VecZnxMulXpMinusOneInplace, VecZnxMulXpMinusOneInplaceTmpBytes, VecZnxNegate, VecZnxNegateInplace, VecZnxNormalize,
VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxRotate, VecZnxRotateInplace, VecZnxRotateInplaceTmpBytes,
VecZnxRsh, VecZnxRshInplace, VecZnxRshTmpBytes, VecZnxSplitRing, VecZnxSplitRingTmpBytes, VecZnxSub, VecZnxSubInplace,
VecZnxSubNegateInplace, VecZnxSubScalar, VecZnxSubScalarInplace, VecZnxSwitchRing,
VecZnxSubNegateInplace, VecZnxSubScalar, VecZnxSubScalarInplace, VecZnxSwitchRing, VecZnxZero,
},
layouts::{Backend, Module, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef},
oep::{
@@ -18,11 +18,23 @@ use crate::{
VecZnxNormalizeInplaceImpl, VecZnxNormalizeTmpBytesImpl, VecZnxRotateImpl, VecZnxRotateInplaceImpl,
VecZnxRotateInplaceTmpBytesImpl, VecZnxRshImpl, VecZnxRshInplaceImpl, VecZnxRshTmpBytesImpl, VecZnxSplitRingImpl,
VecZnxSplitRingTmpBytesImpl, VecZnxSubImpl, VecZnxSubInplaceImpl, VecZnxSubNegateInplaceImpl, VecZnxSubScalarImpl,
VecZnxSubScalarInplaceImpl, VecZnxSwitchRingImpl,
VecZnxSubScalarInplaceImpl, VecZnxSwitchRingImpl, VecZnxZeroImpl,
},
source::Source,
};
impl<B> VecZnxZero for Module<B>
where
B: Backend + VecZnxZeroImpl<B>,
{
fn vec_znx_zero<R>(&self, res: &mut R, res_col: usize)
where
R: VecZnxToMut,
{
B::vec_znx_zero_impl(self, res, res_col);
}
}
impl<B> VecZnxNormalizeTmpBytes for Module<B>
where
B: Backend + VecZnxNormalizeTmpBytesImpl<B>,

View File

@@ -3,6 +3,16 @@ use crate::{
source::Source,
};
/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
/// * See TODO for reference implementation.
/// * See [crate::api::VecZnxZero] for corresponding public API.
/// # Safety [crate::doc::backend_safety] for safety contract.
pub unsafe trait VecZnxZeroImpl<B: Backend> {
fn vec_znx_zero_impl<R>(module: &Module<B>, res: &mut R, res_col: usize)
where
R: VecZnxToMut;
}
/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
/// * See [poulpy-backend/src/cpu_fft64_ref/vec_znx.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/vec_znx.rs) for reference implementation.
/// * See [crate::api::VecZnxNormalizeTmpBytes] for corresponding public API.

View File

@@ -13,6 +13,7 @@ mod split_ring;
mod sub;
mod sub_scalar;
mod switch_ring;
mod zero;
pub use add::*;
pub use add_scalar::*;
@@ -29,3 +30,4 @@ pub use split_ring::*;
pub use sub::*;
pub use sub_scalar::*;
pub use switch_ring::*;
pub use zero::*;

View File

@@ -0,0 +1,16 @@
use crate::{
layouts::{VecZnx, VecZnxToMut, ZnxInfos, ZnxViewMut},
reference::znx::ZnxZero,
};
pub fn vec_znx_zero<R, ZNXARI>(res: &mut R, res_col: usize)
where
R: VecZnxToMut,
ZNXARI: ZnxZero,
{
let mut res: VecZnx<&mut [u8]> = res.to_mut();
let res_size = res.size();
for j in 0..res_size {
ZNXARI::znx_zero(res.at_mut(res_col, j));
}
}