Quotient ring over Finite Field 2^n

30 views
Skip to first unread message

Oleksandr Kazymyrov

unread,
Aug 11, 2014, 1:56:24 PM8/11/14
to sage-s...@googlegroups.com
Hello everyone, 

It seems like quotient_ring doesn't have '__call__'. Does it a bug or a feature?

sage: K = GF(2^8,'a')
sage: P = PolynomialRing(K,'x')
sage: Q = P.quotient_ring(P("x^256+x"),'y')
sage: f = Q.random_element()
sage: f.subs(y=K.random_element()) # random
(a^7 + a^6 + a^3 + a)*y^255 + (a^7 + a^4)*y^254 ...
sage: Q
Univariate Quotient Polynomial Ring in y over Finite Field in a of size 2^8 with modulus x^256 + x

I expect that the output will be in K. 

Kind regards,
Oleksandr

Peter Bruin

unread,
Aug 12, 2014, 4:40:34 PM8/12/14
to sage-s...@googlegroups.com
Hello,

It would in principle not be hard to implement the functionality you are asking for, but I would recommend a solution like the following:

sage: K = GF(2^8, 'a')
sage: P.<x> = PolynomialRing(K)
sage: Q.<y> = P.quotient_ring(x^256 - x)
sage: a = K.random_element()
sage: ev_a = Q.hom([a])  # homomorphism "evaluation in a": Q -> K
sage: f = Q.random_element()
sage: b = ev_a(f)
sage: b  # random
a^7 + a^5 + a^3 + a^2 + a + 1
sage: b.parent() is K
True

In this way, the fact that ev_a is well-defined is checked during its construction, so it doesn't have to be checked when doing the actual evaluation.

Peter

Oleksandr Kazymyrov

unread,
Aug 12, 2014, 5:33:11 PM8/12/14
to sage-s...@googlegroups.com
Hi Peter, 

Your solution can be used in some applications. However, I guess the "call" is more natural and understandable. It can be also used in the following:

K = GF(2^8, 'a')
P.<x> = PolynomialRing(K)
Q.<y> = P.quotient_ring(x^256 - x)
f = Q.random_element()
f.subs(Q.random_element())

Albeit...

K = GF(2^8, 'a')
P.<x> = PolynomialRing(K)
Q.<y> = P.quotient_ring(x^256 - x)
f = Q.random_element()
ev_a = Q.hom([Q.random_element()])  # homomorphism: Q -> Q
f = Q.random_element()
b = ev_a(f)

The code above works fine!

Regards,
Oleksandr 
Reply all
Reply to author
Forward
0 new messages