This will not scale to dimension 100 but will be an improvement on what you now have. It is cribbed from the section "Linear Algebra over Galois Fields here as well as the section "Groebner bases over modules and related computations" in this notebook.
deg = 12;
flen = 3;
j = 0;
While[flen > 2 && j++ < 100,
defpoly =
x^deg + 1 + RandomInteger[{0, 1}, deg - 1].x^Range[1, deg - 1];
flen = Length[FactorList[defpoly, Modulus -> 2]]
]
dim = 20;
mat = Table[
RandomInteger[{0, 1}, deg].x^Range[0, deg - 1], {dim}, {dim}];
newvars = Array[z, 2*dim];
augmat = Transpose[
ArrayFlatten[{mat, IdentityMatrix[Length[mat]]}, 1]];
auxpolys = Union[Flatten[Outer[Times, newvars, newvars]]];
linpolys = Join[augmat.newvars, {defpoly}, auxpolys];
allvars = Append[newvars, x];
Here is the bulk of the computation.
Timing[gb = GroebnerBasis[linpolys, allvars, Modulus -> 2];]
(* {168.240000, Null} *)
Now extract the inverse matrix.
modulegb = Complement[gb, Join[auxpolys, {defpoly}]];
redmat = Reverse[Sort[Outer[D, modulegb, newvars]]];
invmat = Transpose[redmat[[All, dim + 1 ;; 2*dim]]];
We'll check the result.
PolynomialMod[invmat.mat, {defpoly, 2}] === IdentityMatrix[dim]
(* True *)
A serious bottleneck is the need, using this approach, to have $O(\tt{dim}^2)$ auxiliary polynomials.
One can improve on this by writing a direct row reduction using a list representation form the field elements. This would require working with undocumented functionality in the Algebra` context, such as Algebra`PolynomialTimesModList. This TMJ article may give slightly more information should you opt to go that route.
--- edit ---
Here is an approach that will sometimes work. Treat the elements as algebraics over Q instead of GF[2]. Now you can use some built in functionality. If you are lucky you get substantially the same row reduction and can recover the mod-2 result. I'll show what I mean with the example above.
We first set up a matrix of AlgebraicNumber opjects.
alg = algnum[root[defpoly], CoefficientList[#1, x]] &;
mat2 = Map[alg, mat, {2}] /. x -> # /. root[a_] :> Root[a &, 1] /.
algnum -> AlgebraicNumber;
augmat = Transpose[
ArrayFlatten[{mat2, IdentityMatrix[Length[mat2]]}, 1]];
Now row reduce it and hope we do not get any denominators divisible by 2.
Timing[
rred = RowReduce[augmat, Method -> "OneStepRowReduction"];]
(* {36.53499999999994, Null} *)
Extract the inverse part.
invmat = Transpose[
rred[[All, dim + 1 ;; 2*dim]] /.
AlgebraicNumber[aa_, bb_] :>
PolynomialMod[bb, 2].x^Range[0, deg - 1]];
Check:
PolynomialMod[invmat.mat, {defpoly, 2}] === IdentityMatrix[dim]
(* True *)
--- end edit ---