use chrono::{DateTime, Utc};
use ed25519_dalek::{ed25519::signature::Signer, Signature, SigningKey, VerifyingKey};
use serde::{Deserialize, Serialize};
use super::{account_data::AccountDataForServer, machine_id::MachineUid};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountInfoRequest {
pub account_data: AccountDataForServer,
pub time_stamp: DateTime<Utc>,
pub signature: Signature,
}
pub fn prepare_account_info_request(
hw_id: MachineUid,
key: &SigningKey,
pub_key: VerifyingKey,
) -> AccountInfoRequest {
let time_stamp = chrono::Utc::now();
let time_str = time_stamp.to_string();
let signature = key.sign(time_str.as_bytes());
AccountInfoRequest {
account_data: AccountDataForServer {
public_key: pub_key,
hw_id,
},
signature,
time_stamp,
}
}