https://github.com/EasyCrypt/easycrypt
Tip revision: d893b8398d110b566cbe0565d49aa41e0de40980 authored by Pierre-Yves Strub on 19 October 2021, 10:22:51 UTC
Merge branch '1.0' into deploy-pattern-in-rewrite
Merge branch '1.0' into deploy-pattern-in-rewrite
Tip revision: d893b83
CPA.eca
(* --------------------------------------------------------------------
* Copyright (c) - 2012--2016 - IMDEA Software Institute
* Copyright (c) - 2012--2018 - Inria
* Copyright (c) - 2012--2018 - Ecole Polytechnique
*
* Distributed under the terms of the CeCILL-B-V1 license
* -------------------------------------------------------------------- *)
require import Bool Core.
require (*--*) DBool NewSKE.
clone include NewSKE.
module type CPA = {
proc enc(p: plain): cipher option
}.
module type Adv_CPA (O : CPA) = {
proc choose(): plain * plain
proc guess(c: cipher): bool
}.
module IND_CPA ( S : SKE, A : Adv_CPA) = {
module O = Wrap(S)
module A = A(O)
proc main(): bool = {
var b, b', c, p0, p1, p;
O.init();
(p0,p1) <@ A.choose();
b <$ {0,1};
p <- b ? p1 : p0; (* FIXME: need to check whether plaintexts are both valid or both invalid *)
c <- O.enc(p);
b' <- A.guess(oget c);
return b = b';
}
}.