github.com/emmansun/gmsm@v0.29.1/sm9/bn256/gfp2_sqrt.go (about) 1 // Code generated by addchain. DO NOT EDIT. 2 package bn256 3 4 func (e *gfP2) expPMinus1Over4(x *gfP2) *gfP2 { 5 // The sequence of 53 multiplications and 249 squarings is derived from the 6 // following addition chain generated with github.com/mmcloughlin/addchain v0.4.0. 7 // 8 // _10 = 2*1 9 // _100 = 2*_10 10 // _110 = _10 + _100 11 // _1010 = _100 + _110 12 // _1011 = 1 + _1010 13 // _1101 = _10 + _1011 14 // _10000 = _110 + _1010 15 // _10101 = _1010 + _1011 16 // _11011 = _110 + _10101 17 // _11101 = _10 + _11011 18 // _11111 = _10 + _11101 19 // _101001 = _1010 + _11111 20 // _101011 = _10 + _101001 21 // _111011 = _10000 + _101011 22 // _1000101 = _1010 + _111011 23 // _1001111 = _1010 + _1000101 24 // _1010001 = _10 + _1001111 25 // _1011011 = _1010 + _1010001 26 // _1011101 = _10 + _1011011 27 // _1011111 = _10 + _1011101 28 // _1100011 = _100 + _1011111 29 // _1101001 = _110 + _1100011 30 // _1101101 = _100 + _1101001 31 // _1101111 = _10 + _1101101 32 // _1110101 = _110 + _1101111 33 // i71 = ((_1011011 << 3 + 1) << 33 + _10101) << 8 34 // i93 = ((_11101 + i71) << 9 + _1101111) << 10 + _1110101 35 // i115 = ((2*i93 + 1) << 14 + _1110101) << 5 36 // i128 = 2*((_1101 + i115) << 9 + _1110101) + _10101 37 // i152 = ((i128 << 5 + _1011) << 9 + _111011) << 8 38 // i173 = ((_11101 + i152) << 9 + _101001) << 9 + _11111 39 // i200 = ((i173 << 8 + _101001) << 9 + _1101001) << 8 40 // i219 = ((_1100011 + i200) << 8 + _1001111) << 8 + _1011101 41 // i243 = ((i219 << 7 + _1101101) << 7 + _1011111) << 8 42 // i259 = ((_101011 + i243) << 6 + _11111) << 7 + _11011 43 // i285 = ((i259 << 9 + _1001111) << 7 + _1100011) << 8 44 // return ((_1010001 + i285) << 8 + _1000101) << 6 + _11111 45 // 46 var z = new(gfP2).Set(e) 47 var t0 = new(gfP2) 48 var t1 = new(gfP2) 49 var t2 = new(gfP2) 50 var t3 = new(gfP2) 51 var t4 = new(gfP2) 52 var t5 = new(gfP2) 53 var t6 = new(gfP2) 54 var t7 = new(gfP2) 55 var t8 = new(gfP2) 56 var t9 = new(gfP2) 57 var t10 = new(gfP2) 58 var t11 = new(gfP2) 59 var t12 = new(gfP2) 60 var t13 = new(gfP2) 61 var t14 = new(gfP2) 62 var t15 = new(gfP2) 63 var t16 = new(gfP2) 64 var t17 = new(gfP2) 65 var t18 = new(gfP2) 66 67 t17.Square(x) 68 t7.Square(t17) 69 t15.Mul(t17, t7) 70 t2.Mul(t7, t15) 71 t13.Mul(x, t2) 72 t16.Mul(t17, t13) 73 t0.Mul(t15, t2) 74 t14.Mul(t2, t13) 75 t4.Mul(t15, t14) 76 t11.Mul(t17, t4) 77 z.Mul(t17, t11) 78 t10.Mul(t2, z) 79 t5.Mul(t17, t10) 80 t12.Mul(t0, t5) 81 t0.Mul(t2, t12) 82 t3.Mul(t2, t0) 83 t1.Mul(t17, t3) 84 t18.Mul(t2, t1) 85 t8.Mul(t17, t18) 86 t6.Mul(t17, t8) 87 t2.Mul(t7, t6) 88 t9.Mul(t15, t2) 89 t7.Mul(t7, t9) 90 t17.Mul(t17, t7) 91 t15.Mul(t15, t17) 92 for s := 0; s < 3; s++ { 93 t18.Square(t18) 94 } 95 t18.Mul(x, t18) 96 for s := 0; s < 33; s++ { 97 t18.Square(t18) 98 } 99 t18.Mul(t14, t18) 100 for s := 0; s < 8; s++ { 101 t18.Square(t18) 102 } 103 t18.Mul(t11, t18) 104 for s := 0; s < 9; s++ { 105 t18.Square(t18) 106 } 107 t17.Mul(t17, t18) 108 for s := 0; s < 10; s++ { 109 t17.Square(t17) 110 } 111 t17.Mul(t15, t17) 112 t17.Square(t17) 113 t17.Mul(x, t17) 114 for s := 0; s < 14; s++ { 115 t17.Square(t17) 116 } 117 t17.Mul(t15, t17) 118 for s := 0; s < 5; s++ { 119 t17.Square(t17) 120 } 121 t16.Mul(t16, t17) 122 for s := 0; s < 9; s++ { 123 t16.Square(t16) 124 } 125 t15.Mul(t15, t16) 126 t15.Square(t15) 127 t14.Mul(t14, t15) 128 for s := 0; s < 5; s++ { 129 t14.Square(t14) 130 } 131 t13.Mul(t13, t14) 132 for s := 0; s < 9; s++ { 133 t13.Square(t13) 134 } 135 t12.Mul(t12, t13) 136 for s := 0; s < 8; s++ { 137 t12.Square(t12) 138 } 139 t11.Mul(t11, t12) 140 for s := 0; s < 9; s++ { 141 t11.Square(t11) 142 } 143 t11.Mul(t10, t11) 144 for s := 0; s < 9; s++ { 145 t11.Square(t11) 146 } 147 t11.Mul(z, t11) 148 for s := 0; s < 8; s++ { 149 t11.Square(t11) 150 } 151 t10.Mul(t10, t11) 152 for s := 0; s < 9; s++ { 153 t10.Square(t10) 154 } 155 t9.Mul(t9, t10) 156 for s := 0; s < 8; s++ { 157 t9.Square(t9) 158 } 159 t9.Mul(t2, t9) 160 for s := 0; s < 8; s++ { 161 t9.Square(t9) 162 } 163 t9.Mul(t3, t9) 164 for s := 0; s < 8; s++ { 165 t9.Square(t9) 166 } 167 t8.Mul(t8, t9) 168 for s := 0; s < 7; s++ { 169 t8.Square(t8) 170 } 171 t7.Mul(t7, t8) 172 for s := 0; s < 7; s++ { 173 t7.Square(t7) 174 } 175 t6.Mul(t6, t7) 176 for s := 0; s < 8; s++ { 177 t6.Square(t6) 178 } 179 t5.Mul(t5, t6) 180 for s := 0; s < 6; s++ { 181 t5.Square(t5) 182 } 183 t5.Mul(z, t5) 184 for s := 0; s < 7; s++ { 185 t5.Square(t5) 186 } 187 t4.Mul(t4, t5) 188 for s := 0; s < 9; s++ { 189 t4.Square(t4) 190 } 191 t3.Mul(t3, t4) 192 for s := 0; s < 7; s++ { 193 t3.Square(t3) 194 } 195 t2.Mul(t2, t3) 196 for s := 0; s < 8; s++ { 197 t2.Square(t2) 198 } 199 t1.Mul(t1, t2) 200 for s := 0; s < 8; s++ { 201 t1.Square(t1) 202 } 203 t0.Mul(t0, t1) 204 for s := 0; s < 6; s++ { 205 t0.Square(t0) 206 } 207 z.Mul(z, t0) 208 return e.Set(z) 209 } 210 211 func (e *gfP2) expP(x *gfP2) *gfP2 { 212 // The sequence of 56 multiplications and 250 squarings is derived from the 213 // following addition chain generated with github.com/mmcloughlin/addchain v0.4.0. 214 // 215 // _10 = 2*1 216 // _11 = 1 + _10 217 // _100 = 1 + _11 218 // _101 = 1 + _100 219 // _1000 = _11 + _101 220 // _1001 = 1 + _1000 221 // _1011 = _10 + _1001 222 // _1101 = _10 + _1011 223 // _10101 = _1000 + _1101 224 // _11001 = _100 + _10101 225 // _11101 = _100 + _11001 226 // _11111 = _10 + _11101 227 // _100011 = _100 + _11111 228 // _100101 = _10 + _100011 229 // _101001 = _100 + _100101 230 // _101011 = _10 + _101001 231 // _101101 = _10 + _101011 232 // _101111 = _10 + _101101 233 // _110011 = _100 + _101111 234 // _110101 = _10 + _110011 235 // _110111 = _10 + _110101 236 // _111011 = _100 + _110111 237 // _111101 = _10 + _111011 238 // _111111 = _10 + _111101 239 // _1011010 = _11101 + _111101 240 // i71 = ((_1011010 << 3 + _1001) << 33 + _10101) << 8 241 // i88 = ((_11101 + i71) << 8 + _110111) << 6 + _100011 242 // i115 = ((i88 << 6 + _101011) << 12 + _11101) << 7 243 // i128 = ((_101101 + i115) << 8 + _111111) << 2 + _11 244 // i152 = ((i128 << 5 + _1011) << 9 + _111011) << 8 245 // i173 = ((_11101 + i152) << 9 + _101001) << 9 + _11111 246 // i195 = ((i173 << 8 + _101001) << 6 + _1101) << 6 247 // i213 = ((_1011 + i195) << 7 + _1101) << 8 + _111101 248 // i234 = ((i213 << 7 + _111011) << 6 + _101101) << 6 249 // i250 = ((_101111 + i234) << 6 + _100101) << 7 + _110111 250 // i272 = ((i250 << 6 + _110011) << 6 + _11001) << 8 251 // i290 = ((_111111 + i272) << 9 + _110101) << 6 + _101 252 // return (i290 << 9 + _101011) << 5 + _11101 253 // 254 var z = new(gfP2).Set(e) 255 var t0 = new(gfP2) 256 var t1 = new(gfP2) 257 var t2 = new(gfP2) 258 var t3 = new(gfP2) 259 var t4 = new(gfP2) 260 var t5 = new(gfP2) 261 var t6 = new(gfP2) 262 var t7 = new(gfP2) 263 var t8 = new(gfP2) 264 var t9 = new(gfP2) 265 var t10 = new(gfP2) 266 var t11 = new(gfP2) 267 var t12 = new(gfP2) 268 var t13 = new(gfP2) 269 var t14 = new(gfP2) 270 var t15 = new(gfP2) 271 var t16 = new(gfP2) 272 var t17 = new(gfP2) 273 var t18 = new(gfP2) 274 var t19 = new(gfP2) 275 var t20 = new(gfP2) 276 277 t3.Square(x) 278 t16.Mul(x, t3) 279 t10.Mul(x, t16) 280 t1.Mul(x, t10) 281 z.Mul(t16, t1) 282 t19.Mul(x, z) 283 t13.Mul(t3, t19) 284 t12.Mul(t3, t13) 285 t18.Mul(z, t12) 286 t4.Mul(t10, t18) 287 z.Mul(t10, t4) 288 t15.Mul(t3, z) 289 t17.Mul(t10, t15) 290 t7.Mul(t3, t17) 291 t14.Mul(t10, t7) 292 t0.Mul(t3, t14) 293 t9.Mul(t3, t0) 294 t8.Mul(t3, t9) 295 t5.Mul(t10, t8) 296 t2.Mul(t3, t5) 297 t6.Mul(t3, t2) 298 t10.Mul(t10, t6) 299 t11.Mul(t3, t10) 300 t3.Mul(t3, t11) 301 t20.Mul(z, t11) 302 for s := 0; s < 3; s++ { 303 t20.Square(t20) 304 } 305 t19.Mul(t19, t20) 306 for s := 0; s < 33; s++ { 307 t19.Square(t19) 308 } 309 t18.Mul(t18, t19) 310 for s := 0; s < 8; s++ { 311 t18.Square(t18) 312 } 313 t18.Mul(z, t18) 314 for s := 0; s < 8; s++ { 315 t18.Square(t18) 316 } 317 t18.Mul(t6, t18) 318 for s := 0; s < 6; s++ { 319 t18.Square(t18) 320 } 321 t17.Mul(t17, t18) 322 for s := 0; s < 6; s++ { 323 t17.Square(t17) 324 } 325 t17.Mul(t0, t17) 326 for s := 0; s < 12; s++ { 327 t17.Square(t17) 328 } 329 t17.Mul(z, t17) 330 for s := 0; s < 7; s++ { 331 t17.Square(t17) 332 } 333 t17.Mul(t9, t17) 334 for s := 0; s < 8; s++ { 335 t17.Square(t17) 336 } 337 t17.Mul(t3, t17) 338 for s := 0; s < 2; s++ { 339 t17.Square(t17) 340 } 341 t16.Mul(t16, t17) 342 for s := 0; s < 5; s++ { 343 t16.Square(t16) 344 } 345 t16.Mul(t13, t16) 346 for s := 0; s < 9; s++ { 347 t16.Square(t16) 348 } 349 t16.Mul(t10, t16) 350 for s := 0; s < 8; s++ { 351 t16.Square(t16) 352 } 353 t16.Mul(z, t16) 354 for s := 0; s < 9; s++ { 355 t16.Square(t16) 356 } 357 t16.Mul(t14, t16) 358 for s := 0; s < 9; s++ { 359 t16.Square(t16) 360 } 361 t15.Mul(t15, t16) 362 for s := 0; s < 8; s++ { 363 t15.Square(t15) 364 } 365 t14.Mul(t14, t15) 366 for s := 0; s < 6; s++ { 367 t14.Square(t14) 368 } 369 t14.Mul(t12, t14) 370 for s := 0; s < 6; s++ { 371 t14.Square(t14) 372 } 373 t13.Mul(t13, t14) 374 for s := 0; s < 7; s++ { 375 t13.Square(t13) 376 } 377 t12.Mul(t12, t13) 378 for s := 0; s < 8; s++ { 379 t12.Square(t12) 380 } 381 t11.Mul(t11, t12) 382 for s := 0; s < 7; s++ { 383 t11.Square(t11) 384 } 385 t10.Mul(t10, t11) 386 for s := 0; s < 6; s++ { 387 t10.Square(t10) 388 } 389 t9.Mul(t9, t10) 390 for s := 0; s < 6; s++ { 391 t9.Square(t9) 392 } 393 t8.Mul(t8, t9) 394 for s := 0; s < 6; s++ { 395 t8.Square(t8) 396 } 397 t7.Mul(t7, t8) 398 for s := 0; s < 7; s++ { 399 t7.Square(t7) 400 } 401 t6.Mul(t6, t7) 402 for s := 0; s < 6; s++ { 403 t6.Square(t6) 404 } 405 t5.Mul(t5, t6) 406 for s := 0; s < 6; s++ { 407 t5.Square(t5) 408 } 409 t4.Mul(t4, t5) 410 for s := 0; s < 8; s++ { 411 t4.Square(t4) 412 } 413 t3.Mul(t3, t4) 414 for s := 0; s < 9; s++ { 415 t3.Square(t3) 416 } 417 t2.Mul(t2, t3) 418 for s := 0; s < 6; s++ { 419 t2.Square(t2) 420 } 421 t1.Mul(t1, t2) 422 for s := 0; s < 9; s++ { 423 t1.Square(t1) 424 } 425 t0.Mul(t0, t1) 426 for s := 0; s < 5; s++ { 427 t0.Square(t0) 428 } 429 z.Mul(z, t0) 430 return e.Set(z) 431 } 432 433 func (e *gfP2) expPMinus1Over2(x *gfP2) *gfP2 { 434 // The sequence of 53 multiplications and 250 squarings is derived from the 435 // following addition chain generated with github.com/mmcloughlin/addchain v0.4.0. 436 // 437 // _10 = 2*1 438 // _100 = 2*_10 439 // _110 = _10 + _100 440 // _1010 = _100 + _110 441 // _1011 = 1 + _1010 442 // _1101 = _10 + _1011 443 // _10000 = _110 + _1010 444 // _10101 = _1010 + _1011 445 // _11011 = _110 + _10101 446 // _11101 = _10 + _11011 447 // _11111 = _10 + _11101 448 // _101001 = _1010 + _11111 449 // _101011 = _10 + _101001 450 // _111011 = _10000 + _101011 451 // _1000101 = _1010 + _111011 452 // _1001111 = _1010 + _1000101 453 // _1010001 = _10 + _1001111 454 // _1011011 = _1010 + _1010001 455 // _1011101 = _10 + _1011011 456 // _1011111 = _10 + _1011101 457 // _1100011 = _100 + _1011111 458 // _1101001 = _110 + _1100011 459 // _1101101 = _100 + _1101001 460 // _1101111 = _10 + _1101101 461 // _1110101 = _110 + _1101111 462 // i71 = ((_1011011 << 3 + 1) << 33 + _10101) << 8 463 // i93 = ((_11101 + i71) << 9 + _1101111) << 10 + _1110101 464 // i115 = ((2*i93 + 1) << 14 + _1110101) << 5 465 // i128 = 2*((_1101 + i115) << 9 + _1110101) + _10101 466 // i152 = ((i128 << 5 + _1011) << 9 + _111011) << 8 467 // i173 = ((_11101 + i152) << 9 + _101001) << 9 + _11111 468 // i200 = ((i173 << 8 + _101001) << 9 + _1101001) << 8 469 // i219 = ((_1100011 + i200) << 8 + _1001111) << 8 + _1011101 470 // i243 = ((i219 << 7 + _1101101) << 7 + _1011111) << 8 471 // i259 = ((_101011 + i243) << 6 + _11111) << 7 + _11011 472 // i285 = ((i259 << 9 + _1001111) << 7 + _1100011) << 8 473 // i302 = ((_1010001 + i285) << 8 + _1000101) << 6 + _11111 474 // return 2*i302 475 // 476 var z = new(gfP2).Set(e) 477 var t0 = new(gfP2) 478 var t1 = new(gfP2) 479 var t2 = new(gfP2) 480 var t3 = new(gfP2) 481 var t4 = new(gfP2) 482 var t5 = new(gfP2) 483 var t6 = new(gfP2) 484 var t7 = new(gfP2) 485 var t8 = new(gfP2) 486 var t9 = new(gfP2) 487 var t10 = new(gfP2) 488 var t11 = new(gfP2) 489 var t12 = new(gfP2) 490 var t13 = new(gfP2) 491 var t14 = new(gfP2) 492 var t15 = new(gfP2) 493 var t16 = new(gfP2) 494 var t17 = new(gfP2) 495 var t18 = new(gfP2) 496 497 t17.Square(x) 498 t7.Square(t17) 499 t15.Mul(t17, t7) 500 t2.Mul(t7, t15) 501 t13.Mul(x, t2) 502 t16.Mul(t17, t13) 503 t0.Mul(t15, t2) 504 t14.Mul(t2, t13) 505 t4.Mul(t15, t14) 506 t11.Mul(t17, t4) 507 z.Mul(t17, t11) 508 t10.Mul(t2, z) 509 t5.Mul(t17, t10) 510 t12.Mul(t0, t5) 511 t0.Mul(t2, t12) 512 t3.Mul(t2, t0) 513 t1.Mul(t17, t3) 514 t18.Mul(t2, t1) 515 t8.Mul(t17, t18) 516 t6.Mul(t17, t8) 517 t2.Mul(t7, t6) 518 t9.Mul(t15, t2) 519 t7.Mul(t7, t9) 520 t17.Mul(t17, t7) 521 t15.Mul(t15, t17) 522 for s := 0; s < 3; s++ { 523 t18.Square(t18) 524 } 525 t18.Mul(x, t18) 526 for s := 0; s < 33; s++ { 527 t18.Square(t18) 528 } 529 t18.Mul(t14, t18) 530 for s := 0; s < 8; s++ { 531 t18.Square(t18) 532 } 533 t18.Mul(t11, t18) 534 for s := 0; s < 9; s++ { 535 t18.Square(t18) 536 } 537 t17.Mul(t17, t18) 538 for s := 0; s < 10; s++ { 539 t17.Square(t17) 540 } 541 t17.Mul(t15, t17) 542 t17.Square(t17) 543 t17.Mul(x, t17) 544 for s := 0; s < 14; s++ { 545 t17.Square(t17) 546 } 547 t17.Mul(t15, t17) 548 for s := 0; s < 5; s++ { 549 t17.Square(t17) 550 } 551 t16.Mul(t16, t17) 552 for s := 0; s < 9; s++ { 553 t16.Square(t16) 554 } 555 t15.Mul(t15, t16) 556 t15.Square(t15) 557 t14.Mul(t14, t15) 558 for s := 0; s < 5; s++ { 559 t14.Square(t14) 560 } 561 t13.Mul(t13, t14) 562 for s := 0; s < 9; s++ { 563 t13.Square(t13) 564 } 565 t12.Mul(t12, t13) 566 for s := 0; s < 8; s++ { 567 t12.Square(t12) 568 } 569 t11.Mul(t11, t12) 570 for s := 0; s < 9; s++ { 571 t11.Square(t11) 572 } 573 t11.Mul(t10, t11) 574 for s := 0; s < 9; s++ { 575 t11.Square(t11) 576 } 577 t11.Mul(z, t11) 578 for s := 0; s < 8; s++ { 579 t11.Square(t11) 580 } 581 t10.Mul(t10, t11) 582 for s := 0; s < 9; s++ { 583 t10.Square(t10) 584 } 585 t9.Mul(t9, t10) 586 for s := 0; s < 8; s++ { 587 t9.Square(t9) 588 } 589 t9.Mul(t2, t9) 590 for s := 0; s < 8; s++ { 591 t9.Square(t9) 592 } 593 t9.Mul(t3, t9) 594 for s := 0; s < 8; s++ { 595 t9.Square(t9) 596 } 597 t8.Mul(t8, t9) 598 for s := 0; s < 7; s++ { 599 t8.Square(t8) 600 } 601 t7.Mul(t7, t8) 602 for s := 0; s < 7; s++ { 603 t7.Square(t7) 604 } 605 t6.Mul(t6, t7) 606 for s := 0; s < 8; s++ { 607 t6.Square(t6) 608 } 609 t5.Mul(t5, t6) 610 for s := 0; s < 6; s++ { 611 t5.Square(t5) 612 } 613 t5.Mul(z, t5) 614 for s := 0; s < 7; s++ { 615 t5.Square(t5) 616 } 617 t4.Mul(t4, t5) 618 for s := 0; s < 9; s++ { 619 t4.Square(t4) 620 } 621 t3.Mul(t3, t4) 622 for s := 0; s < 7; s++ { 623 t3.Square(t3) 624 } 625 t2.Mul(t2, t3) 626 for s := 0; s < 8; s++ { 627 t2.Square(t2) 628 } 629 t1.Mul(t1, t2) 630 for s := 0; s < 8; s++ { 631 t1.Square(t1) 632 } 633 t0.Mul(t0, t1) 634 for s := 0; s < 6; s++ { 635 t0.Square(t0) 636 } 637 z.Mul(z, t0) 638 z.Square(z) 639 return e.Set(z) 640 }