-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathCommitment.lean
More file actions
162 lines (138 loc) Β· 9.19 KB
/
Copy pathCommitment.lean
File metadata and controls
162 lines (138 loc) Β· 9.19 KB
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
/-
Copyright (c) 2024-2026 ArkLib Contributors. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tobias Rothmann
-/
import ArkLib.Commitments.Functional.Hachi.QuadEval.Basic
import ArkLib.Commitments.Functional.Basic
/-!
# Hachi as a Functional Commitment
Hachi [NOZ26] as a `Commitment.Scheme` (`ArkLib.Commitments.Functional.Basic`) over the multilinear
data `CMlPolynomial (Rq π(q,Ξ±)) (r + m)` β an `(r + m)`-variable multilinear polynomial with
coefficients in the power-of-two cyclotomic ring `Rq π(q,Ξ±) = (ZMod q)[X] / (X^{2^Ξ±} + 1)`. This
file supplies what the generic interface asks of a functional commitment: the multilinear
eval-oracle interface (`multilinearEvalOracleInterface`), honest key generation and commitment
(`keygen` / `commit`, using the canonical base-`b` gadget decomposition `zmodDigitDecomposition` at
the paper's width `Ξ΄ = βlog_b qβ = Nat.clog b q`, Hachi Β§2.1/Β§4.1), and the `hachi` scheme itself.
The eval-oracle interface and the honest committer operations are real; the opening `Proof` is
deferred (`sorry`, see the `TODO`). The coordinate-wise-special-sound (CWSS) composition the
finished opening will run over lives in the sibling `Composition.lean`
(`evalChain` / `eval_coordinateWiseSpecialSound`).
## Main definitions
* `multilinearEvalOracleInterface`: the `OracleInterface` letting a committed polynomial be
queried at an evaluation point, returning its value there β the `Data` of the commitment.
* `keygen`: honest key generation β sample the inner/outer/short Ajtai matrices `(A, B, D)`
uniformly; the resulting `PublicParamsD` serves as both committer and verifier key.
* `commit`: honest commitment β reshape the polynomial into its `2^r Γ 2^m` coefficient matrix,
gadget-decompose it, and outer-commit; the decommitment is the `Decomp` data. Deterministic.
* `hachi`: the `Commitment.Scheme` value packaging the above; its `opening` field is a documented
`sorry` pending the Β§4.3+ subprotocols (see the `TODO` block).
Same namespace/opens discipline as the rest of the Hachi tree
(`namespace ArkLib.Lattices.Ajtai.InnerOuter`, `open WeakBinding`).
## References
* [Nguyen, N. K., and Seiler, G., *Greyhound: Fast Polynomial Commitments from Lattices*][NS24]
* [Nguyen, N. K., O'Rourke, G., and Zhang, J., *Hachi: Efficient Lattice-Based Multilinear
Polynomial Commitments over Extension Fields*][NOZ26]
-/
namespace ArkLib.Lattices.Ajtai.InnerOuter
open CompPoly ArkLib.Lattices.CyclotomicModulus
open WeakBinding
open OracleComp OracleSpec ProtocolSpec CoordinateWise CoordinateWise.SingleRound
section FunctionalCommitment
variable {q : β} [NeZero q] [Fact (Nat.Prime q)] [BEq (ZMod q)] [LawfulBEq (ZMod q)] {Ξ± : β}
variable {innerRows outerRows dRows m r : Nat} {Ο : β}
/-- The **multilinear evaluation oracle** on a committed `n`-variable multilinear polynomial: a
query is an evaluation point `x : Vector (Rq π(q,Ξ±)) n` and the answer is `f x`. This is the
`OracleInterface` that makes `CMlPolynomial (Rq π(q,Ξ±)) n` the `Data` of a functional commitment
(`Commitment.Scheme`); `toOC` follows `OracleContext.ofFunction`. -/
instance multilinearEvalOracleInterface {n : β} :
OracleInterface (CMlPolynomial (Rq π(q, Ξ±)) n) where
Query := Vector (Rq π(q, Ξ±)) n
toOC :=
{ spec := Vector (Rq π(q, Ξ±)) n ββ Rq π(q, Ξ±)
impl := fun p => do return CMlPolynomial.eval (β read) p }
-- `b > 1` is the gadget base used for **all** decompositions. Faithful to Hachi [NOZ26] Β§2.1/Β§4.1,
-- every coefficient is written in `Ξ΄ := βlog_b qβ = Nat.clog b q` base-`b` digits β a single `Ξ΄`
-- shared by the message gadget `Gβ»ΒΉ_{2α΅}` and the inner gadget `Gβ»ΒΉ_{n_A}` β so both digit counts
-- are `Nat.clog b q` (and `q β€ bα΅` holds by `Nat.le_pow_clog`).
variable (b : β)
variable
[SampleableType (Simple.PublicParams π(q, Ξ±) innerRows ((2 ^ m) * Nat.clog b q))]
[SampleableType (Simple.PublicParams π(q, Ξ±) outerRows ((2 ^ r) * (innerRows * Nat.clog b q)))]
[SampleableType (Simple.PublicParams π(q, Ξ±) dRows ((2 ^ r) * Nat.clog b q))]
/-- Honest **key generation**: sample the inner/outer/short Ajtai matrices `(A, B, D)` uniformly
(matching `InnerOuter.commitmentScheme.setup`, extended with the Hachi short-commitment matrix `D`,
Eq. (16)) and return the resulting `PublicParamsD` as both the committer and the verifier key. -/
def keygen :
ProbComp
(Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r) (Nat.clog b q)
dRows Γ
Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r)
(Nat.clog b q) dRows) := do
let A β $α΅ (Simple.PublicParams π(q, Ξ±) innerRows ((2 ^ m) * Nat.clog b q))
let B β $α΅ (Simple.PublicParams π(q, Ξ±) outerRows ((2 ^ r) * (innerRows * Nat.clog b q)))
let D β $α΅ (Simple.PublicParams π(q, Ξ±) dRows ((2 ^ r) * Nat.clog b q))
let pp :
Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r) (Nat.clog b q)
dRows :=
{ innerMatrix := A, outerMatrix := B, dMatrix := D }
pure (pp, pp)
/-- Honest **commitment** to a multilinear polynomial `p`: reshape it into its `2^r Γ 2^m`
coefficient matrix (`Hachi.toMatrix`, definitionally a `Message π(q,Ξ±) (2^m) (2^r)`),
gadget-decompose it into the per-block messages/inner decompositions with the **canonical base-`b`
digit decomposition** `zmodDigitDecomposition` at the paper's width `Ξ΄ = βlog_b qβ = Nat.clog b q`
(the `q β€ bα΅` obligation is `Nat.le_pow_clog`), and outer-commit (`commitWithDecomps`).
Deterministic; the decommitment is the `Decomp` data. -/
def commit [DecidableEq (ZMod q)] (hb : 1 < b)
(pp : Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r)
(Nat.clog b q) dRows)
(p : CMlPolynomial (Rq π(q, Ξ±)) (r + m)) :
Commitment π(q, Ξ±) outerRows Γ
Decomp π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) (2 ^ r) (Nat.clog b q) :=
let decomps := generateDecomps π(q, Ξ±)
(Decomposition.ofDigits π(q, Ξ±)
(zmodDigitDecomposition b (Nat.clog b q) hb (Nat.le_pow_clog hb q))
(zmodDigitDecomposition b (Nat.clog b q) hb (Nat.le_pow_clog hb q)))
pp.toPublicParams (Hachi.toMatrix p)
(commitWithDecomps π(q, Ξ±) pp.toPublicParams decomps, decomps)
/-- **Hachi as a functional commitment** (`Commitment.Scheme`) β β **WIP scaffold.** The eval
oracle and the honest `keygen` / `commit` are real, but the `opening` field is a placeholder
(`sorry`, see below and the `TODO` block), so this value does **not** yet certify end-to-end
opening correctness. It is committed now only as the target packaging the finished opening will
slot into once the Β§4.3+ subprotocols and the honest-prover layer land (the follow-up tracked by
the `TODO` here and in `Composition.lean`).
Over the multilinear data `CMlPolynomial (Rq π(q,Ξ±)) (r + m)` β an `(r + m)`-variable polynomial,
with the `r`/`m` split feeding the outer/inner gadgets. It commits a polynomial directly (no
caller-supplied decompositions): the honest `commit` uses the canonical base-`b` gadget
decomposition at the paper's width `Ξ΄ = βlog_b qβ = Nat.clog b q` (Hachi [NOZ26] Β§2.1/Β§4.1), shared
by the message and inner gadgets β so `messageDigits`/`innerDigits` are not free parameters. The
only parameters are the gadget base `b` and `1 < b`; the scheme carries the eval oracle
`multilinearEvalOracleInterface`, honest `keygen` / `commit`, committer and verifier key
`PublicParamsD`, and decommitment `Decomp`.
The `opening` field β the complete opening `Proof` (a `Reduction β¦ Bool Unit`) β is **provisional**
(`sorry`): its boolean verdict is Hachi Eq. (20) membership (`relOut`), which depends on the never-
sent triple `(Ε΅, tΜ, αΊ)`; it becomes verifier-computable only after the remaining Β§4.3+ subprotocols
and their honest-prover layer (`QuadEval.prover`'s `computeV`/`computeResp`) are formalized.
Everything else here is real. The stated `pSpec` is the composed evaluation protocol spec
(`!p[] ++β pSpec β¦`), i.e. the shape the finished opening will run over β see the `TODO` block. -/
def hachi [DecidableEq (ZMod q)] (hb : 1 < b) :
Commitment.Scheme unifSpec
(CMlPolynomial (Rq π(q, Ξ±)) (r + m))
(Commitment π(q, Ξ±) outerRows)
(Decomp π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) (2 ^ r) (Nat.clog b q))
(Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r) (Nat.clog b q)
dRows)
(Hachi.PublicParamsD π(q, Ξ±) innerRows (2 ^ m) (Nat.clog b q) outerRows (2 ^ r) (Nat.clog b q)
dRows)
((!p[] : ProtocolSpec 0) ++β
pSpec (CarrierCom π(q, Ξ±) dRows) (ShortChallenge π(q, Ξ±) Ο) r) where
keygen := keygen b
commit := fun pp p => pure (commit b hb pp p)
opening := sorry
end FunctionalCommitment
/-! ## TODO β completeness / honest-prover layer
The `opening` field of `hachi` is provisional (`sorry`). Materializing it needs the honest-prover
layer: instantiate `QuadEval.prover`'s `computeV` / `computeResp` from the `QuadEval.Gadgets`
carrier/decomposition definitions (`carrierCommit`, `zDecomp`), discharging
`Commitment.perfectCorrectness` for `hachi`. -/
end ArkLib.Lattices.Ajtai.InnerOuter