Commit 8bd9846
authored
feat(crypto): perfect secrecy framework, forking lemma progress, and seeded oracle proofs (#112)
* feat(QueryCache, PreservesInv, CachingOracle): add connective tissue for random oracle proofs
- QueryCache: partial order, simp lemmas (empty, cacheQuery), sum spec
projections (fst/snd/inl/inr), membership, extensionality
- PreservesInv: composition lemma for oracle transformers, bind lemma
for StateT invariant preservation
- CachingOracle: cache monotonicity (withCaching_cache_le) and
PreservesInv instance showing the cache only grows
Made-with: Cursor
* chore(SimSemantics): silence unused section var warning in apply_compose
Use a local `omit [LawfulMonad m]` on `QueryImpl.apply_compose` so the build stays warning-clean except for existing `sorry` declarations.
Made-with: Cursor
* feat(SeededOracle): prove generateSeed-simulateQ distribution preservation
Prove that running an oracle computation with a seeded oracle (backed by
a randomly generated seed) preserves the output distribution, i.e.
sampling a seed and simulating queries is equivalent to real oracle calls.
Key additions:
- QuerySeed.pop, prependValues helpers and injectivity lemma (Structures)
- probOutput_generateSeed_prependValues factorization lemma (GenerateSeed)
- evalDist_generateSeed_eq_of_countEq seed normalization (GenerateSeed)
- probOutput_generateSeed_bind_simulateQ_bind main theorem (SeededOracle)
- Union bound lemma probEvent_exists_finset_le_sum (EvalDist/Fintype)
Made-with: Cursor
* fork progress
* fix(EvalDist): remove incorrect OracleComp imports from EvalDist/List and EvalDist/BitVec
Both files contained lemmas generic over any `m` with `[HasEvalSPMF m]` but
incorrectly imported from OracleComp, violating the EvalDist → OracleComp
layering. List.lean needed no split — just import and namespace fixes.
BitVec.lean's SampleableType instance moved to SampleableType.lean.
README updated to fix outdated notation (++ₒ→+, [=x|]→Pr[=x|], etc.).
Made-with: Cursor
* fork progress: add collision-penalty helper theory and scaffold final bound
Extend Fork.lean with seed-slot collision probability bounds and the global collision penalty lemma, then wire these into le_probOutput_fork while leaving the final seed-factor/square step explicitly marked for continuation.
Made-with: Cursor
* docs(agents): preserve partial proof attempts
Add agent guidance to keep unfinished Lean proof structure with local `stop` checkpoints instead of deleting blocks, so later iterations can continue from prior search context.
Made-with: Cursor
* feat(crypto): standardize perfect secrecy and prove OTP privacy
Adopt independence as the canonical perfect-secrecy definition with equivalent formulations, so privacy statements align with textbook semantics and are easier to reuse. Prove one-time-pad privacy against the new notion and document the updated proof status.
* feat(crypto): finish Shannon backward proof and remove remaining sorrys
Add reusable perfect-secrecy experiment decomposition lemmas and complete the backward Shannon direction constructively. Make the forward direction explicit via a passed hypothesis so the theorem family is fully sorry-free while keeping proof obligations transparent.
* refactor(crypto): clarify Shannon statements and add all-priors theorem
Replace the misleading Shannon iff path with an explicit constructive theorem over `perfectSecrecyAt`, and add the stronger PMF-prior theorem that proves uniform+unique implies all-priors secrecy. This keeps theorem semantics honest while preserving reusable proof helpers.
* refactor: extract helpers, deduplicate proofs, relocate misplaced code
- Extract ENNReal Cauchy-Schwarz inequalities to ToMathlib/Data/ENNReal/SumSquares.lean
- Factor out cipherGivenMsg_uniform_of_uniformKey_of_uniqueKey in SymmEncAlg.lean,
derive both Shannon theorems and ciphertextRowsEqualAt from it
- Remove unused perfectSecrecyAt_iff_allDefs / perfectSecrecy_iff_allDefs lemmas
- Move XOR probability lemmas to OracleComp/Constructions/BitVec.lean
- Add generic probEvent_liftComp_uniformSample_eq_of_eq helper in SeededOracle.lean,
simplify seed-slot collision lemmas in Fork.lean
- Extract length_eq_of_mem_support_generateSeed to deduplicate repeated blocks
Net -150 lines.
Made-with: Cursor
* chore(Fork): remove superseded commented-out code
Delete ~390 lines of old forking lemma code that used obsolete API
(guard, getM, [= x | ...] notation, s+1 index bug). All theorem
statements are now covered by the active uncommented code.
Made-with: Cursor
* fix(ci): add missing imports for BitVec and SumSquares to library files
Made-with: Cursor1 parent cab88b5 commit 8bd9846
File tree
20 files changed
+2033
-492
lines changed- Examples
- ToMathlib/Data/ENNReal
- VCVio
- CryptoFoundations
- EvalDist
- OracleComp
- Constructions
- QueryTracking
- SimSemantics
20 files changed
+2033
-492
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 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 | + | |
33 | 64 | | |
0 commit comments