intuition.
unfold EncryptOracle.
wftac.
Qed.
Definition IND_CPA_SecretKey_G :=
key <-$ KeyGen ;
[b, _] <-$2
(
[p0, p1, s_A] <--$3 A1;
b <--$$ {0, 1};
pb <- if b then p1 else p0;
c <--$$ Encrypt key pb;
b' <--$ A2 s_A c;
$ ret eqb b b'
)
_ _ (EncryptOracle key) tt;
ret b.
Definition IND_CPA_SecretKey_Advantage := | Pr[IND_CPA_SecretKey_G] - 1 / 2 |.
End IND_CPA_SecretKey_concrete.
Section IND_CPA_SecretKey_O_concrete.
Variable A : OracleComp Plaintext Ciphertext bool.
Hypothesis Ciphertext_EqDec : EqDec Ciphertext.
Variable ptDefault : Plaintext.
Definition EncryptNothingOracle (k : Key)(x : unit)(p : Plaintext)  :=
c <-$ Encrypt k ptDefault;
ret (c, tt).
Definition IND_CPA_SecretKey_O_G0 :=
key <-$ KeyGen ;
[b, _] <-$2 A _ _ (EncryptOracle _ key) tt;
ret b.
Definition IND_CPA_SecretKey_O_G1 :=
key <-$ KeyGen ;
[b, _] <-$2 A _ _ (EncryptNothingOracle key) tt;
ret b.
Definition IND_CPA_SecretKey_O_Advantage := | Pr[IND_CPA_SecretKey_O_G0] - Pr[IND_CPA_SecretKey_O_G1]  |.
End IND_CPA_SecretKey_O_concrete.
(* The reduction from iterated IND-CPA goes through the following definition.  There is probably no reason to use this definition in a security proof.  *)
Section IND_CPA_SecretKey_O_concrete_3Proc.
Variable A B State : Set.
Hypothesis B_EqDec : EqDec B.
Variable A1 : Comp (A * State).
Variable A2 : A -> OracleComp Plaintext Ciphertext B.
Variable A3 : State -> B -> Comp bool.
Hypothesis Ciphertext_EqDec : EqDec Ciphertext.
Variable ptDefault : Plaintext.
Definition IND_CPA_SecretKey_O_3Proc_G0 :=
[a, s_A] <-$2 A1;
key <-$ KeyGen ;
[b, _] <-$2 (A2 a) _ _ (EncryptOracle _ key) tt;
A3 s_A b.
Definition IND_CPA_SecretKey_O_3Proc_G1 :=
[a, s_A] <-$2 A1;
key <-$ KeyGen ;
[b, _] <-$2 (A2 a) _ _ (EncryptNothingOracle _ ptDefault key) tt;
A3 s_A b.
Definition IND_CPA_SecretKey_O_3Proc_Advantage := | Pr[IND_CPA_SecretKey_O_3Proc_G0] - Pr[IND_CPA_SecretKey_O_3Proc_G1]  |.
Definition A_c :=
[a, s_A] <--$2$ A1;
x <--$ A2 a;
$ A3 s_A x.

(* Specifications: *)
Theorem IND_CPA_SecretKey_2Proc_impl_O :
IND_CPA_SecretKey_O_3Proc_Advantage == IND_CPA_SecretKey_O_Advantage A_c _ ptDefault.