Monday, 9 September 2013

finite fields - Calculating syndrome for BCH 18,6



I'm trying to implement a BCH 18,6 decoder for QR Code version verification, and am having a hard time with syndrome calculation. My understanding is that the syndromes should be 0 when the codeword has no errors, but that's not what I'm getting.



The generator polynomial used to encode the version is, per the QR Code spec ISO/IEC 18004:2000(E) (Annex D) is:



$G(x) = x^{12} + x^{11} + x^{10} + x^9 + x^8 + x^5 + x^2 + 1$




The example used in that annex is:




  • Data (version): 000111

  • Error correction: 110010010100

  • Codeword: 000111110010010100



Which gives me




$R(x) = x^{14}+x^{13}+x^{12}+x^{11}+x^{10}+x^7+x^4+x^2$



The spec says to calculate syndrome $S_i$ (for i=1,3,5) by evaluating $R(\alpha^i)$. So i'm trying $S_1$, which gives me:



$S_1 = \alpha^{14}+\alpha^{13}+\alpha^{12}+\alpha^{11}+\alpha^{10}+\alpha^7+\alpha^4+\alpha^2$



I then simplify the terms $\alpha_i$ (for $i>4$) by replacing them with their $GF(2^5)$ equivalents. The spec didn't tell me which $P(x)$ to use, so I picked $P(x)=x^5+x^2+1$ from here. Later I tried all the irreducible degree 5 polynomials from this answer, with no better luck. I suspect that's supposed to be unsurprising, but I'm not sure why. Anyway, back to using $P(x)=x^5+x^2+1$.



To get the in-$GF(2^5)$ values, I started with $\alpha^4=10000$. To calculate $\alpha^5$, left shift 1, then because MSB is 1, XOR with $100101$, get $\alpha^5 = 00101$, and so on for $\alpha^i$ for every i through 14. Thus $\alpha^{14}=11101$, so $\alpha^{14}=\alpha^4+\alpha^3+\alpha^2+1$. Apply that to all terms, and we get:




$S_1 = (\alpha^4+\alpha^3+\alpha^2+1) + (\alpha^4+\alpha^3+\alpha^2) + (\alpha^3+\alpha^2+\alpha) + (\alpha^2+\alpha+1) + (\alpha^4+1) + (\alpha^4+\alpha^2) + \alpha^4 + \alpha^2$



which is:



$S_1 = \alpha^4+\alpha^3+1$



which isn't zero. What am I doing wrong? This same algorithm works for BCH(15,5), which makes me think there's some subtlety of BCH(18,6) or $GF(2^5)$ that I'm missing.


Answer



The OP kindly forwarded me a copy of the specs.




In Annex D.1 they, indeed, describe a code with generator polynomial
$$G(x) = x^{12} + x^{11} + x^{10} + x^9 + x^8 + x^5 + x^2
+ 1.$$

Mathematica kindly factored this polynomial for us as



$$
G(x)=(x+1)(x^{11}+x^9+x^7+x^6+x^5+x+1).
$$



However, in Annex D.2 a standard decoding procedure for a triple error correcting BCH code defined over $GF(2^5)$ is described, starting by calculating the values of a read word (interpreted as a polynomial with coefficients in $GF(2)$) at the expected elements $\alpha$, $\alpha^3$ and $\alpha^5$.




THIS IS TOTAL NON-SENSE AND HIGHLY INCOMPETENT.




  • A BCH code with such a description has a generator polynomial that is the product of three irreducible quintic factors, namely the minimal polynomials of $\alpha$, $\alpha^3$ and $\alpha^5$. It is impossible for $G(x)$ to be such a polynomial

  • They "forgot" to specify which primitive element of $GF(2^5)$ $\alpha$ is. There are $30$ different primitive elements in that field, split into six sets of conjugates. To specify the code they would need to tell the minimal polynomial of $\alpha$.

  • This code has fifteen check bits, not twelve as the one described in annex D.1.



MY INTERPRETATION





  • Whoever wrote Annex D.2 did not read Annex D.1. (or vice versa).

  • One of those two pieces was copy/pasted from somewhere else, by someone who is not qualified.

  • May be a version conflict, or work in progress, or not from an official source?

  • The meetings producing this document did a piss-poor job checking
    these parts.








I'm afraid this means you are screwed. You need another source. Contact the authors (or ask your boss for help in doing that). Undoubtedly there is an umbrella organization who was responsible for specifying this. The system works, so somebody somewhere has a documentation free of errors.




For what it's worth. I'm not a random dude in the internet. At one point I served as an associate editor of coding theory for IEEE Transactions on Information Theory, the top journal in this area. A random dude is not selected to such a position. Bringing this up in case you need to refer to (or copy/paste) this post in your request for a clarification.


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...