The issue is that AES uses an irreducible, but not primitive, polynomial for its extension field. Most extension fields use a primitive polynomial so that x
is a primitive element of the field. I imagine that's what pyfinite has as its default.
Instead, AES uses x^8 + x^4 + x^3 + x + 1
as its irreducible polynomial and has x + 1
as a primitive element (or generator of the multiplicative group).
While I don't know the details of pyfinite, I created a similar library galois that extends NumPy arrays to operate over Galois fields. It supports arbitrarily-sized array arithmetic, linear algebra on Galois field matrices, polynomials over Galois field, and more. The library is written in Python but JIT compiled using Numba so the array arithmetic is as fast as native NumPy.
Here is an example doing what you desired.
In [1]: import galois
In [2]: GF = galois.GF(2**8, irreducible_poly=0x11b)
In [3]: print(GF.properties)
GF(2^8):
characteristic: 2
degree: 8
order: 256
irreducible_poly: x^8 + x^4 + x^3 + x + 1
is_primitive_poly: False
primitive_element: x + 1
In [4]: a = GF(0xbf); a
Out[4]: GF(191, order=2^8)
In [5]: b = GF(0x03); b
Out[5]: GF(3, order=2^8)
In [6]: a * b
Out[6]: GF(218, order=2^8)
In [7]: 0xda
Out[7]: 218