@@ -290,12 +290,6 @@ pub use error::{ErrorKind, Error};
290
290
#[ cfg( feature="std" ) ] pub use entropy_rng:: EntropyRng ;
291
291
#[ cfg( feature="std" ) ] pub use thread_rng:: { ThreadRng , thread_rng, random} ;
292
292
293
- // local use declarations
294
- #[ cfg( target_pointer_width = "32" ) ]
295
- use prng:: IsaacRng as IsaacWordRng ;
296
- #[ cfg( target_pointer_width = "64" ) ]
297
- use prng:: Isaac64Rng as IsaacWordRng ;
298
-
299
293
use distributions:: { Distribution , Uniform , Range } ;
300
294
use distributions:: range:: SampleRange ;
301
295
@@ -1008,16 +1002,21 @@ impl<R: SeedableRng> NewRng for R {
1008
1002
}
1009
1003
}
1010
1004
1011
- /// The standard RNG. This is designed to be efficient on the current
1012
- /// platform.
1005
+ /// The standard RNG. The PRNG algorithm in `StdRng` is choosen to be efficient
1006
+ /// on the current platform, to be statistically strong and unpredictable
1007
+ /// (meaning a cryptographically secure PRNG).
1008
+ ///
1009
+ /// The current algorithm used on all platforms is [HC-128].
1010
+ ///
1011
+ /// Reproducibility of output from this generator is however not required, thus
1012
+ /// future library versions may use a different internal generator with
1013
+ /// different output. Further, this generator may not be portable and can
1014
+ /// produce different output depending on the architecture. If you require
1015
+ /// reproducible output, use a named RNG, for example `ChaChaRng`.
1013
1016
///
1014
- /// Reproducibility of output from this generator is not required, thus future
1015
- /// library versions may use a different internal generator with different
1016
- /// output. Further, this generator may not be portable and can produce
1017
- /// different output depending on the architecture. If you require reproducible
1018
- /// output, use a named RNG, for example `ChaChaRng`.
1017
+ /// [HC-128]: struct.Hc128Rng.html
1019
1018
#[ derive( Clone , Debug ) ]
1020
- pub struct StdRng ( IsaacWordRng ) ;
1019
+ pub struct StdRng ( Hc128Rng ) ;
1021
1020
1022
1021
impl RngCore for StdRng {
1023
1022
fn next_u32 ( & mut self ) -> u32 {
@@ -1038,14 +1037,14 @@ impl RngCore for StdRng {
1038
1037
}
1039
1038
1040
1039
impl SeedableRng for StdRng {
1041
- type Seed = <IsaacWordRng as SeedableRng >:: Seed ;
1040
+ type Seed = <Hc128Rng as SeedableRng >:: Seed ;
1042
1041
1043
1042
fn from_seed ( seed : Self :: Seed ) -> Self {
1044
- StdRng ( IsaacWordRng :: from_seed ( seed) )
1043
+ StdRng ( Hc128Rng :: from_seed ( seed) )
1045
1044
}
1046
1045
1047
1046
fn from_rng < R : Rng > ( rng : & mut R ) -> Result < Self , Error > {
1048
- IsaacWordRng :: from_rng ( rng) . map ( |rng| StdRng ( rng) )
1047
+ Hc128Rng :: from_rng ( rng) . map ( |rng| StdRng ( rng) )
1049
1048
}
1050
1049
}
1051
1050
@@ -1284,25 +1283,13 @@ mod test {
1284
1283
}
1285
1284
1286
1285
#[ test]
1287
- #[ cfg( target_pointer_width = "32" ) ]
1288
- fn test_stdrng_construction ( ) {
1289
- let seed = [ 1 , 0 , 0 , 0 , 23 , 0 , 0 , 0 , 200 , 1 , 0 , 0 , 210 , 30 , 0 , 0 ,
1290
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
1291
- let mut rng1 = StdRng :: from_seed ( seed) ;
1292
- assert_eq ! ( rng1. next_u32( ) , 2869442790 ) ;
1293
-
1294
- let mut rng2 = StdRng :: from_rng ( & mut rng1) . unwrap ( ) ;
1295
- assert_eq ! ( rng2. next_u32( ) , 3094074039 ) ;
1296
- }
1297
- #[ test]
1298
- #[ cfg( target_pointer_width = "64" ) ]
1299
1286
fn test_stdrng_construction ( ) {
1300
1287
let seed = [ 1 , 0 , 0 , 0 , 23 , 0 , 0 , 0 , 200 , 1 , 0 , 0 , 210 , 30 , 0 , 0 ,
1301
1288
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
1302
1289
let mut rng1 = StdRng :: from_seed ( seed) ;
1303
- assert_eq ! ( rng1. next_u64( ) , 14964555543728284049 ) ;
1290
+ assert_eq ! ( rng1. next_u64( ) , 15759097995037006553 ) ;
1304
1291
1305
1292
let mut rng2 = StdRng :: from_rng ( & mut rng1) . unwrap ( ) ;
1306
- assert_eq ! ( rng2. next_u64( ) , 919595328260451758 ) ;
1293
+ assert_eq ! ( rng2. next_u64( ) , 6766915756997287454 ) ;
1307
1294
}
1308
1295
}
0 commit comments