@@ -6,7 +6,6 @@ use super::{
66    jacobi:: { jacobi_symbol_vartime,  JacobiSymbol } , 
77    Primality , 
88} ; 
9- use  crate :: UintLike ; 
109
1110/// The maximum number of attempts to find `D` such that `(D/n) == -1`. 
1211// This is widely believed to be impossible. 
@@ -28,7 +27,7 @@ pub trait LucasBase {
2827    /// Given an odd integer, returns `Ok((P, abs(Q), is_negative(Q)))` on success, 
2928/// or `Err(Primality)` if the primality for the given integer was discovered 
3029/// during the search for a base. 
31- fn  generate < T :  UintLike > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality > ; 
30+ fn  generate < T :  Integer > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality > ; 
3231} 
3332
3433/// "Method A" for selecting the base given in Baillie & Wagstaff[^Baillie1980], 
@@ -46,7 +45,7 @@ pub trait LucasBase {
4645pub  struct  SelfridgeBase ; 
4746
4847impl  LucasBase  for  SelfridgeBase  { 
49-     fn  generate < T :  UintLike > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
48+     fn  generate < T :  Integer > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
5049        let  mut  abs_d = 5 ; 
5150        let  mut  d_is_negative = false ; 
5251        let  n_is_small = n. bits_vartime ( )  < Word :: BITS ;  // if true, `n` fits into one `Word` 
@@ -111,7 +110,7 @@ impl LucasBase for SelfridgeBase {
111110pub  struct  AStarBase ; 
112111
113112impl  LucasBase  for  AStarBase  { 
114-     fn  generate < T :  UintLike > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
113+     fn  generate < T :  Integer > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
115114        SelfridgeBase . generate ( n) . map ( |( p,  abs_q,  q_is_negative) | { 
116115            if  abs_q == 1  && q_is_negative { 
117116                ( 5 ,  5 ,  false ) 
@@ -134,7 +133,7 @@ impl LucasBase for AStarBase {
134133pub  struct  BruteForceBase ; 
135134
136135impl  LucasBase  for  BruteForceBase  { 
137-     fn  generate < T :  UintLike > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
136+     fn  generate < T :  Integer > ( & self ,  n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
138137        let  mut  p = 3 ; 
139138        let  mut  attempts = 0 ; 
140139
@@ -179,7 +178,7 @@ impl LucasBase for BruteForceBase {
179178} 
180179
181180/// For the given odd `n`, finds `s` and odd `d` such that `n + 1 == 2^s * d`. 
182- fn  decompose < T :  UintLike > ( n :  & Odd < T > )  -> ( u32 ,  Odd < T > )  { 
181+ fn  decompose < T :  Integer > ( n :  & Odd < T > )  -> ( u32 ,  Odd < T > )  { 
183182    // Need to be careful here since `n + 1` can overflow. 
184183    // Instead of adding 1 and counting trailing 0s, we count trailing ones on the original `n`. 
185184
@@ -283,7 +282,7 @@ pub enum LucasCheck {
283282/// Performs the primality test based on Lucas sequence. 
284283/// See [`LucasCheck`] for possible checks, and the implementors of [`LucasBase`] 
285284/// for the corresponding bases. 
286- pub  fn  lucas_test < T :  UintLike > ( 
285+ pub  fn  lucas_test < T :  Integer > ( 
287286    candidate :  & Odd < T > , 
288287    base :  impl  LucasBase , 
289288    check :  LucasCheck , 
@@ -340,7 +339,7 @@ pub fn lucas_test<T: UintLike>(
340339
341340    // Some constants in Montgomery form 
342341
343-     let  params = <T  as  Integer >:: Monty :: new_params ( candidate. clone ( ) ) ; 
342+     let  params = <T  as  Integer >:: Monty :: new_params_vartime ( candidate. clone ( ) ) ; 
344343
345344    let  zero = <T  as  Integer >:: Monty :: zero ( params. clone ( ) ) ; 
346345    let  one = <T  as  Integer >:: Monty :: one ( params. clone ( ) ) ; 
@@ -501,18 +500,15 @@ mod tests {
501500
502501    use  alloc:: format; 
503502
504-     use  crypto_bigint:: { Odd ,  Uint ,  Word ,  U128 ,  U64 } ; 
503+     use  crypto_bigint:: { Integer ,   Odd ,  Uint ,  Word ,  U128 ,  U64 } ; 
505504
506505    #[ cfg( feature = "tests-exhaustive" ) ]  
507506    use  num_prime:: nt_funcs:: is_prime64; 
508507
509508    use  super :: { 
510509        decompose,  lucas_test,  AStarBase ,  BruteForceBase ,  LucasBase ,  LucasCheck ,  SelfridgeBase , 
511510    } ; 
512-     use  crate :: { 
513-         hazmat:: { primes,  pseudoprimes,  Primality } , 
514-         UintLike , 
515-     } ; 
511+     use  crate :: hazmat:: { primes,  pseudoprimes,  Primality } ; 
516512
517513    #[ test]  
518514    fn  bases_derived_traits ( )  { 
@@ -557,7 +553,7 @@ mod tests {
557553        struct  TestBase ; 
558554
559555        impl  LucasBase  for  TestBase  { 
560-             fn  generate < T :  UintLike > ( & self ,  _n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
556+             fn  generate < T :  Integer > ( & self ,  _n :  & Odd < T > )  -> Result < ( Word ,  Word ,  bool ) ,  Primality >  { 
561557                Ok ( ( 5 ,  5 ,  false ) ) 
562558            } 
563559        } 
0 commit comments