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)$.

[cite_start]This library contains a pre-computed database of polynomials for degrees $n$ where $2 \le n \le 10,000$[cite: 10]. 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

# 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:

[cite_start]"Table of Low-Weight Binary Irreducible Polynomials" [cite: 1]
[cite_start]Gadiel Seroussi [cite: 3]
[cite_start]Hewlett-Packard Systems Laboratory, Report HPL-98-135, August 1998[cite: 4, 5].

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.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: gf2_irreducibles-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5f9f911dacccdfd65b1b99b1b78c65e232945911e9296a8ce79cbf4e8e9ff0d1
MD5 ab961518e9a53ebf7c6ff9d54d191307
BLAKE2b-256 8cb7f59dadc6691f518e8c626dad4aebc0810722f4617da968ff4bc52e979df0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gf2_irreducibles-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edc82ca0e60bdc809bdfb0584707228ef61a161e6284281be7440c4adfea9199
MD5 f80d704f08612fa642957caa3f92f95e
BLAKE2b-256 eb766c959958f5ceba90ed388ff47d23c41a4273ce34a36c8202434d29880718

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