0

I'm trying to find a C++ library that handles polynomials over some finite field GF(2^n) and have support of matrix representation with support for rank finding/inverse or even solving A=X*B. I'm trying to use Linbox, but there's very little documentation. What I was able to do it to transform an integer to a polynomial representation after doing some nasty stuff with the Givaro part of the library, but I couldn't use the rank/solve part of Linbox as they don't seem to handle polynomials, only prime bases with exponent to be one (GF(2)).

Here's a part from the code

LinBox::GivaroGfq GF28(2, 8);
typedef LinBox::BlasMatrix<LinBox::GivaroGfq> Matrix;
Matrix mat(GF28);
//...Resize to MxM and insert M^2 elements
unsigned long int r;
rank(r, mat);

When debugging, the rank function always treats the elements as elements over GF(2) and return incorrect values.

Any ideas on how to use this library for that matter? Have a matrix of MxM elements of GF(2^n) and inverse it or get its rank or solve linear equations? Or should I use another library?

G. Ko
  • 403
  • 6
  • 15
  • I took a quick look at the LinBox documentation. It appears that the Givaro part of the library is meant to handle fields modulo a prime number or modulo a prime number to some power, GF28 appears to be math modulo 256 instead of a Galios field. For a Galios field composed of 8 bit numbers, the 9 bit polynomial that the field is based on needs to be specified, and I don't see where this is specified in the LinBox documentation. – rcgldr Jan 15 '15 at 16:41
  • Continuing, it seems that the LinBox library could be used for Reed Solomon type operations module 929 (a prime number), but not for Galios fields where there are two layers. The first layer is 1 bit numbers modulo 2, the second layer in this case is 8 bit polynomials modulo some 9 bit polynomial. Then there's a third layer using polynomials that use the 8 bit polynomials as coefficients, but this third layer isn't part of a field or ring. – rcgldr Jan 15 '15 at 16:45
  • Is there someway that the LinBox library would let you specify basic operations on the numbers, such as add (xor), subtract (xor), multiply (multiply 8 bit polynomials modulo 9 bit polynomial, using log table or 65k lookup table), and divide (again using log or lookup table)? – rcgldr Jan 15 '15 at 16:48
  • Looking further into the documentation, it seems that if you create a replacement for archetype.h, for modular uint8_t (8 bit values), you can then define the operator functions. Note that negate should not do anything, since with Galois fields, a+b == a-b . – rcgldr Jan 16 '15 at 01:20
  • As an option, I have a few Reed Solomon example programs that include matrix inversion which can be used to solve linear equations. If interested, I can upload to my website for download, as the source code is a bit too large to include in a reply. – rcgldr Jan 16 '15 at 01:29
  • @rcgldr, thank you for the thorough contribution. Givaro itself is able to deal with polynomials (see Givaro::Poly1Dom and Poly1PadicDom), but the problem is with Linbox's interface to it. The issue at large is that Linbox is using Blas to handle the matrixes and Givaro to handle the polynomials but can't mix the two together. As far as I see, Linbox didn't create an interface for polynomials. – G. Ko Jan 16 '15 at 12:32
  • By polynomials, are you referring polynomials with 1 bit coefficients or with 8 bit coefficients, and what operations do you plan to do with the polynomials? The Reed Solomon code I have uses polynomials with 8 bit coefficients for encoding data and decoding / correcting data. – rcgldr Jan 16 '15 at 16:35
  • If the 1 bit coefficient polynomials are used to represent 8 bit Galois field numbers modulo some 9 bit polynomial, then it seems you need to create / replace archetype.h, which allows you to define the class and class operators for add, subtract, multiply, divide, ... . You'll have to write the code for those operations, but it appears that the rest of LinBox functions like solving linear equations will work with the Galois field math functions you create. – rcgldr Jan 16 '15 at 21:47
  • That seems... unlikely. Givaro allows to create GF(2^n)[X]/GF(2^n) polynomials using Poly1Dom. Anyway, I've tried NTL and it seems to work. Looks like it's the solution. – G. Ko Jan 17 '15 at 11:01
  • I had the impression that if you use archetype.h, then you don't use Givaro. However, it seems you're already found a solution with NTL. What operations are you planning to do with the Galois math? – rcgldr Jan 17 '15 at 18:44
  • Just about everything... add/mul/sub/inv/find irreducible polynomial. Then put the polynomials in a matrix and inverse/get rank/perform gaussian elimination/solve c=A*b. – G. Ko Jan 18 '15 at 07:10

1 Answers1

0

Looks like NTL is the solution. It gives comfortable implementation of GF(2^n) polynomials modulo some polynomial and easy work with matrices (inverse, solving, etc..)

G. Ko
  • 403
  • 6
  • 15