(* Naive vote protocol
   Taken from Delaune, Jacquemard, CSFW'04 *)

type pkey.
type skey.

(* deterministic public key encryption *)

fun pk(skey): pkey.
fun encrypt(bitstring, pkey): bitstring.
reduc forall x: bitstring, y: skey; decrypt(encrypt(x,pk(y)), y) = x.

(* Note that the attack disappears with probabilistic public-key encryption:

type seed.
fun pk(skey): pkey.
fun internal_encrypt(bitstring, pkey, seed): bitstring.
reduc forall x: bitstring, y: skey, r: seed; decrypt(internal_encrypt(x,pk(y),r), y) = x.
letfun encrypt(x: bitstring, y: pkey) = new r: seed; internal_encrypt(x,y,r).

*)

free c: channel.
free v: bitstring [private].

weaksecret v.


process 
	new skS: skey;
	let pkS = pk(skS) in
	out(c, pkS);
	!out(c, encrypt(v, pkS))

(* EXPECTPV
RESULT Weak secret v is false.
0.036s (user 0.028s + system 0.008s), max rss 8812K
END *)
