ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 06 Sep 2018 10:06:30 +0200Strict Avalanche Criteria in Sagehttps://ask.sagemath.org/question/43598/strict-avalanche-criteria-in-sage/ Is there any inbuilt functionality in sage to check if any S-Box satisfies Strict Avalanche Criterion or not?Cryptographer005Thu, 06 Sep 2018 10:06:30 +0200https://ask.sagemath.org/question/43598/HUGE delay in sage.crypto.sbox.SBox method nonlinearity() introduced in v.8.2https://ask.sagemath.org/question/42492/huge-delay-in-sagecryptosboxsbox-method-nonlinearity-introduced-in-v82/Average time in nonlinearity() in v.8.1. was ****200 ms****
Average time in nonlinearity() in v.8.2 is ****5.1 s****
Here is the code I have used in order to track the issue:
sage: for j in range(10):
....: S = [x for x in range(256)];shuffle(S)
....: S = sage.crypto.sbox.SBox(S)
....: %time S.nonlinearity()
Results from Sage 8.1
CPU times: user 237 ms, sys: 1.87 ms, total: 239 ms
Wall time: 236 ms
94
CPU times: user 208 ms, sys: 12.5 ms, total: 220 ms
Wall time: 220 ms
94
CPU times: user 287 ms, sys: 1.41 ms, total: 288 ms
Wall time: 288 ms
92
....
Results from Sage 8.2
CPU times: user 5.12 s, sys: 30.6 ms, total: 5.15 s
Wall time: 5.16 s
92
CPU times: user 5.04 s, sys: 14.3 ms, total: 5.05 s
Wall time: 5.05 s
96
CPU times: user 5.08 s, sys: 13 ms, total: 5.09 s
Wall time: 5.09 s
94
CPU times: user 5.03 s, sys: 8.56 ms, total: 5.04 s
Wall time: 5.04 s
92
.....sageuser1Mon, 04 Jun 2018 12:23:32 +0200https://ask.sagemath.org/question/42492/How can we make the AES S-box using Lagrange interpolation?https://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 10:27:20 +0100https://ask.sagemath.org/question/40008/Error when trying to input an 8-bit Sbox into the argument of S = mq.SBox(.)https://ask.sagemath.org/question/8683/error-when-trying-to-input-an-8-bit-sbox-into-the-argument-of-s-mqsbox/Why is it that when I try to input an 8-bit Sbox into the argument of S = mq.SBox(.), I get the error: "SyntaxError: more than 255 arguments"? Does this class not work for more than 7-bit S-boxes?viviWed, 19 Dec 2012 03:06:04 +0100https://ask.sagemath.org/question/8683/converting from direct representation to indirect representation for S-boxeshttps://ask.sagemath.org/question/26039/converting-from-direct-representation-to-indirect-representation-for-s-boxes/Hi guys, let's we want to get the polynomial expression for a S-Box.
sage: S = mq.SBox(7,6,0,4,2,5,1,3)
sage: P = S.ring()
We can get the **indirect** representation...
sage: S.polynomials()
[x0*x2 + x1 + y1 + 1,
x0*x1 + x1 + x2 + y0 + y1 + y2 + 1,
x0*y1 + x0 + x2 + y0 + y2,
x0*y0 + x0*y2 + x1 + x2 + y0 + y1 + y2 + 1,
x1*x2 + x0 + x1 + x2 + y2 + 1,
x0*y0 + x1*y0 + x0 + x2 + y1 + y2,
x0*y0 + x1*y1 + x1 + y1 + 1,
x1*y2 + x1 + x2 + y0 + y1 + y2 + 1,
x0*y0 + x2*y0 + x1 + x2 + y1 + 1,
x2*y1 + x0 + y1 + y2,
x2*y2 + x1 + y1 + 1,
y0*y1 + x0 + x2 + y0 + y1 + y2,
y0*y2 + x1 + x2 + y0 + y1 + 1,
y1*y2 + x2 + y0]
or the **direct** representation
sage: P.<y0,y1,y2,x0,x1,x2> = PolynomialRing(GF(2),6,order='lex')
sage: S.polynomials([x0,x1,x2],[y0,y1,y2], groebner=True)
[y0 + x0*x1 + x0*x2 + x0 + x1*x2 + x1 + 1,
y1 + x0*x2 + x1 + 1,
y2 + x0 + x1*x2 + x1 + x2 + 1]
My question is, given the **direct** representation of the S-Box, can we retrieve the **indirect** representation for the S-Box?freako89Thu, 05 Mar 2015 05:28:36 +0100https://ask.sagemath.org/question/26039/How to evaluate 16 by 16 s-boxes?https://ask.sagemath.org/question/8923/how-to-evaluate-16-by-16-s-boxes/Hi, I've a query, can we create a 16 by 16 s-box of 8 boolean variables in sage? I'm getting error while calculating difference matrix etc... secondly i'm getting nonlinearity equal to 1 when i give original AES S-box as input to boolean function. Is sage not compatible with large boolean functions/s-boxes?uzmamaroofWed, 25 Apr 2012 02:03:56 +0200https://ask.sagemath.org/question/8923/