galois
A performant NumPy extension for Galois fields and their applications
What it is and what it does
Galois is a NumPy extension that lets you create arrays that perform all arithmetic in a finite field GF(p^m) instead of over real numbers. You define a field using galois.GF(p**m), which returns a FieldArray subclass that behaves like a NumPy array but enforces finite-field arithmetic on all operations. Internally, it replaces NumPy's universal functions with specialized versions compiled by Numba, configurable to use either lookup tables for speed or explicit calculation for memory efficiency.
The library targets research, cryptanalysis, education, and reverse engineering rather than production security (the algorithms are not constant-time and vulnerable to timing attacks). It includes support for linear algebra over finite fields, polynomial operations, forward error correction codes (BCH, Reed-Solomon), linear-feedback shift registers, and number-theoretic functions like factorization and primality testing.
Use it for:
- Implement Reed-Solomon or BCH error correction codes for data transmission or storage systems.
- Perform polynomial arithmetic and factorization over finite fields for cryptanalysis or algorithm research.
- Conduct linear algebra computations (matrix operations, solving systems) constrained to a finite field.
- Prototype or analyze cryptographic algorithms that operate on Galois fields without writing low-level modular arithmetic.
- Generate or test irreducible, primitive, and Conway polynomials for finite field construction.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Galois extends NumPy arrays to perform arithmetic operations over finite fields (Galois fields), enabling efficient computation in GF(p^m) with a NumPy-compatible interface.
Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and uses a permissive MIT license. It fills a clear niche for finite-field arithmetic in Python with NumPy integration. The non-constant-time implementation is explicitly documented as unsuitable for production security but appropriate for research and education, so install only if that scope matches your use case.
Install
galois on PyPI
pip
pip install galoisuv
uv add galoispoetry
poetry add galoisInstalling galois
Before you install
Low friction: pure Python wheel with three runtime dependencies (numpy, numba, typing_extensions). Active maintenance with recent release (104 days ago) and 471 GitHub stars. Supports Python 3.7 through 3.14.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install galois
import galois
import numpy as np
GF = galois.GF(3**5)
x = GF([236, 87, 38, 112])
y = GF([109, 17, 108, 224])
z = x * y # multiplication in GF(3^5)
Verify before relying
- Performance comparison claims ('faster than native NumPy') lack quantitative benchmarks in the fact sheet.
- Whether lookup-table vs. explicit-calculation trade-off is configurable per operation or globally.
- Exact scope of supported polynomial operations beyond univariate polynomials mentioned.
- Whether the library's non-constant-time algorithms pose a practical risk for intended use cases (research, education, cryptanalysis).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, numba, typing_extensions |
| Maintenance | actively maintained — 104 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 269,763/month — #8,250 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: galois-0.4.11-py3-none-any.whl
Keywords: aes, bch, cryptography, ecc, elliptic curve cryptography, elliptic curves, encryption, error correction, fec, finite field, galois field, golay, hamming, numpy, reed solomon, rsa
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
lighteccLightECC provides elliptic curve arithmetic…
permissive · top 15,000 on PyPI
py-eccImplements elliptic curve cryptography…
permissive · top 5,000 on PyPI
reedsoloEncodes and decodes data using Reed-Solomon…
permissive · top 5,000 on PyPI
python-flintPython bindings for FLINT and Arb that provide…
copyleft · top 15,000 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
cypari2cypari2 provides a Python interface to PARI/GP,…
copyleft · top 15,000 on PyPI
pycryptodomexPyCryptodomex provides low-level cryptographic…
permissive · top 1,000 on PyPI
primePyProvides functions to test primality, factor…
permissive · top 5,000 on PyPI
ml-dtypesml_dtypes provides NumPy-compatible data types…
permissive · top 1,000 on PyPI
numpy-quaternionAdds a quaternion dtype to NumPy, enabling…
permissive · top 5,000 on PyPI