I try to use rand
and num::bigint
to generate random big unsigned integer,
here's roughly how I do it:
use num::{bigint::RandBigInt, BigUint};
use rand;
let mut rng = rand::thread_rng();
let r = RandBigInt::gen_biguint_below(&mut rng, &self.p); // self.p is a `BigUint` prime number
and in my Cargo.toml
:
[dependencies]
num = { version = "0.2.1", features = ["rand"] }
rand = "0.7"
And here's the error I got:
error[E0277]: the trait bound `rand::rngs::thread::ThreadRng: rand_core::RngCore` is not satisfied
--> dh/src/mod_p.rs:51:47
|
51 | let r = RandBigInt::gen_biguint_below(&mut rng, &self.p);
| ^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `rand::rngs::thread::ThreadRng`
|
help: trait impl with same name found
--> /Users/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_core-0.5.1/src/lib.rs:388:1
|
388 | / impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
389 | | #[inline(always)]
390 | | fn next_u32(&mut self) -> u32 {
391 | | (**self).next_u32()
... |
407 | | }
408 | | }
| |_^
= note: perhaps two different versions of crate `rand_core` are being used?
= note: required because of the requirements on the impl of `rand::Rng` for `rand::rngs::thread::ThreadRng`
= note: required because of the requirements on the impl of `num_bigint::bigrand::RandBigInt` for `rand::rngs::thread::ThreadRng`
= note: required by `num_bigint::bigrand::RandBigInt::gen_biguint_below`
Anyone has any idea why?