------------------------------------------------
| 834 | |
| 835 | // ------------------------------------------------ |
| 836 | void Int::MontgomeryMult(Int *a) { |
| 837 | |
| 838 | // Compute a*b*R^-1 (mod n), R=2^k (mod n), k = Msize*64 |
| 839 | // a and b must be lower than n |
| 840 | // See SetupField() |
| 841 | |
| 842 | Int t; |
| 843 | Int pr; |
| 844 | Int p; |
| 845 | uint64_t ML; |
| 846 | uint64_t c; |
| 847 | |
| 848 | // i = 0 |
| 849 | imm_umul(a->bits64, bits64[0], pr.bits64); |
| 850 | ML = pr.bits64[0] * MM64; |
| 851 | imm_umul(_P.bits64, ML, p.bits64); |
| 852 | c = pr.AddC(&p); |
| 853 | memcpy(t.bits64, pr.bits64 + 1, 8 * (NB64BLOCK - 1)); |
| 854 | t.bits64[NB64BLOCK - 1] = c; |
| 855 | |
| 856 | for (int i = 1; i < Msize; i++) { |
| 857 | |
| 858 | imm_umul(a->bits64, bits64[i], pr.bits64); |
| 859 | ML = (pr.bits64[0] + t.bits64[0]) * MM64; |
| 860 | imm_umul(_P.bits64, ML, p.bits64); |
| 861 | c = pr.AddC(&p); |
| 862 | t.AddAndShift(&t, &pr, c); |
| 863 | |
| 864 | } |
| 865 | |
| 866 | p.Sub(&t,&_P); |
| 867 | if (p.IsPositive()) |
| 868 | Set(&p); |
| 869 | else |
| 870 | Set(&t); |
| 871 | |
| 872 | } |
| 873 | |
| 874 | void Int::MontgomeryMult(Int *a, Int *b) { |
| 875 |
no test coverage detected