More fixes

This commit is contained in:
Jean-Philippe Bossuat
2025-07-15 20:16:38 +02:00
parent a8e8743b50
commit 07a1d7227e
2 changed files with 13 additions and 13 deletions

View File

@@ -2,7 +2,7 @@ use backend::{
FFT64, MatZnxDftOps, MatZnxDftScratch, Module, Scratch, VecZnxBig, VecZnxBigOps, VecZnxDftAlloc, VecZnxDftOps, VecZnxScratch, FFT64, MatZnxDftOps, MatZnxDftScratch, Module, Scratch, VecZnxBig, VecZnxBigOps, VecZnxDftAlloc, VecZnxDftOps, VecZnxScratch,
}; };
use crate::{FourierGLWECiphertext, GGSWCiphertext, GLWECiphertext, Infos}; use crate::{GGSWCiphertext, GLWECiphertext, Infos};
impl GLWECiphertext<Vec<u8>> { impl GLWECiphertext<Vec<u8>> {
pub fn external_product_scratch_space( pub fn external_product_scratch_space(
@@ -14,21 +14,21 @@ impl GLWECiphertext<Vec<u8>> {
digits: usize, digits: usize,
rank: usize, rank: usize,
) -> usize { ) -> usize {
let res_dft: usize = FourierGLWECiphertext::bytes_of(module, basek, k_ggsw, rank);
let in_size: usize = k_in.div_ceil(basek).div_ceil(digits); let in_size: usize = k_in.div_ceil(basek).div_ceil(digits);
let out_size: usize = k_out.div_ceil(basek); let out_size: usize = k_out.div_ceil(basek);
let ggsw_size: usize = k_ggsw.div_ceil(basek); let ggsw_size: usize = k_ggsw.div_ceil(basek);
let vmp: usize = module.bytes_of_vec_znx_dft(rank + 1, ggsw_size) let res_dft: usize = module.bytes_of_vec_znx_dft(rank + 1, ggsw_size);
+ module.vmp_apply_tmp_bytes( let a_dft: usize = module.bytes_of_vec_znx_dft(rank + 1, in_size);
out_size, let vmp: usize = module.vmp_apply_tmp_bytes(
in_size, out_size,
in_size, // rows in_size,
rank + 1, // cols in in_size, // rows
rank + 1, // cols out rank + 1, // cols in
ggsw_size, rank + 1, // cols out
); ggsw_size,
);
let normalize: usize = module.vec_znx_normalize_tmp_bytes(); let normalize: usize = module.vec_znx_normalize_tmp_bytes();
res_dft + (vmp | normalize) res_dft + a_dft + (vmp | normalize)
} }
pub fn external_product_inplace_scratch_space( pub fn external_product_inplace_scratch_space(

View File

@@ -111,7 +111,7 @@ fn test_encrypt_pk(log_n: usize, basek: usize, k_ct: usize, k_pk: usize, sigma:
let module: Module<FFT64> = Module::<FFT64>::new(1 << log_n); let module: Module<FFT64> = Module::<FFT64>::new(1 << log_n);
let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&module, basek, k_ct, rank); let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&module, basek, k_ct, rank);
let mut pt_have = GLWEPlaintext::alloc(&module, basek, k_ct); let mut pt_have: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc(&module, basek, k_ct);
let mut pt_want: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc(&module, basek, k_ct); let mut pt_want: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc(&module, basek, k_ct);
let mut source_xs: Source = Source::new([0u8; 32]); let mut source_xs: Source = Source::new([0u8; 32]);