mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
dbg normalize check
This commit is contained in:
@@ -339,6 +339,7 @@ where
|
||||
+ SvpPPolBytesOf
|
||||
+ ModuleN
|
||||
+ VecZnxDftBytesOf,
|
||||
BE: Backend<ScalarBig = i64>,
|
||||
Scratch<BE>: ScratchTakeBasic,
|
||||
{
|
||||
fn glwe_encrypt_pk_internal<R, P, K>(
|
||||
@@ -413,11 +414,31 @@ where
|
||||
|
||||
// ct[i] = norm(ci_big)
|
||||
self.vec_znx_big_normalize(&mut res.data, base2k, 0, i, &ci_big, base2k, 0, scratch_2);
|
||||
|
||||
use poulpy_hal::layouts::ZnxView;
|
||||
for k in 0..res.size(){
|
||||
normalize_check(i, k, ci_big.at(i, k), res.data.at(i, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DBG
|
||||
fn normalize_check(i: usize /*col*/, k: usize, a: &[i64], b: &[i64]) {
|
||||
assert_eq!(a.len(), b.len());
|
||||
// let c_{i,j} be the coefficients of the normalized polynomial, then
|
||||
// i. it is K-normalized if c_{i,j} \in [-2^{K-1}, 2^{K-1}) \forall i=0,\ldots,N-1; j \geq 1
|
||||
// ii. it is reduced if additionally c_{i,0}=0 ~\forall~ i=0, \ldots, N-1
|
||||
if k == 0 {
|
||||
for j in 0..a.len() {
|
||||
assert_eq!(b[j], a[j]);
|
||||
}
|
||||
}
|
||||
// println!("a {:?}", a);
|
||||
// println!("b {:?}", b);
|
||||
}
|
||||
|
||||
pub(crate) trait GLWEEncryptSkInternal<BE: Backend> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn glwe_encrypt_sk_internal<R, P, S>(
|
||||
|
||||
Reference in New Issue
Block a user