use crate::{
stream_prng::StreamPRNG,
streams::ChaChaStream,
traits::{CryptographicallySecure, PRNGenerator, Splittable}
};
pub type ChaCha<const ROUNDS: u32> = StreamPRNG<ChaChaStream<ROUNDS>>;
unsafe impl<const ROUNDS: u32> CryptographicallySecure for ChaCha<ROUNDS> { }
impl<const ROUNDS: u32> Splittable for ChaCha<ROUNDS> {
fn split(&mut self) -> Self {
let new_key = self.generate::<[u8; 32]>();
let new_nonce = self.generate::<[u8; 12]>();
let new_chacha_stream = ChaChaStream::from_arrays(new_key, new_nonce);
StreamPRNG::new(new_chacha_stream)
}
}
pub type DefaultChaCha = ChaCha<20>;