| Crates.io | poulpy-hal |
| lib.rs | poulpy-hal |
| version | 0.2.1 |
| created_at | 2025-08-17 17:31:06.673634+00 |
| updated_at | 2025-09-15 17:11:23.923109+00 |
| description | A crate providing layouts and a trait-based hardware acceleration layer with open extension points, matching the API and types of spqlios-arithmetic. |
| homepage | https://github.com/phantomzone-org/poulpy |
| repository | https://github.com/phantomzone-org/poulpy |
| max_upload_size | |
| id | 1799593 |
| size | 655,061 |
Poulpy-HAL is a Rust crate that provide backend agnostic layouts and trait-based low-level lattice arithmetic matching the API of spqlios-arithmetic. This allows developpers to implement lattice-based schemes generically, with the ability to plug in any optimized backends (e.g. CPU, GPU, FPGA) at runtime.
This module defines backend agnostic layouts following spqlios-arithmetic types. There are two main types to distinguish from: user facing types and backend types. User facing types, such as vec_znx, serve both as the input and output of computations, while backend types, such as svp_ppol (a.k.a. scalar vector product prepared polynomial), are pre-processed write-only types stored in a backend-specific representation for optimized evaluation. For example in FFT64 AVX2 CPU implementation, an svp_ppol, which is the prepared type of scalar_znx, is stored in DFT with an AVX optimized data ordering.
This module also provide various helpers over these types, as well as serialization for the front end types scalar_znx, vec_znx and mat_znx.
The module is a struct that stores backend-specific pre-computations (e.g. DFT tables).
A scalar_znx is a front-end generic and backend agnostic type that stores a single small polynomial of i64 coefficients. This type is mainly used to store secret-keys or small plaintext polynomials (for example GGSW plaintexts).
A vec_znx is a front-end generic and backend agnostic type that stores a vector of small polynomials (i.e. a vector of scalars). Each polynomial is a limb that provides an additional basek-bits of precision in the Torus. For example a vec_znx with n=1024 basek=2 with 3 limbs can store 1024 coefficients with 36 bits of precision in the torus. In practice this type is used for LWE and GLWE ciphertexts/plaintexts.
A vec_znx_dft is a backend-specific type that stores a vec_znx in the DFT domain.
A vec_znx_big is a backend-specific type that stores a vec_znx with big coefficient, for example the result of a scalar multiplication or a polynomial convolution. It can be mapped back to a vec_znx by applying a normalization step.
A mat_znx is a front-end generic and backend agnostic type that stores a matrix of small polynomials (i.e. a matrix of scalars). Each row of the matrix is a vec_znx. In practice this type is used for GGLWE and GGSW ciphertexts/plaintexts.
An svp_ppol (scalar vector prepared polynomial) is a backend-specific type that stores a prepared scalar_znx. It is used to perform a scalar vector product which multiplies a vec_znx by a scalar_znx, typically when multiplying with a secret-key.
A vmp_pmat (vector matrix product prepared matrix) is a backend-specific type that stores a prepared mat_znx. It is used to perform a vector matrix product which multiplies a vec_znx by a mat_znx, a typical step of the GLWE gadget product.
A scratch is a backend agnostic scratch space manager which allows to borrows bytes or structs for intermediate computations.
This module provides the user facing traits-based API of the hardware acceleration layer. These are the traits used to implement poulpy-core and poulpy-schemes. These currently include the module instantiation, arithmetic over vec_znx, vec_znx_big, vec_znx_dft, svp_ppol, vmp_pmat and scratch space management.
This module provides open extension points, that can be implemented to provide a concrete backend to crates implementing lattice-based arithmetic using poulpy-hal/api and poulpy-hal/layouts, such as poulpy-core and poulpy-schemes or any other project/application.
This module provides a link between the open extension points and public API.
flowchart TD
A[VecZnx] -->|DFT|B[VecZnxDft]-->E
C[ScalarZnx] -->|prepare|D[SvpPPol]-->E
E{SvpApply}-->VecZnxDft-->|IDFT|VecZnxBig-->|Normalize|VecZnx
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.