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:

  • Trinomials ($x^n + x^k + 1$) where they exist.
  • Pentanomials ($x^n + x^{k_1} + x^{k_2} + x^{k_3} + 1$) where trinomials do not exist.

Among those of minimum weight, the polynomial listed is the one where the intermediate degrees are lowest (lexicographically first).

⚡ 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.2.tar.gz (82.4 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.2-py3-none-any.whl (80.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gf2_irreducibles-0.1.2.tar.gz
  • Upload date:
  • Size: 82.4 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.2.tar.gz
Algorithm Hash digest
SHA256 5b449d95f94d8d10185abc060e52e3a90ee20f27d9b4d0e974f2b4114d204db9
MD5 e248d7699af1633c1739be554870d7af
BLAKE2b-256 0e65f40fa4f9667f233473c0dbb36749774edd5c31523ab1e436ffa0ef1be6fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gf2_irreducibles-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ed9af76ee4b5501bfed4238adc919d77848b81d8bfba7c5660f6dc2763a2334
MD5 69a22d77a838efc1a98e74399c4569bc
BLAKE2b-256 2adf534d1c25cbe312df890131e8d8b5658e4eccb306eb98e5638c938ff727bf

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