use rand::{CryptoRng, Rng, thread_rng};
use tari_ootle_common_types::Network;
use crate::{key_provider::local::LocalKeyProvider, keys::OotleSecretKey};
pub type PrivateKeyProvider = LocalKeyProvider<OotleSecretKey>;
pub type PrivateKeySigner = PrivateKeyProvider;
impl LocalKeyProvider<OotleSecretKey> {
pub fn new(secret: OotleSecretKey) -> Self {
let address = secret.to_address();
Self {
address,
credentials: secret,
}
}
pub fn random(network: Network) -> Self {
Self::random_with(network, &mut thread_rng())
}
pub fn random_with<R: Rng + CryptoRng>(network: Network, rng: &mut R) -> Self {
let secret = OotleSecretKey::random_with(rng, network);
Self::new(secret)
}
}