@@ -26,24 +26,19 @@ mod tests {
2626
2727 #[ test]
2828 fn test_polymul_ntt_square_modulus ( ) {
29- let modulus : i64 = 17 * 17 ; // Prime modulus
29+ let moduli = [ 17 * 17 , 12289 * 12289 ] ; // Different moduli to test
3030 let n: usize = 8 ; // Length of the NTT (must be a power of 2)
31- let omega = omega ( modulus, n) ; // n-th root of unity
32-
33- // Input polynomials (padded to length `n`)
34- let mut a = vec ! [ 1 , 2 , 3 , 4 ] ;
35- let mut b = vec ! [ 5 , 6 , 7 , 8 ] ;
36- a. resize ( n, 0 ) ;
37- b. resize ( n, 0 ) ;
38-
39- // Perform the standard polynomial multiplication
40- let c_std = polymul ( & a, & b, n as i64 , modulus) ;
41-
42- // Perform the NTT-based polynomial multiplication
43- let c_fast = polymul_ntt ( & a, & b, n, modulus, omega) ;
4431
45- // Ensure both methods produce the same result
46- assert_eq ! ( c_std, c_fast, "The results of polymul and polymul_ntt do not match" ) ;
32+ for & modulus in & moduli {
33+ let omega = omega ( modulus, n) ; // n-th root of unity
34+ let mut a = vec ! [ 1 , 2 , 3 , 4 ] ;
35+ let mut b = vec ! [ 5 , 6 , 7 , 8 ] ;
36+ a. resize ( n, 0 ) ;
37+ b. resize ( n, 0 ) ;
38+ let c_std = polymul ( & a, & b, n as i64 , modulus) ;
39+ let c_fast = polymul_ntt ( & a, & b, n, modulus, omega) ;
40+ assert_eq ! ( c_std, c_fast, "The results of polymul and polymul_ntt do not match" ) ;
41+ }
4742 }
4843
4944 #[ test]
0 commit comments