libgf2: a Python module for computation in \(GF(2^n)\)

This module, which no one else actually uses, is intended for exploration of linear feedback shift registers (LFSRs) and other areas related to binary Galois fields.

At present there are two classes which are in a polished state:

GF2QuotientRing -- this models the finite field \(GF(2^n)\) as represented by the quotient ring \(GF(2)[x]/p(x)\), where the polynomial \(p(x)\) is encoded as a bit vector of coefficients.

GF2Element -- this models elements of within the quotient ring \(GF(2)[x]/p(x)\), where each element is a polynomial, encoded as a bit vector of coefficients.

The rest of the module is in a somewhat haphazard and undocumented state.

I take bug reports and suggestions but please don't be offended if I don't act upon them promptly; it is very hard for me to find free time, and when I do, I prefer to work on things which have immediate importance to myself.


libgf2 is freely available under the Apache license.

Copyright 2013-2017 Jason M Sachs

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.