pub struct SecretChatState {Show 17 fields
pub id: i32,
pub access_hash: i64,
pub auth_key: [u8; 256],
pub admin: bool,
pub user_id: i64,
pub in_seq_no: i32,
pub out_seq_no: i32,
pub in_seq_no_x: i32,
pub out_seq_no_x: i32,
pub layer: i32,
pub ttl: i32,
pub ttr: i32,
pub updated_at_secs: u64,
pub mtproto: u8,
pub rekeying_state: RekeyingState,
pub temp_rekey_map: HashMap<i64, Vec<u8>>,
pub sent: VecDeque<(i32, Vec<u8>)>,
}Expand description
Per-chat state stored in memory (and optionally persisted to disk).
Fields§
§id: i32Secret chat id assigned by Telegram.
access_hash: i64Access hash for InputEncryptedChat.
auth_key: [u8; 256]Shared 256-byte key from the DH exchange. Written unencrypted to the store file.
admin: booltrue = we initiated this chat (User A).
user_id: i64Peer user ID.
in_seq_no: i32Raw incoming sequence counter.
out_seq_no: i32Raw outgoing sequence counter.
in_seq_no_x: i32Parity bit for incoming wire encoding.
out_seq_no_x: i32Parity bit for outgoing wire encoding.
layer: i32Remote peer’s supported layer (updated on NotifyLayer receipt).
ttl: i32Per-message TTL in seconds (0 = no TTL).
ttr: i32Messages until next re-key.
updated_at_secs: u64Unix epoch seconds of last auth_key rotation (for 7-day re-key timer).
mtproto: u8MTProto version in use (1 or 2).
rekeying_state: RekeyingStateWhere the current re-key exchange stands.
temp_rekey_map: HashMap<i64, Vec<u8>>Keyed by exchange_id. Requested state: stores 256-byte private key. Accepted state: stores 256-byte computed auth_key.
sent: VecDeque<(i32, Vec<u8>)>Ring buffer of (wire_out_seq_no, encrypted_blob) for Resend support. Not persisted: only valid for the current session.
Implementations§
Source§impl SecretChatState
impl SecretChatState
Sourcepub fn new(
id: i32,
access_hash: i64,
auth_key: [u8; 256],
admin: bool,
user_id: i64,
) -> Self
pub fn new( id: i32, access_hash: i64, auth_key: [u8; 256], admin: bool, user_id: i64, ) -> Self
Create the state for a freshly established chat.
admin is true on the initiating side; it decides the sequence-number
parity bits. The layer defaults to crate::dh::DEFAULT_LAYER until the
peer announces its own.
Sourcepub fn wire_in_seq_no(&self) -> i32
pub fn wire_in_seq_no(&self) -> i32
Wire-encoded incoming seq no: raw * 2 + x.
Sourcepub fn wire_out_seq_no(&self) -> i32
pub fn wire_out_seq_no(&self) -> i32
Wire-encoded outgoing seq no: raw * 2 + x.
Sourcepub fn secs_since_update(&self) -> u64
pub fn secs_since_update(&self) -> u64
Seconds since last auth_key rotation.
Sourcepub fn rotate_key(&mut self, new_key: [u8; 256])
pub fn rotate_key(&mut self, new_key: [u8; 256])
Stamp updated_at_secs to now, reset ttr, swap in the new key.