SlideShare uma empresa Scribd logo
1 de 8
Tutorial on Programming with Python: Galois Field

                                          Kishoj Bajracharya
                                      Asian Institute of Technology

                                               June 20, 2011



Contents

1 Galois Field                                                                                               2
   1.1   To import class FField for Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
   1.2   To Create Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .    2
   1.3   Polynomial Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     2
   1.4   Result of example1.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     3
   1.5   Co-efficient of Polynomial Representation . . . . . . . . . . . . . . . . . . . . . . . . . . .      3
   1.6   Result of example2.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     4
   1.7   Conversion from co-efficient of polynomial to element . . . . . . . . . . . . . . . . . . . .        4
   1.8   Result of example3.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     5

2 Operation Over Galois Field                                                                                5
   2.1   Addition Operation over Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . .      5
   2.2   Result of example4.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     6
   2.3   Multiplication Operation over Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . .    6
   2.4   Result of example5.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     7
   2.5   Operations over Galois Field: Another Approach . . . . . . . . . . . . . . . . . . . . . . .        7
   2.6   Result of example6.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     8




                                                      1
1 Galois Field

     1.1   To import class FField for Galois Field

        1. Browse the URI http://www.mit.edu/˜emin/source_code/py_ecc and see the latest
           release of the file “py ecc-1-4.tar.gz” and download it.
        2. Extract it and keep all the files in a separate folder named “Field”.
        3. Use the import command to use the class FField from the file name “ffield.py”

                        import sys
                        sys.path.append(‘./Field’)
                        import ffield



     1.2   To Create Galois Field

     To create the Galois field F = GF (2n )

                        F = ffield.FField(n)
                        Create the field GF (23 )
                        F = ffield.FField(3)


     1.3   Polynomial Representation

     The polynomial representation of any number a can be obtained using following codes

                        F.ShowPolynomial(a)
                        Returns: string
                        Note: the value of a lies between 0 to 2n − 1


     Following example named “example1.py” shows how do we use python programming language to get poly-
     nomial from galois field.
 1         # example1.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3)
 8
 9         # Show the   polynomial representation from 0-2ˆ3-1 i.e. 0-7
10         print ’For   0, polynomial: ’ + F.ShowPolynomial(0)
11         print ’For   1, polynomial: ’ + F.ShowPolynomial(1)
12         print ’For   2, polynomial: ’ + F.ShowPolynomial(2)
13         print ’For   3, polynomial: ’ + F.ShowPolynomial(3)
14         print ’For   4, polynomial: ’ + F.ShowPolynomial(4)
15         print ’For   5, polynomial: ’ + F.ShowPolynomial(5)
16         print ’For   6, polynomial: ’ + F.ShowPolynomial(6)
17         print ’For   7, polynomial: ’ + F.ShowPolynomial(7)


                                                           2
1.4   Result of example1.py




                                            Fig1: Result of example1.py


     1.5   Co-efficient of Polynomial Representation

     The coefficient of the polynomial representation of any number a can be obtained using following codes

                        F.ShowCoefficients(a)
                        Returns: list
                        Note: the value of a lies between 0 to 2n − 1


     Following example named “example2.py” shows how do we use python programming language to get the
     co-efficient of a polynomial from galois field.

 1         # example2.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3)
 8
 9         # Show the   coefficient of   the coefficient of   polynomial representation of a,b,c,d,e,f,g,h
10         print ’For   0, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(0))
11         print ’For   1, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(1))
12         print ’For   2, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(2))
13         print ’For   3, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(3))
14         print ’For   4, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(4))
15         print ’For   5, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(5))
16         print ’For   6, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(6))
17         print ’For   7, coefficient   of polynomial: ’ +   str(F.ShowCoefficients(7))




                                                         3
1.6   Result of example2.py




                                            Fig2: Result of example2.py


     1.7   Conversion from co-efficient of polynomial to element

     The coefficient(list) of the polynomial can be converted to the element(integer)

                        F.ConvertListToElement(list)
                        Returns: integer
                        Note: the value of a lies between 0 to 2n − 1


     Following example named “example3.py” shows how do we use python programming language to convert
     co-efficient of a polynomial to element over a galois field.

 1         # example3.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3)
 8
 9         # Converting   list into the element
10         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,0,0,0]))
11         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,0,0,1]))
12         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,0,1,0]))
13         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,0,1,1]))
14         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,1,0,0]))
15         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,1,0,1]))
16         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,1,1,0]))
17         print "List:   [0,0,0,0], Element: "   +   str(F.ConvertListToElement([0,1,1,1]))
18
19         # Next method to convert
20         print F.ConvertListToElement(F.ShowCoefficients(0))
21         print F.ConvertListToElement(F.ShowCoefficients(7))




                                                           4
1.8   Result of example3.py




                                        Fig3: Result of example3.py


     2 Operation Over Galois Field

     2.1   Addition Operation over Galois Field

     Following example named “example4.py” shows how do we use python programming language to add
     polynomials over a galois field.

 1         # example4.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3)
 8
 9         print ’For 2 + 5’
10         x = F.Add(2,5)
11         print ’Number: ’ + str(x)
12         print ’Polynomial: ’ + F.ShowPolynomial(x)
13         print ’List: ’ + str(F.ShowCoefficients(x))
14         print ’’
15
16         print ’For 3 + 5’
17         x = F.Add(3,5)
18         print ’Number: ’ + str(x)
19         print ’Polynomial: ’ + F.ShowPolynomial(x)
20         print ’List: ’ + str(F.ShowCoefficients(x))
21         print ’’
22
23         print ’For 6 + 5’
24         x = F.Add(6,5)
25         print ’Number: ’ + str(x)
26         print ’Polynomial: ’ + F.ShowPolynomial(x)
27         print ’List: ’ + str(F.ShowCoefficients(x))
28         print ’’




                                                     5
2.2   Result of example4.py




                                        Fig4: Result of example4.py


     2.3   Multiplication Operation over Galois Field

     Following example named “example5.py” shows how do we use python programming language to multiply
     polynomials over a galois field.

 1         # example5.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3)
 8
 9         print ’For 2 * 5’
10         x = F.Multiply(2,5)
11         print ’Number: ’ + str(x)
12         print ’Polynomial: ’ + F.ShowPolynomial(x)
13         print ’List: ’ + str(F.ShowCoefficients(x))
14         print ’’
15
16         print ’For 3 * 5’
17         x = F.Multiply(3,5)
18         print ’Number: ’ + str(x)
19         print ’Polynomial: ’ + F.ShowPolynomial(x)
20         print ’List: ’ + str(F.ShowCoefficients(x))
21         print ’’
22
23         print ’For 6 * 5’
24         x = F.Multiply(6,5)
25         print ’Number: ’ + str(x)
26         print ’Polynomial: ’ + F.ShowPolynomial(x)
27         print ’List: ’ + str(F.ShowCoefficients(x))
28         print ’’




                                                     6
2.4   Result of example5.py




                                           Fig5: Result of example5.py


     2.5   Operations over Galois Field: Another Approach

     Following example named “example6.py” shows how do we use python programming language to add and
     multiply polynomials over a galois field by another approach.

 1         # example6.py
 2         import sys
 3         sys.path.append(’./Field’)
 4         import ffield
 5
 6         # Create the field GF(2ˆ3)
 7         F = ffield.FField(3) #GF(2ˆ3)
 8
 9         a   =   ffield.FElement(F,0)
10         b   =   ffield.FElement(F,1)
11         c   =   ffield.FElement(F,2)
12         d   =   ffield.FElement(F,3)
13         e   =   ffield.FElement(F,4)
14         f   =   ffield.FElement(F,5)
15         g   =   ffield.FElement(F,6)
16         h   =   ffield.FElement(F,7)
17
18         # Operation in a Galois Field:
19         # Addition Operation
20         p = c + f
21         print p
22         p = d + f
23         print p
24         p = g + f
25         print p
26         print ’’
27
28         # Multiplication Operation
29         q = c * f
30         print q
31         q = d * f


                                                       7
32         print q
33         q = g * f
34         print q



     2.6   Result of example6.py




                                   Fig6: Result of example6.py




                                               8

Mais conteúdo relacionado

Mais procurados (20)

Dfs
DfsDfs
Dfs
 
Numerical Integration
Numerical IntegrationNumerical Integration
Numerical Integration
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 
NP completeness
NP completenessNP completeness
NP completeness
 
A Star Search
A Star SearchA Star Search
A Star Search
 
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor boardLab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
 
Numerical Methods 3
Numerical Methods 3Numerical Methods 3
Numerical Methods 3
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Presentation On Flip-Flop
Presentation On Flip-FlopPresentation On Flip-Flop
Presentation On Flip-Flop
 
Applications of boolean algebra minterm and maxterm expansions
Applications of boolean algebra minterm and maxterm expansionsApplications of boolean algebra minterm and maxterm expansions
Applications of boolean algebra minterm and maxterm expansions
 
Universal logic gate
Universal logic gateUniversal logic gate
Universal logic gate
 
Travelling salesman problem
Travelling salesman problemTravelling salesman problem
Travelling salesman problem
 
BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Edge Trigged Flip Flops
Edge Trigged Flip FlopsEdge Trigged Flip Flops
Edge Trigged Flip Flops
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Local search algorithms
Local search algorithmsLocal search algorithms
Local search algorithms
 
3. multiplexer
3. multiplexer3. multiplexer
3. multiplexer
 

Destaque

A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois FieldHazratali Naim
 
Mortgage Lending After Obergefell v Hodges
Mortgage Lending After Obergefell v HodgesMortgage Lending After Obergefell v Hodges
Mortgage Lending After Obergefell v HodgesBrad Luo
 
15.06.26 cfk
15.06.26 cfk 15.06.26 cfk
15.06.26 cfk APITEC
 
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016Programme ISCC-SFMC-StratAdviser 2 fevrier 2016
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016Jan-Cedric Hansen
 
專題進度一
專題進度一專題進度一
專題進度一Joan0730
 
Préparation iCriris ENSM deSaint Etienne 2016
Préparation iCriris ENSM deSaint Etienne 2016Préparation iCriris ENSM deSaint Etienne 2016
Préparation iCriris ENSM deSaint Etienne 2016Jan-Cedric Hansen
 
Evision- An EV distributor Launch Plan
Evision- An EV distributor Launch PlanEvision- An EV distributor Launch Plan
Evision- An EV distributor Launch Planghisland
 
Keywordsagriculture
KeywordsagricultureKeywordsagriculture
Keywordsagriculturecheergalsal
 
Linked Open Data at SAAM: Past, Present, Future
Linked Open Data at SAAM: Past, Present, FutureLinked Open Data at SAAM: Past, Present, Future
Linked Open Data at SAAM: Past, Present, FutureAmerican Art Collaborative
 
Different types of text in english
Different types of text in englishDifferent types of text in english
Different types of text in englishCristiana Chaves
 
Gestión de recursos humanos en salud
Gestión de recursos humanos en salud Gestión de recursos humanos en salud
Gestión de recursos humanos en salud Ariel Mario Goldman
 

Destaque (20)

Tutorial for RDF Graphs
Tutorial for RDF GraphsTutorial for RDF Graphs
Tutorial for RDF Graphs
 
A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois Field
 
Mortgage Lending After Obergefell v Hodges
Mortgage Lending After Obergefell v HodgesMortgage Lending After Obergefell v Hodges
Mortgage Lending After Obergefell v Hodges
 
15.06.26 cfk
15.06.26 cfk 15.06.26 cfk
15.06.26 cfk
 
Proyecto uso del algoritmo de montecarlo
Proyecto uso del algoritmo de montecarloProyecto uso del algoritmo de montecarlo
Proyecto uso del algoritmo de montecarlo
 
Hill Sheep
Hill SheepHill Sheep
Hill Sheep
 
0215_001
0215_0010215_001
0215_001
 
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016Programme ISCC-SFMC-StratAdviser 2 fevrier 2016
Programme ISCC-SFMC-StratAdviser 2 fevrier 2016
 
專題進度一
專題進度一專題進度一
專題進度一
 
Préparation iCriris ENSM deSaint Etienne 2016
Préparation iCriris ENSM deSaint Etienne 2016Préparation iCriris ENSM deSaint Etienne 2016
Préparation iCriris ENSM deSaint Etienne 2016
 
Manual orange
Manual orangeManual orange
Manual orange
 
Evision- An EV distributor Launch Plan
Evision- An EV distributor Launch PlanEvision- An EV distributor Launch Plan
Evision- An EV distributor Launch Plan
 
Keywordsagriculture
KeywordsagricultureKeywordsagriculture
Keywordsagriculture
 
Linked Open Data at SAAM: Past, Present, Future
Linked Open Data at SAAM: Past, Present, FutureLinked Open Data at SAAM: Past, Present, Future
Linked Open Data at SAAM: Past, Present, Future
 
Different types of text in english
Different types of text in englishDifferent types of text in english
Different types of text in english
 
IPv6 examples
IPv6 examplesIPv6 examples
IPv6 examples
 
Gestión de recursos humanos en salud
Gestión de recursos humanos en salud Gestión de recursos humanos en salud
Gestión de recursos humanos en salud
 
Random Number Generation
Random Number GenerationRandom Number Generation
Random Number Generation
 
OLSR setup
OLSR setup OLSR setup
OLSR setup
 
Random number generation
Random number generationRandom number generation
Random number generation
 

Semelhante a Galios: Python Programming

Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxAaliyanShaikh
 
Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewMarkus Schneider
 
Python intro ch_e_comp
Python intro ch_e_compPython intro ch_e_comp
Python intro ch_e_compPaulo Castro
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminarygo-lang
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdfsrxerox
 
Python programing
Python programingPython programing
Python programinghamzagame
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docxrafbolet0
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
A peek on numerical programming in perl and python e christopher dyken 2005
A peek on numerical programming in perl and python  e christopher dyken  2005A peek on numerical programming in perl and python  e christopher dyken  2005
A peek on numerical programming in perl and python e christopher dyken 2005Jules Krdenas
 
1 ECONOMICS 581 LECTURE NOTES CHAPTER 4 MICROECONO.docx
 1 ECONOMICS 581 LECTURE NOTES  CHAPTER 4 MICROECONO.docx 1 ECONOMICS 581 LECTURE NOTES  CHAPTER 4 MICROECONO.docx
1 ECONOMICS 581 LECTURE NOTES CHAPTER 4 MICROECONO.docxaryan532920
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa Thapa
 

Semelhante a Galios: Python Programming (20)

Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptx
 
Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / Overview
 
Let's golang
Let's golangLet's golang
Let's golang
 
functions
functionsfunctions
functions
 
Python intro ch_e_comp
Python intro ch_e_compPython intro ch_e_comp
Python intro ch_e_comp
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Python programing
Python programingPython programing
Python programing
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
 
function.pptx
function.pptxfunction.pptx
function.pptx
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
A peek on numerical programming in perl and python e christopher dyken 2005
A peek on numerical programming in perl and python  e christopher dyken  2005A peek on numerical programming in perl and python  e christopher dyken  2005
A peek on numerical programming in perl and python e christopher dyken 2005
 
1 ECONOMICS 581 LECTURE NOTES CHAPTER 4 MICROECONO.docx
 1 ECONOMICS 581 LECTURE NOTES  CHAPTER 4 MICROECONO.docx 1 ECONOMICS 581 LECTURE NOTES  CHAPTER 4 MICROECONO.docx
1 ECONOMICS 581 LECTURE NOTES CHAPTER 4 MICROECONO.docx
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 

Último

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Último (20)

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Galios: Python Programming

  • 1. Tutorial on Programming with Python: Galois Field Kishoj Bajracharya Asian Institute of Technology June 20, 2011 Contents 1 Galois Field 2 1.1 To import class FField for Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 To Create Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Polynomial Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 Result of example1.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.5 Co-efficient of Polynomial Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.6 Result of example2.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.7 Conversion from co-efficient of polynomial to element . . . . . . . . . . . . . . . . . . . . 4 1.8 Result of example3.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Operation Over Galois Field 5 2.1 Addition Operation over Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Result of example4.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Multiplication Operation over Galois Field . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 Result of example5.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.5 Operations over Galois Field: Another Approach . . . . . . . . . . . . . . . . . . . . . . . 7 2.6 Result of example6.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1
  • 2. 1 Galois Field 1.1 To import class FField for Galois Field 1. Browse the URI http://www.mit.edu/˜emin/source_code/py_ecc and see the latest release of the file “py ecc-1-4.tar.gz” and download it. 2. Extract it and keep all the files in a separate folder named “Field”. 3. Use the import command to use the class FField from the file name “ffield.py” import sys sys.path.append(‘./Field’) import ffield 1.2 To Create Galois Field To create the Galois field F = GF (2n ) F = ffield.FField(n) Create the field GF (23 ) F = ffield.FField(3) 1.3 Polynomial Representation The polynomial representation of any number a can be obtained using following codes F.ShowPolynomial(a) Returns: string Note: the value of a lies between 0 to 2n − 1 Following example named “example1.py” shows how do we use python programming language to get poly- nomial from galois field. 1 # example1.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) 8 9 # Show the polynomial representation from 0-2ˆ3-1 i.e. 0-7 10 print ’For 0, polynomial: ’ + F.ShowPolynomial(0) 11 print ’For 1, polynomial: ’ + F.ShowPolynomial(1) 12 print ’For 2, polynomial: ’ + F.ShowPolynomial(2) 13 print ’For 3, polynomial: ’ + F.ShowPolynomial(3) 14 print ’For 4, polynomial: ’ + F.ShowPolynomial(4) 15 print ’For 5, polynomial: ’ + F.ShowPolynomial(5) 16 print ’For 6, polynomial: ’ + F.ShowPolynomial(6) 17 print ’For 7, polynomial: ’ + F.ShowPolynomial(7) 2
  • 3. 1.4 Result of example1.py Fig1: Result of example1.py 1.5 Co-efficient of Polynomial Representation The coefficient of the polynomial representation of any number a can be obtained using following codes F.ShowCoefficients(a) Returns: list Note: the value of a lies between 0 to 2n − 1 Following example named “example2.py” shows how do we use python programming language to get the co-efficient of a polynomial from galois field. 1 # example2.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) 8 9 # Show the coefficient of the coefficient of polynomial representation of a,b,c,d,e,f,g,h 10 print ’For 0, coefficient of polynomial: ’ + str(F.ShowCoefficients(0)) 11 print ’For 1, coefficient of polynomial: ’ + str(F.ShowCoefficients(1)) 12 print ’For 2, coefficient of polynomial: ’ + str(F.ShowCoefficients(2)) 13 print ’For 3, coefficient of polynomial: ’ + str(F.ShowCoefficients(3)) 14 print ’For 4, coefficient of polynomial: ’ + str(F.ShowCoefficients(4)) 15 print ’For 5, coefficient of polynomial: ’ + str(F.ShowCoefficients(5)) 16 print ’For 6, coefficient of polynomial: ’ + str(F.ShowCoefficients(6)) 17 print ’For 7, coefficient of polynomial: ’ + str(F.ShowCoefficients(7)) 3
  • 4. 1.6 Result of example2.py Fig2: Result of example2.py 1.7 Conversion from co-efficient of polynomial to element The coefficient(list) of the polynomial can be converted to the element(integer) F.ConvertListToElement(list) Returns: integer Note: the value of a lies between 0 to 2n − 1 Following example named “example3.py” shows how do we use python programming language to convert co-efficient of a polynomial to element over a galois field. 1 # example3.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) 8 9 # Converting list into the element 10 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,0,0,0])) 11 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,0,0,1])) 12 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,0,1,0])) 13 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,0,1,1])) 14 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,1,0,0])) 15 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,1,0,1])) 16 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,1,1,0])) 17 print "List: [0,0,0,0], Element: " + str(F.ConvertListToElement([0,1,1,1])) 18 19 # Next method to convert 20 print F.ConvertListToElement(F.ShowCoefficients(0)) 21 print F.ConvertListToElement(F.ShowCoefficients(7)) 4
  • 5. 1.8 Result of example3.py Fig3: Result of example3.py 2 Operation Over Galois Field 2.1 Addition Operation over Galois Field Following example named “example4.py” shows how do we use python programming language to add polynomials over a galois field. 1 # example4.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) 8 9 print ’For 2 + 5’ 10 x = F.Add(2,5) 11 print ’Number: ’ + str(x) 12 print ’Polynomial: ’ + F.ShowPolynomial(x) 13 print ’List: ’ + str(F.ShowCoefficients(x)) 14 print ’’ 15 16 print ’For 3 + 5’ 17 x = F.Add(3,5) 18 print ’Number: ’ + str(x) 19 print ’Polynomial: ’ + F.ShowPolynomial(x) 20 print ’List: ’ + str(F.ShowCoefficients(x)) 21 print ’’ 22 23 print ’For 6 + 5’ 24 x = F.Add(6,5) 25 print ’Number: ’ + str(x) 26 print ’Polynomial: ’ + F.ShowPolynomial(x) 27 print ’List: ’ + str(F.ShowCoefficients(x)) 28 print ’’ 5
  • 6. 2.2 Result of example4.py Fig4: Result of example4.py 2.3 Multiplication Operation over Galois Field Following example named “example5.py” shows how do we use python programming language to multiply polynomials over a galois field. 1 # example5.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) 8 9 print ’For 2 * 5’ 10 x = F.Multiply(2,5) 11 print ’Number: ’ + str(x) 12 print ’Polynomial: ’ + F.ShowPolynomial(x) 13 print ’List: ’ + str(F.ShowCoefficients(x)) 14 print ’’ 15 16 print ’For 3 * 5’ 17 x = F.Multiply(3,5) 18 print ’Number: ’ + str(x) 19 print ’Polynomial: ’ + F.ShowPolynomial(x) 20 print ’List: ’ + str(F.ShowCoefficients(x)) 21 print ’’ 22 23 print ’For 6 * 5’ 24 x = F.Multiply(6,5) 25 print ’Number: ’ + str(x) 26 print ’Polynomial: ’ + F.ShowPolynomial(x) 27 print ’List: ’ + str(F.ShowCoefficients(x)) 28 print ’’ 6
  • 7. 2.4 Result of example5.py Fig5: Result of example5.py 2.5 Operations over Galois Field: Another Approach Following example named “example6.py” shows how do we use python programming language to add and multiply polynomials over a galois field by another approach. 1 # example6.py 2 import sys 3 sys.path.append(’./Field’) 4 import ffield 5 6 # Create the field GF(2ˆ3) 7 F = ffield.FField(3) #GF(2ˆ3) 8 9 a = ffield.FElement(F,0) 10 b = ffield.FElement(F,1) 11 c = ffield.FElement(F,2) 12 d = ffield.FElement(F,3) 13 e = ffield.FElement(F,4) 14 f = ffield.FElement(F,5) 15 g = ffield.FElement(F,6) 16 h = ffield.FElement(F,7) 17 18 # Operation in a Galois Field: 19 # Addition Operation 20 p = c + f 21 print p 22 p = d + f 23 print p 24 p = g + f 25 print p 26 print ’’ 27 28 # Multiplication Operation 29 q = c * f 30 print q 31 q = d * f 7
  • 8. 32 print q 33 q = g * f 34 print q 2.6 Result of example6.py Fig6: Result of example6.py 8