I am new to rust and encountered the following error when trying to use the secp256k1
crate with the provided example code
error[E0432]: unresolved import `secp256k1::rand::rng`
--> src/main.rs:1:22
|
1 | use secp256k1::rand::rng::OsRng;
| ^^^ could not find `rng` in `rand`
error: aborting due to previous error
My code is really simple
use secp256k1::rand::rng::OsRng;
use secp256k1::Secp256k1;
fn main() {
let secp = Secp256k1::new();
let mut rng = OsRng::new().expect("OsRng");
}
with the Cargo.toml
containing
[dependencies]
secp256k1 = {version="0.20.1", features = ["rand"]}
Are we missing something to get this working?
I tried using rustc 1.22.1 (b01adbbc3 2020-07-08)
and then rustc 1.51.0 (2fd73fabe 2021-03-23)