(* Assignment 4 - Probabilistic Noninterference and EasyCrypt's Probabilistic Relational Hoare Logic (100 points) Due Friday, November 13, at 11:59pm on Gradescope You may *not* use the smt tactic (or /#) in this assignment. (We want you to spot proof patterns, instead of relying on smt. This also lets us avoid the issue of setting the SMT timeout.) If you use AI to solve a question, you must add a comment explaining the process you followed, including a complete transcript of your interaction with the AI agent. Whether or not you use AI, you must understand your answers, and be able to explain them orally. *) prover [""]. (* no use of SMT *) require import AllCore IntDiv Distr. (* minimal axiomatization of bitstrings *) op n : int. (* length of bitstrings *) axiom ge0_n : 0 <= n. type bits. (* type of bit strings of length n *) op zero : bits. (* the all zero bitstring *) op (^^) : bits -> bits -> bits. (* pointwise exclusive or *) axiom xorC (x y : bits) : x ^^ y = y ^^ x. axiom xorA (x y z : bits) : x ^^ y ^^ z = x ^^ (y ^^ z). axiom xor0_ (x : bits) : zero ^^ x = x. lemma xor_0 (x : bits) : x ^^ zero = x. proof. by rewrite xorC xor0_. qed. axiom xorK (x : bits) : x ^^ x = zero. (* uniform, full and lossless distribution on bitstrings *) op dbits : bits distr. axiom dbits_ll : is_lossless dbits. axiom dbits1E (x : bits) : mu1 dbits x = 1%r / (2 ^ n)%r. lemma dbits_fu : is_full dbits. proof. move => x. rewrite /support dbits1E. by rewrite RField.div1r StdOrder.RealOrder.invr_gt0 lt_fromint StdOrder.IntOrder.expr_gt0. qed. (* Question 1 (45 points) *) module M = { var x : bits (* public *) var y : bits (* private *) proc f() : unit = { var a : bits; a <$ dbits; x <- x ^^ a ^^ y; } }. (* you may add auxiliary lemmas here *) (* FILL IN *) (* END FILL IN *) lemma M_prob_noninter : equiv [M.f ~ M.f : ={M.x} ==> ={M.x}]. proof. (* FILL IN *) (* END FILL IN *) qed. (* Question 2 (55 points) *) module N = { var n : int (* private *) var x : bits (* private *) var y : bits (* private *) var z : bits (* public *) var i : int (* public *) proc f() : unit = { var u : bits; while (0 < i) { if (n %% 2 = 0) { u <$ dbits; z <- z ^^ x ^^ u; n <- n + 1; } else { u <$ dbits; z <- z ^^ y ^^ u; n <- n - 1; } i <- i - 1; } } }. (* you may add auxiliary lemmas here, and you may also use ones you defined above *) (* FILL IN *) (* END FILL IN *) lemma N_prob_noninter : equiv [N.f ~ N.f : ={N.z, N.i} ==> ={N.z, N.i}]. proof. (* FILL IN *) (* END FILL IN *) qed.