https://github.com/EasyCrypt/easycrypt
Raw File
Tip revision: c44174dfe2349167774459e3b28424f99a6b8fcb authored by Christian Doczkal on 08 December 2021, 16:20:51 UTC
eager random oracle for unit domain (single random variable)
Tip revision: c44174d
CPA.eca
(* --------------------------------------------------------------------
 * Copyright (c) - 2012--2016 - IMDEA Software Institute
 * Copyright (c) - 2012--2021 - Inria
 * Copyright (c) - 2012--2021 - 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';
  }
}.
back to top