github.com/consensys/gnark-crypto@v0.14.0/ecc/bls12-377/fp/element_exp.go (about)

     1  // Copyright 2020 ConsenSys Software Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Code generated by consensys/gnark-crypto DO NOT EDIT
    16  
    17  package fp
    18  
    19  // expBySqrtExp is equivalent to z.Exp(x, 35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba88600000010a11)
    20  //
    21  // uses github.com/mmcloughlin/addchain v0.4.0 to generate a shorter addition chain
    22  func (z *Element) expBySqrtExp(x Element) *Element {
    23  	// addition chain:
    24  	//
    25  	//	_10       = 2*1
    26  	//	_11       = 1 + _10
    27  	//	_100      = 1 + _11
    28  	//	_101      = 1 + _100
    29  	//	_111      = _10 + _101
    30  	//	_1001     = _10 + _111
    31  	//	_1011     = _10 + _1001
    32  	//	_1111     = _100 + _1011
    33  	//	_10001    = _10 + _1111
    34  	//	_10011    = _10 + _10001
    35  	//	_10111    = _100 + _10011
    36  	//	_11011    = _100 + _10111
    37  	//	_11101    = _10 + _11011
    38  	//	_11111    = _10 + _11101
    39  	//	_110100   = _10111 + _11101
    40  	//	_11010000 = _110100 << 2
    41  	//	_11010111 = _111 + _11010000
    42  	//	i36       = 2*((_11010111 << 8 + _11101) << 7 + _10001)
    43  	//	i50       = ((1 + i36) << 9 + _10111) << 2 + _11
    44  	//	i71       = ((i50 << 6 + _101) << 4 + 1) << 9
    45  	//	i84       = ((_11101 + i71) << 5 + _1011) << 5 + _11
    46  	//	i105      = (2*(i84 << 8 + _11101) + 1) << 10
    47  	//	i125      = ((_10111 + i105) << 12 + _11011) << 5 + _101
    48  	//	i147      = ((i125 << 7 + _101) << 6 + _1001) << 7
    49  	//	i158      = ((_11101 + i147) << 5 + _10001) << 3 + _101
    50  	//	i181      = ((i158 << 8 + _10001) << 6 + _11011) << 7
    51  	//	i200      = ((_11111 + i181) << 4 + _11) << 12 + _1111
    52  	//	i219      = ((i200 << 4 + _101) << 8 + _10011) << 5
    53  	//	i232      = ((_10001 + i219) << 3 + _111) << 7 + _1111
    54  	//	i254      = ((i232 << 5 + _1111) << 7 + _11011) << 8
    55  	//	i269      = ((_10001 + i254) << 6 + _11111) << 6 + _11101
    56  	//	i304      = ((i269 << 9 + _1001) << 5 + _1001) << 19
    57  	//	i321      = ((_10111 + i304) << 8 + _1011) << 6 + _10111
    58  	//	i337      = ((i321 << 4 + _101) << 4 + 1) << 6
    59  	//	i376      = ((_11 + i337) << 29 + 1) << 7 + _101
    60  	//	return      i376 << 9 + _10001
    61  	//
    62  	// Operations: 325 squares 61 multiplies
    63  
    64  	// Allocate Temporaries.
    65  	var (
    66  		t0  = new(Element)
    67  		t1  = new(Element)
    68  		t2  = new(Element)
    69  		t3  = new(Element)
    70  		t4  = new(Element)
    71  		t5  = new(Element)
    72  		t6  = new(Element)
    73  		t7  = new(Element)
    74  		t8  = new(Element)
    75  		t9  = new(Element)
    76  		t10 = new(Element)
    77  		t11 = new(Element)
    78  	)
    79  
    80  	// var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11 Element
    81  	// Step 1: t6 = x^0x2
    82  	t6.Square(&x)
    83  
    84  	// Step 2: t1 = x^0x3
    85  	t1.Mul(&x, t6)
    86  
    87  	// Step 3: t5 = x^0x4
    88  	t5.Mul(&x, t1)
    89  
    90  	// Step 4: t0 = x^0x5
    91  	t0.Mul(&x, t5)
    92  
    93  	// Step 5: t9 = x^0x7
    94  	t9.Mul(t6, t0)
    95  
    96  	// Step 6: t4 = x^0x9
    97  	t4.Mul(t6, t9)
    98  
    99  	// Step 7: t3 = x^0xb
   100  	t3.Mul(t6, t4)
   101  
   102  	// Step 8: t8 = x^0xf
   103  	t8.Mul(t5, t3)
   104  
   105  	// Step 9: z = x^0x11
   106  	z.Mul(t6, t8)
   107  
   108  	// Step 10: t10 = x^0x13
   109  	t10.Mul(t6, z)
   110  
   111  	// Step 11: t2 = x^0x17
   112  	t2.Mul(t5, t10)
   113  
   114  	// Step 12: t7 = x^0x1b
   115  	t7.Mul(t5, t2)
   116  
   117  	// Step 13: t5 = x^0x1d
   118  	t5.Mul(t6, t7)
   119  
   120  	// Step 14: t6 = x^0x1f
   121  	t6.Mul(t6, t5)
   122  
   123  	// Step 15: t11 = x^0x34
   124  	t11.Mul(t2, t5)
   125  
   126  	// Step 17: t11 = x^0xd0
   127  	for s := 0; s < 2; s++ {
   128  		t11.Square(t11)
   129  	}
   130  
   131  	// Step 18: t11 = x^0xd7
   132  	t11.Mul(t9, t11)
   133  
   134  	// Step 26: t11 = x^0xd700
   135  	for s := 0; s < 8; s++ {
   136  		t11.Square(t11)
   137  	}
   138  
   139  	// Step 27: t11 = x^0xd71d
   140  	t11.Mul(t5, t11)
   141  
   142  	// Step 34: t11 = x^0x6b8e80
   143  	for s := 0; s < 7; s++ {
   144  		t11.Square(t11)
   145  	}
   146  
   147  	// Step 35: t11 = x^0x6b8e91
   148  	t11.Mul(z, t11)
   149  
   150  	// Step 36: t11 = x^0xd71d22
   151  	t11.Square(t11)
   152  
   153  	// Step 37: t11 = x^0xd71d23
   154  	t11.Mul(&x, t11)
   155  
   156  	// Step 46: t11 = x^0x1ae3a4600
   157  	for s := 0; s < 9; s++ {
   158  		t11.Square(t11)
   159  	}
   160  
   161  	// Step 47: t11 = x^0x1ae3a4617
   162  	t11.Mul(t2, t11)
   163  
   164  	// Step 49: t11 = x^0x6b8e9185c
   165  	for s := 0; s < 2; s++ {
   166  		t11.Square(t11)
   167  	}
   168  
   169  	// Step 50: t11 = x^0x6b8e9185f
   170  	t11.Mul(t1, t11)
   171  
   172  	// Step 56: t11 = x^0x1ae3a4617c0
   173  	for s := 0; s < 6; s++ {
   174  		t11.Square(t11)
   175  	}
   176  
   177  	// Step 57: t11 = x^0x1ae3a4617c5
   178  	t11.Mul(t0, t11)
   179  
   180  	// Step 61: t11 = x^0x1ae3a4617c50
   181  	for s := 0; s < 4; s++ {
   182  		t11.Square(t11)
   183  	}
   184  
   185  	// Step 62: t11 = x^0x1ae3a4617c51
   186  	t11.Mul(&x, t11)
   187  
   188  	// Step 71: t11 = x^0x35c748c2f8a200
   189  	for s := 0; s < 9; s++ {
   190  		t11.Square(t11)
   191  	}
   192  
   193  	// Step 72: t11 = x^0x35c748c2f8a21d
   194  	t11.Mul(t5, t11)
   195  
   196  	// Step 77: t11 = x^0x6b8e9185f1443a0
   197  	for s := 0; s < 5; s++ {
   198  		t11.Square(t11)
   199  	}
   200  
   201  	// Step 78: t11 = x^0x6b8e9185f1443ab
   202  	t11.Mul(t3, t11)
   203  
   204  	// Step 83: t11 = x^0xd71d230be2887560
   205  	for s := 0; s < 5; s++ {
   206  		t11.Square(t11)
   207  	}
   208  
   209  	// Step 84: t11 = x^0xd71d230be2887563
   210  	t11.Mul(t1, t11)
   211  
   212  	// Step 92: t11 = x^0xd71d230be288756300
   213  	for s := 0; s < 8; s++ {
   214  		t11.Square(t11)
   215  	}
   216  
   217  	// Step 93: t11 = x^0xd71d230be28875631d
   218  	t11.Mul(t5, t11)
   219  
   220  	// Step 94: t11 = x^0x1ae3a4617c510eac63a
   221  	t11.Square(t11)
   222  
   223  	// Step 95: t11 = x^0x1ae3a4617c510eac63b
   224  	t11.Mul(&x, t11)
   225  
   226  	// Step 105: t11 = x^0x6b8e9185f1443ab18ec00
   227  	for s := 0; s < 10; s++ {
   228  		t11.Square(t11)
   229  	}
   230  
   231  	// Step 106: t11 = x^0x6b8e9185f1443ab18ec17
   232  	t11.Mul(t2, t11)
   233  
   234  	// Step 118: t11 = x^0x6b8e9185f1443ab18ec17000
   235  	for s := 0; s < 12; s++ {
   236  		t11.Square(t11)
   237  	}
   238  
   239  	// Step 119: t11 = x^0x6b8e9185f1443ab18ec1701b
   240  	t11.Mul(t7, t11)
   241  
   242  	// Step 124: t11 = x^0xd71d230be28875631d82e0360
   243  	for s := 0; s < 5; s++ {
   244  		t11.Square(t11)
   245  	}
   246  
   247  	// Step 125: t11 = x^0xd71d230be28875631d82e0365
   248  	t11.Mul(t0, t11)
   249  
   250  	// Step 132: t11 = x^0x6b8e9185f1443ab18ec1701b280
   251  	for s := 0; s < 7; s++ {
   252  		t11.Square(t11)
   253  	}
   254  
   255  	// Step 133: t11 = x^0x6b8e9185f1443ab18ec1701b285
   256  	t11.Mul(t0, t11)
   257  
   258  	// Step 139: t11 = x^0x1ae3a4617c510eac63b05c06ca140
   259  	for s := 0; s < 6; s++ {
   260  		t11.Square(t11)
   261  	}
   262  
   263  	// Step 140: t11 = x^0x1ae3a4617c510eac63b05c06ca149
   264  	t11.Mul(t4, t11)
   265  
   266  	// Step 147: t11 = x^0xd71d230be28875631d82e03650a480
   267  	for s := 0; s < 7; s++ {
   268  		t11.Square(t11)
   269  	}
   270  
   271  	// Step 148: t11 = x^0xd71d230be28875631d82e03650a49d
   272  	t11.Mul(t5, t11)
   273  
   274  	// Step 153: t11 = x^0x1ae3a4617c510eac63b05c06ca1493a0
   275  	for s := 0; s < 5; s++ {
   276  		t11.Square(t11)
   277  	}
   278  
   279  	// Step 154: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1
   280  	t11.Mul(z, t11)
   281  
   282  	// Step 157: t11 = x^0xd71d230be28875631d82e03650a49d88
   283  	for s := 0; s < 3; s++ {
   284  		t11.Square(t11)
   285  	}
   286  
   287  	// Step 158: t11 = x^0xd71d230be28875631d82e03650a49d8d
   288  	t11.Mul(t0, t11)
   289  
   290  	// Step 166: t11 = x^0xd71d230be28875631d82e03650a49d8d00
   291  	for s := 0; s < 8; s++ {
   292  		t11.Square(t11)
   293  	}
   294  
   295  	// Step 167: t11 = x^0xd71d230be28875631d82e03650a49d8d11
   296  	t11.Mul(z, t11)
   297  
   298  	// Step 173: t11 = x^0x35c748c2f8a21d58c760b80d942927634440
   299  	for s := 0; s < 6; s++ {
   300  		t11.Square(t11)
   301  	}
   302  
   303  	// Step 174: t11 = x^0x35c748c2f8a21d58c760b80d94292763445b
   304  	t11.Mul(t7, t11)
   305  
   306  	// Step 181: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d80
   307  	for s := 0; s < 7; s++ {
   308  		t11.Square(t11)
   309  	}
   310  
   311  	// Step 182: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f
   312  	t11.Mul(t6, t11)
   313  
   314  	// Step 186: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f0
   315  	for s := 0; s < 4; s++ {
   316  		t11.Square(t11)
   317  	}
   318  
   319  	// Step 187: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f3
   320  	t11.Mul(t1, t11)
   321  
   322  	// Step 199: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f3000
   323  	for s := 0; s < 12; s++ {
   324  		t11.Square(t11)
   325  	}
   326  
   327  	// Step 200: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f
   328  	t11.Mul(t8, t11)
   329  
   330  	// Step 204: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f0
   331  	for s := 0; s < 4; s++ {
   332  		t11.Square(t11)
   333  	}
   334  
   335  	// Step 205: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5
   336  	t11.Mul(t0, t11)
   337  
   338  	// Step 213: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f500
   339  	for s := 0; s < 8; s++ {
   340  		t11.Square(t11)
   341  	}
   342  
   343  	// Step 214: t10 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f513
   344  	t10.Mul(t10, t11)
   345  
   346  	// Step 219: t10 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea260
   347  	for s := 0; s < 5; s++ {
   348  		t10.Square(t10)
   349  	}
   350  
   351  	// Step 220: t10 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271
   352  	t10.Mul(z, t10)
   353  
   354  	// Step 223: t10 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f51388
   355  	for s := 0; s < 3; s++ {
   356  		t10.Square(t10)
   357  	}
   358  
   359  	// Step 224: t9 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f
   360  	t9.Mul(t9, t10)
   361  
   362  	// Step 231: t9 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c780
   363  	for s := 0; s < 7; s++ {
   364  		t9.Square(t9)
   365  	}
   366  
   367  	// Step 232: t9 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f
   368  	t9.Mul(t8, t9)
   369  
   370  	// Step 237: t9 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1e0
   371  	for s := 0; s < 5; s++ {
   372  		t9.Square(t9)
   373  	}
   374  
   375  	// Step 238: t8 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef
   376  	t8.Mul(t8, t9)
   377  
   378  	// Step 245: t8 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f780
   379  	for s := 0; s < 7; s++ {
   380  		t8.Square(t8)
   381  	}
   382  
   383  	// Step 246: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b
   384  	t7.Mul(t7, t8)
   385  
   386  	// Step 254: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b00
   387  	for s := 0; s < 8; s++ {
   388  		t7.Square(t7)
   389  	}
   390  
   391  	// Step 255: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b11
   392  	t7.Mul(z, t7)
   393  
   394  	// Step 261: t7 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c440
   395  	for s := 0; s < 6; s++ {
   396  		t7.Square(t7)
   397  	}
   398  
   399  	// Step 262: t6 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f
   400  	t6.Mul(t6, t7)
   401  
   402  	// Step 268: t6 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117c0
   403  	for s := 0; s < 6; s++ {
   404  		t6.Square(t6)
   405  	}
   406  
   407  	// Step 269: t5 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117dd
   408  	t5.Mul(t5, t6)
   409  
   410  	// Step 278: t5 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba00
   411  	for s := 0; s < 9; s++ {
   412  		t5.Square(t5)
   413  	}
   414  
   415  	// Step 279: t5 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09
   416  	t5.Mul(t4, t5)
   417  
   418  	// Step 284: t5 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f74120
   419  	for s := 0; s < 5; s++ {
   420  		t5.Square(t5)
   421  	}
   422  
   423  	// Step 285: t4 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f74129
   424  	t4.Mul(t4, t5)
   425  
   426  	// Step 304: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09480000
   427  	for s := 0; s < 19; s++ {
   428  		t4.Square(t4)
   429  	}
   430  
   431  	// Step 305: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09480017
   432  	t4.Mul(t2, t4)
   433  
   434  	// Step 313: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba0948001700
   435  	for s := 0; s < 8; s++ {
   436  		t4.Square(t4)
   437  	}
   438  
   439  	// Step 314: t3 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b
   440  	t3.Mul(t3, t4)
   441  
   442  	// Step 320: t3 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2c0
   443  	for s := 0; s < 6; s++ {
   444  		t3.Square(t3)
   445  	}
   446  
   447  	// Step 321: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d7
   448  	t2.Mul(t2, t3)
   449  
   450  	// Step 325: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d70
   451  	for s := 0; s < 4; s++ {
   452  		t2.Square(t2)
   453  	}
   454  
   455  	// Step 326: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d75
   456  	t2.Mul(t0, t2)
   457  
   458  	// Step 330: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d750
   459  	for s := 0; s < 4; s++ {
   460  		t2.Square(t2)
   461  	}
   462  
   463  	// Step 331: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d751
   464  	t2.Mul(&x, t2)
   465  
   466  	// Step 337: t2 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d440
   467  	for s := 0; s < 6; s++ {
   468  		t2.Square(t2)
   469  	}
   470  
   471  	// Step 338: t1 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443
   472  	t1.Mul(t1, t2)
   473  
   474  	// Step 367: t1 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba8860000000
   475  	for s := 0; s < 29; s++ {
   476  		t1.Square(t1)
   477  	}
   478  
   479  	// Step 368: t1 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba8860000001
   480  	t1.Mul(&x, t1)
   481  
   482  	// Step 375: t1 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443000000080
   483  	for s := 0; s < 7; s++ {
   484  		t1.Square(t1)
   485  	}
   486  
   487  	// Step 376: t0 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443000000085
   488  	t0.Mul(t0, t1)
   489  
   490  	// Step 385: t0 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba88600000010a00
   491  	for s := 0; s < 9; s++ {
   492  		t0.Square(t0)
   493  	}
   494  
   495  	// Step 386: z = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba88600000010a11
   496  	z.Mul(z, t0)
   497  
   498  	return z
   499  }
   500  
   501  // expByLegendreExp is equivalent to z.Exp(x, d71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117dd04a4000b85aea2180000004284600000000000)
   502  //
   503  // uses github.com/mmcloughlin/addchain v0.4.0 to generate a shorter addition chain
   504  func (z *Element) expByLegendreExp(x Element) *Element {
   505  	// addition chain:
   506  	//
   507  	//	_10       = 2*1
   508  	//	_11       = 1 + _10
   509  	//	_100      = 1 + _11
   510  	//	_101      = 1 + _100
   511  	//	_111      = _10 + _101
   512  	//	_1001     = _10 + _111
   513  	//	_1011     = _10 + _1001
   514  	//	_1111     = _100 + _1011
   515  	//	_10001    = _10 + _1111
   516  	//	_10011    = _10 + _10001
   517  	//	_10111    = _100 + _10011
   518  	//	_11011    = _100 + _10111
   519  	//	_11101    = _10 + _11011
   520  	//	_11111    = _10 + _11101
   521  	//	_110100   = _10111 + _11101
   522  	//	_11010000 = _110100 << 2
   523  	//	_11010111 = _111 + _11010000
   524  	//	i36       = 2*((_11010111 << 8 + _11101) << 7 + _10001)
   525  	//	i50       = ((1 + i36) << 9 + _10111) << 2 + _11
   526  	//	i71       = ((i50 << 6 + _101) << 4 + 1) << 9
   527  	//	i84       = ((_11101 + i71) << 5 + _1011) << 5 + _11
   528  	//	i105      = (2*(i84 << 8 + _11101) + 1) << 10
   529  	//	i125      = ((_10111 + i105) << 12 + _11011) << 5 + _101
   530  	//	i147      = ((i125 << 7 + _101) << 6 + _1001) << 7
   531  	//	i158      = ((_11101 + i147) << 5 + _10001) << 3 + _101
   532  	//	i181      = ((i158 << 8 + _10001) << 6 + _11011) << 7
   533  	//	i200      = ((_11111 + i181) << 4 + _11) << 12 + _1111
   534  	//	i219      = ((i200 << 4 + _101) << 8 + _10011) << 5
   535  	//	i232      = ((_10001 + i219) << 3 + _111) << 7 + _1111
   536  	//	i254      = ((i232 << 5 + _1111) << 7 + _11011) << 8
   537  	//	i269      = ((_10001 + i254) << 6 + _11111) << 6 + _11101
   538  	//	i304      = ((i269 << 9 + _1001) << 5 + _1001) << 19
   539  	//	i321      = ((_10111 + i304) << 8 + _1011) << 6 + _10111
   540  	//	i337      = ((i321 << 4 + _101) << 4 + 1) << 6
   541  	//	i376      = ((_11 + i337) << 29 + 1) << 7 + _101
   542  	//	return      (2*(i376 << 9 + _10001) + 1) << 45
   543  	//
   544  	// Operations: 371 squares 62 multiplies
   545  
   546  	// Allocate Temporaries.
   547  	var (
   548  		t0  = new(Element)
   549  		t1  = new(Element)
   550  		t2  = new(Element)
   551  		t3  = new(Element)
   552  		t4  = new(Element)
   553  		t5  = new(Element)
   554  		t6  = new(Element)
   555  		t7  = new(Element)
   556  		t8  = new(Element)
   557  		t9  = new(Element)
   558  		t10 = new(Element)
   559  		t11 = new(Element)
   560  	)
   561  
   562  	// var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11 Element
   563  	// Step 1: t6 = x^0x2
   564  	t6.Square(&x)
   565  
   566  	// Step 2: t1 = x^0x3
   567  	t1.Mul(&x, t6)
   568  
   569  	// Step 3: t5 = x^0x4
   570  	t5.Mul(&x, t1)
   571  
   572  	// Step 4: t0 = x^0x5
   573  	t0.Mul(&x, t5)
   574  
   575  	// Step 5: t9 = x^0x7
   576  	t9.Mul(t6, t0)
   577  
   578  	// Step 6: t4 = x^0x9
   579  	t4.Mul(t6, t9)
   580  
   581  	// Step 7: t3 = x^0xb
   582  	t3.Mul(t6, t4)
   583  
   584  	// Step 8: t8 = x^0xf
   585  	t8.Mul(t5, t3)
   586  
   587  	// Step 9: z = x^0x11
   588  	z.Mul(t6, t8)
   589  
   590  	// Step 10: t10 = x^0x13
   591  	t10.Mul(t6, z)
   592  
   593  	// Step 11: t2 = x^0x17
   594  	t2.Mul(t5, t10)
   595  
   596  	// Step 12: t7 = x^0x1b
   597  	t7.Mul(t5, t2)
   598  
   599  	// Step 13: t5 = x^0x1d
   600  	t5.Mul(t6, t7)
   601  
   602  	// Step 14: t6 = x^0x1f
   603  	t6.Mul(t6, t5)
   604  
   605  	// Step 15: t11 = x^0x34
   606  	t11.Mul(t2, t5)
   607  
   608  	// Step 17: t11 = x^0xd0
   609  	for s := 0; s < 2; s++ {
   610  		t11.Square(t11)
   611  	}
   612  
   613  	// Step 18: t11 = x^0xd7
   614  	t11.Mul(t9, t11)
   615  
   616  	// Step 26: t11 = x^0xd700
   617  	for s := 0; s < 8; s++ {
   618  		t11.Square(t11)
   619  	}
   620  
   621  	// Step 27: t11 = x^0xd71d
   622  	t11.Mul(t5, t11)
   623  
   624  	// Step 34: t11 = x^0x6b8e80
   625  	for s := 0; s < 7; s++ {
   626  		t11.Square(t11)
   627  	}
   628  
   629  	// Step 35: t11 = x^0x6b8e91
   630  	t11.Mul(z, t11)
   631  
   632  	// Step 36: t11 = x^0xd71d22
   633  	t11.Square(t11)
   634  
   635  	// Step 37: t11 = x^0xd71d23
   636  	t11.Mul(&x, t11)
   637  
   638  	// Step 46: t11 = x^0x1ae3a4600
   639  	for s := 0; s < 9; s++ {
   640  		t11.Square(t11)
   641  	}
   642  
   643  	// Step 47: t11 = x^0x1ae3a4617
   644  	t11.Mul(t2, t11)
   645  
   646  	// Step 49: t11 = x^0x6b8e9185c
   647  	for s := 0; s < 2; s++ {
   648  		t11.Square(t11)
   649  	}
   650  
   651  	// Step 50: t11 = x^0x6b8e9185f
   652  	t11.Mul(t1, t11)
   653  
   654  	// Step 56: t11 = x^0x1ae3a4617c0
   655  	for s := 0; s < 6; s++ {
   656  		t11.Square(t11)
   657  	}
   658  
   659  	// Step 57: t11 = x^0x1ae3a4617c5
   660  	t11.Mul(t0, t11)
   661  
   662  	// Step 61: t11 = x^0x1ae3a4617c50
   663  	for s := 0; s < 4; s++ {
   664  		t11.Square(t11)
   665  	}
   666  
   667  	// Step 62: t11 = x^0x1ae3a4617c51
   668  	t11.Mul(&x, t11)
   669  
   670  	// Step 71: t11 = x^0x35c748c2f8a200
   671  	for s := 0; s < 9; s++ {
   672  		t11.Square(t11)
   673  	}
   674  
   675  	// Step 72: t11 = x^0x35c748c2f8a21d
   676  	t11.Mul(t5, t11)
   677  
   678  	// Step 77: t11 = x^0x6b8e9185f1443a0
   679  	for s := 0; s < 5; s++ {
   680  		t11.Square(t11)
   681  	}
   682  
   683  	// Step 78: t11 = x^0x6b8e9185f1443ab
   684  	t11.Mul(t3, t11)
   685  
   686  	// Step 83: t11 = x^0xd71d230be2887560
   687  	for s := 0; s < 5; s++ {
   688  		t11.Square(t11)
   689  	}
   690  
   691  	// Step 84: t11 = x^0xd71d230be2887563
   692  	t11.Mul(t1, t11)
   693  
   694  	// Step 92: t11 = x^0xd71d230be288756300
   695  	for s := 0; s < 8; s++ {
   696  		t11.Square(t11)
   697  	}
   698  
   699  	// Step 93: t11 = x^0xd71d230be28875631d
   700  	t11.Mul(t5, t11)
   701  
   702  	// Step 94: t11 = x^0x1ae3a4617c510eac63a
   703  	t11.Square(t11)
   704  
   705  	// Step 95: t11 = x^0x1ae3a4617c510eac63b
   706  	t11.Mul(&x, t11)
   707  
   708  	// Step 105: t11 = x^0x6b8e9185f1443ab18ec00
   709  	for s := 0; s < 10; s++ {
   710  		t11.Square(t11)
   711  	}
   712  
   713  	// Step 106: t11 = x^0x6b8e9185f1443ab18ec17
   714  	t11.Mul(t2, t11)
   715  
   716  	// Step 118: t11 = x^0x6b8e9185f1443ab18ec17000
   717  	for s := 0; s < 12; s++ {
   718  		t11.Square(t11)
   719  	}
   720  
   721  	// Step 119: t11 = x^0x6b8e9185f1443ab18ec1701b
   722  	t11.Mul(t7, t11)
   723  
   724  	// Step 124: t11 = x^0xd71d230be28875631d82e0360
   725  	for s := 0; s < 5; s++ {
   726  		t11.Square(t11)
   727  	}
   728  
   729  	// Step 125: t11 = x^0xd71d230be28875631d82e0365
   730  	t11.Mul(t0, t11)
   731  
   732  	// Step 132: t11 = x^0x6b8e9185f1443ab18ec1701b280
   733  	for s := 0; s < 7; s++ {
   734  		t11.Square(t11)
   735  	}
   736  
   737  	// Step 133: t11 = x^0x6b8e9185f1443ab18ec1701b285
   738  	t11.Mul(t0, t11)
   739  
   740  	// Step 139: t11 = x^0x1ae3a4617c510eac63b05c06ca140
   741  	for s := 0; s < 6; s++ {
   742  		t11.Square(t11)
   743  	}
   744  
   745  	// Step 140: t11 = x^0x1ae3a4617c510eac63b05c06ca149
   746  	t11.Mul(t4, t11)
   747  
   748  	// Step 147: t11 = x^0xd71d230be28875631d82e03650a480
   749  	for s := 0; s < 7; s++ {
   750  		t11.Square(t11)
   751  	}
   752  
   753  	// Step 148: t11 = x^0xd71d230be28875631d82e03650a49d
   754  	t11.Mul(t5, t11)
   755  
   756  	// Step 153: t11 = x^0x1ae3a4617c510eac63b05c06ca1493a0
   757  	for s := 0; s < 5; s++ {
   758  		t11.Square(t11)
   759  	}
   760  
   761  	// Step 154: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1
   762  	t11.Mul(z, t11)
   763  
   764  	// Step 157: t11 = x^0xd71d230be28875631d82e03650a49d88
   765  	for s := 0; s < 3; s++ {
   766  		t11.Square(t11)
   767  	}
   768  
   769  	// Step 158: t11 = x^0xd71d230be28875631d82e03650a49d8d
   770  	t11.Mul(t0, t11)
   771  
   772  	// Step 166: t11 = x^0xd71d230be28875631d82e03650a49d8d00
   773  	for s := 0; s < 8; s++ {
   774  		t11.Square(t11)
   775  	}
   776  
   777  	// Step 167: t11 = x^0xd71d230be28875631d82e03650a49d8d11
   778  	t11.Mul(z, t11)
   779  
   780  	// Step 173: t11 = x^0x35c748c2f8a21d58c760b80d942927634440
   781  	for s := 0; s < 6; s++ {
   782  		t11.Square(t11)
   783  	}
   784  
   785  	// Step 174: t11 = x^0x35c748c2f8a21d58c760b80d94292763445b
   786  	t11.Mul(t7, t11)
   787  
   788  	// Step 181: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d80
   789  	for s := 0; s < 7; s++ {
   790  		t11.Square(t11)
   791  	}
   792  
   793  	// Step 182: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f
   794  	t11.Mul(t6, t11)
   795  
   796  	// Step 186: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f0
   797  	for s := 0; s < 4; s++ {
   798  		t11.Square(t11)
   799  	}
   800  
   801  	// Step 187: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f3
   802  	t11.Mul(t1, t11)
   803  
   804  	// Step 199: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f3000
   805  	for s := 0; s < 12; s++ {
   806  		t11.Square(t11)
   807  	}
   808  
   809  	// Step 200: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f
   810  	t11.Mul(t8, t11)
   811  
   812  	// Step 204: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f0
   813  	for s := 0; s < 4; s++ {
   814  		t11.Square(t11)
   815  	}
   816  
   817  	// Step 205: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5
   818  	t11.Mul(t0, t11)
   819  
   820  	// Step 213: t11 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f500
   821  	for s := 0; s < 8; s++ {
   822  		t11.Square(t11)
   823  	}
   824  
   825  	// Step 214: t10 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f513
   826  	t10.Mul(t10, t11)
   827  
   828  	// Step 219: t10 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea260
   829  	for s := 0; s < 5; s++ {
   830  		t10.Square(t10)
   831  	}
   832  
   833  	// Step 220: t10 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271
   834  	t10.Mul(z, t10)
   835  
   836  	// Step 223: t10 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f51388
   837  	for s := 0; s < 3; s++ {
   838  		t10.Square(t10)
   839  	}
   840  
   841  	// Step 224: t9 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f
   842  	t9.Mul(t9, t10)
   843  
   844  	// Step 231: t9 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c780
   845  	for s := 0; s < 7; s++ {
   846  		t9.Square(t9)
   847  	}
   848  
   849  	// Step 232: t9 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f
   850  	t9.Mul(t8, t9)
   851  
   852  	// Step 237: t9 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1e0
   853  	for s := 0; s < 5; s++ {
   854  		t9.Square(t9)
   855  	}
   856  
   857  	// Step 238: t8 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef
   858  	t8.Mul(t8, t9)
   859  
   860  	// Step 245: t8 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f780
   861  	for s := 0; s < 7; s++ {
   862  		t8.Square(t8)
   863  	}
   864  
   865  	// Step 246: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b
   866  	t7.Mul(t7, t8)
   867  
   868  	// Step 254: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b00
   869  	for s := 0; s < 8; s++ {
   870  		t7.Square(t7)
   871  	}
   872  
   873  	// Step 255: t7 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b11
   874  	t7.Mul(z, t7)
   875  
   876  	// Step 261: t7 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c440
   877  	for s := 0; s < 6; s++ {
   878  		t7.Square(t7)
   879  	}
   880  
   881  	// Step 262: t6 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f
   882  	t6.Mul(t6, t7)
   883  
   884  	// Step 268: t6 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117c0
   885  	for s := 0; s < 6; s++ {
   886  		t6.Square(t6)
   887  	}
   888  
   889  	// Step 269: t5 = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117dd
   890  	t5.Mul(t5, t6)
   891  
   892  	// Step 278: t5 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba00
   893  	for s := 0; s < 9; s++ {
   894  		t5.Square(t5)
   895  	}
   896  
   897  	// Step 279: t5 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09
   898  	t5.Mul(t4, t5)
   899  
   900  	// Step 284: t5 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f74120
   901  	for s := 0; s < 5; s++ {
   902  		t5.Square(t5)
   903  	}
   904  
   905  	// Step 285: t4 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f74129
   906  	t4.Mul(t4, t5)
   907  
   908  	// Step 304: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09480000
   909  	for s := 0; s < 19; s++ {
   910  		t4.Square(t4)
   911  	}
   912  
   913  	// Step 305: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba09480017
   914  	t4.Mul(t2, t4)
   915  
   916  	// Step 313: t4 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba0948001700
   917  	for s := 0; s < 8; s++ {
   918  		t4.Square(t4)
   919  	}
   920  
   921  	// Step 314: t3 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b
   922  	t3.Mul(t3, t4)
   923  
   924  	// Step 320: t3 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2c0
   925  	for s := 0; s < 6; s++ {
   926  		t3.Square(t3)
   927  	}
   928  
   929  	// Step 321: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d7
   930  	t2.Mul(t2, t3)
   931  
   932  	// Step 325: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d70
   933  	for s := 0; s < 4; s++ {
   934  		t2.Square(t2)
   935  	}
   936  
   937  	// Step 326: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d75
   938  	t2.Mul(t0, t2)
   939  
   940  	// Step 330: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d750
   941  	for s := 0; s < 4; s++ {
   942  		t2.Square(t2)
   943  	}
   944  
   945  	// Step 331: t2 = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d751
   946  	t2.Mul(&x, t2)
   947  
   948  	// Step 337: t2 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d440
   949  	for s := 0; s < 6; s++ {
   950  		t2.Square(t2)
   951  	}
   952  
   953  	// Step 338: t1 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443
   954  	t1.Mul(t1, t2)
   955  
   956  	// Step 367: t1 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba8860000000
   957  	for s := 0; s < 29; s++ {
   958  		t1.Square(t1)
   959  	}
   960  
   961  	// Step 368: t1 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba8860000001
   962  	t1.Mul(&x, t1)
   963  
   964  	// Step 375: t1 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443000000080
   965  	for s := 0; s < 7; s++ {
   966  		t1.Square(t1)
   967  	}
   968  
   969  	// Step 376: t0 = x^0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d443000000085
   970  	t0.Mul(t0, t1)
   971  
   972  	// Step 385: t0 = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba88600000010a00
   973  	for s := 0; s < 9; s++ {
   974  		t0.Square(t0)
   975  	}
   976  
   977  	// Step 386: z = x^0x35c748c2f8a21d58c760b80d94292763445b3e601ea271e3de6c45f741290002e16ba88600000010a11
   978  	z.Mul(z, t0)
   979  
   980  	// Step 387: z = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d7510c00000021422
   981  	z.Square(z)
   982  
   983  	// Step 388: z = x^0x6b8e9185f1443ab18ec1701b28524ec688b67cc03d44e3c7bcd88bee82520005c2d7510c00000021423
   984  	z.Mul(&x, z)
   985  
   986  	// Step 433: z = x^0xd71d230be28875631d82e03650a49d8d116cf9807a89c78f79b117dd04a4000b85aea2180000004284600000000000
   987  	for s := 0; s < 45; s++ {
   988  		z.Square(z)
   989  	}
   990  
   991  	return z
   992  }