clippy + cleanup

This commit is contained in:
Rasoul Akhavan Mahdavi
2025-12-01 22:07:03 -05:00
parent 48407ccefc
commit 4a6c96dfc8
4 changed files with 43 additions and 82 deletions

View File

@@ -1,7 +1,7 @@
use std::collections::HashMap;
use poulpy_core::{
GLWEDecrypt, GLWEEncryptSk, GLWEExternalProduct, LWEEncryptSk, ScratchTakeCore,
GLWEDecrypt, GLWEEncryptSk, ScratchTakeCore,
layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEToGGSWKeyLayout, GGSWLayout, GGSWPreparedFactory, GLWEAutomorphismKeyLayout,
GLWELayout, GLWESecret, GLWESecretPrepared, GLWESecretPreparedFactory, GLWESwitchingKeyLayout, GLWEToLWEKeyLayout,
@@ -9,7 +9,7 @@ use poulpy_core::{
},
};
use poulpy_hal::{
api::{ModuleN, ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxRotateInplace},
api::{ModuleN, ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow},
layouts::{Backend, Module, Scratch, ScratchOwned},
source::Source,
};
@@ -41,18 +41,17 @@ use poulpy_cpu_ref::FFT64Ref;
//
// - Result Decryption
//
// There also is an example use of the GLWE Blind Selection operation,
// which can choose between any number of encrypted fheuint inputs
fn example_bdd_arithmetic<BE: Backend, BRA: BlindRotationAlgo>()
where
Module<BE>: ModuleNew<BE>
+ ModuleN
+ GLWESecretPreparedFactory<BE>
+ GLWEExternalProduct<BE>
+ GLWEDecrypt<BE>
+ LWEEncryptSk<BE>
+ GGSWPreparedFactory<BE>
+ GLWEEncryptSk<BE>
+ VecZnxRotateInplace<BE>
+ BDDKeyEncryptSk<BRA, BE>
+ BDDKeyPreparedFactory<BRA, BE>
+ FheUintPrepare<BRA, BE>

View File

@@ -76,37 +76,34 @@ where
dsize: Dsize(1),
};
// Used to generate CBT Keys
let cbt_layout = CircuitBootstrappingKeyLayout {
brk_layout: BlindRotationKeyLayout {
n_glwe: Degree(N_GLWE),
n_lwe: Degree(N_LWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
rank: Rank(RANK),
},
atk_layout: GLWEAutomorphismKeyLayout {
n: Degree(N_GLWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
dsize: Dsize(1),
rank: Rank(RANK),
},
tsk_layout: GGLWEToGGSWKeyLayout {
n: Degree(N_GLWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
dsize: Dsize(1),
rank: Rank(RANK),
},
};
// Used to generate BDD Keys, for the arithmetic operations
let bdd_layout = BDDKeyLayout {
cbt_layout: cbt_layout,
cbt_layout: CircuitBootstrappingKeyLayout {
brk_layout: BlindRotationKeyLayout {
n_glwe: Degree(N_GLWE),
n_lwe: Degree(N_LWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
rank: Rank(RANK),
},
atk_layout: GLWEAutomorphismKeyLayout {
n: Degree(N_GLWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
dsize: Dsize(1),
rank: Rank(RANK),
},
tsk_layout: GGLWEToGGSWKeyLayout {
n: Degree(N_GLWE),
base2k: Base2K(BASE2K),
k: TorusPrecision(4 * BASE2K),
dnum: Dnum(4),
dsize: Dsize(1),
rank: Rank(RANK),
},
},
ks_glwe_layout: Some(GLWESwitchingKeyLayout {
n: Degree(N_GLWE),
base2k: Base2K(BASE2K),
@@ -212,7 +209,7 @@ where
let mut input_i_enc_prepared: FheUintPrepared<Vec<u8>, u32, BE> =
FheUintPrepared::alloc_from_infos(&module, &ggsw_layout);
input_i_enc_prepared.prepare(&module, &input_i, &bdd_key_prepared, scratch.borrow());
input_i_enc_prepared.prepare(&module, input_i, &bdd_key_prepared, scratch.borrow());
// b = (input_i < max)
compare_enc.sltu(