Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
bcbcfba
proof(xmss): add slice 0 of the fresh own-query proof
alexanderlhicks Dec 2, 2026
0d6df29
proof(xmss): fix the slice 0 statements after review
alexanderlhicks Dec 3, 2026
b9fd8cb
proof(xmss): drop the V6 placeholder pending its revision
alexanderlhicks Dec 3, 2026
ebe8610
proof(xmss): state the slice 0 invariants and reduce L5 to three step…
alexanderlhicks Dec 3, 2026
57efeeb
proof(xmss): decide large existentials classically in the fresh games
alexanderlhicks Dec 3, 2026
6b7692f
proof(xmss): prove that a recording step keeps its invariant (L5)
alexanderlhicks Dec 3, 2026
3244f21
proof(xmss): prove that recording projects to testing (L5)
alexanderlhicks Dec 3, 2026
ed6cba6
proof(xmss): move the KI read lemma below the deferral and restate it…
alexanderlhicks Dec 3, 2026
0c64d85
proof(xmss): state the signing-step facts for any oracle-computation …
alexanderlhicks Dec 3, 2026
0e51a94
proof(xmss): prove that G3's flag is a recorded payload that hits (L5…
alexanderlhicks Dec 3, 2026
0148d90
refactor(xmss): drop the unused scan lemma and merge the table-read r…
alexanderlhicks Dec 3, 2026
c6f0910
refactor(xmss): drop the table form of the KI read lemma and name the…
alexanderlhicks Dec 3, 2026
bd68977
chore(xmss): add the invariant-carrying weighted-cap placeholder and …
alexanderlhicks Dec 3, 2026
a8c70e9
refactor(xmss): drop two unused support lemmas of the G3 flag proof
alexanderlhicks Dec 3, 2026
c2f2696
proof(xmss): prove that keygen's decision off a probe reads only expo…
alexanderlhicks Dec 3, 2026
0bad1e4
proof(xmss): prove decodeDigest_injective, reveal_consistent and cach…
alexanderlhicks Dec 3, 2026
a3f77e7
proof(xmss): prove the slot lemma (L6)
alexanderlhicks Dec 3, 2026
6b556ec
proof(xmss): prove one layer of the verifier (L7), both layers
alexanderlhicks Dec 3, 2026
dab57a2
proof(xmss): prove the classification of a clean win (L8)
alexanderlhicks Dec 3, 2026
6eced70
docs(xmss): describe what Lemmas states and where the proved lemmas live
alexanderlhicks Dec 3, 2026
f62279d
proof(xmss): prove the codeword count, the rate bounds and |S| <= V
alexanderlhicks Dec 3, 2026
2fcbe15
refactor(xmss): name the fields of RevealMono and ProvInv
alexanderlhicks Dec 3, 2026
338a38f
chore(xmss): drop the unused descent placeholder and the stale V6 note
alexanderlhicks Dec 3, 2026
7b70c89
chore(xmss): intrinsic module titles, private proof imports, parse_ho…
alexanderlhicks Dec 3, 2026
2c30879
proof(xmss): prove the link lemma verifierReplays_of_verified
alexanderlhicks Dec 3, 2026
3265cb2
proof(xmss): prove the masking step L4
alexanderlhicks Dec 3, 2026
408190d
proof(xmss): prove the repeated-leaf abort L1
alexanderlhicks Dec 3, 2026
ab9e6a5
proof(xmss): prove L0, one handler with verification folded in
alexanderlhicks Dec 3, 2026
86707c6
proof(xmss): prove the oracle-form coupling L4a
alexanderlhicks Dec 3, 2026
d87b40e
refactor(xmss): one lemma per case of a hash step
alexanderlhicks Dec 3, 2026
aea2798
chore(xmss): review NITs on docstrings, names, layout and placeholders
alexanderlhicks Dec 3, 2026
1bf5a54
refactor(xmss): hash-step cases for any answers and any test
alexanderlhicks Dec 3, 2026
e3122e0
chore(xmss): drop the dead L4b placeholder; review NITs of slice 4
alexanderlhicks Dec 3, 2026
4e5199b
build(xmss): bundle the fresh proof's handlers as QueryImpl structures
alexanderlhicks Dec 3, 2026
87e5c56
proof(xmss): use VCVio's and EthLib's declarations in the fresh proof
alexanderlhicks Dec 3, 2026
bee41bd
proof(xmss): prove the pricing of probes (L10) and hits (L11)
alexanderlhicks Dec 3, 2026
7cecc66
fix(xmss): keep the old proof tree out of the fresh proof's imports
alexanderlhicks Dec 3, 2026
39c5baa
proof(xmss): keygen queries each position once (L3 a-c)
alexanderlhicks Dec 3, 2026
896429a
proof(xmss): keygen's run is the relabelled run and an eager table (L…
alexanderlhicks Dec 3, 2026
03d6ea3
proof(xmss): keygen at a table is the table's graph and cache (L3 e)
alexanderlhicks Dec 3, 2026
c6cf52e
proof(xmss): keygen is one uniform table (L3 f, assembly)
alexanderlhicks Dec 3, 2026
fd9be78
proof(xmss): count two units per query of A' pathwise (L16, pathwise)
alexanderlhicks Dec 3, 2026
0852cea
proof(xmss): bound the selection mass of a slice (L14)
alexanderlhicks Dec 3, 2026
8f8f754
proof(xmss): Wald's identities and theta' for the slices (L15)
alexanderlhicks Dec 3, 2026
f5bf814
proof(xmss): add the costs in expectation (L16)
alexanderlhicks Dec 3, 2026
686850b
proof(xmss): the compensated potential of the partnered weight (L13)
alexanderlhicks Dec 3, 2026
fb8ed88
proof(xmss): price the signing step's partnered selection (L12)
alexanderlhicks Dec 3, 2026
232bba8
refactor(xmss): share the verifier's query bound and the logged cache…
alexanderlhicks Dec 3, 2026
4c2cc96
proof(xmss): drop the unused L3 (a) lemmas and route samples_tableOf …
alexanderlhicks Dec 3, 2026
7c1ee5b
proof(xmss): replace every erw in the fresh proof by rw
alexanderlhicks Dec 3, 2026
05044d4
proof(xmss): scope the irreducible lists of the fresh proof
alexanderlhicks Dec 3, 2026
b35259d
proof(xmss): put the fresh-key lemmas in VCVio's FreshKeyQueries name…
alexanderlhicks Dec 3, 2026
af36b77
docs(xmss): rewrap the fresh proof's comments and document every decl…
alexanderlhicks Dec 3, 2026
9d1d48a
refactor(xmss): name the fresh proof's signer namespace for what it h…
alexanderlhicks Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,073 changes: 1,073 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Classify.lean

Large diffs are not rendered by default.

956 changes: 956 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Deferral.lean

Large diffs are not rendered by default.

427 changes: 427 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Games.lean

Large diffs are not rendered by default.

820 changes: 820 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Generic.lean

Large diffs are not rendered by default.

448 changes: 448 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Graph.lean

Large diffs are not rendered by default.

1,520 changes: 1,520 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Keygen.lean

Large diffs are not rendered by default.

1,197 changes: 1,197 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Layers.lean

Large diffs are not rendered by default.

1,033 changes: 1,033 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Lemmas.lean

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Main.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
module

public import EthLib.Cryptography.Proofs.Xmss.Security.Fresh.Keygen
public import EthLib.Cryptography.Proofs.Xmss.Security.Fresh.Partner

/-!
# Fresh leanXMSS proof: the assembled bound

The own-query bound `(2q + 344) / 2^128` from the statements L0 to L16.

The capped bound `(2q + 634) / 2^128` follows as a corollary.
-/

@[expose] public section

open OracleComp OracleSpec ENNReal

namespace XmssSecurity.Fresh

/-- Expectation is monotone in the observation. -/
theorem expect_mono {α : Type} (mx : ProbComp α) {f f' : α → ℝ≥0∞} (h : ∀ z, f z ≤ f' z) :
expect mx f ≤ expect mx f' :=
tsum_le_tsum fun z => mul_le_mul_right (h z) _

/-- The number of digests is not zero. -/
theorem digestCount_ne_zero : digestCount ≠ 0 := by
simp [digestCount]

/-- The number of digests is finite. -/
theorem digestCount_ne_top : digestCount ≠ ⊤ :=
ENNReal.natCast_ne_top _

/-- L8: a clean win of `G2` sets `Hit` or some `Sel_a`.

The link lemma turns the accepted verification into a covered replay.

The classification reads that replay. -/
theorem win_imp_hit_or_sel (A : Adversary) :
∀ z ∈ support (G2 A), Run.win z.2 → ¬Run.bad z.2 → Run.hit z.2 ∨ ∃ a, Run.sel z.2 a := by
intro z hz hwin hbad
simp only [G2, mem_support_bind_iff, support_pure, Set.mem_singleton_iff] at hz
obtain ⟨g, -, r, hr, rfl⟩ := hz
have hv : r.1.2 = true := by
simp only [Run.win, winOf, Bool.and_eq_true] at hwin
exact hwin.2
exact hit_or_sel_of_verifierReplays A g r hr hbad hwin
(verifierReplays_of_verified A g r hr hv)

/-- The corollary of L12 to L15: `Sel_a` costs `(1 + theta')` per cell of `bd(a)`. -/
theorem prEvent_sel_le_theta (A : Adversary) (q' : Nat)
(hcap : ∀ pk, IsQueryBoundP (advPrime A pk) IsAdvHash q') (a : LeafIndex) :
Pr{let z ← G2 A}[Run.sel z.2 a] ≤
(1 + theta q') * expect (G2 A) (fun z => ((Outcome.slice z a).n : ℝ≥0∞)) / digestCount := by
set En := expect (G2 A) fun z => ((Outcome.slice z a).n : ℝ≥0∞)
have hp0 := codewordRate_ne_zero
have hpT : codewordRate ≠ ⊤ := ne_top_of_lt codewordRate_lt_one
-- The partnered weight: `N E[Phi] <= E[V H] / p <= theta' N E[n]`, so `E[Phi] <= theta' E[n]`.
have hPhi : expect (G2 A) (fun z => (Outcome.slice z a).Phi) ≤ theta q' * En := by
have h := (expect_Phi_le A a).trans (expect_VH_le A q' hcap a)
rw [mul_comm (theta q'), mul_assoc] at h
exact (ENNReal.mul_le_mul_iff_right digestCount_ne_zero digestCount_ne_top).1 h
-- The fresh rate: `E[|S|] <= E[V] <= p E[n]`.
have hS : expect (G2 A) (fun z => ((Outcome.slice z a).S.card : ℝ≥0∞)) ≤ codewordRate * En :=
(expect_mono _ fun z => by exact_mod_cast Slice.card_S_le_V _).trans (expect_V_le A a)
calc Pr{let z ← G2 A}[Run.sel z.2 a]
≤ expect (G2 A) (fun z => (Outcome.slice z a).Phi) / digestCount +
expect (G2 A) (fun z => ((Outcome.slice z a).S.card : ℝ≥0∞)) /
(codewordRate * digestCount) := prEvent_sel_le A a
_ ≤ theta q' * En / digestCount + codewordRate * En / (codewordRate * digestCount) :=
add_le_add (ENNReal.div_le_div_right hPhi _) (ENNReal.div_le_div_right hS _)
_ = (1 + theta q') * En / digestCount := by
rw [ENNReal.mul_div_mul_left _ _ hp0 hpT, ← ENNReal.add_div, add_mul, one_mul, add_comm]

/-- The own-query bound.

An adversary with at most `q` hash queries forges with probability at most `(2q + 344) / 2^128`.
-/
theorem forgeAdvantage_le_of_adversaryBound
(q : Nat) (adversary : Adversary)
(hadv : ∀ publicKey, IsQueryBoundP (adversary.main publicKey) IsAdvHash q) :
forgeAdvantage Concrete.scheme adversary ≤
((2 * q + 344 : Nat) : ENNReal) / ((2 ^ 128 : Nat) : ENNReal) := by
by_cases hq : q + 172 < 2 ^ 127
· have hcap := advPrime_isQueryBoundP adversary q hadv
set G := G2 adversary
set θ := theta (q + 172)
-- L0, L1, L3, L4a: the forgery advantage is the win of `G1o`.
rw [forgeAdvantage_eq_G0, G0_false_eq_G0_true, G0_true_eq_G1, G1_eq_G1o]
-- L8 with the union bound: a clean win is `Hit` or some `Sel_a`.
have hclean : Pr{let z ← G}[Run.win z.2 ∧ ¬Run.bad z.2] ≤
Pr{let z ← G}[Run.hit z.2] + ∑ a, Pr{let z ← G}[Run.sel z.2 a] :=
(prEvent_mono_of_support G _ _ fun z hz h =>
win_imp_hit_or_sel adversary z hz h.1 h.2).trans
((prEvent_or_le G _ _).trans (add_le_add le_rfl (prEvent_exists_le G _)))
have hsel : ∑ a, Pr{let z ← G}[Run.sel z.2 a] ≤
∑ a, (1 + θ) * expect G (fun z => ((Outcome.slice z a).n : ℝ≥0∞)) / digestCount :=
Finset.sum_le_sum fun a _ => prEvent_sel_le_theta adversary (q + 172) hcap a
calc Pr{let b ← G1o adversary}[b = true]
≤ Pr{let z ← G}[Run.win z.2 ∧ ¬Run.bad z.2] + Pr{let z ← G}[Run.bad z.2] :=
G1o_le_G2 adversary
_ ≤ (expect G (fun z => (z.2.2.2.targetQueries : ℝ≥0∞)) / digestCount +
∑ a, (1 + θ) * expect G (fun z => ((Outcome.slice z a).n : ℝ≥0∞)) / digestCount) +
expect G (fun z => (z.2.2.1.probes : ℝ≥0∞)) / digestCount :=
add_le_add (hclean.trans (add_le_add (prEvent_hit_le adversary) hsel))
(prEvent_bad_le adversary)
_ = expect G (fun z => (z.2.2.1.probes : ℝ≥0∞)) / digestCount +
expect G (fun z => (z.2.2.2.targetQueries : ℝ≥0∞)) / digestCount +
∑ a, (1 + θ) * expect G (fun z => ((Outcome.slice z a).n : ℝ≥0∞)) / digestCount := by
rw [add_comm, ← add_assoc]
_ ≤ ((2 * (q + 172) : Nat) : ℝ≥0∞) / digestCount :=
accounting_le adversary (q + 172) hq hcap
_ = ((2 * q + 344 : Nat) : ENNReal) / ((2 ^ 128 : Nat) : ENNReal) := by
rw [show 2 * (q + 172) = 2 * q + 344 by omega, digestCount]
· -- From `q + 172 = 2^127` on, the bound is at least one.
refine (prEvent_le_one _).trans ?_
rw [ENNReal.le_div_iff_mul_le (Or.inl (by norm_num)) (Or.inl (ENNReal.natCast_ne_top _)),
one_mul]
exact_mod_cast (show 2 ^ 128 ≤ 2 * q + 344 by omega)

/-- The capped bound: `(2q + 634) / 2^128`, a corollary of the own-query bound. -/
theorem capped_forgeAdvantage_le_of_adversaryBound
(q : Nat) (adversary : Adversary)
(hadv : ∀ publicKey, IsQueryBoundP (adversary.main publicKey) IsAdvHash q) :
forgeAdvantage Concrete.scheme adversary ≤
((2 * q + 634 : Nat) : ENNReal) / ((2 ^ 128 : Nat) : ENNReal) :=
(forgeAdvantage_le_of_adversaryBound q adversary hadv).trans
(ENNReal.div_le_div_right (by exact_mod_cast (show 2 * q + 344 ≤ 2 * q + 634 by omega)) _)

end XmssSecurity.Fresh
Loading
Loading