lundi 4 janvier 2021

The trait `rand_core::CryptoRng` is not implemented for `OsRng`

I've been trying to implement the example given in the following doc: https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/

My code is simply:

extern crate rand;
extern crate ed25519_dalek;


use rand::rngs::OsRng;
use ed25519_dalek::Keypair;


fn main() {
    let mut csprng = OsRng{};
    let keypair: Keypair = Keypair::generate(&mut csprng);
}

But when I try to run I get an error saying that the CryptoRng trait is not implemented in OsRng

11  |     let keypair: Keypair = Keypair::generate(&mut csprng);
    |                                              ^^^^^^^^^^^ the trait `rand_core::CryptoRng` is not implemented for `OsRng`

However, CryptoRng is simply a marker trait, and I saw that it indeed has an empty impl for OsRng...

So what could be the issue here?




Aucun commentaire:

Enregistrer un commentaire