Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
102 views

Binary Galois Field Table Representation Using C++

The document discusses representing Galois fields using C++ code. It begins with background on Galois fields, including definitions of irreducible and primitive polynomials. It then provides the basic properties of Galois field GF(2m) and describes constructing GF(2m) from GF(2). The C++ code uses polynomial multiplication and division to generate a table representing the Galois field elements. The code takes in a primitive polynomial and field size as inputs to build the table.

Uploaded by

Yoo Jinwoo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Binary Galois Field Table Representation Using C++

The document discusses representing Galois fields using C++ code. It begins with background on Galois fields, including definitions of irreducible and primitive polynomials. It then provides the basic properties of Galois field GF(2m) and describes constructing GF(2m) from GF(2). The C++ code uses polynomial multiplication and division to generate a table representing the Galois field elements. The code takes in a primitive polynomial and field size as inputs to build the table.

Uploaded by

Yoo Jinwoo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Dayananda Sagar College of Engineering

Department of Electronics and Communication Engineering


Shavige Malleshwara Hills, Kumaraswamy Layout, Bengaluru – 560 078.
(An Autonomous Institute affiliated to VTU, Approved by AICTE & ISO 9001:2008 Certified )
Accredited by National Assessment and Accreditation Council (NAAC) with ‘A’ grade

Assignment

Program: B.E. Branch: ECE


Course: Error Control Coding Semester : 6
Course Code: 18EC6DECEC Date: 22/07/2021

A Report on

Binary Galois Field Table Representation Using C++

Submitted by

USN:1DS18EC131 NAME:Nikshith Shetty

Faculty In-charge

Prof. Deepa N P

Signature of Faculty In-charge

1
Table of Contents

❖ Introduction
❖ Galois Field
❖ Irreducible Polynomial
❖ Primitive Polynomial
❖ Basic Properties of Galois Field
❖ Construction Of Galois Field GF(2^m) from GF(2)
❖ C++ code for Galois Field Table Representation
❖ Output
❖ Applications Of Galois Field
❖ Conclusion
❖ References

2
Introduction
A field is an algebraic structure that lets you do everything you’re used to from basic math.
All finite fields have p^m elements where p is prime and m is an integer at least 1.
Conversely, for every number of the form p^m there is a field that size.The field with p^m
elements is sometimes called the Galois field.

The Galois fields of order GF(p) are simply the integers mod p. For m> 1, the elements of
GF(p^m) are polynomials of degree m-1 with coefficients coming from GF(p).

Galois Field
A Galois field is an algebraic field that has a finite number of members. Galois fields having
2^m members are used in error-control coding and are denoted GF(2^m).

❖ For any prime p, there exists a finite field of p elements.


❖ In fact, for any positive integer m, it is possible to extend the prime field GF(p) to a
field of pm elements, which is called an extension field of GF(p) and is denoted by
GF(p^m)

❖ The order of any finite field is a power of a prime. Finite fields are also called Galois
fields A large portion of algebraic coding theory, code construction, and decoding is
built around finite fields.
❖ Because finite- field arithmetic is very similar to ordinary arithmetic, most of the rules
of ordinary arithmetic apply to finite-field arithmetic.

Irreducible Polynomial
For a polynomial f(X) over GF(2), if the polynomial has an even number of terms, it is
divisible by X + 1.

A polynomial p(X) over GF(2) of degree m is said to be irreducible over GF(2) if p(X) is not
divisible by any polynomial over GF(2) of degree less than m but greater than zero.

Examples

1. x^3 + x^2 + 1 is irreducible in GF(2) as it is not factorable having a degree of less than 3.

2. x^4 + x^2 + 1 is not irreducible in GF(2), since the polynomial is divisible by the
polynomial x^2 +x+1 with coefficients in GF(2) and with degree of 2 less than 4.

3
Primitive Polynomial
An irreducible polynomial p(X) of degree m is said to be primitive if the smallest positive
integer n for which p(X) divides X^n + 1 is n = 2^m - 1.

We may check that p(X) = X^4 + X + 1 divides X^15 + 1 but does not divide any X^n + 1 for
1 ≤ n < 15. Hence, X^4 + X + 1 is a primitive polynomial.

The polynomial X^4 + X^3 + X^2 + X + 1 is irreducible but it is not primitive, since it
divides X^5 + 1.

It is not easy to recognize a primitive polynomial. However, there are tables of irreducible
polynomials in which primitive polynomials are indicated.

For a given m, there may be more than one primitive polynomial of degree m.

4
BASIC PROPERTIES OF GALOIS FIELD GF(2m)
THEOREM 1: Let f (X) be a polynomial with coefficients from GF(2). Let b(beta) be an
element in an extension field of GF(2).If b is a root of f(X), then for any l>= 0, b^(2^l) is also
a root of f(X).The element b^(2^l)is called a conjugate of b.

THEOREM 2 :The 2^(m) - 1 nonzero elements of GF(2^m) form all the roots of X^(2^m-1) + 1.
THEOREM 3: The minimal polynomial phy(X) of a field element b is irreducible.
THEOREM 4:Let f (X) be a polynomial over GF(2). Let phy(X) be the minimal polynomial of a field
element b. If b is a root of f (X), then f (X) is divisible by phy(X).

THEOREM 5:The minimal polynomial phy(X) of an element b in GF(2^m ) divides x^(2^m) + X.


THEOREM 6:Let f (X) be an irreducible polynomial over GF(2). Let b be an element in
GF(2^m ). Let phy(X) be the minimal polynomial of b. If f (b) = 0, then phy(X) = f (X).
THEOREM 7:Let b be an element in GF(2^m ), and let e be the smallest nonnegative integer
such that b^(2^e) = b. Then,

THEOREM 8;Let phy(X) be the minimal polynomial of an element b in GF(2^m ). Let e be


the smallest integer such that b^(2^e) = b. Then,

THEOREM 9:Let phy(X) be the minimal polynomial of an element b in GF(2^m ). Let e be


the degree of phy(x).Let e be the smallest integer such that b^(2^e) = b. Moreover, e<=m.
THEOREM 10:If b is a primitive element of GF(2^m ), all its conjugates b^2, b^(2^2),...are
also primitive elements of GF(2^m).
THEOREM 11:If b is an element of order n in GF(2^m ), all its conjugates have the same
order n.

5
Construction of Galois Field GF(2^m) from GF(2)
The 2^m elements of GF(2^m) can be written as {0, 1, a, a^2 , · · · , a^(2^m-2)}. All the
nonzero elements of GF(2^m) are generated by the powers of the primitive element a that
satisfies the condition a^(2^m-1) = 1.

The polynomial representation of the elements of GF(2^m) is given by the remainder of x^n
upon division by the polynomial p(x) which is primitive in GF(2).

a^n = Remainder {x^n / p(x)}

Example : Construct GF(8) as a vector space over GF(2).

Solution : Let us consider the construction of GF(8) based on the polynomial

p(x) = x^3 + x + 1 which is primitive in GF(2). Let a be a root of p(x). This implies that

a^3 + a + 1 = 0 or equivalently a^3 = a + 1. The distinct powers of a must have (2^3-1)


distinct nonzero polynomial representations of alpha of degree 2 or less with the coefficients
from GF(2). The set {1, a . a^2} is used as a basis for the vector space representation of
GF(8).

Since every field must contain zero and one element, we have

0=0

a^0 = 1

Since the reminders of x and x^2 upon division by the primitive polynomial

p(x) = x^3 + x + 1 are themselves, the other two possible assignments are as follows:

a^1= x

a^2 = x^2

However, the polynomial representation of x3 can be derived by the following polynomial


division:

6
The remainder is -(x+1): Hence, a^3 = a + 1

The remainder is -(x^2 + x + )1 : Hence, a^5 = a^2 + a + 1: Similarly, x^6 and x^7 follow the
same procedure to get the polynomial representations

7
Representations of elements of GF(8)

C++ code for Galois Field Table Representation


Func_h:
#ifndef FUNC_H
#define FUNC_H
#include <vector>
using namespace std;
class ECC{
public:
vector<int> mul_poly_bin(vector<int> &a, vector<int> &b);
vector<vector<int>> primitive_poly_table_bin(int GF,vector<int> &primitive_poly);
};

#endif // FUNC_H

8
Func_cpp:
#include "func.h"

#include <algorithm>

#include <vector>

#include <math.h>

using namespace std;

vector<int> ECC::mul_poly_bin(vector<int> &a, vector<int> &b){

vector<int> result;

result.clear();

for (int i=0;i<(int)a.size()+(int)b.size()-1;i++) result.push_back(0);

for (int i=0;i<(int)a.size();i++){

rotate(result.begin(),result.begin()+result.size()-1,result.end());

for (int j=0;j<(int)b.size();j++){

result[j]=(result[j]+b[j]*a[(int)a.size()-i-1])%2;

while(result[(int)result.size()-1]==0)result.pop_back();

return result;

vector<vector<int>> ECC::primitive_poly_table_bin(int GF,vector<int> &primitive_poly){

vector<vector<int>> matrix;

vector<int> vect;

matrix.clear();

9
for(int i=0;i<GF;i++) vect.push_back(0); // add 0,0,..,0

matrix.push_back(vect);

vect.clear(); vect.push_back(1); for(int i=1;i<GF;i++) vect.push_back(0); // add 1,0,..,0

matrix.push_back(vect);

for (int i=2;i<(int)pow(2,GF);i++){

vect.clear();

if (matrix[i-1][GF-1]==1){

for (int j=0;j<GF;j++){

if (j==0) vect.push_back((primitive_poly[j]+0)%2);

if (j>0) vect.push_back((primitive_poly[j]+matrix[i-1][j-1])%2);

else{

for (int j=0;j<GF;j++){

if (j==0) vect.push_back(0);

if (j>0) vect.push_back(matrix[i-1][j-1]);

matrix.push_back(vect);

return matrix;

10
Main program:
#include <iostream>

#include <math.h>

#include <algorithm>

#include<vector>

#include "func.h"

using namespace std;

ECC galoisfield;

int GF=4;

vector <int> primitive_poly {1,1,0,0,1}; //x^5 = 1 + x + x^4

int main()

cout << " Poly Table "<<endl;

cout <<"GF(2^"<<GF<< ") |<LSB- -MSB>" << endl;

vector<vector<int>> poly_table =
galoisfield.primitive_poly_table_bin(GF,primitive_poly); //Generate representation GF(2^x)

for (int i=0;i<pow(2,GF);i++){

if (i<=1) cout << i << "\t| ";

if (i>1) cout << "a^" << i-1 << "\t| ";

for (int j=0;j<GF;j++) cout << poly_table[i][j] << " ";

cout << endl;

return 0;

11
Output:

Applications Of Galois Field:


1.Galois field is used in Cryptography

2. Galois field is used in Coding theory and Combinatorial design and Quantum error
correction.

3. The most commonly used Galois Field is GF(256) i.e GF(2^8 ).

4. All CD and DVD players use computation in Galois Field, as do many disk storage system.

5. Galois Field is used to develop some Mathematical Theories , which have a lot of real life
application

Conclusion:
The report gives a detailed explanation on how a Binary Galois Field Table is constructed for
GF(p^m) using a primitive polynomial. The C++ code produces the galois field table upon
giving proper inputs.

12
References:
file:///D:/ECC/ECC%20MOD%201.pdf

Shu Lin, Daniel J Costello Jr., “Error Control Coding”, Pearson Education Asia, Second
Edition, 2004.

https://sci-hub.se/https://link.springer.com/chapter/10.1007/978-81-322-2292-7_3

https://www.slideshare.net/MadhumitaTamhane/basic-galois-field-arithmatics-required-for-er
ror-control-codes

https://www.slideshare.net/HazrataliNaim/a-short-study-of-galois-field

https://in.mathworks.com/help/comm/ug/error-detection-and-correction.html#bql4k5c

https://www.jmilne.org/math/CourseNotes/FT.pdf

Simon Haykin, “Digital communication”, ISBN-9971-51-205-X, John Wiley & Sons

(Asia), Pvt. Ltd, 2008.

13

You might also like