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
85
86
87
88
89
90
91
92
93
94
// Foundation types for the RO(SE)² + SWiSSSE protocol.
// Every byte that crosses a trust boundary goes through these types.
// All secret values implement `Zeroize` so they are wiped from memory on drop.
use ;
use ;
// ── Security parameter ─────────────────────────────────────────────────────────
/// λ = 256 bits. All PRF outputs, keys, and tags are this length.
pub const LAMBDA: usize = 32;
// ── Secret key types ───────────────────────────────────────────────────────────
/// A 256-bit secret key. Wiped from memory the moment it goes out of scope.
///
/// Never clone, print, or log this value.
;
// ── EDB address tag ────────────────────────────────────────────────────────────
/// A pseudorandom tag that acts as the *address* of one entry in the server EDB.
///
/// Derived as: tag = PRF(K_tag, "tag:" || keyword || index || epoch)
///
/// To the server this is indistinguishable from random bytes — it reveals
/// nothing about the keyword, document, or time of write.
;
// ── Encrypted value ────────────────────────────────────────────────────────────
/// An AES-256-GCM ciphertext stored at a Tag address on the server.
/// Contains: nonce (12 B) || ciphertext || GCM tag (16 B)
;
// ── Entry operation ────────────────────────────────────────────────────────────
/// What an EDB entry represents after decryption.
/// The plaintext payload encrypted inside each `EncValue`.
/// After decryption the client learns the doc_id this entry refers to.
// ── Search token ───────────────────────────────────────────────────────────────
/// A SearchToken authorises exactly one search query.
///
/// It contains a list of (EDB address, decryption key) pairs — one per live
/// result. The server fetches each Tag; the client decrypts each value.
///
/// **Forward security**: a token generated at time T cannot read entries
/// written after T (they have different tags from fresh indices).
///
/// **Backward security**: a token generated after a deletion cannot read
/// the deleted entry (its tag was retired with the old epoch).
// ── Epoch ──────────────────────────────────────────────────────────────────────
/// A deletion-epoch counter per keyword.
///
/// Every time a document is deleted from a keyword's result set the epoch
/// increments. All EDB tags for that keyword are re-derived under the new
/// epoch, so old server entries become permanently unreachable — this gives
/// **Backward Security Type-II** as defined in the RO(SE)² paper.
pub type Epoch = u64;