SAES_ToStateMatrix([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
それが私に与えるように最初の関数を呼び出すときの人
[a^3 + a a^3 + a]
[a^3 + a a^3 + a]
SAES_FromStateMatrix([[a^3 + a a^3 + a],[a^3 + a a^3 + a]])
しかし、出力をエラーとして渡すことでエラーが発生し" invalid syntax "
たため、このエラーを回避する方法
ここに私のコードがあります
F = GF(2);
L.<a> = GF(2^4);
V = L.vector_space();
VF8 = VectorSpace(F, 8);
def SAES_ToStateMatrix(block):
r"""
Converts a bit list into an SAES State Matrix
"""
B = block;
# form the plaintext block into a matrix of GF(2^n) elements
S00 = L(V([B[0], B[1], B[2], B[3]]));
S01 = L(V([B[4], B[5], B[6], B[7]]));
S10 = L(V([B[8], B[9], B[10], B[11]]));
S11 = L(V([B[12], B[13], B[14], B[15]]));
state_matrix = Matrix(L, [[S00,S01],[S10,S11]]);
return state_matrix;
def SAES_FromStateMatrix(state_matrix):
r"""
Converts an SAES state_matrix to a bit list.
"""
output = [];
# convert state matrix back into bit list
for r in xrange(2):
for c in xrange(2):
v = V(state_matrix[r,c]);
for j in xrange(4):
output.append(Integer(v[j]));
return output;