Skip to main content

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

pqlattice-0.1.3.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pqlattice-0.1.3-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file pqlattice-0.1.3.tar.gz.

File metadata

  • Download URL: pqlattice-0.1.3.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for pqlattice-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e5ff1e8f302280ad3b28e8ba7ce7e96613b19bc02758d53ac1a8f33449d685da
MD5 743b7e16659bad7b9426064924d5002b
BLAKE2b-256 d0ca728f2caf50febb57471f256afcf6c58ed714ce32d8da533dd55aeaa4cc1f

See more details on using hashes here.

File details

Details for the file pqlattice-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pqlattice-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for pqlattice-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7f45bd163c145145c33a38d62f7375b8ce74252584757b347a9e21b25809dd2f
MD5 a758a1388136b5864c18be0881726813
BLAKE2b-256 fe548e83a4872e56f0d0f9ba143c4d52e2304ea2024b661f67cff31f5122bda1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page