mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
add test for GLWEBlindRotation
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
16
poulpy-hal/src/reference/vec_znx/zero.rs
Normal file
16
poulpy-hal/src/reference/vec_znx/zero.rs
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user