Update doc & readme (#122)

* update poulpy_arch.svg

* update main readme

* update lib_diagram.png & main readme

* update poulpy-core readme

* update backend readmes

* update poulpy-hal readme

* update poulpy-schemes readme

* update CHANGELOG.md
This commit is contained in:
Jean-Philippe Bossuat
2025-11-19 17:08:11 +01:00
committed by GitHub
parent ad837c8fa8
commit 8a039e1c3a
9 changed files with 147 additions and 128 deletions

View File

@@ -1,6 +1,37 @@
# CHANGELOG # CHANGELOG
## [0.3.2] - 2025-10-27 ## [0.4.0] - 2025-10-27
### Summary
- Full support for base2k operations.
- Many improvments to BDD arithmetic.
- Removal of **poulpy-backend** & spqlios backend.
- Addition of individual crates for each specific backend.
- Some minor bug fixes.
### `poulpy-hal`
- Add cross-base2k normalization
### `poulpy-core`
- Add full support for automatic cross-base2k operations & updated tests accordingly.
- Updated noise helper API.
- Fixed many tests that didn't assess noise correctly.
- Fixed decoding function to use arithmetic rounded division instead of arithmetic right shift.
- Fixed packing to clean values correctly.
### `poulpy-schemes`
- Renamed `tfhe` crate to `bin_fhe`.
- Improved support & API for BDD arithmetic, including multi-thread acceleration.
- Updated crate to support cross-base2k operations.
- Add additional operations, such as splice_u8, splice_u16 and sign extension.
- Add `GLWEBlindRetriever` and `GLWEBlindRetrieval`: a `GGSW`-based blind reversible retrieval (enables to instantiate encrypted ROM/RAM like object).
- Improved Cmux speed
### `poulpy-cpu-ref`
- A new crate that provides the refernce CPU implementation of **poulpy-hal**. This replaces the previous **poulpy-backend/cpu_ref**.
### `poulpy-cpu-avx`
- A new crate that provides an AVX/FMA accelerated CPU implementation of **poulpy-hal**. This replaces the previous **poulpy-backend/cpu_avx**.
### `poulpy-schemes` ### `poulpy-schemes`
- Added `sign` argument to GGSW-based blind rotation, which enables to choose the rotation direction of the test vector. - Added `sign` argument to GGSW-based blind rotation, which enables to choose the rotation direction of the test vector.

View File

@@ -17,8 +17,9 @@
- **`poulpy-hal`**: a crate providing layouts and a trait-based hardware acceleration layer with open extension points, matching the API and types of spqlios-arithmetic. This crate does not provide concrete implementations other than the layouts (e.g. `VecZnx`, `VmpPmat`). - **`poulpy-hal`**: a crate providing layouts and a trait-based hardware acceleration layer with open extension points, matching the API and types of spqlios-arithmetic. This crate does not provide concrete implementations other than the layouts (e.g. `VecZnx`, `VmpPmat`).
- **`poulpy-core`**: a backend agnostic crate implementing scheme agnostic RLWE arithmetic for LWE, GLWE, GGLWE and GGSW ciphertexts using **`poulpy-hal`**. Can be instantiated with any backend provided by **`poulpy-backend`**. - **`poulpy-core`**: a backend agnostic crate implementing scheme agnostic RLWE arithmetic for LWE, GLWE, GGLWE and GGSW ciphertexts using **`poulpy-hal`**. Can be instantiated with any backend provided by **`poulpy-backend`**.
- **`poulpy-schemes`**: a backend agnostic crate implementing mainstream FHE schemes using **`poulpy-core`** and **`poulpy-hal`**. The crate can be instantiated with any backend provided by **`poulpy-backend`**. - **`poulpy-schemes`**: a backend agnostic crate implementing mainstream FHE schemes using **`poulpy-core`** and **`poulpy-hal`**.
- **`poulpy-backend`**: a crate providing concrete implementations of **`poulpy-hal`** for various representations and hardwares. - **`poulpy-cpu-ref`**: the reference CPU implementatin of **`poulpy-hal`**.
- **`poulpy-cpu-ref`**: an AVX accelerated CPU implementation of **`poulpy-hal`**.
## Bivariate Polynomial Representation ## Bivariate Polynomial Representation
@@ -43,7 +44,8 @@ This provides the following benefits:
- **`poulpy-hal`**: https://crates.io/crates/poulpy-hal - **`poulpy-hal`**: https://crates.io/crates/poulpy-hal
- **`poulpy-core`**: https://crates.io/crates/poulpy-core - **`poulpy-core`**: https://crates.io/crates/poulpy-core
- **`poulpy-schemes`**: https://crates.io/crates/poulpy-schemes - **`poulpy-schemes`**: https://crates.io/crates/poulpy-schemes
- **`poulpy-backend`**: https://crates.io/crates/poulpy-backend - **`poulpy-cpu-ref`**: https://crates.io/crates/poulpy-cpu-ref
- **`poulpy-cpu-avx`**: https://crates.io/crates/poulpy-cpu-avx
## Documentation ## Documentation
@@ -70,9 +72,9 @@ Poulpy is licensed under the Apache-2.0 License. See [NOTICE](./NOTICE) & [LICEN
Please use the following BibTex entry for citing Poulpy Please use the following BibTex entry for citing Poulpy
@misc{poulpy, @misc{poulpy,
title = {Poulpy v0.3.0}, title = {Poulpy v0.4.0},
howpublished = {Online: \url{https://github.com/phantomzone-org/poulpy}}, howpublished = {Online: \url{https://github.com/phantomzone-org/poulpy}},
month = Oct, month = Nov,
year = 2025, year = 2025,
note = {Phantom Zone} note = {Phantom Zone}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 135 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -5,14 +5,14 @@
## Getting Started ## Getting Started
```rust ```rust
use poulpy_backend::cpu_spqlios::FFT64;
use poulpy_core::{ use poulpy_core::{
GLWEOperations, SIGMA, GLWESub, SIGMA,
layouts::{ layouts::{
GLWECiphertext, GLWEPlaintext, GLWESecret, Infos, Base2K, Degree, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, TorusPrecision,
prepared::{GLWESecretPrepared, PrepareAlloc}, prepared::GLWESecretPrepared,
}, },
}; };
use poulpy_cpu_ref::FFT64Ref;
use poulpy_hal::{ use poulpy_hal::{
api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxFillUniform}, api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxFillUniform},
layouts::{Module, ScratchOwned}, layouts::{Module, ScratchOwned},
@@ -23,27 +23,36 @@ fn main() {
// Ring degree // Ring degree
let log_n: usize = 10; let log_n: usize = 10;
let n: usize = 1<<log_n; let n: Degree = Degree(1 << log_n);
// Base-2-k (implicit digit decomposition) // Base-2-k (implicit digit decomposition)
let base2k: usize = 14; let base2k: Base2K = Base2K(14);
// Ciphertext Torus precision (equivalent to ciphertext modulus) // Ciphertext Torus precision (equivalent to ciphertext modulus)
let k_ct: usize = 27; let k_ct: TorusPrecision = TorusPrecision(27);
// Plaintext Torus precision (equivament to plaintext modulus) // Plaintext Torus precision (equivament to plaintext modulus)
let k_pt: usize = base2k; let k_pt: TorusPrecision = TorusPrecision(base2k.into());
// GLWE rank // GLWE rank
let rank: usize = 1; let rank: Rank = Rank(1);
// Instantiate Module (DFT Tables) // Instantiate Module (DFT Tables)
let module: Module<FFT64> = Module::<FFT64>::new(n as u64); let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(n.0 as u64);
let glwe_ct_infos: GLWELayout = GLWELayout {
n,
base2k,
k: k_ct,
rank,
};
let glwe_pt_infos: GLWEPlaintextLayout = GLWEPlaintextLayout { n, base2k, k: k_pt };
// Allocates ciphertext & plaintexts // Allocates ciphertext & plaintexts
let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(n, base2k, k_ct, rank); let mut ct: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_ct_infos);
let mut pt_want: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc(n, base2k, k_pt); let mut pt_want: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc_from_infos(&glwe_pt_infos);
let mut pt_have: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc(n, base2k, k_pt); let mut pt_have: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::alloc_from_infos(&glwe_pt_infos);
// CPRNG // CPRNG
let mut source_xs: Source = Source::new([0u8; 32]); let mut source_xs: Source = Source::new([0u8; 32]);
@@ -51,20 +60,20 @@ fn main() {
let mut source_xa: Source = Source::new([2u8; 32]); let mut source_xa: Source = Source::new([2u8; 32]);
// Scratch space // Scratch space
let mut scratch: ScratchOwned<FFT64> = ScratchOwned::alloc( let mut scratch: ScratchOwned<FFT64Ref> = ScratchOwned::alloc(
GLWECiphertext::encrypt_sk_tmp_bytes(&module, n, base2k, ct.k()) GLWE::encrypt_sk_tmp_bytes(&module, &glwe_ct_infos) | GLWE::decrypt_tmp_bytes(&module, &glwe_ct_infos),
| GLWECiphertext::decrypt_tmp_bytes(&module, n, base2k, ct.k()),
); );
// Generate secret-key // Generate secret-key
let mut sk: GLWESecret<Vec<u8>> = GLWESecret::alloc(n, rank); let mut sk: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_ct_infos);
sk.fill_ternary_prob(0.5, &mut source_xs); sk.fill_ternary_prob(0.5, &mut source_xs);
// Backend-prepared secret // Backend-prepared secret
let sk_prepared: GLWESecretPrepared<Vec<u8>, FFT64> = sk.prepare_alloc(&module, scratch.borrow()); let mut sk_prepared: GLWESecretPrepared<Vec<u8>, FFT64Ref> = GLWESecretPrepared::alloc(&module, rank);
sk_prepared.prepare(&module, &sk);
// Uniform plaintext // Uniform plaintext
module.vec_znx_fill_uniform(base2k, &mut pt_want.data, 0, k_pt, &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(
@@ -80,10 +89,10 @@ fn main() {
ct.decrypt(&module, &mut pt_have, &sk_prepared, scratch.borrow()); ct.decrypt(&module, &mut pt_have, &sk_prepared, scratch.borrow());
// Diff between pt - Dec(Enc(pt)) // Diff between pt - Dec(Enc(pt))
pt_want.sub_inplace_ab(&module, &pt_have); module.glwe_sub_inplace(&mut pt_want, &pt_have);
// Ideal vs. actual noise // Ideal vs. actual noise
let noise_have: f64 = pt_want.data.std(base2k, 0) * (ct.k() as f64).exp2(); let noise_have: f64 = pt_want.data.stats(base2k.into(), 0).std() * (ct.k().as_u32() as f64).exp2();
let noise_want: f64 = SIGMA; let noise_want: f64 = SIGMA;
// Check // Check
@@ -169,4 +178,4 @@ ggsw.automorphism(...);
## Tests ## Tests
A fully generic test suite is available in [`src/tests/generics`](./src/tests/generics). A fully generic test suite is available in [`src/tests/test_suite`](./src/tests/test_suite).

View File

@@ -1,6 +1,6 @@
# 🐙 Poulpy-Backend # 🐙 Poulpy-CPU-REF
**Poulpy-Backend-CPU-AVX** is a Rust crate that provides concrete implementations of **`poulpy-hal`**. This crate is used to instantiate projects implemented with **`poulpy-hal`**, **`poulpy-core`** and/or **`poulpy-schemes`**. **Poulpy-Backend-CPU-AVX** is a Rust crate that provides an AVX accelerated CPU implementation of **`poulpy-hal`**. This crate is used to instantiate projects implemented with **`poulpy-hal`**, **`poulpy-core`** and/or **`poulpy-schemes`**.
## Example ## Example
@@ -14,5 +14,5 @@ let module = Module<FFT64Avx> = Module<FFT64Avx>::new(1<<log_n);
## Contributors ## Contributors
To add a backend, implement the open extension traits from **`poulpy-hal/oep`** for a struct that implements the `Backend` trait. To add your own backend, implement the open extension traits from **`poulpy-hal/oep`** for a struct that implements the `Backend` trait.
This will automatically make your backend compatible with the API of **`poulpy-hal`**, **`poulpy-core`** and **`poulpy-schemes`**. This will automatically make your backend compatible with the API of **`poulpy-hal`**, **`poulpy-core`** and **`poulpy-schemes`**.

View File

@@ -1,38 +1,18 @@
# 🐙 Poulpy-Backend # 🐙 Poulpy-CPU-AVX
**Poulpy-Backend** is a Rust crate that provides concrete implementations of **`poulpy-hal`**. This crate is used to instantiate projects implemented with **`poulpy-hal`**, **`poulpy-core`** and/or **`poulpy-schemes`**. **Poulpy-Backend-CPU-AVX** is a Rust crate that provides the reference CPU implementation of **`poulpy-hal`**. This crate is used to instantiate projects implemented with **`poulpy-hal`**, **`poulpy-core`** and/or **`poulpy-schemes`**.
## Backends ## Example
### cpu-spqlios
This module provides a CPU AVX2 accelerated backend through C bindings over [**spqlios-arithmetic**](https://github.com/tfhe/spqlios-arithmetic).
- Currently supported: `FFT64` backend
- Planned: `NTT120` backend
### Build Notes
This backend is built and compiled automatically and has been tested on wsl/ubuntu.
- `cmake` is invoked automatically by the build script (`build.rs`) when compiling the crate.
- No manual setup is required beyond having a standard Rust toolchain.
- Build options can be changed in `/build/cpu_spqlios.rs`
- Automatic build of cpu-spqlios/spqlios-arithmetic can be disabled in `build.rs`.
Spqlios-arithmetic is windows/mac compatible but building for those platforms is slightly different (see [spqlios-arithmetic/wiki/build](https://github.com/tfhe/spqlios-arithmetic/wiki/build)) and has not been tested in Poulpy.
### Example
```rust ```rust
use poulpy_backend::cpu_spqlios::FFT64; use poulpy_backend_cpu_ref::FFT64Ref;
use poulpy_hal::{api::ModuleNew, layouts::Module}; use poulpy_hal::{api::ModuleNew, layouts::Module};
let log_n: usize = 10; let log_n: usize = 10;
let module = Module<FFT64> = Module<FFT64>::new(1<<log_n); let module = Module<FFT64Ref> = Module<FFT64Ref>::new(1<<log_n);
``` ```
## Contributors ## Contributors
To add a backend, implement the open extension traits from **`poulpy-hal/oep`** for a struct that implements the `Backend` trait. To add your own backend, implement the open extension traits from **`poulpy-hal/oep`** for a struct that implements the `Backend` trait.
This will automatically make your backend compatible with the API of **`poulpy-hal`**, **`poulpy-core`** and **`poulpy-schemes`**. This will automatically make your backend compatible with the API of **`poulpy-hal`**, **`poulpy-core`** and **`poulpy-schemes`**.

View File

@@ -82,6 +82,6 @@ flowchart TD
E{SvpApply}-->VecZnxDft-->|IDFT|VecZnxBig-->|Normalize|VecZnx E{SvpApply}-->VecZnxDft-->|IDFT|VecZnxBig-->|Normalize|VecZnx
``` ```
## Testing ## Tests
A full generic and backend agnostic testing suit for the layouts and public API is planned. This will allow to test the correctness of any backend easily. A fully generic cross-backend test suite is available in [`src/test_suite`](./src/test_suite).

View File

@@ -8,5 +8,8 @@ See [./examples/circuit_bootstrapping.rs](./examples/circuit_bootstrapping.rs)
## Available Schemes ## Available Schemes
- TFHE/FHEW: under construction. Blind rotation & circuit bootstrapping implemented. - **BIN FHE**:
- CKKS: planned - **bdd_arithmetic**: high level API for u32 arithmetic (u8 to u256 planned) using binary decision circuits. Also provides API for blind retrieval, blind rotation (using encpypted integers) and blind selection.
- **blind_rotation**: API for blind rotation (LWE(m) -> GLWE(X^m))
- **circuit_bootstrapping**: API for circuit bootstrapping (LWE(m) -> GGSW(m) or GGSW(X^m)).
- **CKKS**: planned