'Changing out rng as input to DH keying material
I am currently creating some DH keys using the x25519-dalek-ng crate for it.
Using rand_core I can create them like this, with the OSrng:
use x25519_dalek_ng::{self,PublicKey, StaticSecret};
use rand_core::{OsRng};
fn main() {
let i_dh_privkey : StaticSecret = StaticSecret::new(OsRng);
let i_dh_public_key = PublicKey::from(&i_dh_privkey);
}
But I want to change to a different rng, one that does not require a OS. So I wanted to shift to rand_chacha. I then tried doing this:
use x25519_dalek_ng::{self,PublicKey, StaticSecret};
use rand_chacha::{ChaCha8Rng};
fn main() {
let i_dh_privkey : StaticSecret = StaticSecret::new(ChaCha8Rng);
let i_dh_public_key = PublicKey::from(&i_dh_privkey);
}
And rust doesnt like this, and says:
help: use struct literal syntax instead'
Which I don't really udnerstand, both OSrng and ChaCha8Rng are structs.
StaticSecret::new() takes anything that implements crpytorng, should I do something to implement that for the chacha rng?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
