Metadata-Version: 2.4
Name: pqlattice
Version: 0.1.4
Summary: Add your description here
Project-URL: Repository, https://github.com/MikolajLH/pqlattice.git
Project-URL: Documentation, https://mikolajlh.github.io/pqlattice/
Author-email: Mikołaj Leonhardt <mikolaj.leonhardt@gmail.com>
License: Copyright (c) 2026, Mikołaj Leonhardt
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: cryptography,lattice
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.12
Requires-Dist: numpy>=1.26
Provides-Extra: fast
Requires-Dist: cysignals>=1.12.6; extra == 'fast'
Requires-Dist: fpylll>=0.6.4; extra == 'fast'
Requires-Dist: python-flint>=0.8.0; extra == 'fast'
Description-Content-Type: text/markdown

# pqlattice - Python library for lattice based cryptography and cryptoanalysis
## Summary
`pqlattice` is a Python library for **Lattice-based cryptography and cryptoanalysis**.
It provides implmenetations of lattice reduction algorithms such as **LLL**, **BKZ** and **HKZ**, arithemtics over integer quotient rings and polynomial quotient rings and linear algebra functions for integer based matrices.
It also implements discrete guassian distribution and LWE distribution.
Check out the [API reference](https://mikolajlh.github.io/pqlattice/) for full list of modules and functions.

The core version of pqlattice was written in pure python with `numpy` as only dependency.
There is optional dependencies group `pqlattice[fast]`, that uses `fpylll` for lattice reductions and `python-flint` for hermite normal form computations.

## Instalation
For standard version, install directly via pip:
```
pip install pqlattice
```

For fast backend based on fpylll and python-flint:
```
pip install "pqlattice[fast]"
```
Due to fpylll depending on external binaries it might be not trival to install this version of library, especially on windows. We encourage to the users to use google-collab enviroment which already has all external libraries installed and simple `pip install "pqlattice[fast]"` should work.

## Examples
Too see more examples check out the [examples](https://mikolajlh.github.io/pqlattice/examples/attacking_congruential_pkc/) page.
### Primary attack against LWE instance
```python
import pqlattice as pq
import numpy as np
import math
pq.settings.set_backend("fast")

n = 14
sigma = 2
q = 1000
m = 50
secret_dist = "ternary"

lwe = pq.random.LWE(n, q, sigma, secret_dist, 80)
secret = lwe.secret
A, b = lwe.sample_matrix(m)

K = pq.lattice.embeddings.kannan(A, b, q)

L = pq.lattice.lll(K)
B = pq.lattice.bkz(L)

short_vector = B[0]
e = v[:m]
s = v[m:m + n]

assert np.all(lwe.secret == s)
```
