set allowDiffPatterns=true.

(********   This file has been automatically generated using the tool UKano. It encodes the frame opacity condition. ********)

(******************************************************)
(*                                                    *)
(*               BAC+PA+AA                            *)
(*                                                    *)
(******************************************************)

(* ==THEORY== *)

(* public communication channel *)
free c : channel.
free ct : channel.
free cr : channel.

(* constant values *)
free hole : bitstring.
free error_mac : bitstring.
free init : bitstring.
free read : bitstring.
free ok : bitstring.

 (* Encryption (with mac inside) *)
fun enc(bitstring, bitstring) : bitstring.
  reduc forall xm:bitstring, xk:bitstring;
        dec(enc(xm, xk), xk) = xm.
		       (* we check mac using idTest*)
letfun idEnc(m:bitstring, k:bitstring) = enc(dec(m, k), k).

(* Mac function *)
fun mac(bitstring,bitstring):bitstring.
  reduc forall km:bitstring, m:bitstring;
  	checkMac(mac(m,km),km) = m.

(* generate new bitstring from seed from two bitstrings *)
fun hashKey(bitstring, bitstring) : bitstring.


(*  *)


(* == PROTOCOL WITH IDEALISATION == *)
let SYSTEM =
new skP : bitstring;
( !
  new dgi : bitstring;
  new kM : bitstring;
  new kE : bitstring;
     !
      ((
        new nt: bitstring;
        out(ct, nt);
        in(ct, choice[x1:bitstring,x1id:bitstring]);
        let ((xe: bitstring,xm_37: bitstring)) = x1 in
        let (=xe) = checkMac(xm_37,kM) in
        (
            let ((xnr: bitstring,=nt,xkr: bitstring)) = dec(xe,kE) in
                new kt: bitstring;
                new hole__xnr_I_0: bitstring;
                new hole__kE_I_1: bitstring;
                new hole__kM_I_2: bitstring;
                out(ct, choice[(enc((nt,xnr,kt),kE),mac(enc((nt,xnr,kt),kE),kM)),(enc((nt,hole__xnr_I_0,kt),hole__kE_I_1),mac(enc((nt,hole__xnr_I_0,kt),hole__kE_I_1),hole__kM_I_2))])
            else
                out(ct, error_mac)
        )
        else
            out(ct, error_mac)
      )|(
        in(cr, choice[y1: bitstring,y1id: bitstring]);
        new nr: bitstring;
        new kr: bitstring;
        new hole__kE_R_3: bitstring;
        new hole__kM_R_4: bitstring;
        out(cr, choice[(enc((nr,y1,kr),kE),mac(enc((nr,y1,kr),kE),kM)),(enc((nr,y1id,kr),hole__kE_R_3),mac(enc((nr,y1id,kr),hole__kE_R_3),hole__kM_R_4))]);
        in(cr, choice[y2:bitstring,y2id:bitstring]);
        let ((ye: bitstring,ym: bitstring)) = y2 in
        let (=ye) = checkMac(ym,kM) in
        let ((=y1,=nr,ykt: bitstring)) = dec(ye,kE) in
        new randR: bitstring;
        new hole__ykt_R_5: bitstring;
        out(cr, choice[enc((init,randR),hashKey(ykt,kr)),enc((init,randR),hashKey(hole__ykt_R_5,kr))])
      ))
)
.
process SYSTEM

(* EXPECTPV
RESULT Diff-equivalence is true.
0.244s (user 0.224s + system 0.020s), max rss 35044K
END *)
