ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 08 Dec 2017 03:27:20 -0600How can we make the AES S-box using Lagrange interpolation?http://ask.sagemath.org/question/40008/how-can-we-make-the-aes-s-box-using-lagrange-interpolation/I found the Sage code for the AES S-box online. It is given below.
However, I do not know how to find the coefficients of ***a*** to ***h*** using Lagrange interpolation. They seem to appear from nowhere, but I am told they are the result of *Lagrange interpolation*. I only know how to apply Lagrange interpolation if I have a function and some given points. But it seems there are no given points.
Can anyone help? An example of how to use Lagrange interpolation in Sage for just one or two of these polynomials, say $a =x^2+1$, and $b = x^3+1$ would be very helpful.
R = PolynomialRing(GF(2),'x',1)
x = R.gen()
m = x^8 + x^4 + x^3 + x + 1
v = x^6 + x^5 + x + 1
y = x^7 + x^4 + x^2 + 1
a = x^2 + 1
b = x^3 + 1
c = x^7 + x^6 + x^5 + x^4 + x^3 + 1
d = x^5 + x^2 + 1
e = x^7 + x^6 + x^5 + x^4 + x^2
f = 1
g = x^7 + x^5 + x^4 + x^2 + 1
h = x^7 + x^3 + x^2 + x + 1
s = a*(y^254) + b*(y^253) + c*(y^251) + d*(y^247) + e*(y^239) + f*(y^223) + g*(y^191) + h*(y^127) + v
print (s % m)Redbook1Fri, 08 Dec 2017 03:27:20 -0600http://ask.sagemath.org/question/40008/