Update READMEs & add SECURITY.md (#78)

This commit is contained in:
Jean-Philippe Bossuat
2025-08-20 20:52:59 +02:00
committed by GitHub
parent 3b94ab047e
commit ccd94e36cc
256 changed files with 1982 additions and 31869 deletions

View File

@@ -10,8 +10,8 @@ homepage = "https://github.com/phantomzone-org/poulpy"
documentation = "https://docs.rs/poulpy"
[dependencies]
poulpy-backend = "0.1.2"
poulpy-hal = "0.1.2"
poulpy-core = "0.1.1"
poulpy-backend = {path="../poulpy-backend"}
poulpy-hal = {path="../poulpy-hal"}
poulpy-core = {path="../poulpy-core"}
itertools = "0.14.0"
byteorder = "1.5.0"

View File

@@ -0,0 +1,12 @@
# 🐙 Poulpy-Schemes
**Poulpy-Schemes** is a Rust crate built on **`poulpy-hal`** and **`poulpy-core`**, providing backend agnostic RLWE-based FHE schemes implementation.
## Getting Started
See [./examples/circuit_bootstrapping.rs](./examples/circuit_bootstrapping.rs)
## Available Schemes
- TFHE/FHEW: under construction. Blind rotation & circuit bootstrapping implemented.
- CKKS: planned

View File

@@ -38,9 +38,6 @@ fn main() {
// GLWE rank
let rank: usize = 1;
// Noise (discrete) standard deviation
let sigma: f64 = 3.2;
// LWE degree
let n_lwe: usize = 574;
@@ -110,22 +107,16 @@ fn main() {
// LWE plaintext(data * 2^{- (k_lwe_pt - 1)})
pt_lwe.encode_i64(data, k_lwe_pt + 1); // +1 for padding bit
module.vec_znx_normalize_inplace(basek, pt_lwe.data_mut(), 0, scratch.borrow());
// Normalize plaintext to nicely print coefficients
module.vec_znx_normalize_inplace(basek, pt_lwe.data_mut(), 0, scratch.borrow());
println!("pt_lwe: {}", pt_lwe);
// LWE ciphertext
let mut ct_lwe: LWECiphertext<Vec<u8>> = LWECiphertext::alloc(n_lwe, basek, k_lwe_ct);
// Encrypt LWE Plaintext
ct_lwe.encrypt_sk(
&module,
&pt_lwe,
&sk_lwe,
&mut source_xa,
&mut source_xe,
sigma,
);
ct_lwe.encrypt_sk(&module, &pt_lwe, &sk_lwe, &mut source_xa, &mut source_xe);
let now: Instant = Instant::now();
@@ -143,7 +134,6 @@ fn main() {
rows_tsk,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);
println!("CBT-KGEN: {} ms", now.elapsed().as_millis());
@@ -199,7 +189,6 @@ fn main() {
&sk_glwe_prepared,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);

View File

@@ -71,7 +71,6 @@ where
sk_lwe: &LWESecret<DataSkLWE>,
source_xa: &mut Source,
source_xe: &mut Source,
sigma: f64,
scratch: &mut Scratch<B>,
) where
DataSkGLWE: DataRef,
@@ -100,7 +99,7 @@ where
self.keys.iter_mut().enumerate().for_each(|(i, ggsw)| {
pt.at_mut(0, 0)[0] = sk_ref.at(0, 0)[i];
ggsw.encrypt_sk(module, &pt, sk_glwe, source_xa, source_xe, sigma, scratch);
ggsw.encrypt_sk(module, &pt, sk_glwe, source_xa, source_xe, scratch);
});
}
}
@@ -157,7 +156,6 @@ impl<D: DataMut> BlindRotationKeyCompressed<D, CGGI> {
sk_lwe: &LWESecret<DataSkLWE>,
seed_xa: [u8; 32],
source_xe: &mut Source,
sigma: f64,
scratch: &mut Scratch<B>,
) where
DataSkGLWE: DataRef,
@@ -209,7 +207,6 @@ impl<D: DataMut> BlindRotationKeyCompressed<D, CGGI> {
sk_glwe,
source_xa.new_seed(),
source_xe,
sigma,
scratch,
);
});

View File

@@ -28,7 +28,6 @@ pub trait BlindRotationKeyEncryptSk<B: Backend> {
sk_lwe: &LWESecret<DataSkLWE>,
source_xa: &mut Source,
source_xe: &mut Source,
sigma: f64,
scratch: &mut Scratch<B>,
) where
DataSkGLWE: DataRef,

View File

@@ -127,7 +127,6 @@ where
&sk_lwe,
&mut source_xa,
&mut source_xe,
3.2,
scratch.borrow(),
);
@@ -139,14 +138,7 @@ where
pt_lwe.encode_i64(x, log_message_modulus + 1);
lwe.encrypt_sk(
module,
&pt_lwe,
&sk_lwe,
&mut source_xa,
&mut source_xe,
3.2,
);
lwe.encrypt_sk(module, &pt_lwe, &sk_lwe, &mut source_xa, &mut source_xe);
let f = |x: i64| -> i64 { 2 * x + 1 };

View File

@@ -35,7 +35,6 @@ pub trait CircuitBootstrappingKeyEncryptSk<B: Backend> {
rows_tsk: usize,
source_xa: &mut Source,
source_xe: &mut Source,
sigma: f64,
scratch: &mut Scratch<B>,
) -> Self
where
@@ -88,7 +87,6 @@ where
rows_tsk: usize,
source_xa: &mut Source,
source_xe: &mut Source,
sigma: f64,
scratch: &mut Scratch<B>,
) -> Self
where
@@ -101,9 +99,7 @@ where
gal_els.iter().for_each(|gal_el| {
let mut key: GGLWEAutomorphismKey<Vec<u8>> =
GGLWEAutomorphismKey::alloc(sk_glwe.n(), basek, k_trace, rows_trace, 1, sk_glwe.rank());
key.encrypt_sk(
module, *gal_el, sk_glwe, source_xa, source_xe, sigma, scratch,
);
key.encrypt_sk(module, *gal_el, sk_glwe, source_xa, source_xe, scratch);
auto_keys.insert(*gal_el, key);
});
@@ -124,12 +120,11 @@ where
sk_lwe,
source_xa,
source_xe,
sigma,
scratch,
);
let mut tsk: GGLWETensorKey<Vec<u8>> = GGLWETensorKey::alloc(sk_glwe.n(), basek, k_tsk, rows_tsk, 1, sk_glwe.rank());
tsk.encrypt_sk(module, sk_glwe, source_xa, source_xe, sigma, scratch);
tsk.encrypt_sk(module, sk_glwe, source_xa, source_xe, scratch);
Self {
brk,

View File

@@ -101,7 +101,6 @@ where
let basek: usize = 17;
let extension_factor: usize = 1;
let rank: usize = 1;
let sigma: f64 = 3.2;
let n_lwe: usize = 77;
let k_lwe_pt: usize = 4;
@@ -139,14 +138,7 @@ where
println!("pt_lwe: {}", pt_lwe);
let mut ct_lwe: LWECiphertext<Vec<u8>> = LWECiphertext::alloc(n_lwe, basek, k_lwe_ct);
ct_lwe.encrypt_sk(
module,
&pt_lwe,
&sk_lwe,
&mut source_xa,
&mut source_xe,
sigma,
);
ct_lwe.encrypt_sk(module, &pt_lwe, &sk_lwe, &mut source_xa, &mut source_xe);
let now: Instant = Instant::now();
let cbt_key: CircuitBootstrappingKey<Vec<u8>, BRA> = CircuitBootstrappingKey::encrypt_sk(
@@ -162,7 +154,6 @@ where
rows_tsk,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);
println!("CBT-KGEN: {} ms", now.elapsed().as_millis());
@@ -207,7 +198,6 @@ where
&sk_glwe_prepared,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);
@@ -285,11 +275,10 @@ where
BlindRotationKeyPrepared<Vec<u8>, BRA, B>: BlincRotationExecute<B>,
BlindRotationKey<Vec<u8>, BRA>: BlindRotationKeyAlloc + BlindRotationKeyEncryptSk<B>,
{
let n = module.n();
let n: usize = module.n();
let basek: usize = 14;
let extension_factor: usize = 1;
let rank: usize = 2;
let sigma: f64 = 3.2;
let n_lwe: usize = 77;
let k_lwe_pt: usize = 1;
@@ -327,14 +316,7 @@ where
println!("pt_lwe: {}", pt_lwe);
let mut ct_lwe: LWECiphertext<Vec<u8>> = LWECiphertext::alloc(n_lwe, basek, k_lwe_ct);
ct_lwe.encrypt_sk(
module,
&pt_lwe,
&sk_lwe,
&mut source_xa,
&mut source_xe,
sigma,
);
ct_lwe.encrypt_sk(module, &pt_lwe, &sk_lwe, &mut source_xa, &mut source_xe);
let now: Instant = Instant::now();
let cbt_key: CircuitBootstrappingKey<Vec<u8>, BRA> = CircuitBootstrappingKey::encrypt_sk(
@@ -350,7 +332,6 @@ where
rows_tsk,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);
println!("CBT-KGEN: {} ms", now.elapsed().as_millis());
@@ -391,7 +372,6 @@ where
&sk_glwe_prepared,
&mut source_xa,
&mut source_xe,
sigma,
scratch.borrow(),
);