| 683 | // ------------------------------------------------ |
| 684 | |
| 685 | void Int::SetupField(Int *n, Int *R, Int *R2, Int *R3, Int *R4) { |
| 686 | |
| 687 | // Size in number of 32bit word |
| 688 | int nSize = n->GetSize(); |
| 689 | |
| 690 | // Last digit inversions (Newton's iteration) |
| 691 | { |
| 692 | int64_t x, t; |
| 693 | x = t = (int64_t)n->bits64[0]; |
| 694 | x = x * (2 - t * x); |
| 695 | x = x * (2 - t * x); |
| 696 | x = x * (2 - t * x); |
| 697 | x = x * (2 - t * x); |
| 698 | x = x * (2 - t * x); |
| 699 | MM64 = (uint64_t)(-x); |
| 700 | MM32 = (uint32_t)MM64; |
| 701 | } |
| 702 | _P.Set(n); |
| 703 | |
| 704 | // Size of Montgomery mult (64bits digit) |
| 705 | Msize = nSize/2; |
| 706 | |
| 707 | // Compute few power of R |
| 708 | // R = 2^(64*Msize) mod n |
| 709 | Int Ri; |
| 710 | Ri.MontgomeryMult(&_ONE, &_ONE); // Ri = R^-1 |
| 711 | _R.Set(&Ri); // R = R^-1 |
| 712 | _R2.MontgomeryMult(&Ri, &_ONE); // R2 = R^-2 |
| 713 | _R3.MontgomeryMult(&Ri, &Ri); // R3 = R^-3 |
| 714 | _R4.MontgomeryMult(&_R3, &_ONE); // R4 = R^-4 |
| 715 | |
| 716 | _R.ModInv(); // R = R |
| 717 | _R2.ModInv(); // R2 = R^2 |
| 718 | _R3.ModInv(); // R3 = R^3 |
| 719 | _R4.ModInv(); // R4 = R^4 |
| 720 | |
| 721 | if (R) |
| 722 | R->Set(&_R); |
| 723 | |
| 724 | if (R2) |
| 725 | R2->Set(&_R2); |
| 726 | |
| 727 | if (R3) |
| 728 | R3->Set(&_R3); |
| 729 | |
| 730 | if (R4) |
| 731 | R4->Set(&_R4); |
| 732 | |
| 733 | } |
| 734 | // ------------------------------------------------ |
| 735 | |
| 736 | uint64_t Int::AddC(Int *a) { |
nothing calls this directly
no test coverage detected