|
| 1 | +/- |
| 2 | +Copyright (c) 2024-2026 ArkLib Contributors. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Tobias Rothmann |
| 5 | +-/ |
| 6 | +import ArkLib.Commitments.Functional.Hachi.QuadEval.Bridge |
| 7 | +import ArkLib.Commitments.Functional.Hachi.QuadEval.Soundness |
| 8 | +import ArkLib.OracleReduction.Security.CoordinateWiseSpecialSoundness.Escape |
| 9 | + |
| 10 | +/-! |
| 11 | + # Escape-threaded Hachi front (`evalChainE`) — skeleton (sumcheck-track milestone F2.0) |
| 12 | +
|
| 13 | + The §4.3 opening chain (`RingSwitch/`, `ZeroCheck/`, `Sumcheck/`) introduces a **new |
| 14 | + commitment** — Figure 4's |
| 15 | + `t = Com(w̃)` — whose binding break is a fresh extraction escape (Hachi [NOZ26] Remark 2: |
| 16 | + weak binding, a Module-SIS solution via Lemma 7). Composed CWSS extraction feeds every |
| 17 | + downstream extractor's output into the *previous* seam relation, so this escape must flow |
| 18 | + backwards through **all** upstream seams — including the finished bridge/`QuadEval` chain, |
| 19 | + whose relations (`relPolyEval`, `relIn`, `relOut`) have no home for it. |
| 20 | +
|
| 21 | + This file threads a single abstract escape budget `E` (with escape set `esc : Set E`, |
| 22 | + statement-independent — design decision G1) through the finished front via `Set.withEscape`: |
| 23 | +
|
| 24 | + * `relPolyEvalE`, `relInE`, `relOutE` — the widened relations (witnesses `· ⊕ E`); |
| 25 | + * `bridgePackageE` — the widened polynomial-level bridge, **sorry-free** (the escape branch of |
| 26 | + the pull-back is the identity; the real branch is the finished `mem_relPolyEval_of_relIn`); |
| 27 | + * `quadEval_coordinateWiseSpecialSound_withEscape` — the widened Lemma 8 (**sorried**: re-run |
| 28 | + the finished extraction with an escape-pass-through witness assembler `buildWitnessE`; if any |
| 29 | + branch response is `.inr e`, output `.inr e`; otherwise strip the `Sum.inl`s and apply the |
| 30 | + finished `buildWitness_mem_relIn` verbatim — no edits to done proofs); |
| 31 | + * `quadEvalPackageE` and the composed widened front `evalChainE = bridgePackageE ▷ |
| 32 | + quadEvalPackageE`, the drop-in replacement of `evalChain` that the §4.3 chain composes onto. |
| 33 | +
|
| 34 | + At `E := Empty`, `esc := ∅` the widened relations degenerate to the originals |
| 35 | + (`Set.withEscape_empty_iff`), so nothing is lost. |
| 36 | +
|
| 37 | + ## References |
| 38 | +
|
| 39 | + * [Nguyen, N. K., O'Rourke, G., and Zhang, J., *Hachi: Efficient Lattice-Based Multilinear |
| 40 | + Polynomial Commitments over Extension Fields*][NOZ26] |
| 41 | +-/ |
| 42 | + |
| 43 | +namespace ArkLib.Lattices.Ajtai.InnerOuter |
| 44 | + |
| 45 | +open CompPoly ArkLib.Lattices.CyclotomicModulus |
| 46 | +open WeakBinding |
| 47 | +open OracleComp OracleSpec ProtocolSpec CoordinateWise CoordinateWise.SingleRound |
| 48 | + |
| 49 | +/-- A left-inhabited sum is inhabited — `Nonempty (Wit ⊕ E)` for the escape-threaded witness |
| 50 | +types, from the existing witness `Nonempty` instances. -/ |
| 51 | +instance {A E : Type} [Nonempty A] : Nonempty (A ⊕ E) := ⟨.inl (Classical.arbitrary A)⟩ |
| 52 | + |
| 53 | +section ThreadedRelations |
| 54 | + |
| 55 | +variable {q : ℕ} [NeZero q] [Fact (Nat.Prime q)] [BEq (ZMod q)] [LawfulBEq (ZMod q)] |
| 56 | + (Φ : CyclotomicModulus (ZMod q)) [IsCyclotomic Φ] |
| 57 | +variable {innerRows messageDigits outerRows innerDigits dRows zDigits m r : Nat} |
| 58 | +variable {E : Type} |
| 59 | + |
| 60 | +/-- Escape-threaded `relPolyEval` (the chain-head relation): a real polynomial-level witness, or |
| 61 | +an escape from further down the chain. -/ |
| 62 | +def relPolyEvalE (base : ZMod q) (βSq γ κ : ℕ) (esc : Set E) : |
| 63 | + Set (PolyEvalStatement Φ innerRows messageDigits outerRows innerDigits dRows m r × |
| 64 | + (QuadEvalWitness Φ innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E)) := |
| 65 | + (relPolyEval Φ base βSq γ κ).withEscape esc |
| 66 | + |
| 67 | +/-- Escape-threaded `QuadEval.relIn` (Lemma 8's extraction disjunction, widened). -/ |
| 68 | +def relInE (base : ZMod q) (βSq γ κ : ℕ) (esc : Set E) : |
| 69 | + Set (QuadEvalStatement Φ innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 70 | + dRows × |
| 71 | + (QuadEvalWitness Φ innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E)) := |
| 72 | + (relIn Φ base βSq γ κ).withEscape esc |
| 73 | + |
| 74 | +/-- Escape-threaded `QuadEval.relOut` (Hachi Eq. (20) + range checks, widened): the §4.3 chain's |
| 75 | +input seam. -/ |
| 76 | +def relOutE (base : ZMod q) (ω γ : ℕ) (esc : Set E) : |
| 77 | + Set ((QuadEvalStatement Φ innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 78 | + dRows × |
| 79 | + CarrierCom Φ dRows × (Fin (2 ^ r) → ShortChallenge Φ ω)) × |
| 80 | + (QuadEvalResponse Φ innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits zDigits ⊕ E)) := |
| 81 | + (relOut (zDigits := zDigits) Φ base ω γ).withEscape esc |
| 82 | + |
| 83 | +omit [NeZero q] in |
| 84 | +/-- **Escape-threaded pull-back** for the polynomial-level bridge (the `hRel` of |
| 85 | +`bridgePackageE`): the real branch is the finished `mem_relPolyEval_of_relIn`; the escape branch |
| 86 | +passes through (escapes are statement-independent). Sorry-free. -/ |
| 87 | +theorem mem_relPolyEvalE_of_relInE (base : ZMod q) (βSq γ κ : ℕ) (esc : Set E) |
| 88 | + (s : PolyEvalStatement Φ innerRows messageDigits outerRows innerDigits dRows m r) |
| 89 | + (w : QuadEvalWitness Φ innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E) |
| 90 | + (h : (toQuadEvalStatement Φ s, w) ∈ relInE Φ base βSq γ κ esc) : |
| 91 | + (s, w) ∈ relPolyEvalE Φ base βSq γ κ esc := by |
| 92 | + cases w with |
| 93 | + | inl w' => exact mem_relPolyEval_of_relIn Φ base βSq γ κ s w' h |
| 94 | + | inr e => exact h |
| 95 | + |
| 96 | +end ThreadedRelations |
| 97 | + |
| 98 | +section ThreadedPackages |
| 99 | + |
| 100 | +variable {q : ℕ} [NeZero q] [Fact (Nat.Prime q)] [BEq (ZMod q)] [LawfulBEq (ZMod q)] {α : ℕ} |
| 101 | +variable {innerRows messageDigits outerRows innerDigits dRows zDigits m r : Nat} |
| 102 | +variable {ι : Type} {oSpec : OracleSpec ι} {σ : Type} {E : Type} |
| 103 | + |
| 104 | +/-- **The escape-threaded polynomial-level bridge as a `CWSSPackage`** (widened |
| 105 | +`bridgePackage`), sorry-free: the same zero-round `ReduceClaim` verifier, with the widened |
| 106 | +relations and the escape-pass-through pull-back `mem_relPolyEvalE_of_relInE`. -/ |
| 107 | +def bridgePackageE (init : ProbComp σ) (impl : QueryImpl oSpec (StateT σ ProbComp)) |
| 108 | + (base : ZMod q) (βSq γ κ : ℕ) (esc : Set E) : |
| 109 | + CWSSPackage init impl |
| 110 | + (PolyEvalStatement 𝓜(q, α) innerRows messageDigits outerRows innerDigits dRows m r) |
| 111 | + (QuadEvalWitness 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E) |
| 112 | + (QuadEvalStatement 𝓜(q, α) innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 113 | + dRows) |
| 114 | + (QuadEvalWitness 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E) |
| 115 | + (!p[] : ProtocolSpec 0) where |
| 116 | + verifier := bridgeVerifier (oSpec := oSpec) 𝓜(q, α) |
| 117 | + struct := CWSSStructure.ofIsEmpty |
| 118 | + relIn := relPolyEvalE 𝓜(q, α) base βSq γ κ esc |
| 119 | + relOut := relInE 𝓜(q, α) base βSq γ κ esc |
| 120 | + isPure := ⟨fun stmt _ => toQuadEvalStatement 𝓜(q, α) stmt, fun _ _ => rfl⟩ |
| 121 | + isCWSS := ReduceClaim.verifier_coordinateWiseSpecialSound |
| 122 | + (relIn := relPolyEvalE 𝓜(q, α) base βSq γ κ esc) |
| 123 | + (relOut := relInE 𝓜(q, α) base βSq γ κ esc) |
| 124 | + (mapWitInv := fun _ w => w) (D := CWSSStructure.ofIsEmpty) |
| 125 | + (mem_relPolyEvalE_of_relInE 𝓜(q, α) base βSq γ κ esc) |
| 126 | + |
| 127 | +/-- **Escape-threaded Hachi Lemma 8 (skeleton).** The `QuadEval` fold verifier is CWSS for the |
| 128 | +*widened* relations `relInE`/`relOutE`. |
| 129 | +
|
| 130 | +**Sorried (F2.0).** Proof plan: `coordinateWiseSpecialSound_of_mkWitness` with the widened |
| 131 | +assembler `buildWitnessE` — if some branch response is `.inr e` (pick the least such branch), |
| 132 | +output `.inr e` (its `relOutE`-membership is exactly `e ∈ esc`, which is `relInE`'s `.inr` |
| 133 | +case); otherwise all responses are `.inl`, strip them and apply the finished |
| 134 | +`buildWitness_mem_relIn` verbatim. No edits to the finished sorry-free proofs. -/ |
| 135 | +theorem quadEval_coordinateWiseSpecialSound_withEscape |
| 136 | + (init : ProbComp σ) (impl : QueryImpl oSpec (StateT σ ProbComp)) |
| 137 | + (hq5 : q % 8 = 5) {b ω γ : ℕ} (hκ : (2 * ω) ^ 2 < q) (hτ : 0 < zDigits) (esc : Set E) : |
| 138 | + (verifier (oSpec := oSpec) (ω := ω) 𝓜(q, α) (innerRows := innerRows) |
| 139 | + (messageDigits := messageDigits) (outerRows := outerRows) |
| 140 | + (innerDigits := innerDigits) (dRows := dRows) (m := m) |
| 141 | + (r := r)).coordinateWiseSpecialSound init impl |
| 142 | + (foldStructure (CarrierCom := CarrierCom 𝓜(q, α) dRows) |
| 143 | + (C := ShortChallenge 𝓜(q, α) ω) (r := r)) |
| 144 | + (relInE 𝓜(q, α) (b : ZMod q) |
| 145 | + (quadEvalBetaSq γ b zDigits ((𝓜(q, α)).φ.natDegree) m messageDigits) γ (2 * ω) esc) |
| 146 | + (relOutE (zDigits := zDigits) 𝓜(q, α) (b : ZMod q) ω γ esc) := by |
| 147 | + sorry |
| 148 | + |
| 149 | +/-- **Escape-threaded `QuadEval` package** (widened `quadEvalPackage`): the same two-round fold |
| 150 | +verifier and `foldStructure`, with the widened relations; the certificate is the sorried |
| 151 | +`quadEval_coordinateWiseSpecialSound_withEscape`. -/ |
| 152 | +def quadEvalPackageE (init : ProbComp σ) (impl : QueryImpl oSpec (StateT σ ProbComp)) |
| 153 | + (hq5 : q % 8 = 5) {b ω γ : ℕ} (hκ : (2 * ω) ^ 2 < q) (hτ : 0 < zDigits) (esc : Set E) : |
| 154 | + CWSSPackage init impl |
| 155 | + (QuadEvalStatement 𝓜(q, α) innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 156 | + dRows) |
| 157 | + (QuadEvalWitness 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E) |
| 158 | + (QuadEvalStatement 𝓜(q, α) innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 159 | + dRows × |
| 160 | + CarrierCom 𝓜(q, α) dRows × (Fin (2 ^ r) → ShortChallenge 𝓜(q, α) ω)) |
| 161 | + (QuadEvalResponse 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits zDigits ⊕ E) |
| 162 | + (pSpec (CarrierCom 𝓜(q, α) dRows) (ShortChallenge 𝓜(q, α) ω) r) where |
| 163 | + verifier := verifier (oSpec := oSpec) (ω := ω) 𝓜(q, α) |
| 164 | + struct := |
| 165 | + foldStructure (CarrierCom := CarrierCom 𝓜(q, α) dRows) (C := ShortChallenge 𝓜(q, α) ω) |
| 166 | + (r := r) |
| 167 | + relIn := relInE 𝓜(q, α) (b : ZMod q) |
| 168 | + (quadEvalBetaSq γ b zDigits ((𝓜(q, α)).φ.natDegree) m messageDigits) γ (2 * ω) esc |
| 169 | + relOut := relOutE (zDigits := zDigits) 𝓜(q, α) (b : ZMod q) ω γ esc |
| 170 | + isPure := ⟨fun stmt tr => (stmt, tr.messages ⟨0, rfl⟩, tr.challenges ⟨1, rfl⟩), fun _ _ => rfl⟩ |
| 171 | + isCWSS := quadEval_coordinateWiseSpecialSound_withEscape init impl hq5 hκ hτ esc |
| 172 | + |
| 173 | +/-- **The escape-threaded evaluation front** `bridgePackageE ▷ quadEvalPackageE`: the widened |
| 174 | +drop-in for `evalChain`, from `relPolyEvalE` to `relOutE` (Eq. (20) + ranges, widened). The |
| 175 | +§4.3 opening chain (`RingSwitch/` onwards) composes onto this front's `relOutE` seam. -/ |
| 176 | +def evalChainE (init : ProbComp σ) (impl : QueryImpl oSpec (StateT σ ProbComp)) |
| 177 | + (hq5 : q % 8 = 5) {b ω γ : ℕ} (hκ : (2 * ω) ^ 2 < q) (hτ : 0 < zDigits) (esc : Set E) : |
| 178 | + CWSSPackage init impl |
| 179 | + (PolyEvalStatement 𝓜(q, α) innerRows messageDigits outerRows innerDigits dRows m r) |
| 180 | + (QuadEvalWitness 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits ⊕ E) |
| 181 | + (QuadEvalStatement 𝓜(q, α) innerRows (2 ^ m) messageDigits outerRows (2 ^ r) innerDigits |
| 182 | + dRows × |
| 183 | + CarrierCom 𝓜(q, α) dRows × (Fin (2 ^ r) → ShortChallenge 𝓜(q, α) ω)) |
| 184 | + (QuadEvalResponse 𝓜(q, α) innerRows (2 ^ m) messageDigits (2 ^ r) innerDigits zDigits ⊕ E) |
| 185 | + ((!p[] : ProtocolSpec 0) ++ₚ |
| 186 | + pSpec (CarrierCom 𝓜(q, α) dRows) (ShortChallenge 𝓜(q, α) ω) r) := |
| 187 | + bridgePackageE init impl (b : ZMod q) |
| 188 | + (quadEvalBetaSq γ b zDigits ((𝓜(q, α)).φ.natDegree) m messageDigits) γ (2 * ω) esc ▷ |
| 189 | + quadEvalPackageE init impl hq5 hκ hτ esc |
| 190 | + |
| 191 | +end ThreadedPackages |
| 192 | + |
| 193 | +end ArkLib.Lattices.Ajtai.InnerOuter |
0 commit comments