Ask Your Question
0

How to convert an Integer to a GF representation

asked 2018-11-06 04:48:34 -0600

Lujmina gravatar image

Hi,

I would like to convert an Integer to a GF, however I do not seem to find anything about this or whether it is possible or not. I am using the following code:

e = 48
n = 2
m = 3

F.<t> = GF(2)[]
K.<q> = GF(2^48, name='q', modulus=t^48 + t^28 + t^27 + t + 1, repr='int')

test = 0x944a58ec1f29
print test
print Integer(test)
print K(test)

Thank you

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-06 05:19:25 -0600

dan_fulea gravatar image

Here are some possibilities to lift, we may use a list to lift. (A number can also be considered as an element in $\Bbb Z$, and the coercion to $\Bbb F_2=$GF(2) makes it zero or one. So:

sage: F.<t> = GF(2)[]
sage: K.<q> = GF(2^48, name='q', modulus=t^48 + t^28 + t^27 + t + 1, repr='int')
sage: test = 0x944a58ec1f29
sage: test
163047040360233

sage: F(test.digits(base=2))
t^47 + t^44 + t^42 + t^38 + t^35 + t^33 + t^30 + t^28 + t^27 + t^23 + t^22 + t^21 
     + t^19 + t^18 + t^12 + t^11 + t^10 + t^9 + t^8 + t^5 + t^3 + 1
sage: K(test.digits(base=2))
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
     + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

sage: test.binary()
'100101000100101001011000111011000001111100101001'

sage: K(list(test.binary()))    # not what we want!
q^47 + q^44 + q^42 + q^39 + q^38 + q^37 + q^36 + q^35 + q^29 + q^28 + q^26 + q^25 + q^24 
     + q^20 + q^19 + q^17 + q^14 + q^12 + q^9 + q^5 + q^3 + 1
sage: K(list(test.binary())[::-1])
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
      + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

sage: K(test.bits())
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
      + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

For short, use test.bits() or test.digits(2) as an intermediate step.

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: 2018-11-06 04:48:34 -0600

Seen: 29 times

Last updated: Nov 06