skillfed

galois

A performant NumPy extension for Galois fields and their applications

galois v0.4.11 269.8K downloads/30d#8,250 on PyPI471
Permissive license MIT Active released

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 galois

uv

uv add galois

poetry

poetry add galois

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchIntended Audience :: Telecommunications IndustryLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: MathematicsTopic :: Security :: CryptographyTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

galois field arithmeticfinite field numpyGF(p^m) arrayserror correction codesreed solomon BCHcryptography finite fieldspolynomial arithmetic modular
finite-fieldscryptanalysiserror-correction

More Python Modules packages