Ask Your Question
0

How to handle elements of two different Galois fields simultaneously?

asked 2019-06-01 03:45:13 -0500

updated 2019-06-01 09:20:45 -0500

slelievre gravatar image

I would like to operate the elements of two different fields simultaneously. I have used the following codes, both are not working at the same time whereas only one work at a time.

G.<x> = GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1)
F.<x> = GF(2^3, name='x', modulus=x^3 + x^2 + 1)

for i in range(2^3):
    print G.fetch_int(i).integer_representation(), '=', G.fetch_int(i)
    print  F.fetch_int(i).integer_representation(), '=', F.fetch_int(i)
edit retag flag offensive close merge delete

Comments

Use different names..

FrédéricC gravatar imageFrédéricC ( 2019-06-01 05:24:03 -0500 )edit

@FrédéricC I have used different names, but this also gives error: raise ValueError("the degree of the modulus does not equal the degree of the field") ValueError: the degree of the modulus does not equal the degree of the field

math.mks@yandex.com gravatar imagemath.mks@yandex.com ( 2019-06-01 05:29:34 -0500 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2019-06-01 06:13:32 -0500

rburing gravatar image

The modulus should be a polynomial over the prime field.

R.<x> = PolynomialRing(GF(2))
G = GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1)
F = GF(2^3, name='x', modulus=x^3 + x^2 + 1)

for i in range(2^3):
    print G.fetch_int(i).integer_representation(), '=', G.fetch_int(i)
    print F.fetch_int(i).integer_representation(), '=', F.fetch_int(i)

To get the generator of, say, F, use F.gen(). Or give them different names like so (still using x in R):

G.<a> = GF(2^8, modulus=x^8 + x^5 + x^3 + x + 1)
F.<b> = GF(2^3, modulus=x^3 + x^2 + 1)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-06-01 03:45:13 -0500

Seen: 34 times

Last updated: Jun 01