------------------------------------------------
| 775 | |
| 776 | // ------------------------------------------------ |
| 777 | void Int::MontgomeryMult(Int *a) { |
| 778 | |
| 779 | // Compute a*b*R^-1 (mod n), R=2^k (mod n), k = Msize*64 |
| 780 | // a and b must be lower than n |
| 781 | // See SetupField() |
| 782 | |
| 783 | Int t; |
| 784 | Int pr; |
| 785 | Int p; |
| 786 | uint64_t ML; |
| 787 | uint64_t c; |
| 788 | |
| 789 | // i = 0 |
| 790 | imm_umul(a->bits64, bits64[0], pr.bits64); |
| 791 | ML = pr.bits64[0] * MM64; |
| 792 | imm_umul(_P.bits64, ML, p.bits64); |
| 793 | c = pr.AddC(&p); |
| 794 | memcpy(t.bits64, pr.bits64 + 1, 8 * (NB64BLOCK - 1)); |
| 795 | t.bits64[NB64BLOCK - 1] = c; |
| 796 | |
| 797 | for (int i = 1; i < Msize; i++) { |
| 798 | |
| 799 | imm_umul(a->bits64, bits64[i], pr.bits64); |
| 800 | ML = (pr.bits64[0] + t.bits64[0]) * MM64; |
| 801 | imm_umul(_P.bits64, ML, p.bits64); |
| 802 | c = pr.AddC(&p); |
| 803 | t.AddAndShift(&t, &pr, c); |
| 804 | |
| 805 | } |
| 806 | |
| 807 | p.Sub(&t,&_P); |
| 808 | if (p.IsPositive()) |
| 809 | Set(&p); |
| 810 | else |
| 811 | Set(&t); |
| 812 | |
| 813 | } |
| 814 | |
| 815 | void Int::MontgomeryMult(Int *a, Int *b) { |
| 816 |
no test coverage detected