-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericSpecialSoundness.eca
389 lines (330 loc) · 15.5 KB
/
GenericSpecialSoundness.eca
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
pragma Goals:printall.
require import AllCore List Distr Real RealExp.
import StdOrder.RealOrder.
require GenericExtractability.
clone include GenericExtractability. (* inherit defs. *)
abstract theory SpecialSoundness.
op special_soundness_extract (s:statement)(t1 t2:transcript): witness.
(* importing rewinding library *)
require RewBasics.
clone import RewBasics as Rew with type sbits <- sbits,
op pair_sbits <- pair_sbits,
op unpair <- unpair
proof *.
realize ips. apply ips. qed.
realize unpair_pair. apply unpair_pair. qed.
module type SpecialSoundnessAdversary = {
proc attack(statement:statement) : transcript * transcript
}.
op valid_transcript_pair (s: statement)
(t1 t2: transcript) : bool
= t1.`1 = t2.`1
/\ t1.`2 <> t2.`2
/\ verify_transcript s t1
/\ verify_transcript s t2.
(* special soundness adversary for computational case *)
module SpecialSoundnessAdversary(P : RewMaliciousProver)
: SpecialSoundnessAdversary = {
proc attack(statement:statement):transcript * transcript = {
var i,c1,c2,r1,r2, pstate;
i <@ P.commitment(statement);
c1 <$ duniform challenge_set;
pstate <@ P.getState();
r1 <@ P.response(c1);
c2 <$ duniform challenge_set;
P.setState(pstate);
r2 <@ P.response(c2);
return ((i,c1,r1), (i,c2,r2));
}
}.
module (Extractor : Extractor)(P : RewMaliciousProver) = {
module SA = SpecialSoundnessAdversary(P)
proc extract(p : statement) : witness = {
var t1,t2;
(t1,t2) <@ SA.attack(p);
return special_soundness_extract p t1 t2;
}
}.
theory Computational.
require import ExtractabilityEquations.
clone import ExtractabilityEquationsTheory as GKE with type pt <- statement,
type auxt <- unit,
type irt <- commitment,
type ct <- challenge,
type rt <- response,
type sbits <- sbits,
op RWI.pair_sbits <- pair_sbits,
op RWI.unpair <- unpair,
op d <- duniform challenge_set,
op allcs <- challenge_set
proof *.
realize RWI.ips. apply ips. qed.
realize RWI.RW.ips. apply ips. qed.
realize RWI.unpair_pair. apply unpair_pair. qed.
realize RWI.RW.unpair_pair. apply unpair_pair. qed.
realize duni. smt(@Distr). qed.
realize dll. apply duniform_ll. smt(challenge_set_size). qed.
realize allcs_uniq. smt(challenge_set_unique). qed.
realize allcs_all. smt(@Distr). qed.
realize ss. progress.
rewrite duniform1E_uniq. apply challenge_set_unique. rewrite H. auto.
qed.
section.
declare module P <: RewMaliciousProver{-HV}.
declare axiom P_response_ll : islossless P.response.
declare axiom P_commitment_ll : islossless P.commitment.
(* rewindability assumption *)
declare axiom rewindable_P_plus :
(exists (f : glob P -> sbits),
injective f /\
(forall &m, Pr[ P.getState() @ &m : (glob P) = ((glob P){m})
/\ res = f ((glob P){m} ) ] = 1%r) /\
(forall &m b (x: glob P), b = f x =>
Pr[P.setState(b) @ &m : glob P = x] = 1%r) /\
islossless P.setState).
local module A(P : RewMaliciousProver) : Adv = {
proc init (p : statement,x:unit) : commitment = {
var i : commitment;
i <@ P.commitment(p);
return i;
}
proc run(hcm : commitment, hcc: challenge) : response = {
var r;
r <@ P.response(hcc);
return r;
}
proc getState = P.getState
proc setState = P.setState
}.
op hc_verify = fun s cm ch rs => verify_transcript s (cm , ch, rs). (* TODO: remove later *)
local lemma ex_a_eq_f &m p aux f :
Pr[ InitRun2(A(P)).run(p,aux) @ &m
: res.`1.`1 <> res.`2.`1 /\
hc_verify p res.`1.`2.`2 res.`1.`1 res.`1.`2.`1 /\
hc_verify p res.`2.`2.`2 res.`2.`1 res.`2.`2.`1 /\
f (soundness_relation p (special_soundness_extract p (res.`1.`2.`2, res.`1.`1, res.`1.`2.`1)
(res.`2.`2.`2, res.`2.`1, res.`2.`2.`1))) ]
= Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
f (soundness_relation p (special_soundness_extract p res.`1 res.`2))].
proof. byequiv;auto.
proc. simplify. inline*. wp. call (_:true). wp. call (_:true). rnd. wp.
call (_:true). wp. call (_:true). rnd. wp. call (_:true). wp. skip. progress;smt().
qed.
local lemma pok' &m p aux deltoid :
Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p
(special_soundness_extract p res.`1 res.`2)] <= deltoid
=> Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
soundness_relation p (special_soundness_extract p res.`1 res.`2)]
>= (Pr[ InitRun1(A(P)).run(p,aux) @ &m
: hc_verify p res.`2.`2 res.`1 res.`2.`1 ]^2
- (1%r/ (size (challenge_set ) ) %r)
* Pr[ InitRun1(A(P)).run(p,aux) @ &m
: hc_verify p res.`2.`2 res.`1 res.`2.`1 ])
- deltoid.
proof. rewrite - (ex_a_eq_f &m p aux).
move => f. simplify.
rewrite - (ex_a_eq_f &m p aux (fun x => x) ).
apply (extraction_success_prob (A(P)) _ _ _ &m (fun pq (r : challenge * (response * commitment)) =>
hc_verify (fst pq) r.`2.`2 r.`1 r.`2.`1) (fun (pq :statement * unit)
(r1 r2 : challenge * (response * commitment)) => soundness_relation (fst pq)
(special_soundness_extract (fst pq) (r1.`2.`2, r1.`1, r1.`2.`1) (r2.`2.`2, r2.`1, r2.`2.`1)))
(p, aux)
deltoid _).
proc. call P_response_ll;auto.
proc. call P_commitment_ll;auto.
simplify.
apply (rewindable_A_plus P rewindable_P_plus).
auto.
qed.
local lemma ssa_ext &m p :
Pr[SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
soundness_relation p (special_soundness_extract p res.`1 res.`2)]
<= Pr[Extractor(P).extract(p) @ &m : soundness_relation p res].
byequiv. proc. inline*. wp. call (_:true).
call (_:true). rnd. call (_:true). call (_:true).
rnd. call (_:true). wp. skip. progress. auto. auto.
qed.
local lemma onerun1_soundness &m p aux:
Pr[ InitRun1(A(P)).run(p,aux) @ &m
: hc_verify p res.`2.`2 res.`1 res.`2.`1 ]
= Pr[Soundness(P, HV).run(p) @ &m : res].
byequiv. proc. inline*. wp. call (_:true).
wp. rnd. wp. call (_:true). wp.
skip. simplify. progress. auto. auto.
qed.
lemma computational_extractability &m p deltoid:
Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)] <=
deltoid =>
Pr[Extractor(P).extract(p) @ &m : soundness_relation p res] >=
(Pr[Soundness(P, HV).run(p) @ &m : res]^2
- (1%r/ (size challenge_set)%r) * Pr[Soundness(P, HV).run(p) @ &m : res])
- deltoid.
progress.
have f : Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
soundness_relation p (special_soundness_extract p res.`1 res.`2)]
>= (Pr[ InitRun1(A(P)).run(p,tt) @ &m : hc_verify p res.`2.`2 res.`1 res.`2.`1 ]^2
- (1%r/ (size (challenge_set ) ) %r) * Pr[ InitRun1(A(P)).run(p,tt) @ &m : hc_verify p res.`2.`2 res.`1 res.`2.`1 ])
- deltoid. apply (pok' &m p). auto.
have g : Pr[ InitRun1(A(P)).run(p,tt) @ &m
: hc_verify p res.`2.`2 res.`1 res.`2.`1 ]
= Pr[Soundness(P, HV).run(p) @ &m : res]. apply onerun1_soundness.
have j : Pr[SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
soundness_relation p (special_soundness_extract p res.`1 res.`2)]
<= Pr[Extractor(P).extract(p) @ &m : soundness_relation p res].
apply ssa_ext. smt().
qed.
local lemma ssa_ext1 (a b : real) : a <= b => sqrt a <= sqrt b.
smt(@RealExp). qed.
local lemma ssa_ext2 (a b : real) : a ^ 2 <= b => a <= sqrt b.
smt(@RealExp). qed.
lemma computational_soundness &m p deltoid:
! in_language soundness_relation p =>
Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)]
<= deltoid
=> Pr[Soundness(P, HV).run(p) @ &m : res]
<= (sqrt deltoid) + (1%r/(size challenge_set)%r).
proof. progress.
have f1 : Pr[Extractor(P).extract(p) @ &m : soundness_relation p res] = 0%r.
have <-: Pr[Extractor(P).extract(p) @ &m : false ] = 0%r.
rewrite Pr[mu_false]. auto.
rewrite Pr[mu_eq]. smt(). auto.
have : 0%r >=
(Pr[Soundness(P, HV).run(p) @ &m : res]^2
- (1%r/ (size (challenge_set ))%r) * Pr[Soundness(P, HV).run(p) @ &m : res])
- deltoid.
rewrite - f1.
apply (computational_extractability &m p). auto.
pose a := Pr[Soundness(P, HV).run(p) @ &m : res].
pose b := deltoid.
have f2 : 0%r <= a <= 1%r. split. rewrite /a. rewrite Pr[mu_ge0]. auto. rewrite /a. rewrite Pr[mu_le1]. auto.
progress.
have f3 : a ^ 2 - 1%r / (size challenge_set)%r * a <= b. smt().
have f4 : a * (a - 1%r / (size challenge_set)%r) <= b. smt(@Real challenge_set_size).
case (a < 1%r / (size challenge_set)%r). smt(@RealExp). progress.
have f51: (a >= 1%r / (size challenge_set)%r). smt().
have f52: (a - 1%r / (size challenge_set)%r) <= a. smt(challenge_set_size).
have f54 : 0%r <= a. smt().
have f53: (a - 1%r / (size challenge_set)%r) * (a - 1%r / (size challenge_set)%r) <= a * (a - 1%r / (size challenge_set)%r).
smt().
have f5 : (a - 1%r / (size challenge_set)%r)^2 <= b.
have f511 : (a - 1%r / (size challenge_set)%r)^2 <= a * (a - 1%r / (size challenge_set)%r).
have ->: (a - 1%r / (size challenge_set)%r)^2 = (a - 1%r / (size challenge_set)%r) * (a - 1%r / (size challenge_set)%r).
smt(@RField).
apply f53. smt().
smt(@RealExp).
qed.
(* depending on the size of challenge_set either computational_soundness
or computational_soundness_II provide a better bound *)
lemma computational_soundness_II &m p deltoid:
! in_language soundness_relation p =>
Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)]
<= deltoid =>
Pr[Soundness(P, HV).run(p) @ &m : res]
<= ((size challenge_set)%r * deltoid)
+ (1%r/ (size challenge_set)%r).
proof. progress.
have f1 : Pr[Extractor(P).extract(p) @ &m : soundness_relation p res] = 0%r.
have <-: Pr[Extractor(P).extract(p) @ &m : false ] = 0%r.
rewrite Pr[mu_false]. auto.
rewrite Pr[mu_eq]. smt(). auto.
have : 0%r >=
(Pr[Soundness(P, HV).run(p) @ &m : res]^2
- (1%r/ (size (challenge_set ))%r) * Pr[Soundness(P, HV).run(p) @ &m : res])
- deltoid.
rewrite - f1.
apply (computational_extractability &m p). auto.
pose a := Pr[Soundness(P, HV).run(p) @ &m : res].
pose b := deltoid.
pose c := (size challenge_set)%r.
have f2 : 0%r <= a <= 1%r. split. rewrite /a. rewrite Pr[mu_ge0]. auto. rewrite /a. rewrite Pr[mu_le1]. auto.
progress.
have f3 : a ^ 2 - 1%r / c * a <= b. smt().
have f4 : a * (a - 1%r /c) <= b. smt(@Real challenge_set_size).
case (a < 1%r /c). rewrite /c. progress.
have : b >= 0%r. rewrite /b.
have : Pr[SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)] >= 0%r. rewrite Pr[mu_ge0]. auto. smt().
smt().
progress.
have f51: (a >= 1%r / c). smt().
have f52: (a - 1%r / c) <= a. smt(challenge_set_size).
have f54 : 0%r <= a. smt().
have f6 : a * c * (a - 1%r / c) <= b * c.
have -> : a * c * (a - 1%r / c) = a * (a - 1%r / c) * c. smt().
apply ler_wpmul2r. smt().
smt().
have f7 : (1%r/c) * c * (a - 1%r / c) <= b * c.
case (c = 0%r). move => h. rewrite h. simplify. auto.
move => h.
have f71 : 0%r < c. smt(). clear h.
have -> : 1%r / c * c * (a - 1%r / c) = (1%r / c) * (c * (a - 1%r / c)). smt().
have f72 : 1%r / c * (c * (a - 1%r / c)) <= a * c * (a - 1%r / c).
have -> : a * c * (a - 1%r / c) = a * (c * (a - 1%r / c)). smt().
apply ler_wpmul2r. smt(). smt(). smt().
have f8 : (a - 1%r / c) <= b * c. smt(challenge_set_size).
have f9 : a <= b * c + 1%r/c. smt().
smt (challenge_set_size).
qed.
end section.
end Computational.
theory Perfect.
import Computational.
section.
declare module P <: RewMaliciousProver{-HV}.
(* rewindability assumption *)
declare axiom rewindable_P_plus :
(exists (f : glob P -> sbits),
injective f /\
(forall &m, Pr[ P.getState() @ &m : (glob P) = ((glob P){m})
/\ res = f ((glob P){m} ) ] = 1%r) /\
(forall &m b (x: glob P), b = f x =>
Pr[P.setState(b) @ &m : glob P = x] = 1%r) /\
islossless P.setState).
declare axiom P_response_ll : islossless P.response.
declare axiom P_commitment_ll : islossless P.commitment.
declare axiom perfect_special_soundness p :
(forall t1 t2, valid_transcript_pair p t1 t2 =>
soundness_relation p (special_soundness_extract p t1 t2)).
lemma statistical_extractability &m p :
Pr[Extractor(P).extract(p) @ &m : soundness_relation p res]
>= Pr[Soundness(P, HV).run(p) @ &m : res]^2
- 1%r/(size challenge_set)%r
* Pr[Soundness(P, HV).run(p) @ &m : res].
proof. progress.
have f : Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)] = 0%r.
have -> : 0%r = Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m : false]. rewrite Pr[mu_false]. auto.
rewrite Pr[mu_eq]. progress. smt(perfect_special_soundness). auto.
apply (Computational.computational_extractability P P_response_ll _ _ &m p 0%r).
apply P_commitment_ll. apply rewindable_P_plus. rewrite f. auto.
qed.
lemma statistical_soundness &m p :
! in_language soundness_relation p
=> Pr[Soundness(P, HV).run(p) @ &m : res]
<= ((1%r/ (size (challenge_set))%r)).
proof. progress.
have ->: inv (size challenge_set)%r = sqrt 0%r + inv (size challenge_set)%r. smt().
apply (computational_soundness P P_response_ll _ _ &m p 0%r H _). apply P_commitment_ll. apply rewindable_P_plus.
have -> : Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m :
valid_transcript_pair p res.`1 res.`2 /\
! soundness_relation p (special_soundness_extract p res.`1 res.`2)] = 0%r.
have -> : 0%r = Pr[ SpecialSoundnessAdversary(P).attack(p) @ &m : false]. rewrite Pr[mu_false]. auto.
rewrite Pr[mu_eq]. smt(perfect_special_soundness). auto. auto. qed.
end section.
end Perfect.
end SpecialSoundness.