#[cfg(not(target_arch = "wasm32"))]
use std::time::SystemTime;
#[cfg(target_arch = "wasm32")]
use web_time::SystemTime;
use rand::{thread_rng, Rng};
use secp256k1::SecretKey;
#[cfg(target_arch = "wasm32")]
use rustls_pki_types::UnixTime;
pub fn new_keys() -> SecretKey {
let mut rng = thread_rng();
let private_key: [u8; 32] = rng.gen();
let secret_key = SecretKey::from_slice(&private_key).unwrap();
secret_key
}
pub fn get_unix_timestamp() -> u64 {
let now = SystemTime::now();
let duration_since_epoch = now
.duration_since(SystemTime::UNIX_EPOCH)
.expect("Time went backwards");
#[cfg(target_arch = "wasm32")]
let current_unix_time = UnixTime::since_unix_epoch(duration_since_epoch);
#[cfg(not(target_arch = "wasm32"))]
let current_unix_time = duration_since_epoch;
current_unix_time.as_secs()
}