mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
prototype trait for Elem<T> + new ciphertext for VmPPmat
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
use base2k::{Encoding, FFT64, SvpPPolOps, VecZnxApi, VecZnx};
|
||||
use base2k::{Encoding, FFT64, SvpPPolOps, VecZnx, VecZnxApi};
|
||||
use rlwe::{
|
||||
ciphertext::Ciphertext,
|
||||
decryptor::{Decryptor, decrypt_rlwe_thread_safe_tmp_byte},
|
||||
encryptor::{EncryptorSk, encrypt_rlwe_sk_tmp_bytes},
|
||||
keys::SecretKey,
|
||||
parameters::{Parameters, ParametersLiteral},
|
||||
plaintext::Plaintext,
|
||||
};
|
||||
use sampling::source::{Source, new_seed};
|
||||
use sampling::source::Source;
|
||||
|
||||
fn main() {
|
||||
let params_lit: ParametersLiteral = ParametersLiteral {
|
||||
@@ -30,8 +28,7 @@ fn main() {
|
||||
|
||||
let mut source: Source = Source::new([0; 32]);
|
||||
let mut sk: SecretKey = SecretKey::new(params.module());
|
||||
//sk.fill_ternary_hw(params.xs(), &mut source);
|
||||
sk.0.0[0] = 1;
|
||||
sk.fill_ternary_hw(params.xs(), &mut source);
|
||||
|
||||
let mut want = vec![i64::default(); params.n()];
|
||||
|
||||
@@ -47,10 +44,10 @@ fn main() {
|
||||
pt.0.value[0].normalize(log_base2k, &mut tmp_bytes);
|
||||
|
||||
println!("log_k: {}", log_k);
|
||||
pt.0.value[0].print_limbs(pt.limbs(), 16);
|
||||
pt.0.value[0].print(pt.cols(), 16);
|
||||
println!();
|
||||
|
||||
let mut ct: Ciphertext = params.new_ciphertext(params.log_q());
|
||||
let mut ct: Ciphertext<VecZnx> = params.new_ciphertext(params.log_q());
|
||||
|
||||
let mut source_xe: Source = Source::new([1; 32]);
|
||||
let mut source_xa: Source = Source::new([2; 32]);
|
||||
@@ -69,7 +66,7 @@ fn main() {
|
||||
|
||||
params.decrypt_rlwe_thread_safe(&mut pt, &ct, &sk_svp_ppol, &mut tmp_bytes);
|
||||
|
||||
pt.0.value[0].print_limbs(pt.limbs(), 16);
|
||||
pt.0.value[0].print(pt.cols(), 16);
|
||||
|
||||
let mut have = vec![i64::default(); params.n()];
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
use base2k::{
|
||||
Encoding, FFT64, Infos, Sampling, Scalar, SvpPPolOps, VecZnx, VecZnxApi, VecZnxBig, VecZnxDft,
|
||||
VecZnxOps,
|
||||
};
|
||||
use base2k::{Encoding, FFT64, SvpPPolOps, VecZnx, VecZnxApi, VmpPMat};
|
||||
use rlwe::{
|
||||
ciphertext::{Ciphertext, GadgetCiphertext},
|
||||
decryptor::{Decryptor, decrypt_rlwe_thread_safe, decrypt_rlwe_thread_safe_tmp_byte},
|
||||
elem::Elem,
|
||||
encryptor::{
|
||||
EncryptorSk, encrypt_grlwe_sk_thread_safe, encrypt_grlwe_sk_tmp_bytes,
|
||||
encrypt_rlwe_sk_tmp_bytes,
|
||||
},
|
||||
ciphertext::{Ciphertext, new_gadget_ciphertext},
|
||||
decryptor::decrypt_rlwe_thread_safe,
|
||||
encryptor::{encrypt_grlwe_sk_thread_safe, encrypt_grlwe_sk_tmp_bytes},
|
||||
evaluator::{gadget_product_inplace_thread_safe, gadget_product_tmp_bytes},
|
||||
key_generator::{gen_switching_key_thread_safe, gen_switching_key_thread_safe_tmp_bytes},
|
||||
keys::{SecretKey, SwitchingKey},
|
||||
key_generator::gen_switching_key_thread_safe_tmp_bytes,
|
||||
keys::SecretKey,
|
||||
parameters::{Parameters, ParametersLiteral},
|
||||
plaintext::Plaintext,
|
||||
};
|
||||
use sampling::source::{Source, new_seed};
|
||||
use sampling::source::Source;
|
||||
|
||||
fn main() {
|
||||
let params_lit: ParametersLiteral = ParametersLiteral {
|
||||
@@ -82,7 +75,7 @@ fn main() {
|
||||
let mut sk1_svp_ppol: base2k::SvpPPol = params.module().new_svp_ppol();
|
||||
params.module().svp_prepare(&mut sk1_svp_ppol, &sk1.0);
|
||||
|
||||
let mut gadget_ct: GadgetCiphertext = GadgetCiphertext::new(
|
||||
let mut gadget_ct: Ciphertext<VmpPMat> = new_gadget_ciphertext(
|
||||
params.module(),
|
||||
log_base2k,
|
||||
params.limbs_q(),
|
||||
@@ -100,21 +93,15 @@ fn main() {
|
||||
&mut tmp_bytes,
|
||||
);
|
||||
|
||||
println!("DONE?");
|
||||
|
||||
let mut pt: Plaintext<VecZnx> = Plaintext::<VecZnx>::new(
|
||||
params.module(),
|
||||
params.log_base2k(),
|
||||
params.log_q(),
|
||||
params.log_scale(),
|
||||
);
|
||||
let mut pt: Plaintext<VecZnx> =
|
||||
Plaintext::<VecZnx>::new(params.module(), params.log_base2k(), params.log_q());
|
||||
|
||||
let mut want = vec![i64::default(); params.n()];
|
||||
want.iter_mut().enumerate().for_each(|(i, x)| *x = i as i64);
|
||||
pt.0.value[0].encode_vec_i64(log_base2k, log_k, &want, 32);
|
||||
pt.0.value[0].normalize(log_base2k, &mut tmp_bytes);
|
||||
|
||||
let mut ct: Ciphertext = params.new_ciphertext(params.log_q());
|
||||
let mut ct: Ciphertext<VecZnx> = params.new_ciphertext(params.log_q());
|
||||
|
||||
params.encrypt_rlwe_sk_thread_safe(
|
||||
&mut ct,
|
||||
@@ -132,10 +119,10 @@ fn main() {
|
||||
&mut tmp_bytes,
|
||||
);
|
||||
|
||||
println!("ct.limbs()={}", ct.limbs());
|
||||
println!("ct.limbs()={}", ct.cols());
|
||||
println!("gadget_ct.rows()={}", gadget_ct.rows());
|
||||
println!("gadget_ct.cols()={}", gadget_ct.cols());
|
||||
println!("res.limbs()={}", ct.limbs());
|
||||
println!("res.limbs()={}", ct.cols());
|
||||
println!();
|
||||
|
||||
decrypt_rlwe_thread_safe(
|
||||
@@ -146,7 +133,7 @@ fn main() {
|
||||
&mut tmp_bytes,
|
||||
);
|
||||
|
||||
pt.0.value[0].print_limbs(pt.limbs(), 16);
|
||||
pt.0.value[0].print(pt.cols(), 16);
|
||||
|
||||
let mut have: Vec<i64> = vec![i64::default(); params.n()];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user