github.com/consensys/gnark-crypto@v0.14.0/ecc/bls24-317/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, 41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b95976acaab) 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 // _111 = _10 + _101 29 // _1001 = _10 + _111 30 // _1011 = _10 + _1001 31 // _1101 = _10 + _1011 32 // _1111 = _10 + _1101 33 // _10000 = 1 + _1111 34 // _10001 = 1 + _10000 35 // _10011 = _10 + _10001 36 // _10101 = _10 + _10011 37 // _10111 = _10 + _10101 38 // _11001 = _10 + _10111 39 // _11101 = _1101 + _10000 40 // _111010 = 2*_11101 41 // _111111 = _101 + _111010 42 // _1000000 = 1 + _111111 43 // i37 = ((_1000000 << 3 + _1011) << 8 + _11001) << 6 44 // i53 = ((_10001 + i37) << 8 + _10011) << 5 + _1111 45 // i74 = ((i53 << 3 + _11) << 10 + _10001) << 6 46 // i86 = ((_1001 + i74) << 6 + _11001) << 3 + _111 47 // i109 = ((i86 << 5 + _101) << 9 + _111111) << 7 48 // i123 = ((_1011 + i109) << 2 + 1) << 9 + _1011 49 // i141 = ((i123 << 7 + _111111) << 2 + _11) << 7 50 // i160 = ((_11101 + i141) << 9 + _111) << 7 + _10001 51 // i177 = ((i160 << 5 + _1101) << 6 + _1101) << 4 52 // i194 = ((_11 + i177) << 8 + _1111) << 6 + _1101 53 // i217 = ((i194 << 9 + _10011) << 6 + _111) << 6 54 // i232 = ((_1101 + i217) << 8 + _10001) << 4 + _1011 55 // i251 = ((i232 << 5 + _1011) << 5 + _1111) << 7 56 // i262 = ((_11001 + i251) << 5 + _11001) << 3 + _111 57 // i283 = ((i262 << 3 + 1) << 8 + _1101) << 8 58 // i296 = ((_1001 + i283) << 3 + 1) << 7 + _111111 59 // i316 = ((i296 << 7 + _111111) << 6 + _10001) << 5 60 // i332 = ((_10101 + i316) << 6 + _10001) << 7 + _10111 61 // i351 = ((i332 << 7 + _10101) << 4 + _1001) << 6 62 // i365 = ((_11101 + i351) << 5 + _10101) << 6 + _11001 63 // return (i365 << 6 + _10101) << 5 + _1011 64 // 65 // Operations: 310 squares 68 multiplies 66 67 // Allocate Temporaries. 68 var ( 69 t0 = new(Element) 70 t1 = new(Element) 71 t2 = new(Element) 72 t3 = new(Element) 73 t4 = new(Element) 74 t5 = new(Element) 75 t6 = new(Element) 76 t7 = new(Element) 77 t8 = new(Element) 78 t9 = new(Element) 79 t10 = new(Element) 80 t11 = new(Element) 81 t12 = new(Element) 82 t13 = new(Element) 83 ) 84 85 // var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13 Element 86 // Step 1: t1 = x^0x2 87 t1.Square(&x) 88 89 // Step 2: t11 = x^0x3 90 t11.Mul(&x, t1) 91 92 // Step 3: t12 = x^0x5 93 t12.Mul(t1, t11) 94 95 // Step 4: t8 = x^0x7 96 t8.Mul(t1, t12) 97 98 // Step 5: t3 = x^0x9 99 t3.Mul(t1, t8) 100 101 // Step 6: z = x^0xb 102 z.Mul(t1, t3) 103 104 // Step 7: t7 = x^0xd 105 t7.Mul(t1, z) 106 107 // Step 8: t9 = x^0xf 108 t9.Mul(t1, t7) 109 110 // Step 9: t2 = x^0x10 111 t2.Mul(&x, t9) 112 113 // Step 10: t5 = x^0x11 114 t5.Mul(&x, t2) 115 116 // Step 11: t10 = x^0x13 117 t10.Mul(t1, t5) 118 119 // Step 12: t0 = x^0x15 120 t0.Mul(t1, t10) 121 122 // Step 13: t4 = x^0x17 123 t4.Mul(t1, t0) 124 125 // Step 14: t1 = x^0x19 126 t1.Mul(t1, t4) 127 128 // Step 15: t2 = x^0x1d 129 t2.Mul(t7, t2) 130 131 // Step 16: t6 = x^0x3a 132 t6.Square(t2) 133 134 // Step 17: t6 = x^0x3f 135 t6.Mul(t12, t6) 136 137 // Step 18: t13 = x^0x40 138 t13.Mul(&x, t6) 139 140 // Step 21: t13 = x^0x200 141 for s := 0; s < 3; s++ { 142 t13.Square(t13) 143 } 144 145 // Step 22: t13 = x^0x20b 146 t13.Mul(z, t13) 147 148 // Step 30: t13 = x^0x20b00 149 for s := 0; s < 8; s++ { 150 t13.Square(t13) 151 } 152 153 // Step 31: t13 = x^0x20b19 154 t13.Mul(t1, t13) 155 156 // Step 37: t13 = x^0x82c640 157 for s := 0; s < 6; s++ { 158 t13.Square(t13) 159 } 160 161 // Step 38: t13 = x^0x82c651 162 t13.Mul(t5, t13) 163 164 // Step 46: t13 = x^0x82c65100 165 for s := 0; s < 8; s++ { 166 t13.Square(t13) 167 } 168 169 // Step 47: t13 = x^0x82c65113 170 t13.Mul(t10, t13) 171 172 // Step 52: t13 = x^0x1058ca2260 173 for s := 0; s < 5; s++ { 174 t13.Square(t13) 175 } 176 177 // Step 53: t13 = x^0x1058ca226f 178 t13.Mul(t9, t13) 179 180 // Step 56: t13 = x^0x82c6511378 181 for s := 0; s < 3; s++ { 182 t13.Square(t13) 183 } 184 185 // Step 57: t13 = x^0x82c651137b 186 t13.Mul(t11, t13) 187 188 // Step 67: t13 = x^0x20b19444dec00 189 for s := 0; s < 10; s++ { 190 t13.Square(t13) 191 } 192 193 // Step 68: t13 = x^0x20b19444dec11 194 t13.Mul(t5, t13) 195 196 // Step 74: t13 = x^0x82c651137b0440 197 for s := 0; s < 6; s++ { 198 t13.Square(t13) 199 } 200 201 // Step 75: t13 = x^0x82c651137b0449 202 t13.Mul(t3, t13) 203 204 // Step 81: t13 = x^0x20b19444dec11240 205 for s := 0; s < 6; s++ { 206 t13.Square(t13) 207 } 208 209 // Step 82: t13 = x^0x20b19444dec11259 210 t13.Mul(t1, t13) 211 212 // Step 85: t13 = x^0x1058ca226f60892c8 213 for s := 0; s < 3; s++ { 214 t13.Square(t13) 215 } 216 217 // Step 86: t13 = x^0x1058ca226f60892cf 218 t13.Mul(t8, t13) 219 220 // Step 91: t13 = x^0x20b19444dec11259e0 221 for s := 0; s < 5; s++ { 222 t13.Square(t13) 223 } 224 225 // Step 92: t12 = x^0x20b19444dec11259e5 226 t12.Mul(t12, t13) 227 228 // Step 101: t12 = x^0x41632889bd8224b3ca00 229 for s := 0; s < 9; s++ { 230 t12.Square(t12) 231 } 232 233 // Step 102: t12 = x^0x41632889bd8224b3ca3f 234 t12.Mul(t6, t12) 235 236 // Step 109: t12 = x^0x20b19444dec11259e51f80 237 for s := 0; s < 7; s++ { 238 t12.Square(t12) 239 } 240 241 // Step 110: t12 = x^0x20b19444dec11259e51f8b 242 t12.Mul(z, t12) 243 244 // Step 112: t12 = x^0x82c651137b044967947e2c 245 for s := 0; s < 2; s++ { 246 t12.Square(t12) 247 } 248 249 // Step 113: t12 = x^0x82c651137b044967947e2d 250 t12.Mul(&x, t12) 251 252 // Step 122: t12 = x^0x1058ca226f60892cf28fc5a00 253 for s := 0; s < 9; s++ { 254 t12.Square(t12) 255 } 256 257 // Step 123: t12 = x^0x1058ca226f60892cf28fc5a0b 258 t12.Mul(z, t12) 259 260 // Step 130: t12 = x^0x82c651137b044967947e2d0580 261 for s := 0; s < 7; s++ { 262 t12.Square(t12) 263 } 264 265 // Step 131: t12 = x^0x82c651137b044967947e2d05bf 266 t12.Mul(t6, t12) 267 268 // Step 133: t12 = x^0x20b19444dec11259e51f8b416fc 269 for s := 0; s < 2; s++ { 270 t12.Square(t12) 271 } 272 273 // Step 134: t12 = x^0x20b19444dec11259e51f8b416ff 274 t12.Mul(t11, t12) 275 276 // Step 141: t12 = x^0x1058ca226f60892cf28fc5a0b7f80 277 for s := 0; s < 7; s++ { 278 t12.Square(t12) 279 } 280 281 // Step 142: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d 282 t12.Mul(t2, t12) 283 284 // Step 151: t12 = x^0x20b19444dec11259e51f8b416ff3a00 285 for s := 0; s < 9; s++ { 286 t12.Square(t12) 287 } 288 289 // Step 152: t12 = x^0x20b19444dec11259e51f8b416ff3a07 290 t12.Mul(t8, t12) 291 292 // Step 159: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d0380 293 for s := 0; s < 7; s++ { 294 t12.Square(t12) 295 } 296 297 // Step 160: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d0391 298 t12.Mul(t5, t12) 299 300 // Step 165: t12 = x^0x20b19444dec11259e51f8b416ff3a07220 301 for s := 0; s < 5; s++ { 302 t12.Square(t12) 303 } 304 305 // Step 166: t12 = x^0x20b19444dec11259e51f8b416ff3a0722d 306 t12.Mul(t7, t12) 307 308 // Step 172: t12 = x^0x82c651137b044967947e2d05bfce81c8b40 309 for s := 0; s < 6; s++ { 310 t12.Square(t12) 311 } 312 313 // Step 173: t12 = x^0x82c651137b044967947e2d05bfce81c8b4d 314 t12.Mul(t7, t12) 315 316 // Step 177: t12 = x^0x82c651137b044967947e2d05bfce81c8b4d0 317 for s := 0; s < 4; s++ { 318 t12.Square(t12) 319 } 320 321 // Step 178: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d3 322 t11.Mul(t11, t12) 323 324 // Step 186: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d300 325 for s := 0; s < 8; s++ { 326 t11.Square(t11) 327 } 328 329 // Step 187: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d30f 330 t11.Mul(t9, t11) 331 332 // Step 193: t11 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3c0 333 for s := 0; s < 6; s++ { 334 t11.Square(t11) 335 } 336 337 // Step 194: t11 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd 338 t11.Mul(t7, t11) 339 340 // Step 203: t11 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a00 341 for s := 0; s < 9; s++ { 342 t11.Square(t11) 343 } 344 345 // Step 204: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a13 346 t10.Mul(t10, t11) 347 348 // Step 210: t10 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c0 349 for s := 0; s < 6; s++ { 350 t10.Square(t10) 351 } 352 353 // Step 211: t10 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c7 354 t10.Mul(t8, t10) 355 356 // Step 217: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131c0 357 for s := 0; s < 6; s++ { 358 t10.Square(t10) 359 } 360 361 // Step 218: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd 362 t10.Mul(t7, t10) 363 364 // Step 226: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd00 365 for s := 0; s < 8; s++ { 366 t10.Square(t10) 367 } 368 369 // Step 227: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11 370 t10.Mul(t5, t10) 371 372 // Step 231: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd110 373 for s := 0; s < 4; s++ { 374 t10.Square(t10) 375 } 376 377 // Step 232: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b 378 t10.Mul(z, t10) 379 380 // Step 237: t10 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a2360 381 for s := 0; s < 5; s++ { 382 t10.Square(t10) 383 } 384 385 // Step 238: t10 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b 386 t10.Mul(z, t10) 387 388 // Step 243: t10 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d60 389 for s := 0; s < 5; s++ { 390 t10.Square(t10) 391 } 392 393 // Step 244: t9 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f 394 t9.Mul(t9, t10) 395 396 // Step 251: t9 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b780 397 for s := 0; s < 7; s++ { 398 t9.Square(t9) 399 } 400 401 // Step 252: t9 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799 402 t9.Mul(t1, t9) 403 404 // Step 257: t9 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f320 405 for s := 0; s < 5; s++ { 406 t9.Square(t9) 407 } 408 409 // Step 258: t9 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339 410 t9.Mul(t1, t9) 411 412 // Step 261: t9 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799c8 413 for s := 0; s < 3; s++ { 414 t9.Square(t9) 415 } 416 417 // Step 262: t8 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf 418 t8.Mul(t8, t9) 419 420 // Step 265: t8 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce78 421 for s := 0; s < 3; s++ { 422 t8.Square(t8) 423 } 424 425 // Step 266: t8 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce79 426 t8.Mul(&x, t8) 427 428 // Step 274: t8 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce7900 429 for s := 0; s < 8; s++ { 430 t8.Square(t8) 431 } 432 433 // Step 275: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d 434 t7.Mul(t7, t8) 435 436 // Step 283: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d00 437 for s := 0; s < 8; s++ { 438 t7.Square(t7) 439 } 440 441 // Step 284: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d09 442 t7.Mul(t3, t7) 443 444 // Step 287: t7 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c86848 445 for s := 0; s < 3; s++ { 446 t7.Square(t7) 447 } 448 449 // Step 288: t7 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c86849 450 t7.Mul(&x, t7) 451 452 // Step 295: t7 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e4342480 453 for s := 0; s < 7; s++ { 454 t7.Square(t7) 455 } 456 457 // Step 296: t7 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf 458 t7.Mul(t6, t7) 459 460 // Step 303: t7 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125f80 461 for s := 0; s < 7; s++ { 462 t7.Square(t7) 463 } 464 465 // Step 304: t6 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf 466 t6.Mul(t6, t7) 467 468 // Step 310: t6 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efc0 469 for s := 0; s < 6; s++ { 470 t6.Square(t6) 471 } 472 473 // Step 311: t6 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1 474 t6.Mul(t5, t6) 475 476 // Step 316: t6 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa20 477 for s := 0; s < 5; s++ { 478 t6.Square(t6) 479 } 480 481 // Step 317: t6 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa35 482 t6.Mul(t0, t6) 483 484 // Step 323: t6 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d40 485 for s := 0; s < 6; s++ { 486 t6.Square(t6) 487 } 488 489 // Step 324: t5 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d51 490 t5.Mul(t5, t6) 491 492 // Step 331: t5 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a880 493 for s := 0; s < 7; s++ { 494 t5.Square(t5) 495 } 496 497 // Step 332: t4 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a897 498 t4.Mul(t4, t5) 499 500 // Step 339: t4 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b80 501 for s := 0; s < 7; s++ { 502 t4.Square(t4) 503 } 504 505 // Step 340: t4 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b95 506 t4.Mul(t0, t4) 507 508 // Step 344: t4 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b950 509 for s := 0; s < 4; s++ { 510 t4.Square(t4) 511 } 512 513 // Step 345: t3 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b959 514 t3.Mul(t3, t4) 515 516 // Step 351: t3 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d512e5640 517 for s := 0; s < 6; s++ { 518 t3.Square(t3) 519 } 520 521 // Step 352: t2 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d512e565d 522 t2.Mul(t2, t3) 523 524 // Step 357: t2 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacba0 525 for s := 0; s < 5; s++ { 526 t2.Square(t2) 527 } 528 529 // Step 358: t2 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5 530 t2.Mul(t0, t2) 531 532 // Step 364: t2 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed40 533 for s := 0; s < 6; s++ { 534 t2.Square(t2) 535 } 536 537 // Step 365: t1 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed59 538 t1.Mul(t1, t2) 539 540 // Step 371: t1 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5640 541 for s := 0; s < 6; s++ { 542 t1.Square(t1) 543 } 544 545 // Step 372: t0 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5655 546 t0.Mul(t0, t1) 547 548 // Step 377: t0 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b95976acaa0 549 for s := 0; s < 5; s++ { 550 t0.Square(t0) 551 } 552 553 // Step 378: z = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b95976acaab 554 z.Mul(z, t0) 555 556 return z 557 } 558 559 // expByLegendreExp is equivalent to z.Exp(x, 82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed59555) 560 // 561 // uses github.com/mmcloughlin/addchain v0.4.0 to generate a shorter addition chain 562 func (z *Element) expByLegendreExp(x Element) *Element { 563 // addition chain: 564 // 565 // _10 = 2*1 566 // _11 = 1 + _10 567 // _101 = _10 + _11 568 // _111 = _10 + _101 569 // _1001 = _10 + _111 570 // _1011 = _10 + _1001 571 // _1101 = _10 + _1011 572 // _1111 = _10 + _1101 573 // _10000 = 1 + _1111 574 // _10001 = 1 + _10000 575 // _10011 = _10 + _10001 576 // _10101 = _10 + _10011 577 // _10111 = _10 + _10101 578 // _11001 = _10 + _10111 579 // _11101 = _1101 + _10000 580 // _111010 = 2*_11101 581 // _111111 = _101 + _111010 582 // _1000000 = 1 + _111111 583 // i37 = ((_1000000 << 3 + _1011) << 8 + _11001) << 6 584 // i53 = ((_10001 + i37) << 8 + _10011) << 5 + _1111 585 // i74 = ((i53 << 3 + _11) << 10 + _10001) << 6 586 // i86 = ((_1001 + i74) << 6 + _11001) << 3 + _111 587 // i109 = ((i86 << 5 + _101) << 9 + _111111) << 7 588 // i123 = ((_1011 + i109) << 2 + 1) << 9 + _1011 589 // i141 = ((i123 << 7 + _111111) << 2 + _11) << 7 590 // i160 = ((_11101 + i141) << 9 + _111) << 7 + _10001 591 // i177 = ((i160 << 5 + _1101) << 6 + _1101) << 4 592 // i194 = ((_11 + i177) << 8 + _1111) << 6 + _1101 593 // i217 = ((i194 << 9 + _10011) << 6 + _111) << 6 594 // i232 = ((_1101 + i217) << 8 + _10001) << 4 + _1011 595 // i251 = ((i232 << 5 + _1011) << 5 + _1111) << 7 596 // i262 = ((_11001 + i251) << 5 + _11001) << 3 + _111 597 // i283 = ((i262 << 3 + 1) << 8 + _1101) << 8 598 // i296 = ((_1001 + i283) << 3 + 1) << 7 + _111111 599 // i316 = ((i296 << 7 + _111111) << 6 + _10001) << 5 600 // i332 = ((_10101 + i316) << 6 + _10001) << 7 + _10111 601 // i351 = ((i332 << 7 + _10101) << 4 + _1001) << 6 602 // i365 = ((_11101 + i351) << 5 + _10101) << 6 + _11001 603 // return (i365 << 6 + _10101) << 6 + _10101 604 // 605 // Operations: 311 squares 68 multiplies 606 607 // Allocate Temporaries. 608 var ( 609 t0 = new(Element) 610 t1 = new(Element) 611 t2 = new(Element) 612 t3 = new(Element) 613 t4 = new(Element) 614 t5 = new(Element) 615 t6 = new(Element) 616 t7 = new(Element) 617 t8 = new(Element) 618 t9 = new(Element) 619 t10 = new(Element) 620 t11 = new(Element) 621 t12 = new(Element) 622 t13 = new(Element) 623 ) 624 625 // var t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13 Element 626 // Step 1: t0 = x^0x2 627 t0.Square(&x) 628 629 // Step 2: t11 = x^0x3 630 t11.Mul(&x, t0) 631 632 // Step 3: t12 = x^0x5 633 t12.Mul(t0, t11) 634 635 // Step 4: t7 = x^0x7 636 t7.Mul(t0, t12) 637 638 // Step 5: t2 = x^0x9 639 t2.Mul(t0, t7) 640 641 // Step 6: t9 = x^0xb 642 t9.Mul(t0, t2) 643 644 // Step 7: t6 = x^0xd 645 t6.Mul(t0, t9) 646 647 // Step 8: t8 = x^0xf 648 t8.Mul(t0, t6) 649 650 // Step 9: t1 = x^0x10 651 t1.Mul(&x, t8) 652 653 // Step 10: t4 = x^0x11 654 t4.Mul(&x, t1) 655 656 // Step 11: t10 = x^0x13 657 t10.Mul(t0, t4) 658 659 // Step 12: z = x^0x15 660 z.Mul(t0, t10) 661 662 // Step 13: t3 = x^0x17 663 t3.Mul(t0, z) 664 665 // Step 14: t0 = x^0x19 666 t0.Mul(t0, t3) 667 668 // Step 15: t1 = x^0x1d 669 t1.Mul(t6, t1) 670 671 // Step 16: t5 = x^0x3a 672 t5.Square(t1) 673 674 // Step 17: t5 = x^0x3f 675 t5.Mul(t12, t5) 676 677 // Step 18: t13 = x^0x40 678 t13.Mul(&x, t5) 679 680 // Step 21: t13 = x^0x200 681 for s := 0; s < 3; s++ { 682 t13.Square(t13) 683 } 684 685 // Step 22: t13 = x^0x20b 686 t13.Mul(t9, t13) 687 688 // Step 30: t13 = x^0x20b00 689 for s := 0; s < 8; s++ { 690 t13.Square(t13) 691 } 692 693 // Step 31: t13 = x^0x20b19 694 t13.Mul(t0, t13) 695 696 // Step 37: t13 = x^0x82c640 697 for s := 0; s < 6; s++ { 698 t13.Square(t13) 699 } 700 701 // Step 38: t13 = x^0x82c651 702 t13.Mul(t4, t13) 703 704 // Step 46: t13 = x^0x82c65100 705 for s := 0; s < 8; s++ { 706 t13.Square(t13) 707 } 708 709 // Step 47: t13 = x^0x82c65113 710 t13.Mul(t10, t13) 711 712 // Step 52: t13 = x^0x1058ca2260 713 for s := 0; s < 5; s++ { 714 t13.Square(t13) 715 } 716 717 // Step 53: t13 = x^0x1058ca226f 718 t13.Mul(t8, t13) 719 720 // Step 56: t13 = x^0x82c6511378 721 for s := 0; s < 3; s++ { 722 t13.Square(t13) 723 } 724 725 // Step 57: t13 = x^0x82c651137b 726 t13.Mul(t11, t13) 727 728 // Step 67: t13 = x^0x20b19444dec00 729 for s := 0; s < 10; s++ { 730 t13.Square(t13) 731 } 732 733 // Step 68: t13 = x^0x20b19444dec11 734 t13.Mul(t4, t13) 735 736 // Step 74: t13 = x^0x82c651137b0440 737 for s := 0; s < 6; s++ { 738 t13.Square(t13) 739 } 740 741 // Step 75: t13 = x^0x82c651137b0449 742 t13.Mul(t2, t13) 743 744 // Step 81: t13 = x^0x20b19444dec11240 745 for s := 0; s < 6; s++ { 746 t13.Square(t13) 747 } 748 749 // Step 82: t13 = x^0x20b19444dec11259 750 t13.Mul(t0, t13) 751 752 // Step 85: t13 = x^0x1058ca226f60892c8 753 for s := 0; s < 3; s++ { 754 t13.Square(t13) 755 } 756 757 // Step 86: t13 = x^0x1058ca226f60892cf 758 t13.Mul(t7, t13) 759 760 // Step 91: t13 = x^0x20b19444dec11259e0 761 for s := 0; s < 5; s++ { 762 t13.Square(t13) 763 } 764 765 // Step 92: t12 = x^0x20b19444dec11259e5 766 t12.Mul(t12, t13) 767 768 // Step 101: t12 = x^0x41632889bd8224b3ca00 769 for s := 0; s < 9; s++ { 770 t12.Square(t12) 771 } 772 773 // Step 102: t12 = x^0x41632889bd8224b3ca3f 774 t12.Mul(t5, t12) 775 776 // Step 109: t12 = x^0x20b19444dec11259e51f80 777 for s := 0; s < 7; s++ { 778 t12.Square(t12) 779 } 780 781 // Step 110: t12 = x^0x20b19444dec11259e51f8b 782 t12.Mul(t9, t12) 783 784 // Step 112: t12 = x^0x82c651137b044967947e2c 785 for s := 0; s < 2; s++ { 786 t12.Square(t12) 787 } 788 789 // Step 113: t12 = x^0x82c651137b044967947e2d 790 t12.Mul(&x, t12) 791 792 // Step 122: t12 = x^0x1058ca226f60892cf28fc5a00 793 for s := 0; s < 9; s++ { 794 t12.Square(t12) 795 } 796 797 // Step 123: t12 = x^0x1058ca226f60892cf28fc5a0b 798 t12.Mul(t9, t12) 799 800 // Step 130: t12 = x^0x82c651137b044967947e2d0580 801 for s := 0; s < 7; s++ { 802 t12.Square(t12) 803 } 804 805 // Step 131: t12 = x^0x82c651137b044967947e2d05bf 806 t12.Mul(t5, t12) 807 808 // Step 133: t12 = x^0x20b19444dec11259e51f8b416fc 809 for s := 0; s < 2; s++ { 810 t12.Square(t12) 811 } 812 813 // Step 134: t12 = x^0x20b19444dec11259e51f8b416ff 814 t12.Mul(t11, t12) 815 816 // Step 141: t12 = x^0x1058ca226f60892cf28fc5a0b7f80 817 for s := 0; s < 7; s++ { 818 t12.Square(t12) 819 } 820 821 // Step 142: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d 822 t12.Mul(t1, t12) 823 824 // Step 151: t12 = x^0x20b19444dec11259e51f8b416ff3a00 825 for s := 0; s < 9; s++ { 826 t12.Square(t12) 827 } 828 829 // Step 152: t12 = x^0x20b19444dec11259e51f8b416ff3a07 830 t12.Mul(t7, t12) 831 832 // Step 159: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d0380 833 for s := 0; s < 7; s++ { 834 t12.Square(t12) 835 } 836 837 // Step 160: t12 = x^0x1058ca226f60892cf28fc5a0b7f9d0391 838 t12.Mul(t4, t12) 839 840 // Step 165: t12 = x^0x20b19444dec11259e51f8b416ff3a07220 841 for s := 0; s < 5; s++ { 842 t12.Square(t12) 843 } 844 845 // Step 166: t12 = x^0x20b19444dec11259e51f8b416ff3a0722d 846 t12.Mul(t6, t12) 847 848 // Step 172: t12 = x^0x82c651137b044967947e2d05bfce81c8b40 849 for s := 0; s < 6; s++ { 850 t12.Square(t12) 851 } 852 853 // Step 173: t12 = x^0x82c651137b044967947e2d05bfce81c8b4d 854 t12.Mul(t6, t12) 855 856 // Step 177: t12 = x^0x82c651137b044967947e2d05bfce81c8b4d0 857 for s := 0; s < 4; s++ { 858 t12.Square(t12) 859 } 860 861 // Step 178: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d3 862 t11.Mul(t11, t12) 863 864 // Step 186: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d300 865 for s := 0; s < 8; s++ { 866 t11.Square(t11) 867 } 868 869 // Step 187: t11 = x^0x82c651137b044967947e2d05bfce81c8b4d30f 870 t11.Mul(t8, t11) 871 872 // Step 193: t11 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3c0 873 for s := 0; s < 6; s++ { 874 t11.Square(t11) 875 } 876 877 // Step 194: t11 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd 878 t11.Mul(t6, t11) 879 880 // Step 203: t11 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a00 881 for s := 0; s < 9; s++ { 882 t11.Square(t11) 883 } 884 885 // Step 204: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a13 886 t10.Mul(t10, t11) 887 888 // Step 210: t10 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c0 889 for s := 0; s < 6; s++ { 890 t10.Square(t10) 891 } 892 893 // Step 211: t10 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c7 894 t10.Mul(t7, t10) 895 896 // Step 217: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131c0 897 for s := 0; s < 6; s++ { 898 t10.Square(t10) 899 } 900 901 // Step 218: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd 902 t10.Mul(t6, t10) 903 904 // Step 226: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd00 905 for s := 0; s < 8; s++ { 906 t10.Square(t10) 907 } 908 909 // Step 227: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11 910 t10.Mul(t4, t10) 911 912 // Step 231: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd110 913 for s := 0; s < 4; s++ { 914 t10.Square(t10) 915 } 916 917 // Step 232: t10 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b 918 t10.Mul(t9, t10) 919 920 // Step 237: t10 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a2360 921 for s := 0; s < 5; s++ { 922 t10.Square(t10) 923 } 924 925 // Step 238: t9 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b 926 t9.Mul(t9, t10) 927 928 // Step 243: t9 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d60 929 for s := 0; s < 5; s++ { 930 t9.Square(t9) 931 } 932 933 // Step 244: t8 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f 934 t8.Mul(t8, t9) 935 936 // Step 251: t8 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b780 937 for s := 0; s < 7; s++ { 938 t8.Square(t8) 939 } 940 941 // Step 252: t8 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799 942 t8.Mul(t0, t8) 943 944 // Step 257: t8 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f320 945 for s := 0; s < 5; s++ { 946 t8.Square(t8) 947 } 948 949 // Step 258: t8 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339 950 t8.Mul(t0, t8) 951 952 // Step 261: t8 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799c8 953 for s := 0; s < 3; s++ { 954 t8.Square(t8) 955 } 956 957 // Step 262: t7 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf 958 t7.Mul(t7, t8) 959 960 // Step 265: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce78 961 for s := 0; s < 3; s++ { 962 t7.Square(t7) 963 } 964 965 // Step 266: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce79 966 t7.Mul(&x, t7) 967 968 // Step 274: t7 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce7900 969 for s := 0; s < 8; s++ { 970 t7.Square(t7) 971 } 972 973 // Step 275: t6 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d 974 t6.Mul(t6, t7) 975 976 // Step 283: t6 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d00 977 for s := 0; s < 8; s++ { 978 t6.Square(t6) 979 } 980 981 // Step 284: t6 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d09 982 t6.Mul(t2, t6) 983 984 // Step 287: t6 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c86848 985 for s := 0; s < 3; s++ { 986 t6.Square(t6) 987 } 988 989 // Step 288: t6 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c86849 990 t6.Mul(&x, t6) 991 992 // Step 295: t6 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e4342480 993 for s := 0; s < 7; s++ { 994 t6.Square(t6) 995 } 996 997 // Step 296: t6 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf 998 t6.Mul(t5, t6) 999 1000 // Step 303: t6 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125f80 1001 for s := 0; s < 7; s++ { 1002 t6.Square(t6) 1003 } 1004 1005 // Step 304: t5 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf 1006 t5.Mul(t5, t6) 1007 1008 // Step 310: t5 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efc0 1009 for s := 0; s < 6; s++ { 1010 t5.Square(t5) 1011 } 1012 1013 // Step 311: t5 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1 1014 t5.Mul(t4, t5) 1015 1016 // Step 316: t5 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa20 1017 for s := 0; s < 5; s++ { 1018 t5.Square(t5) 1019 } 1020 1021 // Step 317: t5 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa35 1022 t5.Mul(z, t5) 1023 1024 // Step 323: t5 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d40 1025 for s := 0; s < 6; s++ { 1026 t5.Square(t5) 1027 } 1028 1029 // Step 324: t4 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d51 1030 t4.Mul(t4, t5) 1031 1032 // Step 331: t4 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a880 1033 for s := 0; s < 7; s++ { 1034 t4.Square(t4) 1035 } 1036 1037 // Step 332: t3 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a897 1038 t3.Mul(t3, t4) 1039 1040 // Step 339: t3 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b80 1041 for s := 0; s < 7; s++ { 1042 t3.Square(t3) 1043 } 1044 1045 // Step 340: t3 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b95 1046 t3.Mul(z, t3) 1047 1048 // Step 344: t3 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b950 1049 for s := 0; s < 4; s++ { 1050 t3.Square(t3) 1051 } 1052 1053 // Step 345: t2 = x^0x41632889bd8224b3ca3f1682dfe740e45a69879a131cd11b5bcce790d092fdfa3544b959 1054 t2.Mul(t2, t3) 1055 1056 // Step 351: t2 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d512e5640 1057 for s := 0; s < 6; s++ { 1058 t2.Square(t2) 1059 } 1060 1061 // Step 352: t1 = x^0x1058ca226f60892cf28fc5a0b7f9d039169a61e684c73446d6f339e43424bf7e8d512e565d 1062 t1.Mul(t1, t2) 1063 1064 // Step 357: t1 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacba0 1065 for s := 0; s < 5; s++ { 1066 t1.Square(t1) 1067 } 1068 1069 // Step 358: t1 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5 1070 t1.Mul(z, t1) 1071 1072 // Step 364: t1 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed40 1073 for s := 0; s < 6; s++ { 1074 t1.Square(t1) 1075 } 1076 1077 // Step 365: t0 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed59 1078 t0.Mul(t0, t1) 1079 1080 // Step 371: t0 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5640 1081 for s := 0; s < 6; s++ { 1082 t0.Square(t0) 1083 } 1084 1085 // Step 372: t0 = x^0x20b19444dec11259e51f8b416ff3a0722d34c3cd098e688dade673c868497efd1aa25cacbb5655 1086 t0.Mul(z, t0) 1087 1088 // Step 378: t0 = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed59540 1089 for s := 0; s < 6; s++ { 1090 t0.Square(t0) 1091 } 1092 1093 // Step 379: z = x^0x82c651137b044967947e2d05bfce81c8b4d30f342639a236b799cf21a125fbf46a8972b2ed59555 1094 z.Mul(z, t0) 1095 1096 return z 1097 }