Skip to main content

Lookup table for low-weight binary irreducible polynomials (GF(2^n)).

Project description

gf2-irreducibles 🔐

License: MIT Python Versions

A zero-dependency, high-performance lookup library for low-weight binary irreducible polynomials over $GF(2)$.

This library contains a pre-computed database of polynomials for degrees $n$ where $2 \le n \le 10,000$. It is designed for researchers and engineers working in cryptography (ECC, finite field arithmetic) who need instant access to standard irreducible polynomials without expensive runtime testing.

🚀 Installation

pip install gf2-irreducibles

📖 Usage

Basic Lookup

Retrieve the minimal weight polynomial for a given degree.

import gf2_irreducibles as gf2

# Get the polynomial for degree 8
poly = gf2.get_poly(8)

print(f"Polynomial: {poly}")
# Output: x^8 + x^4 + x^3 + x^1 + 1

print(f"Integer:    {poly.to_int()}")
# Output: 283  (useful for bitwise operations)

print(f"Hex:        {poly.to_hex()}")
# Output: 0x11b

Checking Availability

if gf2.has_degree(123):
    print("Polynomial found!")

LaTeX Output for Papers

Useful for copying formulas directly into academic papers or reports.

# Generate LaTeX string for documentation
print(poly.to_latex())
# Output: x^{8} + x^{4} + x^{3} + x + 1

📚 Data Source

The polynomial data is derived from the technical report:

"Table of Low-Weight Binary Irreducible Polynomials" > Gadiel Seroussi > Hewlett-Packard Systems Laboratory, Report HPL-98-135, August 1998.

This library implements the data tables presented in the report, providing:

  • [cite_start]Trinomials ($x^n + x^k + 1$) where they exist[cite: 27].
  • [cite_start]Pentanomials ($x^n + x^{k_1} + x^{k_2} + x^{k_3} + 1$) where trinomials do not exist[cite: 28].

[cite_start]Among those of minimum weight, the polynomial listed is the one where the intermediate degrees are lowest (lexicographically first)[cite: 11].

⚡ Performance

  • O(1) Lookup: Uses a static hash map. No irreducibility tests are performed at runtime.
  • Zero Dependencies: Pure Python, standard library only.
  • Lightweight: Minimal memory footprint.

🤝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

📄 License

MIT

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

gf2_irreducibles-0.1.1.tar.gz (82.5 kB view details)

Uploaded Source

Built Distribution

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

gf2_irreducibles-0.1.1-py3-none-any.whl (80.6 kB view details)

Uploaded Python 3

File details

Details for the file gf2_irreducibles-0.1.1.tar.gz.

File metadata

  • Download URL: gf2_irreducibles-0.1.1.tar.gz
  • Upload date:
  • Size: 82.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for gf2_irreducibles-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8d730b22dacd2fb325d5bde46b0580f97cc215bdc99ef3c0ee73e3c461af8542
MD5 5b616124a51bf4d68f56b1a427d55265
BLAKE2b-256 399378c010d92edefb3a234fad36bceeda568c9c06d8129493cf6e4cc6d2a7d6

See more details on using hashes here.

File details

Details for the file gf2_irreducibles-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gf2_irreducibles-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 297b9d89605c16d76764a69286589052aaf69fff00b0ce59154c3fb678618977
MD5 f26c16578364b46e9f5206e6b5a33178
BLAKE2b-256 e675ad08bd70835b93d140b55f2260f4aba330cf81a03a49e396001c022620c4

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