Python Reed-Solomon encoding in a GF(2^8)

127 Views Asked by At

I'm working on a school project and I have to encode a message using Reed-Solomon encoding procedure and Python. I couldn't wrap my head around a way to divide my generator polynomial $g(x)$ with my information polynomial $I(x)x^{n-k}$, and I stumbled upon this implementation (https://rextester.com/ZMBYT68318) :

def RSEncode(self, argMesg, errSize):
        
        # prepare the generator polynomial
        polyGen = self._rsGenPoly(errSize)
        
        # prepare the output buffer
        outBuffer = (len(argMesg) + errSize)
        outBuffer = [0] * outBuffer
        
        # initialise the output buffer
        for mesgPos in range(0, len(argMesg)):
            mesgChar = argMesg[mesgPos]
            outBuffer[mesgPos] = ord(mesgChar)
        
        # begin encoding
        for mesgPos in range(0, len(argMesg)):
            mesgChar = outBuffer[mesgPos]
            if (mesgChar != 0):
                for polyPos in range(0, len(polyGen)):
                    tempValu = self.__gfMult(polyGen[polyPos], mesgChar)
                    outBuffer[mesgPos + polyPos] ^= tempValu
        
        # finalise the output buffer
        for mesgPos in range(0, len(argMesg)):
            mesgChar = argMesg[mesgPos]
            outBuffer[mesgPos] = ord(mesgChar)
        
        # return the output buffer
        return (outBuffer)

What I can't understand is why a multiplication is working when I kept reading that I had to divide $I(x)x^{n-k}$, my information offset by $n-k$ parity bits, with $g(x)$ my generator polynomial so that my final encoded message would be $$ E(x) = I(x)x^{n-k} + r(x) $$ $r(x)$ being the remainder of my euclidean division. I know that in a Galois field, division is multiplication by the inverse modulo p, but it doesn't seem the be the case here, am I missing something ? (Obviously yes !).

Additionnaly, if you have a clue on how to divide two polynomials, I'm definitely good with any advices you may give !

Thanks in advance for the help !

1

There are 1 best solutions below

1
On

I finally figured that encoding was actually an implementation of a Synthetic division : https://en.wikipedia.org/wiki/Synthetic_division

Being new on this website, I also wonder why my post was downvoted without any comment mentioning why, so if anyone can help me understand the reason so I can be a better user of the website, I'm down :) !

Bye !