mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
wip
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use poulpy_core::layouts::{
|
||||
Base2K, Degree, Dnum, Dsize, GGSWCiphertext, GGSWCiphertextLayout, GLWECiphertext, GLWECiphertextLayout, GLWESecret, Rank,
|
||||
Base2K, Degree, Dnum, Dsize, GGSW, GGSWCiphertextLayout, GLWECiphertext, GLWECiphertextLayout, GLWESecret, Rank,
|
||||
TorusPrecision,
|
||||
prepared::{GGSWCiphertextPrepared, GLWESecretPrepared, PrepareAlloc},
|
||||
prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc},
|
||||
};
|
||||
use std::hint::black_box;
|
||||
|
||||
@@ -62,13 +62,13 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
rank,
|
||||
};
|
||||
|
||||
let mut ct_ggsw: GGSWCiphertext<Vec<u8>> = GGSWCiphertext::alloc(&ggsw_layout);
|
||||
let mut ct_ggsw: GGSW<Vec<u8>> = GGSW::alloc(&ggsw_layout);
|
||||
let mut ct_glwe_in: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_in_layout);
|
||||
let mut ct_glwe_out: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_out_layout);
|
||||
let pt_rgsw: ScalarZnx<Vec<u8>> = ScalarZnx::alloc(n.into(), 1);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
GGSWCiphertext::encrypt_sk_scratch_space(&module, &ggsw_layout)
|
||||
GGSW::encrypt_sk_scratch_space(&module, &ggsw_layout)
|
||||
| GLWECiphertext::encrypt_sk_scratch_space(&module, &glwe_in_layout)
|
||||
| GLWECiphertext::external_product_scratch_space(&module, &glwe_out_layout, &glwe_in_layout, &ggsw_layout),
|
||||
);
|
||||
@@ -98,7 +98,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let ggsw_prepared: GGSWCiphertextPrepared<Vec<u8>, FFT64Spqlios> = ct_ggsw.prepare_alloc(&module, scratch.borrow());
|
||||
let ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Spqlios> = ct_ggsw.prepare_alloc(&module, scratch.borrow());
|
||||
|
||||
move || {
|
||||
ct_glwe_out.external_product(&module, &ct_glwe_in, &ggsw_prepared, scratch.borrow());
|
||||
@@ -163,12 +163,12 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
rank,
|
||||
};
|
||||
|
||||
let mut ct_ggsw: GGSWCiphertext<Vec<u8>> = GGSWCiphertext::alloc(&ggsw_layout);
|
||||
let mut ct_ggsw: GGSW<Vec<u8>> = GGSW::alloc(&ggsw_layout);
|
||||
let mut ct_glwe: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_layout);
|
||||
let pt_rgsw: ScalarZnx<Vec<u8>> = ScalarZnx::alloc(n.into(), 1);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
GGSWCiphertext::encrypt_sk_scratch_space(&module, &ggsw_layout)
|
||||
GGSW::encrypt_sk_scratch_space(&module, &ggsw_layout)
|
||||
| GLWECiphertext::encrypt_sk_scratch_space(&module, &glwe_layout)
|
||||
| GLWECiphertext::external_product_inplace_scratch_space(&module, &glwe_layout, &ggsw_layout),
|
||||
);
|
||||
@@ -198,7 +198,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let ggsw_prepared: GGSWCiphertextPrepared<Vec<u8>, FFT64Spqlios> = ct_ggsw.prepare_alloc(&module, scratch.borrow());
|
||||
let ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Spqlios> = ct_ggsw.prepare_alloc(&module, scratch.borrow());
|
||||
|
||||
move || {
|
||||
let scratch_borrow = scratch.borrow();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use poulpy_core::layouts::{
|
||||
Base2K, Degree, Dnum, Dsize, GGLWEAutomorphismKey, GGLWEAutomorphismKeyLayout, GGLWESwitchingKey, GGLWESwitchingKeyLayout,
|
||||
GLWECiphertext, GLWECiphertextLayout, GLWESecret, Rank, TorusPrecision,
|
||||
prepared::{GGLWEAutomorphismKeyPrepared, GGLWESwitchingKeyPrepared, GLWESecretPrepared, PrepareAlloc},
|
||||
AutomorphismKey, AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GLWECiphertext, GLWECiphertextLayout, GLWESecret,
|
||||
GLWESwitchingKey, GLWESwitchingKeyLayout, Rank, TorusPrecision,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared, GLWESwitchingKeyPrepared, PrepareAlloc},
|
||||
};
|
||||
use std::{hint::black_box, time::Duration};
|
||||
|
||||
@@ -39,7 +39,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
|
||||
let dnum: Dnum = p.k_ct_in.div_ceil(p.base2k.0 * dsize.0).into();
|
||||
|
||||
let gglwe_atk_layout: GGLWEAutomorphismKeyLayout = GGLWEAutomorphismKeyLayout {
|
||||
let gglwe_atk_layout: AutomorphismKeyLayout = AutomorphismKeyLayout {
|
||||
n,
|
||||
base2k,
|
||||
k: k_gglwe,
|
||||
@@ -62,12 +62,12 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
rank,
|
||||
};
|
||||
|
||||
let mut ksk: GGLWEAutomorphismKey<Vec<u8>> = GGLWEAutomorphismKey::alloc(&gglwe_atk_layout);
|
||||
let mut ksk: AutomorphismKey<Vec<u8>> = AutomorphismKey::alloc(&gglwe_atk_layout);
|
||||
let mut ct_in: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_in_layout);
|
||||
let mut ct_out: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_out_layout);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
GGLWESwitchingKey::encrypt_sk_scratch_space(&module, &gglwe_atk_layout)
|
||||
GLWESwitchingKey::encrypt_sk_scratch_space(&module, &gglwe_atk_layout)
|
||||
| GLWECiphertext::encrypt_sk_scratch_space(&module, &glwe_in_layout)
|
||||
| GLWECiphertext::keyswitch_scratch_space(
|
||||
&module,
|
||||
@@ -102,7 +102,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let ksk_prepared: GGLWEAutomorphismKeyPrepared<Vec<u8>, _> = ksk.prepare_alloc(&module, scratch.borrow());
|
||||
let ksk_prepared: AutomorphismKeyPrepared<Vec<u8>, _> = ksk.prepare_alloc(&module, scratch.borrow());
|
||||
|
||||
move || {
|
||||
ct_out.automorphism(&module, &ct_in, &ksk_prepared, scratch.borrow());
|
||||
@@ -157,7 +157,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
|
||||
let dnum: Dnum = p.k_ct.div_ceil(p.base2k).into();
|
||||
|
||||
let gglwe_layout: GGLWESwitchingKeyLayout = GGLWESwitchingKeyLayout {
|
||||
let gglwe_layout: GLWESwitchingKeyLayout = GLWESwitchingKeyLayout {
|
||||
n,
|
||||
base2k,
|
||||
k: k_ksk,
|
||||
@@ -174,11 +174,11 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
rank,
|
||||
};
|
||||
|
||||
let mut ksk: GGLWESwitchingKey<Vec<u8>> = GGLWESwitchingKey::alloc(&gglwe_layout);
|
||||
let mut ksk: GLWESwitchingKey<Vec<u8>> = GLWESwitchingKey::alloc(&gglwe_layout);
|
||||
let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(&glwe_layout);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
GGLWESwitchingKey::encrypt_sk_scratch_space(&module, &gglwe_layout)
|
||||
GLWESwitchingKey::encrypt_sk_scratch_space(&module, &gglwe_layout)
|
||||
| GLWECiphertext::encrypt_sk_scratch_space(&module, &glwe_layout)
|
||||
| GLWECiphertext::keyswitch_inplace_scratch_space(&module, &glwe_layout, &gglwe_layout),
|
||||
);
|
||||
@@ -211,7 +211,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let ksk_prepared: GGLWESwitchingKeyPrepared<Vec<u8>, FFT64Spqlios> = ksk.prepare_alloc(&module, scratch.borrow());
|
||||
let ksk_prepared: GLWESwitchingKeyPrepared<Vec<u8>, FFT64Spqlios> = ksk.prepare_alloc(&module, scratch.borrow());
|
||||
|
||||
move || {
|
||||
ct.keyswitch_inplace(&module, &ksk_prepared, scratch.borrow());
|
||||
|
||||
Reference in New Issue
Block a user