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.3.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.3-py3-none-any.whl (80.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gf2_irreducibles-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d4e20a722451a7169bd894be477fc3574a5cca658fbffd201e8e5cab49390dff
MD5 fe46d897924b490009e085a5cbebe6fd
BLAKE2b-256 12b37215336b9a235262b9426d980a2feaace34c883ad0849cb3e99c6d635b45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gf2_irreducibles-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ce7023d862e1f22fcdc52f116a4d64f9afca10a0d173947f194663fefda06f58
MD5 9d20f114c6414e5e28c9dcb151f50a49
BLAKE2b-256 3196b6130e9f545a5088216c94b78567161d8b48e0329e6a43c10106d4c36178

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