0

I am implementing GF(8) Multiplication. Primitive Polynomial is x^3 + x + 1. I know the basics: if multiplication overflows, I can xor it with my primitive polynomial and bring it into the range of finite field.

However the trouble occurs when the overflow occurs for more than one bit. For example: Correct Result: alpha^3(011) * alpha^2(100) in binary results 12(1001). Product overflows and hence doing XOR with primitive polynomial gives the correct value i.e. alpha^5(111). Incorrect Result: alpha^5(111) * alpha^3(011) in binary results 21(10101).Here the result overflows by two bits and doing XOR with primitive polynomial doesn't give the correct result.

What am I missing?

1 Answers1

0

GF multiplication is a polynomial multiplication, so there are no carries. So 111*011 = 1001 and 1001 modulo 1011 is 010. However, consider the case 100 * 100 = 10000. In this case you need to do two "divide" steps (similar to calculating CRC using low level binary math, using XOR instead of subtract).

          10
     -------
1011 | 10000
       1011
       ----
         110
         000
         ---
         110

So 100*100 mod 1011 = 110.

You could create an antilog table and a log table. For this GF(8) = GF(2^3) field based on x^3 + x + 1, all 7 non-zero numbers are a power of 1x + 0 (hex 2):

  0   1   2   3   4   5   6    antilog table
001 010 100 011 110 111 101 

001 010 011 100 101 110 111    log table
  0   1   3   2   6   4   5

Using the tables, a*b = alog((log(a) + log(b))%7). 100*100 = alog((log(100)+log(100))%7) = alog((2+2)&7 = alog(4) = 110. 110*111 = alog((log(110)+log(111))%7) = alog((4+5)%7) = alog(2) = 100.

You can eliminate the need for the %7 by doubling the antilog table, the log table would remain the same:

  0   1   2   3   4   5   6   7   8   9  10  11  12  13  antilog table
001 010 100 011 110 111 101 001 010 100 011 110 111 101 

a*b = alog(log(a) + log(b)). Also for divide: a/b = alog(7+log(a)-log(b)).

rcgldr
  • 27,407
  • 3
  • 36
  • 61
  • The division explanation you gave fails for alpha^3(011) * alpha^5(111). The correct result is alpha^1(010). Going by the method mentioned by you, the result comes out to be alpha^3(011). – Saurabh Singh Jan 28 '19 at 09:06
  • @SaurabhSingh - 011*111 = 1001. There's one divide step, 1001 xor 1011 = 010. – rcgldr Jan 28 '19 at 11:31
  • I don't understand how 011*111= 1001? This expression is equivalent to 3 * 7 in decimal. It results 21. – Saurabh Singh Jan 28 '19 at 11:38
  • @SaurabhSingh - the notation used here is a shortcut for polynomials with 1 bit GF(2) coefficients: 011*111 = (x+1)(x^2+x+1) = (x^3+x^2+x) xor (x^2+x+1) = x^3 + 1. – rcgldr Jan 28 '19 at 14:11
  • @SaurabhSingh - you can confirm this or other multiplies using expand ... modulo 2 at wolfram alpha, such as [this example](https://www.wolframalpha.com/input/?i=expand((x%2B1)(x%5E2%2Bx%2B1))+modulus+2) . – rcgldr Jan 28 '19 at 19:49