1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! §5.2 — msg1's 12-byte encrypted payload.
//!
//! ```text
//! msg1 payload (12 B, encrypted in msg1's tail):
//! ts_secs(8, BE) ‖ ts_nanos(4, BE)
//! msg2: no payload (its encrypted tail is the empty payload's tag alone)
//! ```
//!
//! # This file is big-endian, and every other byte in `packet` is not
//!
//! §3.1 makes the packet **header** little-endian (ruling 64), and it
//! reaches exactly three fields — `sender_index`, `receiver_index` and
//! `counter`. This timestamp is not one of them: it is a payload, it
//! rides inside msg1's AEAD-sealed tail, and §3.1 names it as the second
//! of the rule's three stated exclusions. It is big-endian
//! **deliberately** — §5.3's strictly-greater test is an ordering, and a
//! big-endian `ts_secs` orders correctly compared as an octet string.
//!
//! Unlike §8.1's varints, this one genuinely *is* observable beside a
//! little-endian header: the responder decrypts msg1 while still holding
//! the header bytes. That is why the byte order lives in its own file
//! with its own heading, and why this module is the only place in
//! `src/packet/` where an integer's octet order is written by hand.
//!
//! # What is not here
//!
//! No clock read, no monotonic forcing, no orphan cap, no `SystemTime`.
//! §5.3's strictly-greater rule and §17.1's guard both consume this codec
//! and neither belongs to it; the protocol's one wall-clock read (§16.5)
//! is not made in the packet layer. This module encodes and decodes, and
//! that is all it does.
use crateconstants;
/// The 12-byte payload carried in msg1's encrypted tail. §5.2.
///
/// **Unattested name** — §5.2 names the payload, not a type.
///
/// [`Ord`] is derived over `(secs, nanos)` in that field order, which is
/// chronological order: §5.3's strictly-greater rule and §17.1's guard
/// both compare timestamps, and this is the comparison they need.
pub
// The payload is the timestamp and nothing else: `constants.rs` already
// asserts `MSG1_PAYLOAD_LEN == TIMESTAMP_LEN`, and `encode`'s return type
// ties this codec to the same constant. The layout below is what makes
// the two halves add up.
const _: = assert!;