poulpy/poulpy-backend/src/cpu_spqlios/spqlios-arithmetic/README.md
poulpy-backend/src/cpu_spqlios/spqlios-arithmetic/README.mdRaw
1# SPQlios library
2
3
4
5The SPQlios library provides fast arithmetic for Fully Homomorphic Encryption, and other lattice constructions that arise in post quantum cryptography.
6
7<img src="docs/api-full.svg">
8
9Namely, it is divided into 4 sections:
10
11* The low-level DFT section support FFT over 64-bit floats, as well as NTT modulo one fixed 120-bit modulus. It is an upgrade of the original spqlios-fft module embedded in the TFHE library since 2016. The DFT section exposes the traditional DFT, inverse-DFT, and coefficient-wise multiplications in DFT space.
12* The VEC_ZNX section exposes fast algebra over vectors of small integer polynomial modulo $X^N+1$. It proposed in particular efficient (prepared) vector-matrix products, scalar-vector products, convolution products, and element-wise products, operations that naturally occurs on gadget-decomposed Ring-LWE coordinates.
13* The RNX section is a simpler variant of VEC_ZNX, to represent single polynomials modulo $X^N+1$ (over the reals or over the torus) when the coefficient precision fits on 64-bit doubles. The small vector-matrix API of the RNX section is particularly adapted to reproducing the fastest CGGI-based bootstrappings.
14* The ZN section focuses over vector and matrix algebra over scalars (used by scalar LWE, or scalar key-switches, but also on non-ring schemes like Frodo, FrodoPIR, and SimplePIR).
15
16### A high value target for hardware accelerations
17
18SPQlios is more than a library, it is also a good target for hardware developers.
19On one hand, the arithmetic operations that are defined in the library have a clear standalone mathematical definition. And at the same time, the amount of work in each operations is sufficiently large so that meaningful functions only require a few of these.
20
21This makes the SPQlios API a high value target for hardware acceleration, that targets FHE.
22
23### SPQLios is not an FHE library, but a huge enabler
24
25SPQlios itself is not an FHE library: there is no ciphertext, plaintext or key. It is a mathematical library that exposes efficient algebra over polynomials. Using the functions exposed, it is possible to quickly build efficient FHE libraries, with support for the main schemes based on Ring-LWE: BFV, BGV, CGGI, DM, CKKS.
26
27
28## Dependencies
29
30The SPQLIOS-FFT library is a C library that can be compiled with a standard C compiler, and depends only on libc and libm. The API
31interface can be used in a regular C code, and any other language via classical foreign APIs.
32
33The unittests and integration tests are in an optional part of the code, and are written in C++. These tests rely on
34[```benchmark```](https://github.com/google/benchmark), and [```gtest```](https://github.com/google/googletest) libraries, and therefore require a C++17 compiler.
35
36Currently, the project has been tested with the gcc,g++ >= 11.3.0 compiler under Linux (x86_64). In the future, we plan to
37extend the compatibility to other compilers, platforms and operating systems.
38
39
40## Installation
41
42The library uses a classical ```cmake``` build mechanism: use ```cmake``` to create a ```build``` folder in the top level directory and run ```make``` from inside it. This assumes that the standard tool ```cmake``` is already installed on the system, and an up-to-date c++ compiler (i.e. g++ >=11.3.0) as well.
43
44It will compile the shared library in optimized mode, and ```make install``` install it to the desired prefix folder (by default ```/usr/local/lib```).
45
46If you want to choose additional compile options (i.e. other installation folder, debug mode, tests), you need to run cmake manually and pass the desired options:
47```
48mkdir build
49cd build
50cmake ../src -CMAKE_INSTALL_PREFIX=/usr/
51make
52```
53The available options are the following:
54
55| Variable Name | values |
56| -------------------- | ------------------------------------------------------------ |
57| CMAKE_INSTALL_PREFIX | */usr/local* installation folder (libs go in lib/ and headers in include/) |
58| WARNING_PARANOID | All warnings are shown and treated as errors. Off by default |
59| ENABLE_TESTING | Compiles unit tests and integration tests |
60
61------
62
63<img src="docs/logo-sandboxaq-black.svg">
64
65<img src="docs/logo-inpher1.png">