SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Sistem operasi terdistribusi
Sistem operasi terdistribusiSistem operasi terdistribusi
Sistem operasi terdistribusihofidatur
 
MAKALAH DOUBLE LINKED LIST BAHASA C.docx
MAKALAH DOUBLE LINKED LIST BAHASA C.docxMAKALAH DOUBLE LINKED LIST BAHASA C.docx
MAKALAH DOUBLE LINKED LIST BAHASA C.docxDikicandra6
 
Actividad Topologías VoIP
Actividad Topologías VoIPActividad Topologías VoIP
Actividad Topologías VoIPcyberleon95
 
Anexo 1 guia rapida de cacti
Anexo 1 guia rapida de cactiAnexo 1 guia rapida de cacti
Anexo 1 guia rapida de cactiRenè Grillet
 
Modul 1 konsep dasar pemrograman delphi
Modul   1 konsep dasar pemrograman delphiModul   1 konsep dasar pemrograman delphi
Modul 1 konsep dasar pemrograman delphiFajar Istiqomah
 
Actividad Firewall Cisco ASA 5510
Actividad Firewall Cisco ASA 5510Actividad Firewall Cisco ASA 5510
Actividad Firewall Cisco ASA 5510Yeider Fernandez
 
Tutorial aplikasi toko online berbasis web dengan PHP
Tutorial aplikasi toko online berbasis web dengan PHPTutorial aplikasi toko online berbasis web dengan PHP
Tutorial aplikasi toko online berbasis web dengan PHPDeka M Wildan
 
Cara kerja internet[1]
Cara kerja internet[1]Cara kerja internet[1]
Cara kerja internet[1]Andi Kusuma
 
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...Uofa_Unsada
 
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)Eliel Simb
 
La apple - the apple
La apple - the appleLa apple - the apple
La apple - the appleStudent
 
Cara proses perhitungan cpu
Cara proses perhitungan cpu Cara proses perhitungan cpu
Cara proses perhitungan cpu Dyah19
 
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSM
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSMPembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSM
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSMI Putu Hariyadi
 
Tugas topologi jaringan
Tugas topologi jaringanTugas topologi jaringan
Tugas topologi jaringanFandi Rahmat
 
PPT Teknik Informatika.pptx
PPT Teknik Informatika.pptxPPT Teknik Informatika.pptx
PPT Teknik Informatika.pptxUcihaJinRio
 

Was ist angesagt? (20)

Arkom2
Arkom2Arkom2
Arkom2
 
Sistem operasi terdistribusi
Sistem operasi terdistribusiSistem operasi terdistribusi
Sistem operasi terdistribusi
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
MAKALAH DOUBLE LINKED LIST BAHASA C.docx
MAKALAH DOUBLE LINKED LIST BAHASA C.docxMAKALAH DOUBLE LINKED LIST BAHASA C.docx
MAKALAH DOUBLE LINKED LIST BAHASA C.docx
 
Actividad Topologías VoIP
Actividad Topologías VoIPActividad Topologías VoIP
Actividad Topologías VoIP
 
Anexo 1 guia rapida de cacti
Anexo 1 guia rapida de cactiAnexo 1 guia rapida de cacti
Anexo 1 guia rapida de cacti
 
Modul 1 konsep dasar pemrograman delphi
Modul   1 konsep dasar pemrograman delphiModul   1 konsep dasar pemrograman delphi
Modul 1 konsep dasar pemrograman delphi
 
Actividad Firewall Cisco ASA 5510
Actividad Firewall Cisco ASA 5510Actividad Firewall Cisco ASA 5510
Actividad Firewall Cisco ASA 5510
 
Tutorial aplikasi toko online berbasis web dengan PHP
Tutorial aplikasi toko online berbasis web dengan PHPTutorial aplikasi toko online berbasis web dengan PHP
Tutorial aplikasi toko online berbasis web dengan PHP
 
Cara kerja internet[1]
Cara kerja internet[1]Cara kerja internet[1]
Cara kerja internet[1]
 
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...
Perancangan Antena Mikrostrip Pada Frekuensi 2,3 Ghz Untuk Aplikasi LTE (Long...
 
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)
CCNA Discovery 4.0 Examen Capítulo I Examen 5 (Respuestas o Solucionario)
 
La apple - the apple
La apple - the appleLa apple - the apple
La apple - the apple
 
Jaringan perceptron
Jaringan perceptronJaringan perceptron
Jaringan perceptron
 
Cara proses perhitungan cpu
Cara proses perhitungan cpu Cara proses perhitungan cpu
Cara proses perhitungan cpu
 
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSM
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSMPembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSM
Pembahasan Tugas 1 Jaringan Komputer tentang Perhitungan VLSM
 
Sister 06 - client server
Sister   06 - client serverSister   06 - client server
Sister 06 - client server
 
[PBO] Pertemuan 6 - Abstrak
[PBO] Pertemuan 6 - Abstrak[PBO] Pertemuan 6 - Abstrak
[PBO] Pertemuan 6 - Abstrak
 
Tugas topologi jaringan
Tugas topologi jaringanTugas topologi jaringan
Tugas topologi jaringan
 
PPT Teknik Informatika.pptx
PPT Teknik Informatika.pptxPPT Teknik Informatika.pptx
PPT Teknik Informatika.pptx
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 
Please provide a complete Python code with these provided co.pdf
Please provide a complete Python code with these provided co.pdfPlease provide a complete Python code with these provided co.pdf
Please provide a complete Python code with these provided co.pdfmukulsingh0025
 
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
 

Ähnlich wie 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
 
IO_Matlab.pdf
IO_Matlab.pdfIO_Matlab.pdf
IO_Matlab.pdf
 
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
 
Please provide a complete Python code with these provided co.pdf
Please provide a complete Python code with these provided co.pdfPlease provide a complete Python code with these provided co.pdf
Please provide a complete Python code with these provided co.pdf
 
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
 

Kürzlich hochgeladen

Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSyedNadeemGillANi
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Dr. Asif Anas
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 

Kürzlich hochgeladen (20)

Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
 
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic SupportMarch 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 

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