Add your description here
Project description
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pqlattice-0.1.4.tar.gz.
File metadata
- Download URL: pqlattice-0.1.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aa7ed7021511b67ea183d6dd09b3a95fb5316d5e5322c4f46514e06da7268eb
|
|
| MD5 |
c11cda90cfe14897074f357305531723
|
|
| BLAKE2b-256 |
69f6ed79b6f2f81a0177535e6e05f7a43fc9a64d984298c9c3a23ec89e30b1ba
|
File details
Details for the file pqlattice-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pqlattice-0.1.4-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
482fc213a318194a28e25341cade1eaf64a129e281a772e06d8713205cb81897
|
|
| MD5 |
f2199fb3112e1fc48854183336033cb3
|
|
| BLAKE2b-256 |
01e9880664ff10694f9d121af68e0471eca512aaaad42a4033cf1a32e67cdab2
|