@@ -1866,7 +1866,7 @@ static int test_mp_root_u32(void)
18661866 return EXIT_FAILURE ;
18671867}
18681868
1869- static int test_s_mp_balance_mul (void )
1869+ static int test_s_mp_mul_balance (void )
18701870{
18711871 mp_int a , b , c ;
18721872
@@ -1881,7 +1881,7 @@ static int test_s_mp_balance_mul(void)
18811881 DO (mp_read_radix (& a , na , 64 ));
18821882 DO (mp_read_radix (& b , nb , 64 ));
18831883
1884- DO (s_mp_balance_mul (& a , & b , & c ));
1884+ DO (s_mp_mul_balance (& a , & b , & c ));
18851885
18861886 DO (mp_read_radix (& b , nc , 64 ));
18871887
@@ -1896,18 +1896,18 @@ static int test_s_mp_balance_mul(void)
18961896 return EXIT_FAILURE ;
18971897}
18981898
1899- #define s_mp_mul (a , b , c ) s_mp_mul_digs (a, b, c, (a)->used + (b)->used + 1)
1900- static int test_s_mp_karatsuba_mul (void )
1899+ #define s_mp_mul_full (a , b , c ) s_mp_mul (a, b, c, (a)->used + (b)->used + 1)
1900+ static int test_s_mp_mul_karatsuba (void )
19011901{
19021902 mp_int a , b , c , d ;
19031903 int size ;
19041904
19051905 DOR (mp_init_multi (& a , & b , & c , & d , NULL ));
1906- for (size = MP_KARATSUBA_MUL_CUTOFF ; size < MP_KARATSUBA_MUL_CUTOFF + 20 ; size ++ ) {
1906+ for (size = MP_MUL_KARATSUBA_CUTOFF ; size < MP_MUL_KARATSUBA_CUTOFF + 20 ; size ++ ) {
19071907 DO (mp_rand (& a , size ));
19081908 DO (mp_rand (& b , size ));
1909- DO (s_mp_karatsuba_mul (& a , & b , & c ));
1910- DO (s_mp_mul (& a ,& b ,& d ));
1909+ DO (s_mp_mul_karatsuba (& a , & b , & c ));
1910+ DO (s_mp_mul_full (& a ,& b ,& d ));
19111911 if (mp_cmp (& c , & d ) != MP_EQ ) {
19121912 fprintf (stderr , "Karatsuba multiplication failed at size %d\n" , size );
19131913 goto LBL_ERR ;
@@ -1921,15 +1921,15 @@ static int test_s_mp_karatsuba_mul(void)
19211921 return EXIT_FAILURE ;
19221922}
19231923
1924- static int test_s_mp_karatsuba_sqr (void )
1924+ static int test_s_mp_sqr_karatsuba (void )
19251925{
19261926 mp_int a , b , c ;
19271927 int size ;
19281928
19291929 DOR (mp_init_multi (& a , & b , & c , NULL ));
1930- for (size = MP_KARATSUBA_SQR_CUTOFF ; size < MP_KARATSUBA_SQR_CUTOFF + 20 ; size ++ ) {
1930+ for (size = MP_SQR_KARATSUBA_CUTOFF ; size < MP_SQR_KARATSUBA_CUTOFF + 20 ; size ++ ) {
19311931 DO (mp_rand (& a , size ));
1932- DO (s_mp_karatsuba_sqr (& a , & b ));
1932+ DO (s_mp_sqr_karatsuba (& a , & b ));
19331933 DO (s_mp_sqr (& a , & c ));
19341934 if (mp_cmp (& b , & c ) != MP_EQ ) {
19351935 fprintf (stderr , "Karatsuba squaring failed at size %d\n" , size );
@@ -1944,7 +1944,7 @@ static int test_s_mp_karatsuba_sqr(void)
19441944 return EXIT_FAILURE ;
19451945}
19461946
1947- static int test_s_mp_toom_mul (void )
1947+ static int test_s_mp_mul_toom (void )
19481948{
19491949 mp_int a , b , c , d ;
19501950 int size ;
@@ -1965,22 +1965,22 @@ static int test_s_mp_toom_mul(void)
19651965 DO (mp_2expt (& c , 99000 - 1000 ));
19661966 DO (mp_add (& b , & c , & b ));
19671967
1968- tc_cutoff = MP_TOOM_MUL_CUTOFF ;
1969- MP_TOOM_MUL_CUTOFF = INT_MAX ;
1968+ tc_cutoff = MP_MUL_TOOM_CUTOFF ;
1969+ MP_MUL_TOOM_CUTOFF = INT_MAX ;
19701970 DO (mp_mul (& a , & b , & c ));
1971- MP_TOOM_MUL_CUTOFF = tc_cutoff ;
1971+ MP_MUL_TOOM_CUTOFF = tc_cutoff ;
19721972 DO (mp_mul (& a , & b , & d ));
19731973 if (mp_cmp (& c , & d ) != MP_EQ ) {
19741974 fprintf (stderr , "Toom-Cook 3-way multiplication failed for edgecase f1 * f2\n" );
19751975 goto LBL_ERR ;
19761976 }
19771977#endif
19781978
1979- for (size = MP_TOOM_MUL_CUTOFF ; size < MP_TOOM_MUL_CUTOFF + 20 ; size ++ ) {
1979+ for (size = MP_MUL_TOOM_CUTOFF ; size < MP_MUL_TOOM_CUTOFF + 20 ; size ++ ) {
19801980 DO (mp_rand (& a , size ));
19811981 DO (mp_rand (& b , size ));
1982- DO (s_mp_toom_mul (& a , & b , & c ));
1983- DO (s_mp_mul (& a ,& b ,& d ));
1982+ DO (s_mp_mul_toom (& a , & b , & c ));
1983+ DO (s_mp_mul_full (& a ,& b ,& d ));
19841984 if (mp_cmp (& c , & d ) != MP_EQ ) {
19851985 fprintf (stderr , "Toom-Cook 3-way multiplication failed at size %d\n" , size );
19861986 goto LBL_ERR ;
@@ -1994,15 +1994,15 @@ static int test_s_mp_toom_mul(void)
19941994 return EXIT_FAILURE ;
19951995}
19961996
1997- static int test_s_mp_toom_sqr (void )
1997+ static int test_s_mp_sqr_toom (void )
19981998{
19991999 mp_int a , b , c ;
20002000 int size ;
20012001
20022002 DOR (mp_init_multi (& a , & b , & c , NULL ));
2003- for (size = MP_TOOM_SQR_CUTOFF ; size < MP_TOOM_SQR_CUTOFF + 20 ; size ++ ) {
2003+ for (size = MP_SQR_TOOM_CUTOFF ; size < MP_SQR_TOOM_CUTOFF + 20 ; size ++ ) {
20042004 DO (mp_rand (& a , size ));
2005- DO (s_mp_toom_sqr (& a , & b ));
2005+ DO (s_mp_sqr_toom (& a , & b ));
20062006 DO (s_mp_sqr (& a , & c ));
20072007 if (mp_cmp (& b , & c ) != MP_EQ ) {
20082008 fprintf (stderr , "Toom-Cook 3-way squaring failed at size %d\n" , size );
@@ -2075,7 +2075,7 @@ static int test_s_mp_div_recursive(void)
20752075
20762076 DOR (mp_init_multi (& a , & b , & c_q , & c_r , & d_q , & d_r , NULL ));
20772077
2078- for (size = MP_KARATSUBA_MUL_CUTOFF ; size < 3 * MP_KARATSUBA_MUL_CUTOFF ; size += 10 ) {
2078+ for (size = MP_MUL_KARATSUBA_CUTOFF ; size < 3 * MP_MUL_KARATSUBA_CUTOFF ; size += 10 ) {
20792079 printf ("\rsizes = %d / %d" , 10 * size , size );
20802080 /* Relation 10:1 */
20812081 DO (mp_rand (& a , 10 * size ));
@@ -2139,7 +2139,7 @@ static int test_s_mp_div_small(void)
21392139 int size ;
21402140
21412141 DOR (mp_init_multi (& a , & b , & c_q , & c_r , & d_q , & d_r , NULL ));
2142- for (size = 1 ; size < MP_KARATSUBA_MUL_CUTOFF ; size += 10 ) {
2142+ for (size = 1 ; size < MP_MUL_KARATSUBA_CUTOFF ; size += 10 ) {
21432143 printf ("\rsizes = %d / %d" , 2 * size , size );
21442144 /* Relation 10:1 */
21452145 DO (mp_rand (& a , 2 * size ));
@@ -2332,11 +2332,11 @@ static int unit_tests(int argc, char **argv)
23322332 T1 (mp_xor , MP_XOR ),
23332333 T2 (s_mp_div_recursive , S_MP_DIV_RECURSIVE , S_MP_DIV_SCHOOL ),
23342334 T2 (s_mp_div_small , S_MP_DIV_SMALL , S_MP_DIV_SCHOOL ),
2335- T1 (s_mp_balance_mul , S_MP_BALANCE_MUL ),
2336- T1 (s_mp_karatsuba_mul , S_MP_KARATSUBA_MUL ),
2337- T1 (s_mp_karatsuba_sqr , S_MP_KARATSUBA_SQR ),
2338- T1 (s_mp_toom_mul , S_MP_TOOM_MUL ),
2339- T1 (s_mp_toom_sqr , S_MP_TOOM_SQR )
2335+ T1 (s_mp_mul_balance , S_MP_MUL_BALANCE ),
2336+ T1 (s_mp_mul_karatsuba , S_MP_MUL_KARATSUBA ),
2337+ T1 (s_mp_sqr_karatsuba , S_MP_SQR_KARATSUBA ),
2338+ T1 (s_mp_mul_toom , S_MP_MUL_TOOM ),
2339+ T1 (s_mp_sqr_toom , S_MP_SQR_TOOM )
23402340#undef T2
23412341#undef T1
23422342 };
0 commit comments