diff --git a/src/sage/crypto/lwe.py b/src/sage/crypto/lwe.py index db675ebafaa..25bb2a3fb47 100644 --- a/src/sage/crypto/lwe.py +++ b/src/sage/crypto/lwe.py @@ -312,10 +312,10 @@ def __init__(self, n, q, D, secret_dist='uniform', m=None): ... IndexError: Number of available samples exhausted. """ - self.n = ZZ(n) + self.n = ZZ(n) self.m = m self.__i = 0 - self.K = IntegerModRing(q) + self.K = IntegerModRing(q) self.FM = FreeModule(self.K, n) self.D = D @@ -443,7 +443,7 @@ def __init__(self, n, delta=0.01, m=None): s = sqrt(s_t_bound*floor(q/4)) # Transform s into stddev stddev = s/sqrt(2*pi.n()) - D = DiscreteGaussianDistributionIntegerSampler(stddev) + D = DiscreteGaussianDistributionIntegerSampler(stddev) LWE.__init__(self, n=n, q=q, D=D, secret_dist='noise', m=m) @@ -484,11 +484,11 @@ def __init__(self, n, instance='key', m=None): raise TypeError("Parameter too small") n2 = n - C = 4/sqrt(2*pi) + C = 4/sqrt(2*pi) kk = floor((n2-2*log(n2, 2)**2)/5) n1 = (3*n2-5*kk) // 2 ke = floor((n1-2*log(n1, 2)**2)/5) - l = (3*n1-5*ke) // 2 - n2 + l = (3*n1-5*ke) // 2 - n2 sk = ceil((C*(n1+n2))**(ZZ(3)/2)) se = ceil((C*(n1+n2+l))**(ZZ(3)/2)) q = next_prime(max(ceil((4*sk)**(ZZ(n1+n2)/n1)), @@ -499,12 +499,12 @@ def __init__(self, n, instance='key', m=None): raise TypeError("Parameter too small") if instance == 'key': - D = UniformSampler(0, sk-1) + D = UniformSampler(0, sk-1) if m is None: m = n1 LWE.__init__(self, n=n2, q=q, D=D, secret_dist='noise', m=m) elif instance == 'encrypt': - D = UniformSampler(0, se-1) + D = UniformSampler(0, se-1) if m is None: m = n2+l LWE.__init__(self, n=n1, q=q, D=D, secret_dist='noise', m=m) @@ -544,11 +544,11 @@ def __init__(self, N, q, D, poly=None, secret_dist='uniform', m=None): sage: RingLWE(N=20, q=next_prime(800), D=D) # needs sage.libs.pari RingLWE(20, 809, Discrete Gaussian sampler for polynomials of degree < 8 with σ=3.000000 in each component, x^8 - x^6 + x^4 - x^2 + 1, 'uniform', None) """ - self.N = ZZ(N) + self.N = ZZ(N) self.n = euler_phi(N) self.m = m self.__i = 0 - self.K = IntegerModRing(q) + self.K = IntegerModRing(q) if self.n != D.n: raise ValueError("Noise distribution has dimensions %d != %d" % (D.n, self.n)) diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index f4ddf5c1844..c4293c5a0e2 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -1947,7 +1947,7 @@ def key_schedule_polynomials(self, i): si = Matrix(R, r*e, 1, self.vars("s", i-1, r, e)) rc = Matrix(R, r*e, 1, self.phi([a**(i-1)] + [k(0)]*(r-1)) ) - d = Matrix(R, r*e, 1, self.phi([self.sbox_constant()]*r) ) + d = Matrix(R, r*e, 1, self.phi([self.sbox_constant()]*r) ) sbox = [] @@ -3123,8 +3123,8 @@ def _inversion_polynomials_single_sbox(self, x=None, w=None, biaffine_only=None, l.append( (Cw * x + o).list()[:-1] ) else: l.append( (Cw * x + o).list() ) - l.append( (Cw * S * x + x).list() ) - l.append( (Cx * S * w + w).list() ) + l.append( (Cw * S * x + x).list() ) + l.append( (Cx * S * w + w).list() ) if not biaffine_only: l.append( ((Cw * S**2 + Cx*S)*x).list() ) l.append( ((Cx * S**2 + Cw*S)*w).list() ) diff --git a/src/sage/crypto/sboxes.py b/src/sage/crypto/sboxes.py index 27ca13fbcc3..749593c401b 100644 --- a/src/sage/crypto/sboxes.py +++ b/src/sage/crypto/sboxes.py @@ -220,8 +220,8 @@ def carlet_tang_tang_liao(n, c=None, bf=None): if n < 6 or n % 2: raise TypeError("n >= 6 has to be even") - K = GF(2**(n-1)) - L = GF(2**n) + K = GF((2, n - 1)) + L = GF((2, n)) if c is None: c = K.random_element() @@ -392,7 +392,7 @@ def monomial_function(n, e): from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.finite_rings.finite_field_constructor import GF - base_ring = GF(2**n, name='x') + base_ring = GF((2, n), name='x') R = PolynomialRing(base_ring, name='X') X = R.gen() return SBox(X**e) @@ -516,18 +516,18 @@ def monomial_function(n, e): 112,130, 44,236,179, 39,192,229,228,133, 87, 53,234, 12,174, 65, 35,239,107,147, 69, 25,165, 33,237, 14, 79, 78, 29,101,146,189, 134,184,175,143,124,235, 31,206, 62, 48,220, 95, 94,197, 11, 26, - 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, + 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, 139, 13,154,102,251,204,176, 45,116, 18, 43, 32,240,177,132,153, - 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, + 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, 20, 88, 58, 97,222, 27, 17, 28, 50, 15,156, 22, 83, 24,242, 34, - 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, + 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, 170,208,160,125,161,137, 98,151, 84, 91, 30,149,224,255,100,210, - 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, - 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, + 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, + 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, 82,155,216, 38,200, 55,198, 59,129,150,111, 75, 19,190, 99, 46, 233,121,167,140,159,110,188,142, 41,245,249,182, 47,253,180, 89, - 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, - 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, + 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, + 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, 64, 40,211,123,187,201, 67,193, 21,227,173,244,119,199,128,158]) # source: https://www.schneier.com/academic/paperfiles/paper-cmea.pdf @@ -1063,20 +1063,20 @@ def monomial_function(n, e): newDES = SBox([ 32,137,239,188,102,125,221, 72,212, 68, 81, 37, 86,237,147,149, 70,229, 17,124,115,207, 33, 20,122,143, 25,215, 51,183,138,142, - 146,211,110,173, 1,228,189, 14,103, 78,162, 36,253,167,116,255, - 158, 45,185, 50, 98,168,250,235, 54,141,195,247,240, 63,148, 2, + 146,211,110,173, 1,228,189, 14,103, 78,162, 36,253,167,116,255, + 158, 45,185, 50, 98,168,250,235, 54,141,195,247,240, 63,148, 2, 224,169,214,180, 62, 22,117,108, 19,172,161,159,160, 47, 43,171, - 194,175,178, 56,196,112, 23,220, 89, 21,164,130,157, 8, 85,251, + 194,175,178, 56,196,112, 23,220, 89, 21,164,130,157, 8, 85,251, 216, 44, 94,179,226, 38, 90,119, 40,202, 34,206, 35, 69,231,246, - 29,109, 74, 71,176, 6, 60,145, 65, 13, 77,151, 12,127, 95,199, - 57,101, 5,232,150,210,129, 24,181, 10,121,187, 48,193,139,252, + 29,109, 74, 71,176, 6, 60,145, 65, 13, 77,151, 12,127, 95,199, + 57,101, 5,232,150,210,129, 24,181, 10,121,187, 48,193,139,252, 219, 64, 88,233, 96,128, 80, 53,191,144,218, 11,106,132,155,104, 91,136, 31, 42,243, 66,126,135, 30, 26, 87,186,182,154,242,123, 82,166,208, 39,152,190,113,205,114,105,225, 84, 73,163, 99,111, - 204, 61,200,217,170, 15,198, 28,192,254,134,234,222, 7,236,248, - 201, 41,177,156, 92,131, 67,249,245,184,203, 9,241, 0, 27, 46, - 133,174, 75, 18, 93,209,100,120, 76,213, 16, 83, 4,107,140, 52, - 58, 55, 3,244, 97,197,238,227,118, 49, 79,230,223,165,153, 59]) + 204, 61,200,217,170, 15,198, 28,192,254,134,234,222, 7,236,248, + 201, 41,177,156, 92,131, 67,249,245,184,203, 9,241, 0, 27, 46, + 133,174, 75, 18, 93,209,100,120, 76,213, 16, 83, 4,107,140, 52, + 58, 55, 3,244, 97,197,238,227,118, 49, 79,230,223,165,153, 59]) Picaro = SBox([ 0x08,0x0c,0x03,0x06,0x06,0x04,0x05,0x06,0x05,0x04,0x0c,0x0c,0x04,0x03,0x05,0x03, @@ -1097,22 +1097,22 @@ def monomial_function(n, e): 0x01,0xfd,0x75,0x8a,0xea,0x1c,0x9f,0x6a,0x5f,0xac,0x2d,0xdd,0xbc,0x45,0xcf,0x35]) Safer = SBox([ - 1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63, - 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247, - 64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, - 255, 167, 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, - 241, 51, 239, 218, 44, 181, 178, 43, 136, 209, 153, 203, 140, 132, 29, 20, - 129, 151, 113, 202, 95, 163, 139, 87, 60, 130, 196, 82, 92, 28, 232, 160, - 4, 180, 133, 74, 246, 19, 84, 182, 223, 12, 26, 142, 222, 224, 57, 252, - 32, 155, 36, 78, 169, 152, 158, 171, 242, 96, 208, 108, 234, 250, 199, 217, - 0, 212, 31, 110, 67, 188, 236, 83, 137, 254, 122, 93, 73, 201, 50, 194, - 249, 154, 248, 109, 22, 219, 89, 150, 68, 233, 205, 230, 70, 66, 143, 10, - 193, 204, 185, 101, 176, 210, 198, 172, 30, 65, 98, 41, 46, 14, 116, 80, - 2, 90, 195, 37, 123, 138, 42, 91, 240, 6, 13, 71, 111, 112, 157, 126, - 16, 206, 18, 39, 213, 76, 79, 214, 121, 48, 104, 54, 117, 125, 228, 237, - 128, 106, 144, 55, 162, 94, 118, 170, 197, 127, 61, 175, 165, 229, 25, 97, - 253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5, - 225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40]) + 1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63, + 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247, + 64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, + 255, 167, 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, + 241, 51, 239, 218, 44, 181, 178, 43, 136, 209, 153, 203, 140, 132, 29, 20, + 129, 151, 113, 202, 95, 163, 139, 87, 60, 130, 196, 82, 92, 28, 232, 160, + 4, 180, 133, 74, 246, 19, 84, 182, 223, 12, 26, 142, 222, 224, 57, 252, + 32, 155, 36, 78, 169, 152, 158, 171, 242, 96, 208, 108, 234, 250, 199, 217, + 0, 212, 31, 110, 67, 188, 236, 83, 137, 254, 122, 93, 73, 201, 50, 194, + 249, 154, 248, 109, 22, 219, 89, 150, 68, 233, 205, 230, 70, 66, 143, 10, + 193, 204, 185, 101, 176, 210, 198, 172, 30, 65, 98, 41, 46, 14, 116, 80, + 2, 90, 195, 37, 123, 138, 42, 91, 240, 6, 13, 71, 111, 112, 157, 126, + 16, 206, 18, 39, 213, 76, 79, 214, 121, 48, 104, 54, 117, 125, 228, 237, + 128, 106, 144, 55, 162, 94, 118, 170, 197, 127, 61, 175, 165, 229, 25, 97, + 253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5, + 225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40]) Scream = SBox([ 0x20,0x8D,0xB2,0xDA,0x33,0x35,0xA6,0xFF,0x7A,0x52,0x6A,0xC6,0xA4,0xA8,0x51,0x23, @@ -1433,8 +1433,8 @@ def monomial_function(n, e): 20,26,7,31,19,12,10,15,22,30,13,14,4,24,9, 18,27,11,1,21,6,16,2,28,23,5,8,3,0,17,29,25]) -Shamash = SBox([16, 14, 13, 2, 11, 17, 21, 30, 7, 24, 18, 28, 26, 1, 12, 6, - 31, 25, 0, 23, 20, 22, 8, 27, 4, 3, 19, 5, 9, 10, 29, 15]) +Shamash = SBox([16, 14, 13, 2, 11, 17, 21, 30, 7, 24, 18, 28, 26, 1, 12, 6, + 31, 25, 0, 23, 20, 22, 8, 27, 4, 3, 19, 5, 9, 10, 29, 15]) SYCON = SBox([8, 19, 30, 7, 6, 25, 16, 13, 22, 15, 3, 24, 17, 12, 4, 27, 11, 0, 29, 20, 1, 14, 23, 26, 28, 21, 9, 2, 31, 18, 10, 5]) @@ -1444,8 +1444,8 @@ def monomial_function(n, e): Elephant = SBox([0xE, 0xD, 0xB, 0x0, 0x2, 0x1, 0x4, 0xF, 0x7, 0xA, 0x8, 0x5, 0x9, 0xC, 0x3, 0x6]) -KNOT = SBox([0x4, 0x0, 0xA, 0x7, 0xB, 0xE, 0x1, 0xD, 0x9, 0xF, 0x6, 0x8, - 0x5, 0x2, 0xC, 0x3]) +KNOT = SBox([0x4, 0x0, 0xA, 0x7, 0xB, 0xE, 0x1, 0xD, 0x9, 0xF, 0x6, 0x8, + 0x5, 0x2, 0xC, 0x3]) Pyjamask_4 = SBox([0x2, 0xd, 0x3, 0x9, 0x7, 0xb, 0xa, 0x6, 0xe, 0x0, 0xf, 0x4, 0x8, 0x5, 0x1, 0xc]) SATURNIN_0 = SBox([0x0, 0x6, 0xE, 0x1, 0xF, 0x4, 0x7, 0xD, 0x9, 0x8, 0xC, 0x5, @@ -1457,9 +1457,9 @@ def monomial_function(n, e): Clyde = Spook Shadow = Spook TRIFLE = SBox([0x0, 0xC, 0x9, 0x7, 0x3, 0x5, 0xE, 0x4, 0x6, 0xB, 0xA, 0x2, - 0xD, 0x1, 0x8, 0xF]) + 0xD, 0x1, 0x8, 0xF]) Yarara = SBox([0x4, 0x7, 0x1, 0xC, 0x2, 0x8, 0xF, 0x3, 0xD, 0xA, 0xe, 0x9, 0xB, - 0x6, 0x5, 0x0]) + 0x6, 0x5, 0x0]) Coral = Yarara # DES @@ -1570,44 +1570,44 @@ def monomial_function(n, e): SERPENT_S7 = SBox([1,13,15,0,14,8,2,11,7,4,12,10,9,3,5,6]) # Other Block ciphers -KLEIN = SBox([0x7,0x4,0xA,0x9,0x1,0xF,0xB,0x0,0xC,0x3,0x2,0x6,0x8,0xE,0xD,0x5]) -MIBS = SBox([4,15,3,8,13,10,12,0,11,5,7,14,2,6,1,9]) -Midori_Sb0 = SBox([0xc,0xa,0xd,0x3,0xe,0xb,0xf,0x7,0x8,0x9,0x1,0x5,0x0,0x2,0x4,0x6]) +KLEIN = SBox([0x7,0x4,0xA,0x9,0x1,0xF,0xB,0x0,0xC,0x3,0x2,0x6,0x8,0xE,0xD,0x5]) +MIBS = SBox([4,15,3,8,13,10,12,0,11,5,7,14,2,6,1,9]) +Midori_Sb0 = SBox([0xc,0xa,0xd,0x3,0xe,0xb,0xf,0x7,0x8,0x9,0x1,0x5,0x0,0x2,0x4,0x6]) MANTIS = Midori_Sb0 CRAFT = Midori_Sb0 -Midori_Sb1 = SBox([0x1,0x0,0x5,0x3,0xe,0x2,0xf,0x7,0xd,0xa,0x9,0xb,0xc,0x8,0x4,0x6]) -Noekeon = SBox([0x7,0xA,0x2,0xC,0x4,0x8,0xF,0x0,0x5,0x9,0x1,0xE,0x3,0xD,0xB,0x6]) -Piccolo = SBox([0xe,0x4,0xb,0x2,0x3,0x8,0x0,0x9,0x1,0xa,0x7,0xf,0x6,0xc,0x5,0xd]) -Panda = SBox([0x0,0x1,0x3,0x2,0xf,0xc,0x9,0xb,0xa,0x6,0x8,0x7,0x5,0xe,0xd,0x4]) -PRESENT = SBox([0xC,0x5,0x6,0xB,0x9,0x0,0xA,0xD,0x3,0xE,0xF,0x8,0x4,0x7,0x1,0x2]) -CiliPadi = PRESENT -PHOTON = PRESENT -ORANGE = PHOTON -GIFT = SBox([0x1,0xa,0x4,0xc,0x6,0xf,0x3,0x9,0x2,0xd,0xb,0x7,0x5,0x0,0x8,0xe]) -HYENA = GIFT -Fountain_1 = GIFT -TGIF = GIFT -Fountain_2 = SBox([0x9, 0x5, 0x6, 0xD, 0x8, 0xA, 0x7, 0x2, 0xE, 0x4, 0xC, - 0x1, 0xF, 0x0, 0xB, 0x3]) -Fountain_3 = SBox([0x9, 0xD, 0xE, 0x5, 0x8, 0xA, 0xF, 0x2, 0x6, 0xC, 0x4, - 0x1, 0x7, 0x0, 0xB, 0x3]) -Fountain_4 = SBox([0xB, 0xF, 0xE, 0x8, 0x7, 0xA, 0x2, 0xD, 0x9, 0x3, 0x4, - 0xC, 0x5, 0x0, 0x6, 0x1]) -Pride = SBox([0x0,0x4,0x8,0xf,0x1,0x5,0xe,0x9,0x2,0x7,0xa,0xc,0xb,0xd,0x6,0x3]) -PRINCE = SBox([0xB,0xF,0x3,0x2,0xA,0xC,0x9,0x1,0x6,0x7,0x8,0x0,0xE,0x5,0xD,0x4]) -Prost = Pride +Midori_Sb1 = SBox([0x1,0x0,0x5,0x3,0xe,0x2,0xf,0x7,0xd,0xa,0x9,0xb,0xc,0x8,0x4,0x6]) +Noekeon = SBox([0x7,0xA,0x2,0xC,0x4,0x8,0xF,0x0,0x5,0x9,0x1,0xE,0x3,0xD,0xB,0x6]) +Piccolo = SBox([0xe,0x4,0xb,0x2,0x3,0x8,0x0,0x9,0x1,0xa,0x7,0xf,0x6,0xc,0x5,0xd]) +Panda = SBox([0x0,0x1,0x3,0x2,0xf,0xc,0x9,0xb,0xa,0x6,0x8,0x7,0x5,0xe,0xd,0x4]) +PRESENT = SBox([0xC,0x5,0x6,0xB,0x9,0x0,0xA,0xD,0x3,0xE,0xF,0x8,0x4,0x7,0x1,0x2]) +CiliPadi = PRESENT +PHOTON = PRESENT +ORANGE = PHOTON +GIFT = SBox([0x1,0xa,0x4,0xc,0x6,0xf,0x3,0x9,0x2,0xd,0xb,0x7,0x5,0x0,0x8,0xe]) +HYENA = GIFT +Fountain_1 = GIFT +TGIF = GIFT +Fountain_2 = SBox([0x9, 0x5, 0x6, 0xD, 0x8, 0xA, 0x7, 0x2, 0xE, 0x4, 0xC, + 0x1, 0xF, 0x0, 0xB, 0x3]) +Fountain_3 = SBox([0x9, 0xD, 0xE, 0x5, 0x8, 0xA, 0xF, 0x2, 0x6, 0xC, 0x4, + 0x1, 0x7, 0x0, 0xB, 0x3]) +Fountain_4 = SBox([0xB, 0xF, 0xE, 0x8, 0x7, 0xA, 0x2, 0xD, 0x9, 0x3, 0x4, + 0xC, 0x5, 0x0, 0x6, 0x1]) +Pride = SBox([0x0,0x4,0x8,0xf,0x1,0x5,0xe,0x9,0x2,0x7,0xa,0xc,0xb,0xd,0x6,0x3]) +PRINCE = SBox([0xB,0xF,0x3,0x2,0xA,0xC,0x9,0x1,0x6,0x7,0x8,0x0,0xE,0x5,0xD,0x4]) +Prost = Pride Qarma_sigma0 = SBox([0, 14, 2, 10, 9, 15, 8, 11, 6, 4, 3, 7, 13, 12, 1, 5]) Qarma_sigma1 = SBox([10, 13, 14, 6, 15, 7, 3, 5, 9, 8, 0, 12, 11, 1, 2, 4]) -Qameleon = Qarma_sigma1 +Qameleon = Qarma_sigma1 Qarma_sigma2 = SBox([11, 6, 8, 15, 12, 0, 9, 14, 3, 7, 4, 5, 13, 2, 1, 10]) -REC_0 = SBox([0x9,0x4,0xF,0xA,0xE,0x1,0x0,0x6,0xC,0x7,0x3,0x8,0x2,0xB,0x5,0xD]) -Rectangle = SBox([0x6,0x5,0xC,0xA,0x1,0xE,0x7,0x9,0xB,0x0,0x3,0xD,0x8,0xF,0x4,0x2]) -SC2000_4 = SBox([2,5,10,12,7,15,1,11,13,6,0,9,4,8,3,14]) -SKINNY_4 = SBox([0xc,0x6,0x9,0x0,0x1,0xa,0x2,0xb,0x3,0x8,0x5,0xd,0x4,0xe,0x7,0xf]) +REC_0 = SBox([0x9,0x4,0xF,0xA,0xE,0x1,0x0,0x6,0xC,0x7,0x3,0x8,0x2,0xB,0x5,0xD]) +Rectangle = SBox([0x6,0x5,0xC,0xA,0x1,0xE,0x7,0x9,0xB,0x0,0x3,0xD,0x8,0xF,0x4,0x2]) +SC2000_4 = SBox([2,5,10,12,7,15,1,11,13,6,0,9,4,8,3,14]) +SKINNY_4 = SBox([0xc,0x6,0x9,0x0,0x1,0xa,0x2,0xb,0x3,0x8,0x5,0xd,0x4,0xe,0x7,0xf]) ForkSkinny_4 = SKINNY_4 -Remus_4 = SKINNY_4 +Remus_4 = SKINNY_4 -TWINE = SBox([0xC,0x0,0xF,0xA,0x2,0xB,0x9,0x5,0x8,0x3,0xD,0x7,0x1,0xE,0x6,0x4]) +TWINE = SBox([0xC,0x0,0xF,0xA,0x2,0xB,0x9,0x5,0x8,0x3,0xD,0x7,0x1,0xE,0x6,0x4]) # Sub-components of hash functions Luffa_v1 = SBox([0x7,0xd,0xb,0xa,0xc,0x4,0x8,0x3,0x5,0xf,0x6,0x0,0x9,0x1,0x2,0xe]) @@ -1654,10 +1654,10 @@ def monomial_function(n, e): Twofish_Q1_T1 = SBox([0x1,0xE,0x2,0xB,0x4,0xC,0x3,0x7,0x6,0xD,0xA,0x5,0xF,0x9,0x0,0x8]) Twofish_Q1_T2 = SBox([0x4,0xC,0x7,0x5,0x1,0x6,0x9,0xA,0x0,0xE,0xD,0x8,0x2,0xB,0x3,0xF]) Twofish_Q1_T3 = SBox([0xB,0x9,0x5,0x1,0xC,0x3,0xD,0xE,0x6,0x4,0x7,0xF,0x2,0x0,0x8,0xA]) -Kuznyechik_nu0 = SBox([0x2,0x5,0x3,0xb,0x6,0x9,0xe,0xa,0x0,0x4,0xf,0x1,0x8,0xd,0xc,0x7]) -Kuznyechik_nu1 = SBox([0x7,0x6,0xc,0x9,0x0,0xf,0x8,0x1,0x4,0x5,0xb,0xe,0xd,0x2,0x3,0xa]) +Kuznyechik_nu0 = SBox([0x2,0x5,0x3,0xb,0x6,0x9,0xe,0xa,0x0,0x4,0xf,0x1,0x8,0xd,0xc,0x7]) +Kuznyechik_nu1 = SBox([0x7,0x6,0xc,0x9,0x0,0xf,0x8,0x1,0x4,0x5,0xb,0xe,0xd,0x2,0x3,0xa]) Kuznyechik_sigma = SBox([0xc,0xd,0x0,0x4,0x8,0xb,0xa,0xe,0x3,0x9,0x5,0x2,0xf,0x1,0x6,0x7]) -Kuznyechik_phi = SBox([0xb,0x2,0xb,0x8,0xc,0x4,0x1,0xc,0x6,0x3,0x5,0x8,0xe,0x3,0x6,0xb]) +Kuznyechik_phi = SBox([0xb,0x2,0xb,0x8,0xc,0x4,0x1,0xc,0x6,0x3,0x5,0x8,0xe,0x3,0x6,0xb]) Optimal_S0 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 12, 9, 3, 14, 10, 5]) Optimal_S1 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 5, 9, 10, 12]) Optimal_S2 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 10, 12, 5, 9]) diff --git a/src/sage/databases/cremona.py b/src/sage/databases/cremona.py index a74eeac74d2..3e1615e5fd4 100644 --- a/src/sage/databases/cremona.py +++ b/src/sage/databases/cremona.py @@ -1623,7 +1623,7 @@ def _init_allbsd(self, ftpdata, largest_conductor=0): curve_data = [] class_data = [] for L in open(ftpdata + "/" + F).readlines(): - N, iso, num, eqn, rank, tor, cp, om, L, reg, sha = L.split() + N, iso, num, eqn, rank, tor, cp, om, L, reg, sha = L.split() if largest_conductor and int(N) > largest_conductor: break cls = N+iso diff --git a/src/sage/databases/findstat.py b/src/sage/databases/findstat.py index 86ab944744a..5b8455a49a2 100644 --- a/src/sage/databases/findstat.py +++ b/src/sage/databases/findstat.py @@ -263,20 +263,20 @@ def mapping(sigma): ###################################################################### # the FindStat URLs -FINDSTAT_URL = 'https://www.findstat.org/' -FINDSTAT_API = FINDSTAT_URL + "api/" -FINDSTAT_API_COLLECTIONS = FINDSTAT_API + 'CollectionsDatabase/' -FINDSTAT_API_STATISTICS = FINDSTAT_API + 'StatisticsDatabase/' -FINDSTAT_API_MAPS = FINDSTAT_API + 'MapsDatabase/' - -FINDSTAT_URL_LOGIN = FINDSTAT_URL + "?action=login" -FINDSTAT_URL_COLLECTIONS = FINDSTAT_URL + 'CollectionsDatabase/' -FINDSTAT_URL_STATISTICS = FINDSTAT_URL + 'StatisticsDatabase/' +FINDSTAT_URL = 'https://www.findstat.org/' +FINDSTAT_API = FINDSTAT_URL + "api/" +FINDSTAT_API_COLLECTIONS = FINDSTAT_API + 'CollectionsDatabase/' +FINDSTAT_API_STATISTICS = FINDSTAT_API + 'StatisticsDatabase/' +FINDSTAT_API_MAPS = FINDSTAT_API + 'MapsDatabase/' + +FINDSTAT_URL_LOGIN = FINDSTAT_URL + "?action=login" +FINDSTAT_URL_COLLECTIONS = FINDSTAT_URL + 'CollectionsDatabase/' +FINDSTAT_URL_STATISTICS = FINDSTAT_URL + 'StatisticsDatabase/' FINDSTAT_URL_EDIT_STATISTIC = FINDSTAT_URL + 'EditStatistic/' -FINDSTAT_URL_NEW_STATISTIC = FINDSTAT_URL + 'NewStatistic/' -FINDSTAT_URL_MAPS = FINDSTAT_URL + 'MapsDatabase/' -FINDSTAT_URL_EDIT_MAP = FINDSTAT_URL + 'EditMap/' -FINDSTAT_URL_NEW_MAP = FINDSTAT_URL + 'NewMap/' +FINDSTAT_URL_NEW_STATISTIC = FINDSTAT_URL + 'NewStatistic/' +FINDSTAT_URL_MAPS = FINDSTAT_URL + 'MapsDatabase/' +FINDSTAT_URL_EDIT_MAP = FINDSTAT_URL + 'EditMap/' +FINDSTAT_URL_NEW_MAP = FINDSTAT_URL + 'NewMap/' ###################################################################### # the number of values FindStat allows to search for at most @@ -297,9 +297,9 @@ def mapping(sigma): FINDSTAT_STATISTIC_REGEXP = '^St[0-9]{6}$' FINDSTAT_MAP_REGEXP = '^Mp[0-9]{5}$' FINDSTAT_COLLECTION_REGEXP = '^Cc[0-9]{4}$' -FINDSTAT_STATISTIC_PADDED_IDENTIFIER = "St%06d" -FINDSTAT_MAP_PADDED_IDENTIFIER = "Mp%05d" -FINDSTAT_COLLECTION_PADDED_IDENTIFIER = "Cc%04d" +FINDSTAT_STATISTIC_PADDED_IDENTIFIER = "St%06d" +FINDSTAT_MAP_PADDED_IDENTIFIER = "Mp%05d" +FINDSTAT_COLLECTION_PADDED_IDENTIFIER = "Cc%04d" ###################################################################### @@ -333,7 +333,7 @@ def __init__(self): The Combinatorial Statistic Finder (https://www.findstat.org/) """ # user credentials if provided - self._user_name = "" + self._user_name = "" self._user_email = "" self._allow_execution = False @@ -384,7 +384,7 @@ def set_user(self, name=None, email=None): raise ValueError("the given name (%s) should be a string" % name) if not isinstance(email, str): raise ValueError("the given email (%s) should be a string" % email) - self._user_name = name + self._user_name = name self._user_email = email def user_name(self): @@ -2375,14 +2375,14 @@ def submit(self, max_values=FINDSTAT_MAX_SUBMISSION_VALUES): """ args = {} args["OriginalStatistic"] = self.id_str() - args["Domain"] = self.domain().id_str() - args["Values"] = self.first_terms_str(max_values=max_values) - args["Description"] = self.description() - args["References"] = self.references_raw() - args["Code"] = self.code() - args["SageCode"] = self.sage_code() - args["CurrentAuthor"] = FindStat().user_name() - args["CurrentEmail"] = FindStat().user_email() + args["Domain"] = self.domain().id_str() + args["Values"] = self.first_terms_str(max_values=max_values) + args["Description"] = self.description() + args["References"] = self.references_raw() + args["Code"] = self.code() + args["SageCode"] = self.sage_code() + args["CurrentAuthor"] = FindStat().user_name() + args["CurrentEmail"] = FindStat().user_email() if not self.id(): url = FINDSTAT_NEWSTATISTIC_FORM_HEADER % FINDSTAT_URL_NEW_STATISTIC @@ -3212,16 +3212,16 @@ def submit(self): sage: s.reset() # optional -- internet """ args = dict() - args["OriginalMap"] = self.id_str() - args["Domain"] = self.domain().id_str() - args["Codomain"] = self.codomain().id_str() - args["Name"] = self.name() - args["Description"] = self.description() - args["References"] = self.references_raw() - args["Properties"] = self.properties_raw() - args["SageCode"] = self.sage_code() - args["CurrentAuthor"] = FindStat().user_name() - args["CurrentEmail"] = FindStat().user_email() + args["OriginalMap"] = self.id_str() + args["Domain"] = self.domain().id_str() + args["Codomain"] = self.codomain().id_str() + args["Name"] = self.name() + args["Description"] = self.description() + args["References"] = self.references_raw() + args["Properties"] = self.properties_raw() + args["SageCode"] = self.sage_code() + args["CurrentAuthor"] = FindStat().user_name() + args["CurrentEmail"] = FindStat().user_email() if not self.id(): url = FINDSTAT_NEWMAP_FORM_HEADER % FINDSTAT_URL_NEW_MAP @@ -3930,7 +3930,7 @@ def _finite_irreducible_cartan_types_by_rank(n): sage: _finite_irreducible_cartan_types_by_rank(2) [['A', 2], ['B', 2], ['G', 2]] """ - cartan_types = [CartanType(['A',n])] + cartan_types = [CartanType(['A',n])] if n >= 2: cartan_types += [CartanType(['B',n])] if n >= 3: diff --git a/src/sage/databases/knotinfo_db.py b/src/sage/databases/knotinfo_db.py index 2828c3ace45..df0b8310456 100644 --- a/src/sage/databases/knotinfo_db.py +++ b/src/sage/databases/knotinfo_db.py @@ -350,18 +350,18 @@ def __init__(self, install=False): 'linkinfo_data_complete']> """ # some constants - self._names_column = 'name' + self._names_column = 'name' self._components_column = 'components' - self._knot_prefix = 'K' + self._knot_prefix = 'K' self._knot_list = None self._link_list = None - self._demo = None + self._demo = None self._num_knots = None from sage.features.databases import DatabaseKnotInfo from sage.env import DOT_SAGE - self._feature = DatabaseKnotInfo() + self._feature = DatabaseKnotInfo() self._sobj_path = os.path.join(DOT_SAGE, 'knotinfo') def create_filecache(self, force=False): diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py index 83b5a93c006..16fadc5b594 100644 --- a/src/sage/interacts/library.py +++ b/src/sage/interacts/library.py @@ -218,11 +218,11 @@ def taylor_polynomial(title, f, order: int): f: EvalText(value='e^(-x)*sin(x)', description='$f(x)=$', layout=Layout(max_width='81em')) order: SelectionSlider(description='order', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), value=1) """ - x0 = 0 - p = plot(f,(x,-1,5), thickness=2) - dot = point((x0,f(x=x0)),pointsize=80,rgbcolor=(1,0,0)) - ft = f.taylor(x,x0,order) - pt = plot(ft,(-1, 5), color='green', thickness=2) + x0 = 0 + p = plot(f, (x, -1, 5), thickness=2) + dot = point((x0, f(x=x0)), pointsize=80, rgbcolor=(1, 0, 0)) + ft = f.taylor(x, x0, order) + pt = plot(ft, (-1, 5), color='green', thickness=2) html(r'$f(x)\;=\;%s$' % latex(f)) html(r'$\hat{f}(x;%s)\;=\;%s+\mathcal{O}(x^{%s})$' % (x0, latex(ft), order + 1)) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index 8c4ba93a25f..3a2ed434091 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1699,7 +1699,7 @@ def gfq_gap_to_sage(x, F): return F(0) i1 = s.index("(") i2 = s.index(")") - q = eval(s[i1+1:i2].replace('^','**')) + q = eval(s[i1+1:i2].replace('^','**')) if not F.cardinality().is_power_of(q): raise ValueError('%r has no subfield of size %r' % (F, q)) if s.find(')^') == -1: diff --git a/src/sage/interfaces/octave.py b/src/sage/interfaces/octave.py index a1a9ba50582..d0f5694c8bc 100644 --- a/src/sage/interfaces/octave.py +++ b/src/sage/interfaces/octave.py @@ -511,7 +511,7 @@ def solve_linear_system(self, A, b): from sage.matrix.matrix_space import MatrixSpace from sage.rings.rational_field import QQ MS = MatrixSpace(QQ,m,1) - b = MS(list(b)) # converted b to a "column vector" + b = MS(list(b)) # converted b to a "column vector" sA = self.sage2octave_matrix_string(A) sb = self.sage2octave_matrix_string(b) self.eval("a = " + sA ) @@ -520,7 +520,7 @@ def solve_linear_system(self, A, b): soln = soln.replace("\n\n ","[") soln = soln.rstrip() + "]" soln = soln.replace("\n",",") - sol = soln[3:] + sol = soln[3:] return eval(sol) def sage2octave_matrix_string(self, A): diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index 331d698d3ab..c5a50438f03 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -410,7 +410,7 @@ def __init__(self, maxread=None, script_subdirectory=None, verbose_start=False, logfile=logfile, eval_using_file_cutoff=100 if os.uname()[0] == "SunOS" else 1000) - self.__libs = [] + self.__libs = [] self._prompt_wait = prompt self.__to_clear = [] # list of variable names that need to be cleared. self._seed = seed diff --git a/src/sage/interfaces/tides.py b/src/sage/interfaces/tides.py index 765b8bd3cb4..f70a2357cd3 100644 --- a/src/sage/interfaces/tides.py +++ b/src/sage/interfaces/tides.py @@ -532,13 +532,13 @@ def genfiles_mintides(integrator, driver, f, ics, initial, final, delta, elif el[0] == 'div_c': string += "inv_mc("+el[2]+","+el[1]+",XX[{}], i);".format(i+n) elif el[0] == 'log': - string += "log_mc("+el[1]+",XX[{}], i);".format(i+n) + string += "log_mc(" + el[1] + ",XX[{}], i);".format(i+n) elif el[0] == 'exp': - string += "exp_mc("+el[1]+",XX[{}], i);".format(i+n) + string += "exp_mc(" + el[1] + ",XX[{}], i);".format(i+n) elif el[0] == 'sin': - string += "sin_mc("+el[1]+",XX[{}], i);".format(i+n+1) + string += "sin_mc(" + el[1] + ",XX[{}], i);".format(i+n+1) elif el[0] == 'cos': - string += "cos_mc("+el[1]+",XX[{}], i);".format(i+n-1) + string += "cos_mc(" + el[1] + ",XX[{}], i);".format(i+n-1) res.append(string) @@ -583,7 +583,7 @@ def genfiles_mintides(integrator, driver, f, ics, initial, final, delta, for(i=0;i 11 and co > 1: @@ -3873,7 +3873,7 @@ def _knotinfo_matching_list(self): if cr > 12: cr = 12 - Hp = self.homfly_polynomial(normalization='vz') + Hp = self.homfly_polynomial(normalization='vz') det = None if cr > 6: @@ -3902,7 +3902,7 @@ def _knotinfo_matching_list(self): ln = Sn.lower_list(oriented=True, comp=co, det=det, homfly=Hp) l = sorted(list(set(la + ln))) - br = self.braid() + br = self.braid() br_ind = br.strands() res = [] diff --git a/src/sage/manifolds/differentiable/chart.py b/src/sage/manifolds/differentiable/chart.py index 6ea06b662ed..a40ebb8e5b2 100644 --- a/src/sage/manifolds/differentiable/chart.py +++ b/src/sage/manifolds/differentiable/chart.py @@ -1155,7 +1155,7 @@ def __init__(self, chart1, chart2, *transformations): """ CoordChange.__init__(self, chart1, chart2, *transformations) # Jacobian matrix: - self._jacobian = self._transf.jacobian() + self._jacobian = self._transf.jacobian() # If the two charts are on the same open subset, the Jacobian matrix is # added to the dictionary of changes of frame: if chart1.domain() == chart2.domain(): diff --git a/src/sage/manifolds/differentiable/scalarfield_algebra.py b/src/sage/manifolds/differentiable/scalarfield_algebra.py index 7bbf5a39146..44e6e16bff4 100644 --- a/src/sage/manifolds/differentiable/scalarfield_algebra.py +++ b/src/sage/manifolds/differentiable/scalarfield_algebra.py @@ -465,12 +465,11 @@ def _latex_(self): 'C^{\\infty}\\left(M\\right)' sage: latex(CM) # indirect doctest C^{\infty}\left(M\right) - """ degree = self._domain.diff_degree() if degree == infinity: latex_degree = r"\infty" # to skip the "+" in latex(infinity) else: latex_degree = "{}".format(degree) - return r"C^{" + latex_degree + r"}\left(" + self._domain._latex_() + \ + return r"C^{" + latex_degree + r"}\left(" + self._domain._latex_() + \ r"\right)" diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py index 52c89fd9959..d7941fad08c 100644 --- a/src/sage/manifolds/scalarfield_algebra.py +++ b/src/sage/manifolds/scalarfield_algebra.py @@ -568,7 +568,7 @@ def _latex_(self): C^0 \left(M\right) """ - return r"C^0 \left(" + self._domain._latex_() + r"\right)" + return r"C^0 \left(" + self._domain._latex_() + r"\right)" @cached_method def zero(self): diff --git a/src/sage/sat/solvers/dimacs.py b/src/sage/sat/solvers/dimacs.py index f9688ecd8d6..cfe3c7cd4ed 100644 --- a/src/sage/sat/solvers/dimacs.py +++ b/src/sage/sat/solvers/dimacs.py @@ -93,7 +93,7 @@ def __init__(self, command=None, filename=None, verbosity=0, **kwds): else: self._command = self.__class__.command - self._tail = open(tmp_filename(),'w') + self._tail = open(tmp_filename(), 'w') self._var = 0 self._lit = 0 diff --git a/src/sage/structure/factorization_integer.py b/src/sage/structure/factorization_integer.py index 2ea04be826e..4d01cea5a6f 100644 --- a/src/sage/structure/factorization_integer.py +++ b/src/sage/structure/factorization_integer.py @@ -69,9 +69,9 @@ def __init__(self, x, unit=None, cr=False, sort=True, simplify=True, else: self._Factorization__unit = unit - self._Factorization__x = x + self._Factorization__x = x self._Factorization__universe = ZZ - self._Factorization__cr = cr + self._Factorization__cr = cr if sort: self.sort() diff --git a/src/sage/tensor/modules/tensor_free_submodule.py b/src/sage/tensor/modules/tensor_free_submodule.py index 177eb1f3248..6503c310a91 100644 --- a/src/sage/tensor/modules/tensor_free_submodule.py +++ b/src/sage/tensor/modules/tensor_free_submodule.py @@ -152,7 +152,7 @@ def power_name(op, s, latex=False): if latex: superscript = r'\{' + superscript + r'\}' else: - superscript = '{' + superscript + '}' + superscript = '{' + superscript + '}' if latex: if len(superscript) != 1: superscript = '{' + superscript + '}'