Ask Your Question

rlsw's profile - activity

2023-02-27 15:08:44 +0200 received badge  Notable Question (source)
2022-10-30 13:18:44 +0200 received badge  Notable Question (source)
2022-02-07 18:12:17 +0200 received badge  Popular Question (source)
2020-12-22 10:25:01 +0200 received badge  Popular Question (source)
2018-12-15 20:46:52 +0200 received badge  Nice Question (source)
2018-12-15 19:16:38 +0200 commented answer How to express unknown coefficients in GF(2^8)?

thank you so much! this is exactly what I need

2018-12-15 19:16:12 +0200 received badge  Supporter (source)
2018-12-15 19:16:10 +0200 received badge  Scholar (source)
2018-12-15 18:05:29 +0200 received badge  Editor (source)
2018-12-15 17:32:46 +0200 asked a question How to express unknown coefficients in GF(2^8)?

I want to make computations in GF(2^8) using the Rijndael modulus X^8+X^4+X^3+X+1 and with unknown elements of GF(2^8).

For example, I need a polynomial x which is defined as x = x_7 * X^7 + x_6 * X^6 + x_5 * X^7 + ... + x_0

x.coefficients() should return [x_0, x_1, x_2, x_3, x_4, ...]

If I for example add x to y, I would expect that the result would be a term like (x_7+y_7) * X^7 + (x_6+y_6)*X^6 + ...

I tried the following:

sage: pgen = polygen(Integers(2))
sage: modulus = pgen()**8 + pgen()**4 + pgen()**3 + pgen() + 1
sage: F = FiniteField(2**8, 'X', modulus = modulus)
sage: X = F.gen()
X
sage: x_coeffs = list(var('x_%d' % i) for i in range(8))
sage: y_coeffs = list(var('y_%d' % i) for i in range(8))
sage: uF = PolynomialRing(F, 16, x_coeffs + y_coeffs); uF
Multivariate Polynomial Ring in x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, y_0, y_1, y_2, y_3, y_4, y_5, y_6, y_7 over Finite Field in a of size 2^8

sage: poly_x = uF(x_0 * X^0 + x_1 * X^1 + x_2 * X^2 + x_3 * X^3 + x_4 * X^4 + x_5 * X^5 + x_6 * X^6 + x_7 * X^7)
sage: poly_y = uF(y_0 * X^0 + y_1 * X^1 + y_2 * X^2 + y_3 * X^3 + y_4 * X^4 + y_5 * X^5 + y_6 * X^6 + y_7 * X^7)

(which is very much like I found it in the sources of sage.crypto.mq.rijndael_gf.RijndaelGF)

But the coefficients of poly_x and poly_y are not the variables x_0, x_1 etc. but the X^0, X^1, etc...

I also tried:

sage: F = GF(2^8, 'X')
sage: X = F.gen()
X
sage: x_coeffs = list(var('x_%d' % i) for i in range(8))
sage: y_coeffs = list(var('y_%d' % i) for i in range(8))
sage: poly_x = 0*X
sage: type(poly_x)
<type 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'>
sage: for i in xrange(8):
....:     poly_x += x_coeffs[i] * X^i
....:
sage: poly_x
x_0 + X*x_1 + X^2*x_2 + X^3*x_3 + X^4*x_4 + X^5*x_5 + X^6*x_6 + X^7*x_7
sage: type(poly_x)
<type 'sage.symbolic.expression.Expression'>
sage: poly_x.coefficients()
[[X*x_1 + X^2*x_2 + X^3*x_3 + X^4*x_4 + X^5*x_5 + X^6*x_6 + X^7*x_7, 0],
 [1, 1]]

which is also not what I want. Also, expressions like the follow lead to an error:

sage: F(x_1*X)
TypeError: unable to coerce <type 'sage.symbolic.expression.Expression'>

How can I express unknown elements with unknown coefficients?

2018-11-05 22:45:40 +0200 received badge  Student (source)
2018-11-05 22:26:24 +0200 asked a question how to get the transformation matrix for a transformation over 4x4 matrices?

I have the following transformation:

M = MatrixSpace(QQ,4,4)
def f(m):
    return matrix([
            [m[0][0], m[0][1], m[0][2], m[0][3]],
            [m[1][3], m[1][0], m[1][1], m[1][2]],
            [m[2][2], m[2][3], m[2][0], m[2][1]],
            [m[3][1], m[3][2], m[3][3], m[3][0]]
        ])
print linear_transformation(M, M, f)

This is not working - but I can't figure out what linear_transformation is expecting. How can I get this to work? Is this even possible?