mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
minimal changes to reproduce printing ci_big at encrypt_pk
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
use poulpy_core::{
|
use poulpy_core::{
|
||||||
GLWESub, SIGMA,
|
|
||||||
layouts::{
|
layouts::{
|
||||||
Base2K, Degree, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, TorusPrecision,
|
prepared::GLWESecretPrepared, Base2K, Degree, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank,
|
||||||
prepared::GLWESecretPrepared,
|
TorusPrecision, GLWE,
|
||||||
},
|
},
|
||||||
|
GLWESub, SIGMA,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(feature = "enable-avx", target_arch = "x86_64"))]
|
#[cfg(all(feature = "enable-avx", target_arch = "x86_64"))]
|
||||||
@@ -71,14 +71,33 @@ fn main() {
|
|||||||
let mut sk_prepared: GLWESecretPrepared<Vec<u8>, BackendImpl> = GLWESecretPrepared::alloc(&module, rank);
|
let mut sk_prepared: GLWESecretPrepared<Vec<u8>, BackendImpl> = GLWESecretPrepared::alloc(&module, rank);
|
||||||
sk_prepared.prepare(&module, &sk);
|
sk_prepared.prepare(&module, &sk);
|
||||||
|
|
||||||
|
// DBG:
|
||||||
|
// obtain pk from sk
|
||||||
|
let mut pk = poulpy_core::layouts::GLWEPublicKey::alloc_from_infos(&glwe_ct_infos);
|
||||||
|
pk.generate(&module, &sk_prepared, &mut source_xa, &mut source_xe);
|
||||||
|
// Backend-prepared publickey:
|
||||||
|
let mut pk_prepared: poulpy_core::layouts::GLWEPublicKeyPrepared<Vec<u8>, BackendImpl> =
|
||||||
|
poulpy_core::layouts::GLWEPublicKeyPrepared::alloc(&module, base2k, k_ct, rank);
|
||||||
|
pk_prepared.prepare(&module, &pk);
|
||||||
|
|
||||||
// Uniform plaintext
|
// Uniform plaintext
|
||||||
module.vec_znx_fill_uniform(base2k.into(), &mut pt_want.data, 0, &mut source_xa);
|
module.vec_znx_fill_uniform(base2k.into(), &mut pt_want.data, 0, &mut source_xa);
|
||||||
|
|
||||||
// Encryption
|
// Encryption
|
||||||
ct.encrypt_sk(
|
// ct.encrypt_sk(
|
||||||
|
// &module,
|
||||||
|
// &pt_want,
|
||||||
|
// &sk_prepared,
|
||||||
|
// &mut source_xa,
|
||||||
|
// &mut source_xe,
|
||||||
|
// scratch.borrow(),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// DBG: encrypt with public key
|
||||||
|
ct.encrypt_pk(
|
||||||
&module,
|
&module,
|
||||||
&pt_want,
|
&pt_want,
|
||||||
&sk_prepared,
|
&pk_prepared,
|
||||||
&mut source_xa,
|
&mut source_xa,
|
||||||
&mut source_xe,
|
&mut source_xe,
|
||||||
scratch.borrow(),
|
scratch.borrow(),
|
||||||
|
|||||||
@@ -401,6 +401,9 @@ where
|
|||||||
// ci_big = u * p[i]
|
// ci_big = u * p[i]
|
||||||
let mut ci_big = self.vec_znx_idft_apply_consume(ci_dft);
|
let mut ci_big = self.vec_znx_idft_apply_consume(ci_dft);
|
||||||
|
|
||||||
|
// to print it run: cargo run --example encryption -- --nocapture
|
||||||
|
println!("DBG: ci_big before adding e: {:?}", &ci_big.data);
|
||||||
|
|
||||||
// ci_big = u * pk[i] + e
|
// ci_big = u * pk[i] + e
|
||||||
self.vec_znx_big_add_normal(base2k, &mut ci_big, 0, pk.k().into(), source_xe, SIGMA, SIGMA_BOUND);
|
self.vec_znx_big_add_normal(base2k, &mut ci_big, 0, pk.k().into(), source_xe, SIGMA, SIGMA_BOUND);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user