
The galois
library is a Python 3 package that extends NumPy arrays to operate over finite fields.
The user creates a Galois field array class using GF = galois.GF(p**m)
. The Galois field array class GF
is a subclass
of numpy.ndarray
and its constructor x = GF(array_like)
mimics the call signature of numpy.array()
. The Galois field array
x
is operated on like any other NumPy array except all arithmetic is performed in \(\mathrm{GF}(p^m)\), not \(\mathbb{R}\).
Internally, the finite field arithmetic is implemented by replacing NumPy ufuncs. The new ufuncs are written in pure Python and just-in-time compiled with Numba. The ufuncs can be configured to use either lookup tables (for speed) or explicit calculation (for memory savings).
Disclaimer
The algorithms implemented in the NumPy ufuncs are not constant-time, but were instead designed for performance. As such, the library could be vulnerable to a side-channel timing attack. This library is not intended for production security, but instead for research & development, reverse engineering, cryptanalysis, experimentation, and general education.
Features¶
Supports all Galois fields \(\mathrm{GF}(p^m)\), even arbitrarily-large fields!
Faster than native NumPy!
GF(x) * GF(y)
is faster than(x * y) % p
for \(\mathrm{GF}(p)\).Seamless integration with NumPy – normal NumPy functions work on Galois field arrays.
Linear algebra over finite fields using normal
numpy.linalg
functions.Linear transforms over finite fields, such as the NTT with
galois.ntt()
andgalois.intt()
.Functions to generate irreducible, primitive, and Conway polynomials.
Univariate polynomials over finite fields with
galois.Poly
.Forward error correction codes with
galois.BCH
andgalois.ReedSolomon
.Fibonacci and Galois linear-feedback shift registers over any finite field with
galois.FLFSR
andgalois.GLFSR
.Various number theoretic functions.
Integer factorization and accompanying algorithms.
Prime number generation and primality testing.
Roadmap¶
DFT over all finite fields
Elliptic curves over finite fields
Galois ring arrays
GPU support
Acknowledgements¶
The galois
library is an extension of, and completely dependent on, NumPy. It also heavily
relies on Numba and the LLVM just-in-time compiler for optimizing performance
of the finite field arithmetic.
Frank Luebeck’s compilation of Conway polynomials and Wolfram’s compilation of primitive polynomials are used for efficient polynomial lookup, when possible.
Sage is used extensively for generating test vectors for finite field arithmetic and polynomial arithmetic. SymPy is used to generate some test vectors. Octave is used to generator test vectors for forward error correction codes.
This library would not be possible without all of the other libraries mentioned. Thank you to all their developers!
Citation¶
If this library was useful to you in your research, please cite us. Following the GitHub citation standards, here is the recommended citation.
BibTeX¶
@software{Hostetter_Galois_2020,
title = {{Galois: A performant NumPy extension for Galois fields}},
author = {Hostetter, Matt},
month = {11},
year = {2020},
url = {https://github.com/mhostetter/galois},
}
APA¶
Hostetter, M. (2020). Galois: A performant NumPy extension for Galois fields [Computer software]. https://github.com/mhostetter/galois