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 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 page.
Primary attack against LWE instance
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)
Metadata
Release files for pqlattice 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pqlattice-0.1.4.tar.gz | 1.1 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pqlattice-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / pqlattice-0.1.4.tar.gz
| Download URL | pqlattice-0.1.4.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6aa7ed7021511b67ea183d6dd09b3a95fb5316d5e5322c4f46514e06da7268eb
|
|
BLAKE2b-256 checksum How to use checksums |
69f6ed79b6f2f81a0177535e6e05f7a43fc9a64d984298c9c3a23ec89e30b1ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Release files / pqlattice-0.1.4-py3-none-any.whl
| Download URL | pqlattice-0.1.4-py3-none-any.whl |
|---|---|
| Size | 36.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
482fc213a318194a28e25341cade1eaf64a129e281a772e06d8713205cb81897
|
|
BLAKE2b-256 checksum How to use checksums |
01e9880664ff10694f9d121af68e0471eca512aaaad42a4033cf1a32e67cdab2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Security for pqlattice 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.