zkgroup/crypto/
timestamp_struct.rs1use curve25519_dalek_signal::scalar::Scalar;
7use serde::{Deserialize, Serialize};
8
9use crate::common::sho::Sho;
10use crate::common::simple_types::Timestamp;
11
12#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
13pub struct TimestampStruct {
14 pub(crate) timestamp: Timestamp,
15}
16
17impl TimestampStruct {
18 pub fn new(timestamp: Timestamp) -> Self {
19 Self { timestamp }
20 }
21
22 pub fn calc_m(&self) -> Scalar {
23 Self::calc_m_from(self.timestamp)
24 }
25
26 pub fn calc_m_from(timestamp: Timestamp) -> Scalar {
27 let mut sho = Sho::new(
28 b"Signal_ZKGroup_20220524_Timestamp_Calc_m",
29 ×tamp.to_be_bytes(),
30 );
31 sho.get_scalar()
32 }
33}