github.com/consensys/gnark-crypto@v0.14.0/ecc/bw6-633/fr/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 fr
    18  
    19  // expBySqrtExp is equivalent to z.Exp(x, 2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017fa01)
    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  	//	_101      = _10 + _11
    28  	//	_110      = 1 + _101
    29  	//	_1011     = _101 + _110
    30  	//	_1101     = _10 + _1011
    31  	//	_10001    = _110 + _1011
    32  	//	_10011    = _10 + _10001
    33  	//	_11001    = _110 + _10011
    34  	//	_11011    = _10 + _11001
    35  	//	_11101    = _10 + _11011
    36  	//	_11111    = _10 + _11101
    37  	//	_100001   = _10 + _11111
    38  	//	_100011   = _10 + _100001
    39  	//	_100101   = _10 + _100011
    40  	//	_101001   = _110 + _100011
    41  	//	_101011   = _10 + _101001
    42  	//	_101111   = _110 + _101001
    43  	//	_110101   = _110 + _101111
    44  	//	_110111   = _10 + _110101
    45  	//	_111011   = _110 + _110101
    46  	//	_111101   = _10 + _111011
    47  	//	_111111   = _10 + _111101
    48  	//	_1111110  = 2*_111111
    49  	//	_1111111  = 1 + _1111110
    50  	//	_10011000 = _11001 + _1111111
    51  	//	i51       = ((_10011000 << 7 + _100011) << 3 + _101) << 13
    52  	//	i68       = ((_101011 + i51) << 5 + _1011) << 9 + _11011
    53  	//	i88       = ((i68 << 5 + _1011) << 5 + _101) << 8
    54  	//	i105      = ((_1101 + i88) << 8 + _111111) << 6 + _11101
    55  	//	i129      = ((i105 << 7 + _10011) << 9 + _101111) << 6
    56  	//	i147      = ((_101001 + i129) << 6 + _11111) << 9 + _101111
    57  	//	i168      = ((i147 << 7 + _101011) << 6 + _111101) << 6
    58  	//	i194      = ((_111011 + i168) << 10 + _11101) << 13 + _110101
    59  	//	i220      = ((i194 << 6 + _10001) << 8 + _111101) << 10
    60  	//	i237      = ((_110101 + i220) << 2 + _11) << 12 + _100001
    61  	//	i261      = ((i237 << 10 + _111101) << 5 + _11001) << 7
    62  	//	i279      = ((_111011 + i261) << 7 + _100101) << 8 + _101011
    63  	//	i304      = ((i279 << 6 + _110111) << 6 + _100101) << 11
    64  	//	i317      = ((_10011 + i304) << 8 + _1111111) << 2 + 1
    65  	//	i338      = 2*((i317 << 10 + 1) << 8 + _1111111)
    66  	//	return      ((1 + i338) << 2 + 1) << 9 + 1
    67  	//
    68  	// Operations: 288 squares 64 multiplies
    69  
    70  	// Allocate Temporaries.
    71  	var (
    72  		t0  = new(Element)
    73  		t1  = new(Element)
    74  		t2  = new(Element)
    75  		t3  = new(Element)
    76  		t4  = new(Element)
    77  		t5  = new(Element)
    78  		t6  = new(Element)
    79  		t7  = new(Element)
    80  		t8  = new(Element)
    81  		t9  = new(Element)
    82  		t10 = new(Element)
    83  		t11 = new(Element)
    84  		t12 = new(Element)
    85  		t13 = new(Element)
    86  		t14 = new(Element)
    87  		t15 = new(Element)
    88  		t16 = new(Element)
    89  		t17 = new(Element)
    90  		t18 = new(Element)
    91  		t19 = new(Element)
    92  		t20 = new(Element)
    93  		t21 = new(Element)
    94  	)
    95  
    96  	// var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21 Element
    97  	// Step 1: z = x^0x2
    98  	z.Square(&x)
    99  
   100  	// Step 2: t8 = x^0x3
   101  	t8.Mul(&x, z)
   102  
   103  	// Step 3: t17 = x^0x5
   104  	t17.Mul(z, t8)
   105  
   106  	// Step 4: t4 = x^0x6
   107  	t4.Mul(&x, t17)
   108  
   109  	// Step 5: t18 = x^0xb
   110  	t18.Mul(t17, t4)
   111  
   112  	// Step 6: t16 = x^0xd
   113  	t16.Mul(z, t18)
   114  
   115  	// Step 7: t10 = x^0x11
   116  	t10.Mul(t4, t18)
   117  
   118  	// Step 8: t0 = x^0x13
   119  	t0.Mul(z, t10)
   120  
   121  	// Step 9: t5 = x^0x19
   122  	t5.Mul(t4, t0)
   123  
   124  	// Step 10: t19 = x^0x1b
   125  	t19.Mul(z, t5)
   126  
   127  	// Step 11: t11 = x^0x1d
   128  	t11.Mul(z, t19)
   129  
   130  	// Step 12: t13 = x^0x1f
   131  	t13.Mul(z, t11)
   132  
   133  	// Step 13: t7 = x^0x21
   134  	t7.Mul(z, t13)
   135  
   136  	// Step 14: t20 = x^0x23
   137  	t20.Mul(z, t7)
   138  
   139  	// Step 15: t1 = x^0x25
   140  	t1.Mul(z, t20)
   141  
   142  	// Step 16: t14 = x^0x29
   143  	t14.Mul(t4, t20)
   144  
   145  	// Step 17: t3 = x^0x2b
   146  	t3.Mul(z, t14)
   147  
   148  	// Step 18: t12 = x^0x2f
   149  	t12.Mul(t4, t14)
   150  
   151  	// Step 19: t9 = x^0x35
   152  	t9.Mul(t4, t12)
   153  
   154  	// Step 20: t2 = x^0x37
   155  	t2.Mul(z, t9)
   156  
   157  	// Step 21: t4 = x^0x3b
   158  	t4.Mul(t4, t9)
   159  
   160  	// Step 22: t6 = x^0x3d
   161  	t6.Mul(z, t4)
   162  
   163  	// Step 23: t15 = x^0x3f
   164  	t15.Mul(z, t6)
   165  
   166  	// Step 24: z = x^0x7e
   167  	z.Square(t15)
   168  
   169  	// Step 25: z = x^0x7f
   170  	z.Mul(&x, z)
   171  
   172  	// Step 26: t21 = x^0x98
   173  	t21.Mul(t5, z)
   174  
   175  	// Step 33: t21 = x^0x4c00
   176  	for s := 0; s < 7; s++ {
   177  		t21.Square(t21)
   178  	}
   179  
   180  	// Step 34: t20 = x^0x4c23
   181  	t20.Mul(t20, t21)
   182  
   183  	// Step 37: t20 = x^0x26118
   184  	for s := 0; s < 3; s++ {
   185  		t20.Square(t20)
   186  	}
   187  
   188  	// Step 38: t20 = x^0x2611d
   189  	t20.Mul(t17, t20)
   190  
   191  	// Step 51: t20 = x^0x4c23a000
   192  	for s := 0; s < 13; s++ {
   193  		t20.Square(t20)
   194  	}
   195  
   196  	// Step 52: t20 = x^0x4c23a02b
   197  	t20.Mul(t3, t20)
   198  
   199  	// Step 57: t20 = x^0x984740560
   200  	for s := 0; s < 5; s++ {
   201  		t20.Square(t20)
   202  	}
   203  
   204  	// Step 58: t20 = x^0x98474056b
   205  	t20.Mul(t18, t20)
   206  
   207  	// Step 67: t20 = x^0x1308e80ad600
   208  	for s := 0; s < 9; s++ {
   209  		t20.Square(t20)
   210  	}
   211  
   212  	// Step 68: t19 = x^0x1308e80ad61b
   213  	t19.Mul(t19, t20)
   214  
   215  	// Step 73: t19 = x^0x2611d015ac360
   216  	for s := 0; s < 5; s++ {
   217  		t19.Square(t19)
   218  	}
   219  
   220  	// Step 74: t18 = x^0x2611d015ac36b
   221  	t18.Mul(t18, t19)
   222  
   223  	// Step 79: t18 = x^0x4c23a02b586d60
   224  	for s := 0; s < 5; s++ {
   225  		t18.Square(t18)
   226  	}
   227  
   228  	// Step 80: t17 = x^0x4c23a02b586d65
   229  	t17.Mul(t17, t18)
   230  
   231  	// Step 88: t17 = x^0x4c23a02b586d6500
   232  	for s := 0; s < 8; s++ {
   233  		t17.Square(t17)
   234  	}
   235  
   236  	// Step 89: t16 = x^0x4c23a02b586d650d
   237  	t16.Mul(t16, t17)
   238  
   239  	// Step 97: t16 = x^0x4c23a02b586d650d00
   240  	for s := 0; s < 8; s++ {
   241  		t16.Square(t16)
   242  	}
   243  
   244  	// Step 98: t15 = x^0x4c23a02b586d650d3f
   245  	t15.Mul(t15, t16)
   246  
   247  	// Step 104: t15 = x^0x1308e80ad61b59434fc0
   248  	for s := 0; s < 6; s++ {
   249  		t15.Square(t15)
   250  	}
   251  
   252  	// Step 105: t15 = x^0x1308e80ad61b59434fdd
   253  	t15.Mul(t11, t15)
   254  
   255  	// Step 112: t15 = x^0x98474056b0daca1a7ee80
   256  	for s := 0; s < 7; s++ {
   257  		t15.Square(t15)
   258  	}
   259  
   260  	// Step 113: t15 = x^0x98474056b0daca1a7ee93
   261  	t15.Mul(t0, t15)
   262  
   263  	// Step 122: t15 = x^0x1308e80ad61b59434fdd2600
   264  	for s := 0; s < 9; s++ {
   265  		t15.Square(t15)
   266  	}
   267  
   268  	// Step 123: t15 = x^0x1308e80ad61b59434fdd262f
   269  	t15.Mul(t12, t15)
   270  
   271  	// Step 129: t15 = x^0x4c23a02b586d650d3f7498bc0
   272  	for s := 0; s < 6; s++ {
   273  		t15.Square(t15)
   274  	}
   275  
   276  	// Step 130: t14 = x^0x4c23a02b586d650d3f7498be9
   277  	t14.Mul(t14, t15)
   278  
   279  	// Step 136: t14 = x^0x1308e80ad61b59434fdd262fa40
   280  	for s := 0; s < 6; s++ {
   281  		t14.Square(t14)
   282  	}
   283  
   284  	// Step 137: t13 = x^0x1308e80ad61b59434fdd262fa5f
   285  	t13.Mul(t13, t14)
   286  
   287  	// Step 146: t13 = x^0x2611d015ac36b2869fba4c5f4be00
   288  	for s := 0; s < 9; s++ {
   289  		t13.Square(t13)
   290  	}
   291  
   292  	// Step 147: t12 = x^0x2611d015ac36b2869fba4c5f4be2f
   293  	t12.Mul(t12, t13)
   294  
   295  	// Step 154: t12 = x^0x1308e80ad61b59434fdd262fa5f1780
   296  	for s := 0; s < 7; s++ {
   297  		t12.Square(t12)
   298  	}
   299  
   300  	// Step 155: t12 = x^0x1308e80ad61b59434fdd262fa5f17ab
   301  	t12.Mul(t3, t12)
   302  
   303  	// Step 161: t12 = x^0x4c23a02b586d650d3f7498be97c5eac0
   304  	for s := 0; s < 6; s++ {
   305  		t12.Square(t12)
   306  	}
   307  
   308  	// Step 162: t12 = x^0x4c23a02b586d650d3f7498be97c5eafd
   309  	t12.Mul(t6, t12)
   310  
   311  	// Step 168: t12 = x^0x1308e80ad61b59434fdd262fa5f17abf40
   312  	for s := 0; s < 6; s++ {
   313  		t12.Square(t12)
   314  	}
   315  
   316  	// Step 169: t12 = x^0x1308e80ad61b59434fdd262fa5f17abf7b
   317  	t12.Mul(t4, t12)
   318  
   319  	// Step 179: t12 = x^0x4c23a02b586d650d3f7498be97c5eafdec00
   320  	for s := 0; s < 10; s++ {
   321  		t12.Square(t12)
   322  	}
   323  
   324  	// Step 180: t11 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d
   325  	t11.Mul(t11, t12)
   326  
   327  	// Step 193: t11 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a000
   328  	for s := 0; s < 13; s++ {
   329  		t11.Square(t11)
   330  	}
   331  
   332  	// Step 194: t11 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a035
   333  	t11.Mul(t9, t11)
   334  
   335  	// Step 200: t11 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d40
   336  	for s := 0; s < 6; s++ {
   337  		t11.Square(t11)
   338  	}
   339  
   340  	// Step 201: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d51
   341  	t10.Mul(t10, t11)
   342  
   343  	// Step 209: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d5100
   344  	for s := 0; s < 8; s++ {
   345  		t10.Square(t10)
   346  	}
   347  
   348  	// Step 210: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d
   349  	t10.Mul(t6, t10)
   350  
   351  	// Step 220: t10 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f400
   352  	for s := 0; s < 10; s++ {
   353  		t10.Square(t10)
   354  	}
   355  
   356  	// Step 221: t9 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435
   357  	t9.Mul(t9, t10)
   358  
   359  	// Step 223: t9 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d4
   360  	for s := 0; s < 2; s++ {
   361  		t9.Square(t9)
   362  	}
   363  
   364  	// Step 224: t8 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7
   365  	t8.Mul(t8, t9)
   366  
   367  	// Step 236: t8 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7000
   368  	for s := 0; s < 12; s++ {
   369  		t8.Square(t8)
   370  	}
   371  
   372  	// Step 237: t7 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7021
   373  	t7.Mul(t7, t8)
   374  
   375  	// Step 247: t7 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c08400
   376  	for s := 0; s < 10; s++ {
   377  		t7.Square(t7)
   378  	}
   379  
   380  	// Step 248: t6 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843d
   381  	t6.Mul(t6, t7)
   382  
   383  	// Step 253: t6 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087a0
   384  	for s := 0; s < 5; s++ {
   385  		t6.Square(t6)
   386  	}
   387  
   388  	// Step 254: t5 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b9
   389  	t5.Mul(t5, t6)
   390  
   391  	// Step 261: t5 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dc80
   392  	for s := 0; s < 7; s++ {
   393  		t5.Square(t5)
   394  	}
   395  
   396  	// Step 262: t4 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb
   397  	t4.Mul(t4, t5)
   398  
   399  	// Step 269: t4 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5d80
   400  	for s := 0; s < 7; s++ {
   401  		t4.Square(t4)
   402  	}
   403  
   404  	// Step 270: t4 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da5
   405  	t4.Mul(t1, t4)
   406  
   407  	// Step 278: t4 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da500
   408  	for s := 0; s < 8; s++ {
   409  		t4.Square(t4)
   410  	}
   411  
   412  	// Step 279: t3 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52b
   413  	t3.Mul(t3, t4)
   414  
   415  	// Step 285: t3 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694ac0
   416  	for s := 0; s < 6; s++ {
   417  		t3.Square(t3)
   418  	}
   419  
   420  	// Step 286: t2 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af7
   421  	t2.Mul(t2, t3)
   422  
   423  	// Step 292: t2 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bdc0
   424  	for s := 0; s < 6; s++ {
   425  		t2.Square(t2)
   426  	}
   427  
   428  	// Step 293: t1 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5
   429  	t1.Mul(t1, t2)
   430  
   431  	// Step 304: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef2800
   432  	for s := 0; s < 11; s++ {
   433  		t1.Square(t1)
   434  	}
   435  
   436  	// Step 305: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef2813
   437  	t0.Mul(t0, t1)
   438  
   439  	// Step 313: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef281300
   440  	for s := 0; s < 8; s++ {
   441  		t0.Square(t0)
   442  	}
   443  
   444  	// Step 314: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f
   445  	t0.Mul(z, t0)
   446  
   447  	// Step 316: t0 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb4a57bca04dfc
   448  	for s := 0; s < 2; s++ {
   449  		t0.Square(t0)
   450  	}
   451  
   452  	// Step 317: t0 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb4a57bca04dfd
   453  	t0.Mul(&x, t0)
   454  
   455  	// Step 327: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f400
   456  	for s := 0; s < 10; s++ {
   457  		t0.Square(t0)
   458  	}
   459  
   460  	// Step 328: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f401
   461  	t0.Mul(&x, t0)
   462  
   463  	// Step 336: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f40100
   464  	for s := 0; s < 8; s++ {
   465  		t0.Square(t0)
   466  	}
   467  
   468  	// Step 337: z = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017f
   469  	z.Mul(z, t0)
   470  
   471  	// Step 338: z = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802fe
   472  	z.Square(z)
   473  
   474  	// Step 339: z = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802ff
   475  	z.Mul(&x, z)
   476  
   477  	// Step 341: z = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af79409bfa00bfc
   478  	for s := 0; s < 2; s++ {
   479  		z.Square(z)
   480  	}
   481  
   482  	// Step 342: z = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af79409bfa00bfd
   483  	z.Mul(&x, z)
   484  
   485  	// Step 351: z = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017fa00
   486  	for s := 0; s < 9; s++ {
   487  		z.Square(z)
   488  	}
   489  
   490  	// Step 352: z = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017fa01
   491  	z.Mul(&x, z)
   492  
   493  	return z
   494  }
   495  
   496  // expByLegendreExp is equivalent to z.Exp(x, 2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017fa0180000)
   497  //
   498  // uses github.com/mmcloughlin/addchain v0.4.0 to generate a shorter addition chain
   499  func (z *Element) expByLegendreExp(x Element) *Element {
   500  	// addition chain:
   501  	//
   502  	//	_10       = 2*1
   503  	//	_11       = 1 + _10
   504  	//	_101      = _10 + _11
   505  	//	_110      = 1 + _101
   506  	//	_1011     = _101 + _110
   507  	//	_1101     = _10 + _1011
   508  	//	_10001    = _110 + _1011
   509  	//	_10011    = _10 + _10001
   510  	//	_11001    = _110 + _10011
   511  	//	_11011    = _10 + _11001
   512  	//	_11101    = _10 + _11011
   513  	//	_11111    = _10 + _11101
   514  	//	_100001   = _10 + _11111
   515  	//	_100011   = _10 + _100001
   516  	//	_100101   = _10 + _100011
   517  	//	_101001   = _110 + _100011
   518  	//	_101011   = _10 + _101001
   519  	//	_101111   = _110 + _101001
   520  	//	_110101   = _110 + _101111
   521  	//	_110111   = _10 + _110101
   522  	//	_111011   = _110 + _110101
   523  	//	_111101   = _10 + _111011
   524  	//	_111111   = _10 + _111101
   525  	//	_1111110  = 2*_111111
   526  	//	_1111111  = 1 + _1111110
   527  	//	_10011000 = _11001 + _1111111
   528  	//	i51       = ((_10011000 << 7 + _100011) << 3 + _101) << 13
   529  	//	i68       = ((_101011 + i51) << 5 + _1011) << 9 + _11011
   530  	//	i88       = ((i68 << 5 + _1011) << 5 + _101) << 8
   531  	//	i105      = ((_1101 + i88) << 8 + _111111) << 6 + _11101
   532  	//	i129      = ((i105 << 7 + _10011) << 9 + _101111) << 6
   533  	//	i147      = ((_101001 + i129) << 6 + _11111) << 9 + _101111
   534  	//	i168      = ((i147 << 7 + _101011) << 6 + _111101) << 6
   535  	//	i194      = ((_111011 + i168) << 10 + _11101) << 13 + _110101
   536  	//	i220      = ((i194 << 6 + _10001) << 8 + _111101) << 10
   537  	//	i237      = ((_110101 + i220) << 2 + _11) << 12 + _100001
   538  	//	i261      = ((i237 << 10 + _111101) << 5 + _11001) << 7
   539  	//	i279      = ((_111011 + i261) << 7 + _100101) << 8 + _101011
   540  	//	i304      = ((i279 << 6 + _110111) << 6 + _100101) << 11
   541  	//	i317      = ((_10011 + i304) << 8 + _1111111) << 2 + 1
   542  	//	i338      = 2*((i317 << 10 + 1) << 8 + _1111111)
   543  	//	i353      = ((1 + i338) << 2 + 1) << 10 + _11
   544  	//	return      i353 << 19
   545  	//
   546  	// Operations: 308 squares 64 multiplies
   547  
   548  	// Allocate Temporaries.
   549  	var (
   550  		t0  = new(Element)
   551  		t1  = new(Element)
   552  		t2  = new(Element)
   553  		t3  = new(Element)
   554  		t4  = new(Element)
   555  		t5  = new(Element)
   556  		t6  = new(Element)
   557  		t7  = new(Element)
   558  		t8  = new(Element)
   559  		t9  = new(Element)
   560  		t10 = new(Element)
   561  		t11 = new(Element)
   562  		t12 = new(Element)
   563  		t13 = new(Element)
   564  		t14 = new(Element)
   565  		t15 = new(Element)
   566  		t16 = new(Element)
   567  		t17 = new(Element)
   568  		t18 = new(Element)
   569  		t19 = new(Element)
   570  		t20 = new(Element)
   571  		t21 = new(Element)
   572  	)
   573  
   574  	// var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21 Element
   575  	// Step 1: t0 = x^0x2
   576  	t0.Square(&x)
   577  
   578  	// Step 2: z = x^0x3
   579  	z.Mul(&x, t0)
   580  
   581  	// Step 3: t17 = x^0x5
   582  	t17.Mul(t0, z)
   583  
   584  	// Step 4: t5 = x^0x6
   585  	t5.Mul(&x, t17)
   586  
   587  	// Step 5: t18 = x^0xb
   588  	t18.Mul(t17, t5)
   589  
   590  	// Step 6: t16 = x^0xd
   591  	t16.Mul(t0, t18)
   592  
   593  	// Step 7: t10 = x^0x11
   594  	t10.Mul(t5, t18)
   595  
   596  	// Step 8: t1 = x^0x13
   597  	t1.Mul(t0, t10)
   598  
   599  	// Step 9: t6 = x^0x19
   600  	t6.Mul(t5, t1)
   601  
   602  	// Step 10: t19 = x^0x1b
   603  	t19.Mul(t0, t6)
   604  
   605  	// Step 11: t11 = x^0x1d
   606  	t11.Mul(t0, t19)
   607  
   608  	// Step 12: t13 = x^0x1f
   609  	t13.Mul(t0, t11)
   610  
   611  	// Step 13: t8 = x^0x21
   612  	t8.Mul(t0, t13)
   613  
   614  	// Step 14: t20 = x^0x23
   615  	t20.Mul(t0, t8)
   616  
   617  	// Step 15: t2 = x^0x25
   618  	t2.Mul(t0, t20)
   619  
   620  	// Step 16: t14 = x^0x29
   621  	t14.Mul(t5, t20)
   622  
   623  	// Step 17: t4 = x^0x2b
   624  	t4.Mul(t0, t14)
   625  
   626  	// Step 18: t12 = x^0x2f
   627  	t12.Mul(t5, t14)
   628  
   629  	// Step 19: t9 = x^0x35
   630  	t9.Mul(t5, t12)
   631  
   632  	// Step 20: t3 = x^0x37
   633  	t3.Mul(t0, t9)
   634  
   635  	// Step 21: t5 = x^0x3b
   636  	t5.Mul(t5, t9)
   637  
   638  	// Step 22: t7 = x^0x3d
   639  	t7.Mul(t0, t5)
   640  
   641  	// Step 23: t15 = x^0x3f
   642  	t15.Mul(t0, t7)
   643  
   644  	// Step 24: t0 = x^0x7e
   645  	t0.Square(t15)
   646  
   647  	// Step 25: t0 = x^0x7f
   648  	t0.Mul(&x, t0)
   649  
   650  	// Step 26: t21 = x^0x98
   651  	t21.Mul(t6, t0)
   652  
   653  	// Step 33: t21 = x^0x4c00
   654  	for s := 0; s < 7; s++ {
   655  		t21.Square(t21)
   656  	}
   657  
   658  	// Step 34: t20 = x^0x4c23
   659  	t20.Mul(t20, t21)
   660  
   661  	// Step 37: t20 = x^0x26118
   662  	for s := 0; s < 3; s++ {
   663  		t20.Square(t20)
   664  	}
   665  
   666  	// Step 38: t20 = x^0x2611d
   667  	t20.Mul(t17, t20)
   668  
   669  	// Step 51: t20 = x^0x4c23a000
   670  	for s := 0; s < 13; s++ {
   671  		t20.Square(t20)
   672  	}
   673  
   674  	// Step 52: t20 = x^0x4c23a02b
   675  	t20.Mul(t4, t20)
   676  
   677  	// Step 57: t20 = x^0x984740560
   678  	for s := 0; s < 5; s++ {
   679  		t20.Square(t20)
   680  	}
   681  
   682  	// Step 58: t20 = x^0x98474056b
   683  	t20.Mul(t18, t20)
   684  
   685  	// Step 67: t20 = x^0x1308e80ad600
   686  	for s := 0; s < 9; s++ {
   687  		t20.Square(t20)
   688  	}
   689  
   690  	// Step 68: t19 = x^0x1308e80ad61b
   691  	t19.Mul(t19, t20)
   692  
   693  	// Step 73: t19 = x^0x2611d015ac360
   694  	for s := 0; s < 5; s++ {
   695  		t19.Square(t19)
   696  	}
   697  
   698  	// Step 74: t18 = x^0x2611d015ac36b
   699  	t18.Mul(t18, t19)
   700  
   701  	// Step 79: t18 = x^0x4c23a02b586d60
   702  	for s := 0; s < 5; s++ {
   703  		t18.Square(t18)
   704  	}
   705  
   706  	// Step 80: t17 = x^0x4c23a02b586d65
   707  	t17.Mul(t17, t18)
   708  
   709  	// Step 88: t17 = x^0x4c23a02b586d6500
   710  	for s := 0; s < 8; s++ {
   711  		t17.Square(t17)
   712  	}
   713  
   714  	// Step 89: t16 = x^0x4c23a02b586d650d
   715  	t16.Mul(t16, t17)
   716  
   717  	// Step 97: t16 = x^0x4c23a02b586d650d00
   718  	for s := 0; s < 8; s++ {
   719  		t16.Square(t16)
   720  	}
   721  
   722  	// Step 98: t15 = x^0x4c23a02b586d650d3f
   723  	t15.Mul(t15, t16)
   724  
   725  	// Step 104: t15 = x^0x1308e80ad61b59434fc0
   726  	for s := 0; s < 6; s++ {
   727  		t15.Square(t15)
   728  	}
   729  
   730  	// Step 105: t15 = x^0x1308e80ad61b59434fdd
   731  	t15.Mul(t11, t15)
   732  
   733  	// Step 112: t15 = x^0x98474056b0daca1a7ee80
   734  	for s := 0; s < 7; s++ {
   735  		t15.Square(t15)
   736  	}
   737  
   738  	// Step 113: t15 = x^0x98474056b0daca1a7ee93
   739  	t15.Mul(t1, t15)
   740  
   741  	// Step 122: t15 = x^0x1308e80ad61b59434fdd2600
   742  	for s := 0; s < 9; s++ {
   743  		t15.Square(t15)
   744  	}
   745  
   746  	// Step 123: t15 = x^0x1308e80ad61b59434fdd262f
   747  	t15.Mul(t12, t15)
   748  
   749  	// Step 129: t15 = x^0x4c23a02b586d650d3f7498bc0
   750  	for s := 0; s < 6; s++ {
   751  		t15.Square(t15)
   752  	}
   753  
   754  	// Step 130: t14 = x^0x4c23a02b586d650d3f7498be9
   755  	t14.Mul(t14, t15)
   756  
   757  	// Step 136: t14 = x^0x1308e80ad61b59434fdd262fa40
   758  	for s := 0; s < 6; s++ {
   759  		t14.Square(t14)
   760  	}
   761  
   762  	// Step 137: t13 = x^0x1308e80ad61b59434fdd262fa5f
   763  	t13.Mul(t13, t14)
   764  
   765  	// Step 146: t13 = x^0x2611d015ac36b2869fba4c5f4be00
   766  	for s := 0; s < 9; s++ {
   767  		t13.Square(t13)
   768  	}
   769  
   770  	// Step 147: t12 = x^0x2611d015ac36b2869fba4c5f4be2f
   771  	t12.Mul(t12, t13)
   772  
   773  	// Step 154: t12 = x^0x1308e80ad61b59434fdd262fa5f1780
   774  	for s := 0; s < 7; s++ {
   775  		t12.Square(t12)
   776  	}
   777  
   778  	// Step 155: t12 = x^0x1308e80ad61b59434fdd262fa5f17ab
   779  	t12.Mul(t4, t12)
   780  
   781  	// Step 161: t12 = x^0x4c23a02b586d650d3f7498be97c5eac0
   782  	for s := 0; s < 6; s++ {
   783  		t12.Square(t12)
   784  	}
   785  
   786  	// Step 162: t12 = x^0x4c23a02b586d650d3f7498be97c5eafd
   787  	t12.Mul(t7, t12)
   788  
   789  	// Step 168: t12 = x^0x1308e80ad61b59434fdd262fa5f17abf40
   790  	for s := 0; s < 6; s++ {
   791  		t12.Square(t12)
   792  	}
   793  
   794  	// Step 169: t12 = x^0x1308e80ad61b59434fdd262fa5f17abf7b
   795  	t12.Mul(t5, t12)
   796  
   797  	// Step 179: t12 = x^0x4c23a02b586d650d3f7498be97c5eafdec00
   798  	for s := 0; s < 10; s++ {
   799  		t12.Square(t12)
   800  	}
   801  
   802  	// Step 180: t11 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d
   803  	t11.Mul(t11, t12)
   804  
   805  	// Step 193: t11 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a000
   806  	for s := 0; s < 13; s++ {
   807  		t11.Square(t11)
   808  	}
   809  
   810  	// Step 194: t11 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a035
   811  	t11.Mul(t9, t11)
   812  
   813  	// Step 200: t11 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d40
   814  	for s := 0; s < 6; s++ {
   815  		t11.Square(t11)
   816  	}
   817  
   818  	// Step 201: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d51
   819  	t10.Mul(t10, t11)
   820  
   821  	// Step 209: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d5100
   822  	for s := 0; s < 8; s++ {
   823  		t10.Square(t10)
   824  	}
   825  
   826  	// Step 210: t10 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d
   827  	t10.Mul(t7, t10)
   828  
   829  	// Step 220: t10 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f400
   830  	for s := 0; s < 10; s++ {
   831  		t10.Square(t10)
   832  	}
   833  
   834  	// Step 221: t9 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435
   835  	t9.Mul(t9, t10)
   836  
   837  	// Step 223: t9 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d4
   838  	for s := 0; s < 2; s++ {
   839  		t9.Square(t9)
   840  	}
   841  
   842  	// Step 224: t9 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7
   843  	t9.Mul(z, t9)
   844  
   845  	// Step 236: t9 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7000
   846  	for s := 0; s < 12; s++ {
   847  		t9.Square(t9)
   848  	}
   849  
   850  	// Step 237: t8 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d7021
   851  	t8.Mul(t8, t9)
   852  
   853  	// Step 247: t8 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c08400
   854  	for s := 0; s < 10; s++ {
   855  		t8.Square(t8)
   856  	}
   857  
   858  	// Step 248: t7 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843d
   859  	t7.Mul(t7, t8)
   860  
   861  	// Step 253: t7 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087a0
   862  	for s := 0; s < 5; s++ {
   863  		t7.Square(t7)
   864  	}
   865  
   866  	// Step 254: t6 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b9
   867  	t6.Mul(t6, t7)
   868  
   869  	// Step 261: t6 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dc80
   870  	for s := 0; s < 7; s++ {
   871  		t6.Square(t6)
   872  	}
   873  
   874  	// Step 262: t5 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb
   875  	t5.Mul(t5, t6)
   876  
   877  	// Step 269: t5 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5d80
   878  	for s := 0; s < 7; s++ {
   879  		t5.Square(t5)
   880  	}
   881  
   882  	// Step 270: t5 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da5
   883  	t5.Mul(t2, t5)
   884  
   885  	// Step 278: t5 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da500
   886  	for s := 0; s < 8; s++ {
   887  		t5.Square(t5)
   888  	}
   889  
   890  	// Step 279: t4 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52b
   891  	t4.Mul(t4, t5)
   892  
   893  	// Step 285: t4 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694ac0
   894  	for s := 0; s < 6; s++ {
   895  		t4.Square(t4)
   896  	}
   897  
   898  	// Step 286: t3 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af7
   899  	t3.Mul(t3, t4)
   900  
   901  	// Step 292: t3 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bdc0
   902  	for s := 0; s < 6; s++ {
   903  		t3.Square(t3)
   904  	}
   905  
   906  	// Step 293: t2 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5
   907  	t2.Mul(t2, t3)
   908  
   909  	// Step 304: t2 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef2800
   910  	for s := 0; s < 11; s++ {
   911  		t2.Square(t2)
   912  	}
   913  
   914  	// Step 305: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef2813
   915  	t1.Mul(t1, t2)
   916  
   917  	// Step 313: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef281300
   918  	for s := 0; s < 8; s++ {
   919  		t1.Square(t1)
   920  	}
   921  
   922  	// Step 314: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f
   923  	t1.Mul(t0, t1)
   924  
   925  	// Step 316: t1 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb4a57bca04dfc
   926  	for s := 0; s < 2; s++ {
   927  		t1.Square(t1)
   928  	}
   929  
   930  	// Step 317: t1 = x^0x98474056b0daca1a7ee9317d2f8bd5fbd83a03544f435c0843dcbb4a57bca04dfd
   931  	t1.Mul(&x, t1)
   932  
   933  	// Step 327: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f400
   934  	for s := 0; s < 10; s++ {
   935  		t1.Square(t1)
   936  	}
   937  
   938  	// Step 328: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f401
   939  	t1.Mul(&x, t1)
   940  
   941  	// Step 336: t1 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f40100
   942  	for s := 0; s < 8; s++ {
   943  		t1.Square(t1)
   944  	}
   945  
   946  	// Step 337: t0 = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017f
   947  	t0.Mul(t0, t1)
   948  
   949  	// Step 338: t0 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802fe
   950  	t0.Square(t0)
   951  
   952  	// Step 339: t0 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802ff
   953  	t0.Mul(&x, t0)
   954  
   955  	// Step 341: t0 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af79409bfa00bfc
   956  	for s := 0; s < 2; s++ {
   957  		t0.Square(t0)
   958  	}
   959  
   960  	// Step 342: t0 = x^0x1308e80ad61b59434fdd262fa5f17abf7b07406a89e86b81087b97694af79409bfa00bfd
   961  	t0.Mul(&x, t0)
   962  
   963  	// Step 352: t0 = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802ff400
   964  	for s := 0; s < 10; s++ {
   965  		t0.Square(t0)
   966  	}
   967  
   968  	// Step 353: z = x^0x4c23a02b586d650d3f7498be97c5eafdec1d01aa27a1ae0421ee5da52bde5026fe802ff403
   969  	z.Mul(z, t0)
   970  
   971  	// Step 372: z = x^0x2611d015ac36b2869fba4c5f4be2f57ef60e80d513d0d70210f72ed295ef28137f4017fa0180000
   972  	for s := 0; s < 19; s++ {
   973  		z.Square(z)
   974  	}
   975  
   976  	return z
   977  }