@@ -83,7 +83,7 @@ import H.Lazy.
8383(* BR93 is a module that, given access to an oracle H from type *)
8484(* `from` to type `rand` (see `print Oracle.`), implements procedures *)
8585(* `keygen`, `enc` and `dec` as follows described below. *)
86- module BR93 (H: Oracle) = {
86+ module BR93 (H : Oracle) = {
8787 (* `keygen` simply samples a key pair in `dkeys` *)
8888 proc keygen() = {
8989 var kp;
@@ -183,14 +183,14 @@ qed.
183183
184184(* But we can' t do it (yet) for IND-CPA because of the random oracle *)
185185(* Instead, we define CPA for BR93 with that particular RO. *)
186- module type Adv (ARO: POracle) = {
186+ module type Adv (ARO : POracle) = {
187187 proc a1(p:pkey): (ptxt * ptxt)
188188 proc a2(c:ctxt): bool
189189}.
190190
191191(* We need to log the random oracle queries made to the adversary *)
192192(* in order to express the final theorem. *)
193- module Log (H: Oracle) = {
193+ module Log (H : Oracle) = {
194194 var qs: rand list
195195
196196 proc init() = {
@@ -251,23 +251,16 @@ declare axiom A_a1_ll (O <: POracle {-A}): islossless O.o => islossless A(O).a1.
251251declare axiom A_a2_ll (O <: POracle {-A}): islossless O.o => islossless A(O).a2.
252252
253253(* Step 1 : replace RO call with random sampling *)
254- local module Game1 = {
255- var r: rand
256-
257- proc main () = {
258- var pk, sk, m0, m1, b, h, c, b' ;
259- Log(LRO).init();
260- (pk,sk) <$ dkeys;
261- (m0,m1) <@ A(Log(LRO)).a1(pk);
262- b <$ {0,1};
263-
264- r <$ drand;
265- h <$ dptxt;
266- c <- ((f pk r),h +^ (b?m0:m1));
267-
268- b' <@ A (Log (LRO)).a2 (c);
269- return b' = b;
270- }
254+ local module Game1 = BR93_CPA(A) with {
255+ var r : rand
256+ var h : ptxt (* This should be local *)
257+
258+ proc main [
259+ (* inline key generation *)
260+ 2 ~ { (pk, sk) <$ dkeys; },
261+ (* inline challenge encryption and idealize RO call *)
262+ 5 ~ { r <$ drand; h <$ dptxt; c <- (f pk r, h +^ (b ? m0 : m1)); }
263+ ]
271264}.
272265
273266local lemma pr_Game0_Game1 &m:
@@ -327,23 +320,11 @@ by move=> _ rR aL mL aR qsR mR h /h [] ->.
327320qed.
328321
329322(* Step 2 : replace h ^ m with h in the challenge encryption *)
330- local module Game2 = {
331- var r: rand
332-
333- proc main() = {
334- var pk, sk, m0, m1, b, h, c, b' ;
335- Log (LRO).init ();
336- (pk,sk) <$ dkeys;
337- (m0,m1) <@ A (Log (LRO)).a1 (pk);
338- b <$ {0 ,1 };
339-
340- r <$ drand;
341- h <$ dptxt;
342- c <- ((f pk r),h);
343-
344- b' <@ A(Log(LRO)).a2(c);
345- return b' = b;
346- }
323+ local module Game2 = Game1 with {
324+ proc main [
325+ (* Challenge ciphertext is now produced uniformly at random *)
326+ 7 ~ { c <- (f pk r, h); }
327+ ]
347328}.
348329
349330local equiv eq_Game1_Game2: Game1.main ~ Game2.main:
@@ -402,12 +383,12 @@ local module OWr (I : Inverter) = {
402383
403384(* We can easily prove that it is strictly equivalent to OW *)
404385local lemma OW_OWr &m (I <: Inverter {-OWr}):
405- Pr[OW(I).main() @ &m: res]
386+ Pr[OW(I).main() @ &m: res]
406387 = Pr[OWr(I).main() @ &m: res].
407388proof. by byequiv=> // =; sim. qed.
408389
409390local lemma pr_Game2_OW &m:
410- Pr[Game2.main() @ &m: Game2.r \in Log.qs]
391+ Pr[Game2.main() @ &m: Game2.r \in Log.qs]
411392 <= Pr[OW(I(A)).main() @ &m: res].
412393proof.
413394rewrite (OW_OWr &m (I(A))). (* Note: we proved it forall (abstract) I *)
@@ -431,7 +412,7 @@ by auto=> /> [pk sk] ->.
431412qed.
432413
433414lemma Reduction &m:
434- Pr[BR93_CPA(A).main() @ &m : res] - 1 %r/2 %r
415+ Pr[BR93_CPA(A).main() @ &m : res] - 1 %r/2 %r
435416 <= Pr[OW(I(A)).main() @ &m: res].
436417proof.
437418smt (pr_Game0_Game1 pr_Game1_Game2 pr_bad_Game1_Game2 pr_Game2 pr_Game2_OW).
0 commit comments