|
20 | 20 | #include "hurchalla/util/conditional_select.h" |
21 | 21 | #include "hurchalla/util/cselect_on_bit.h" |
22 | 22 | #include "hurchalla/util/unsigned_multiply_to_hilo_product.h" |
| 23 | +#include "hurchalla/util/unsigned_square_to_hilo_product.h" |
23 | 24 | #include "hurchalla/util/compiler_macros.h" |
24 | 25 | #include "hurchalla/modular_arithmetic/detail/clockwork_programming_by_contract.h" |
25 | 26 | #include <type_traits> |
@@ -423,12 +424,12 @@ class MontyFullRangeMasked final : |
423 | 424 |
|
424 | 425 | // This function computes the full two-word product of x*x. It returns the |
425 | 426 | // high word of x*x, and writes the low word of x*x to u_lo. |
426 | | - HURCHALLA_FORCE_INLINE T squareToHiLo(T& u_lo, V x) const |
| 427 | + HURCHALLA_FORCE_INLINE T squareToHiLo(T& HURCHALLA_RESTRICT u_lo, V x) const |
427 | 428 | { |
428 | 429 | HPBC_CLOCKWORK_PRECONDITION2(isValid(x)); |
429 | 430 | T a = x.getbits(); |
430 | 431 | T umlo; |
431 | | - T umhi = ::hurchalla::unsigned_multiply_to_hilo_product(umlo, a, a); |
| 432 | + T umhi = ::hurchalla::unsigned_square_to_hilo_product(umlo, a); |
432 | 433 | T masked_a = static_cast<T>(x.getmask() & a); |
433 | 434 | T result_hi = static_cast<T>(umhi - masked_a - masked_a); |
434 | 435 | u_lo = umlo; |
@@ -511,9 +512,9 @@ class MontyFullRangeMasked final : |
511 | 512 | // Recall that asqrHi and asqrLo are simply any values that satisfy |
512 | 513 | // asqrHi*R + asqrLo == a*a, with 0 <= asqrHi < R and 0 <= asqrLo < R. |
513 | 514 | // When we compute |
514 | | - // T umlo; T umhi = unsigned_multiply_to_hilo_product(umlo, a, a); |
| 515 | + // T umlo; T umhi = unsigned_square_to_hilo_product(umlo, a); |
515 | 516 | // umhi and umlo satisfy these requirements, since all type T variables |
516 | | - // have bounds [0, R), and unsigned_multiply_to_hilo_product() computes |
| 517 | + // have bounds [0, R), and unsigned_square_to_hilo_product() computes |
517 | 518 | // the full two-word product of a*a. |
518 | 519 | // Therefore, since |
519 | 520 | // x*x == (asqrHi + s*(R-2*a))*R + asqrLo, we can substitute and get |
@@ -565,7 +566,7 @@ class MontyFullRangeMasked final : |
565 | 566 | // We can express all of this in code via |
566 | 567 | // T a = x.getbits(); |
567 | 568 | // T umlo; |
568 | | - // T umhi = ::hurchalla::unsigned_multiply_to_hilo_product(umlo, a, a); |
| 569 | + // T umhi = ::hurchalla::unsigned_square_to_hilo_product(umlo, a); |
569 | 570 | // T neg2a = static_cast<T>(-2) * a; |
570 | 571 | // T result_hi = umhi + (x.getmask() & neg2a); |
571 | 572 | // u_lo = umlo; |
|
0 commit comments