Skip to content

Commit 7bd2461

Browse files
committed
Change std::rand to just rand::, though there is still a 'unimplemented trait' error :/
1 parent d2fcbbe commit 7bd2461

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use std::intrinsics::copy_nonoverlapping;
1919
use std::cmp;
2020
use std::fmt;
21-
use std::rand::Rng;
21+
use rand::Rng;
2222
use serialize::{Decoder, Decodable, Encoder, Encodable};
2323

2424
use crypto::digest::Digest;

src/secp256k1.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@
3838
extern crate crypto;
3939

4040
extern crate libc;
41+
extern crate rand;
4142
extern crate serialize;
4243
extern crate test;
4344

4445
use std::intrinsics::copy_nonoverlapping;
4546
use std::io;
46-
use std::rand::{OsRng, Rng, SeedableRng};
47+
use std::rand::OsRng;
4748
use std::sync::{Once, ONCE_INIT};
4849
use libc::c_int;
50+
use rand::{Rng, SeedableRng};
4951

5052
use crypto::fortuna::Fortuna;
5153

@@ -272,8 +274,8 @@ impl Secp256k1 {
272274
#[cfg(test)]
273275
mod tests {
274276
use std::iter::repeat;
275-
use std::rand;
276-
use std::rand::Rng;
277+
use std::rand::thread_rng;
278+
use rand::Rng;
277279

278280
use test::{Bencher, black_box};
279281

@@ -287,7 +289,7 @@ mod tests {
287289
let sig = Signature::from_slice(&[0; 72]).unwrap();
288290
let pk = PublicKey::new(true);
289291

290-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
292+
thread_rng().fill_bytes(msg.as_mut_slice());
291293

292294
assert_eq!(Secp256k1::verify(msg.as_mut_slice(), &sig, &pk), Err(InvalidPublicKey));
293295
}
@@ -301,7 +303,7 @@ mod tests {
301303
let mut msg: Vec<u8> = repeat(0).take(32).collect();
302304
let sig = Signature::from_slice(&[0; 72]).unwrap();
303305

304-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
306+
thread_rng().fill_bytes(msg.as_mut_slice());
305307

306308
assert_eq!(Secp256k1::verify(msg.as_mut_slice(), &sig, &pk), Err(InvalidSignature));
307309
}
@@ -314,7 +316,7 @@ mod tests {
314316
let mut msg: Vec<u8> = repeat(0).take(32).collect();
315317
let sig = Signature::from_slice(&[0; 72]).unwrap();
316318

317-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
319+
thread_rng().fill_bytes(msg.as_mut_slice());
318320

319321
assert_eq!(Secp256k1::verify(msg.as_mut_slice(), &sig, &pk), Err(InvalidSignature));
320322
}
@@ -324,7 +326,7 @@ mod tests {
324326
let mut s = Secp256k1::new().unwrap();
325327

326328
let mut msg = [0u8; 32];
327-
rand::thread_rng().fill_bytes(&mut msg);
329+
thread_rng().fill_bytes(&mut msg);
328330

329331
let (sk, _) = s.generate_keypair(false);
330332
let nonce = s.generate_nonce();
@@ -337,7 +339,7 @@ mod tests {
337339
let mut s = Secp256k1::new().unwrap();
338340

339341
let mut msg: Vec<u8> = repeat(0).take(32).collect();
340-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
342+
thread_rng().fill_bytes(msg.as_mut_slice());
341343

342344
let (sk, pk) = s.generate_keypair(false);
343345
let nonce = s.generate_nonce();
@@ -352,14 +354,14 @@ mod tests {
352354
let mut s = Secp256k1::new().unwrap();
353355

354356
let mut msg: Vec<u8> = repeat(0).take(32).collect();
355-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
357+
thread_rng().fill_bytes(msg.as_mut_slice());
356358

357359
let (sk, pk) = s.generate_keypair(false);
358360
let nonce = s.generate_nonce();
359361

360362
let sig = s.sign(msg.as_slice(), &sk, &nonce).unwrap();
361363

362-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
364+
thread_rng().fill_bytes(msg.as_mut_slice());
363365
assert_eq!(Secp256k1::verify(msg.as_slice(), &sig, &pk), Err(IncorrectSignature));
364366
}
365367

@@ -368,7 +370,7 @@ mod tests {
368370
let mut s = Secp256k1::new().unwrap();
369371

370372
let mut msg = [0u8; 32];
371-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
373+
thread_rng().fill_bytes(msg.as_mut_slice());
372374

373375
let (sk, pk) = s.generate_keypair(false);
374376
let nonce = s.generate_nonce();
@@ -381,7 +383,7 @@ mod tests {
381383
#[test]
382384
fn deterministic_sign() {
383385
let mut msg = [0u8; 32];
384-
rand::thread_rng().fill_bytes(msg.as_mut_slice());
386+
thread_rng().fill_bytes(msg.as_mut_slice());
385387

386388
let mut s = Secp256k1::new().unwrap();
387389
let (sk, pk) = s.generate_keypair(true);

0 commit comments

Comments
 (0)