Repository navigation
Expand file tree
/
Copy pathVectorIOR.lean
More file actions
195 lines (145 loc) · 7.89 KB
/
Copy pathVectorIOR.lean
File metadata and controls
195 lines (145 loc) · 7.89 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
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
/-
Copyright (c) 2024-2025 ArkLib Contributors. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Quang Dao
-/
module
public import ArkLib.OracleReduction.Security.RoundByRound
/-!
# Vector Interactive Oracle Reductions
We define vector interactive oracle reductions (V-IOR) and vector interactive oracle proofs
(V-IOPs), as special cases IORs/IOPs where all messages and oracle statements are vectors over some
alphabet. We also define their proximity versions, V-IORP and V-IOPP, which exhibit a gap between
the relation for completeness and the relation for soundness.
This is the original formulation of IOPs in [BCS16]. Many IOPs of interest in the literature are of
this form, and so we isolate this special case for ease of notation and reasoning.
We also define complexity measures for V-IORs, such as proof length and verifier's query complexity.
-/
@[expose] public section
namespace ProtocolSpec
/-- The protocol specification for a V-IOR, which consists of the direction of each message and its
length.
(assumed to be working over a fixed alphabet) -/
@[ext]
structure VectorSpec (n : ℕ) where
dir : Fin n → Direction
length : Fin n → Nat
namespace VectorSpec
variable {n : ℕ}
/-- Convert a `VectorSpec` into a `ProtocolSpec` for a given alphabet type `A`. The `i`-th message
is a vector of length `vPSpec i.2` over `A`.
Note that we give the `Vector A n` type for this, instead of `Fin n → A`, for better performance in
(future) implementations. We may revisit this choice in the future. -/
@[reducible, simp]
def toProtocolSpec (A : Type) (vPSpec : VectorSpec n) : ProtocolSpec n :=
⟨vPSpec.dir, fun i => Vector A (vPSpec.length i)⟩
/-- The type of indices for messages in a `VectorSpec`. -/
@[reducible, inline, specialize, simp]
def MessageIdx (vPSpec : VectorSpec n) := {i : Fin n // vPSpec.dir i = .P_to_V}
/-- The type of indices for challenges in a `VectorSpec`. -/
@[reducible, inline, specialize, simp]
def ChallengeIdx (vPSpec : VectorSpec n) := {i : Fin n // vPSpec.dir i = .V_to_P}
/-- The length of the `i`-th prover's message in a `VectorSpec`. -/
@[reducible]
def messageLength (vPSpec : VectorSpec n) (i : MessageIdx vPSpec) : Nat := vPSpec.length i
/-- The length of the `i`-th challenge in a `VectorSpec`. -/
@[reducible]
def challengeLength (vPSpec : VectorSpec n) (i : ChallengeIdx vPSpec) : Nat := vPSpec.length i
/-- The total length of all messages in a `VectorSpec`. -/
@[reducible]
def totalMessageLength (vPSpec : VectorSpec n) : Nat := ∑ i, vPSpec.messageLength i
/-- The total length of all challenges in a `VectorSpec`
(i.e. the verifier's randomness complexity). -/
@[reducible]
def totalChallengeLength (vPSpec : VectorSpec n) : Nat := ∑ i, vPSpec.challengeLength i
variable {A : Type} {vPSpec : VectorSpec n}
/-- All messages in an V-IOR have the same vector oracle interface. -/
instance : OracleInterfaces (vPSpec.toProtocolSpec A) where
oracleInterfaces := fun _ => some OracleInterface.instVector
instance : ∀ i, OracleInterface ((vPSpec.toProtocolSpec A).Message i) :=
fun _ => OracleInterface.instVector
instance [VCVCompatible A] : ∀ i, VCVCompatible ((vPSpec.toProtocolSpec A).Challenge i) :=
fun _ => by dsimp; infer_instance
end VectorSpec
end ProtocolSpec
variable {n : ℕ} {ι : Type}
/-- Vector Interactive Oracle Reductions.
This is just a specialization of `OracleReduction` to the case where all messages and oracle
statements are vectors over some alphabet, and there is no shared oracle.
We do _not_ require the (oracle) statements and witnesses to be vectors as well, though this can
be done if needed. -/
@[reducible]
def VectorIOR
(StmtIn : Type) {ιₛᵢ : Type} (OStmtIn : ιₛᵢ → Type) (WitIn : Type)
(StmtOut : Type) {ιₛₒ : Type} (OStmtOut : ιₛₒ → Type) (WitOut : Type)
(vPSpec : ProtocolSpec.VectorSpec n) (A : Type)
[∀ i, OracleInterface (OStmtIn i)] [∀ i, OracleInterface (OStmtOut i)] :=
OracleReduction []ₒ StmtIn OStmtIn WitIn StmtOut OStmtOut WitOut (vPSpec.toProtocolSpec A)
/-- Vector Interactive Oracle Proofs
This is just a specialization of `OracleProof` to the case where all messages and oracle statements
are vectors over some alphabet. We do _not_ require the (oracle) statements and witnesses to be
vectors as well, though this can be done if needed. -/
@[reducible]
def VectorIOP
(Statement : Type) {ιₛ : Type} (OStatement : ιₛ → Type) (Witness : Type)
(vPSpec : ProtocolSpec.VectorSpec n) (A : Type)
[∀ i, OracleInterface (OStatement i)] :=
OracleProof []ₒ Statement OStatement Witness (vPSpec.toProtocolSpec A)
variable {n : ℕ} {vPSpec : ProtocolSpec.VectorSpec n} {A : Type}
[SampleableType A]
open scoped NNReal
namespace VectorIOR
variable {StmtIn WitIn StmtOut WitOut : Type} {ιₛᵢ : Type} {OStmtIn : ιₛᵢ → Type}
[∀ i, OracleInterface (OStmtIn i)] {ιₛₒ : Type} {OStmtOut : ιₛₒ → Type}
[∀ i, OracleInterface (OStmtOut i)]
/-- A vector IOR is **secure** with respect to input relation `relIn`, output relation `relOut`, and
round-by-round knowledge error `ε_rbr` if it satisfies (perfect) completeness and round-by-round
knowledge soundness with respect to `relIn`, `relOut`, and `ε_rbr`. -/
class IsSecure
(relIn : Set ((StmtIn × ∀ i, OStmtIn i) × WitIn))
(relOut : Set ((StmtOut × ∀ i, OStmtOut i) × WitOut))
(ε_rbr : vPSpec.ChallengeIdx → ℝ≥0)
(vectorIOR : VectorIOR StmtIn OStmtIn WitIn StmtOut OStmtOut WitOut vPSpec A) where
/-- The reduction is perfectly complete. -/
is_complete : vectorIOR.perfectCompleteness (pure ()) isEmptyElim relIn relOut
/-- The reduction is round-by-round knowledge sound with respect to `relIn`, `relOut`,
`ε_rbr`, and the state function. -/
is_rbr_knowledge_sound :
vectorIOR.verifier.rbrKnowledgeSoundness (pure ()) isEmptyElim relIn relOut ε_rbr
-- TODO: define V-IOR of proximity
end VectorIOR
namespace VectorIOP
variable {Statement Witness : Type} {ιₛ : Type} {OStatement : ιₛ → Type}
[∀ i, OracleInterface (OStatement i)]
/-- A vector IOP is **secure** with respect to relation `relation` and round-by-round knowledge
error `ε_rbr` if it satisfies (perfect) completeness and round-by-round knowledge soundness
with respect to `relation` and `ε_rbr`. -/
class IsSecure
(relation : Set ((Statement × ∀ i, OStatement i) × Witness))
(ε_rbr : vPSpec.ChallengeIdx → ℝ≥0)
(vectorIOP : VectorIOP Statement OStatement Witness vPSpec A) where
/-- The reduction is perfectly complete. -/
is_complete : vectorIOP.perfectCompleteness (pure ()) isEmptyElim relation
/-- The reduction is round-by-round knowledge sound with respect to `relIn`, `relOut`,
`ε_rbr`, and the state function. -/
is_rbr_knowledge_sound :
OracleProof.rbrKnowledgeSoundness
(pure ()) isEmptyElim relation vectorIOP.toOracleVerifier ε_rbr
/-- A vector IOP **of proximity** is **secure** with respect to completeness relation
`completeRelation`, soundness relation `soundRelation`, and round-by-round knowledge error
`ε_rbr` if it satisfies:
- (perfect) completeness with respect to `completeRelation`,
- round-by-round knowledge soundness with respect to `soundRelation` and `ε_rbr`. -/
class IsSecureWithGap
(completeRelation : Set ((Statement × ∀ i, OStatement i) × Witness))
(soundRelation : Set ((Statement × ∀ i, OStatement i) × Witness))
(ε_rbr : vPSpec.ChallengeIdx → ℝ≥0)
(vectorIOP : VectorIOP Statement OStatement Witness vPSpec A) where
/-- The reduction is perfectly complete. -/
is_complete : vectorIOP.perfectCompleteness (pure ()) isEmptyElim completeRelation
/-- The reduction is round-by-round knowledge sound with respect to `relIn`, `relOut`,
`ε_rbr`, and the state function. -/
is_rbr_knowledge_sound :
OracleProof.rbrKnowledgeSoundness
(pure ()) isEmptyElim soundRelation vectorIOP.toOracleVerifier ε_rbr
end VectorIOP