# Applied pi calculus[^2]
Mark D. Ryan, Ben Smyth
July 2010
Revised: November 2010, March 2011,
November 2012, March 2013.
## Abstract
The applied pi calculus is a language for modelling security protocols. It is an extension of the pi calculus, a language for studying concurrency and process interaction. This chapter presents the applied pi calculus in a tutorial style. It describes reachability, correspondence, and observational equivalence properties, with examples showing how to model secrecy, authentication, and privacy aspects of protocols.
**Keywords:** Cryptographic protocols, protocol verification, formal methods, reachability, correspondence properties, observational equivalence, tutorial.
# Introduction
The applied pi calculus (**AppliedPi?**) is a language for describing and analysing security protocols. It provides an intuitive process syntax for detailing the actions of the participants in a protocol, emphasising their communication. The syntax is coupled with a formal semantics to allow reasoning about protocols. The language is based on the pi calculus with the addition of a rich term algebra to enable modelling of the cryptographic operations used by security protocols. A wide variety of cryptographic primitives can be abstractly modelled by means of an equational theory. The calculus allows one to express several types of security goal, and to analyse whether the protocol meets its goal or not. This analysis can sometimes be performed automatically, using the ProVerif software tool (**Blanchet07b?**; **BlanchetJCS09?**; **BlanchetSmyth2010?**).
The applied pi calculus has been used to model security protocols in a variety of areas. The following examples are not exhaustive:
- Certified email (**AbadiBlanchet'05?**);
- Privacy properties (**KremerRyan2005?**; **DKR09?**; **Backes08?**; **Kuesters09?**), and election verifiability properties (**SRK10?**; **SRKK10?**) in electronic voting;
- Authorisation protocols (**ChenRyan:FAST09?**; **Mukhamedov09?**), and attestation protocols (**src07?**; **BackesMU08?**) in trusted computing;
- Interoperability of web services, where a compiler (**BFGT06:VerifiedInteroperableImplementationsOfSecurityProtocols?**) converts descriptions in the F# language (**SGC07:ExpertFSharp?**) into applied pi, suitable for analysis by ProVerif;
- Integrity of file systems on untrusted storage (**Chaudhuri08?**);
- Authentication protocols and key agreement (**Blanchet07?**).
#### Notation and running example.
Throughout this Chapter we will make use of the Handshake protocol discussed in Section 1.1. The following notation will be used, symmetric encryption of a message $m$ with key $k$ is denoted ${\ensuremath{\left\{\!\left|{m}\right|\!\right\}^{\mathsf s}_{k}}}$. Similarly, we write ${\ensuremath{\left\{\!\left|{m}\right|\!\right\}^{\mathsf a}_{pk}}}$ for the asymmetric encryption of $m$ with the public key $pk$ and ${\ensuremath{ \left[{m}\right]_{sk}}}$ for the digital signature of $m$ with the secret key $sk$. The pairing of messages $m_1$ and $m_2$ is denoted ${\ensuremath{\langle{m_1},{m_2}\rangle}}$.
## Handshake protocol
A naïve Handshake protocol between a client ${\ensuremath{\mathcal{C}}}$ and server ${\ensuremath{\mathcal{S}}}$ is illustrated below. It is assumed that each of them has a public/private key pair, and that the client knows the server’s public key ${\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}}$. The aim of the protocol is to establish a secret symmetric key $k$, enabling the client to communicate a secret $s$ to the server. The protocol proceeds as follows. On request from a client ${\ensuremath{\mathcal{C}}}$, server ${\ensuremath{\mathcal{S}}}$ generates a fresh session key $k$, signs it with her private key $sk_{{\ensuremath{\mathcal{S}}}}$ and encrypts it using her client’s public key ${\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}}$. When ${\ensuremath{\mathcal{C}}}$ receives this message he decrypts it using his private key $sk_{{\ensuremath{\mathcal{C}}}}$, verifies the digital signature made by ${\ensuremath{\mathcal{S}}}$ using her public key ${\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}}$, and extracts the session key $k$. ${\ensuremath{\mathcal{C}}}$ uses this key to symmetrically encrypt the secret $s$ and sends the encrypted message to ${\ensuremath{\mathcal{S}}}$. The rationale behind the protocol is that ${\ensuremath{\mathcal{C}}}$ receives the signature asymmetrically encrypted with his public key and hence he should be the only one able to decrypt its content. Moreover, the digital signature should ensure that ${\ensuremath{\mathcal{S}}}$ is the originator of the message. The protocol narration is illustrated as follows:
c@width 1pt\> X@width 1ptc &&
&
&
&
&&
Note that protocol narrations (as above) are useful, but lack detail. For example, they do not specify the construction of nonces, nor do they describe any checks which should be made by the participants during the execution of the protocol. Such checks include verifying digital signatures and ensuring that encrypted messages are correctly formed. Failure of these checks typically results in the participant aborting the protocol. These details will be explicitly stated when protocols are modelled in the applied pi calculus. (For further discussion on protocol specification see (**Abadi96?**; **Abadi99?**).)
Informally, the three properties we would like this protocol to provide are:
1. Secrecy: The value $s$ is known only to ${\ensuremath{\mathcal{C}}}$ and ${\ensuremath{\mathcal{S}}}$.
2. Authentication of ${\ensuremath{\mathcal{S}}}$: if ${\ensuremath{\mathcal{C}}}$ reaches the end of the protocol with session key $k$, then ${\ensuremath{\mathcal{S}}}$ proposed $k$ for use by ${\ensuremath{\mathcal{C}}}$.
3. Authentication of ${\ensuremath{\mathcal{C}}}$: if ${\ensuremath{\mathcal{S}}}$ reaches the end of the protocol and believes session key $k$ has been shared with ${\ensuremath{\mathcal{C}}}$, then ${\ensuremath{\mathcal{C}}}$ was indeed her interlocutor and has $k$.
The different forms of the two authentication properties arise because of the different assumptions we made about ${\ensuremath{\mathcal{C}}}$ and ${\ensuremath{\mathcal{S}}}$. Recall that ${\ensuremath{\mathcal{C}}}$ knows ${\ensuremath{\mathcal{S}}}$’s public key, and is only willing to run the protocol with ${\ensuremath{\mathcal{S}}}$. But ${\ensuremath{\mathcal{S}}}$ is willing to run the protocol with anyone.
Careful analysis reveals that the protocol does not satisfy all three of the intended properties. It is vulnerable to a *man-in-the-middle* attack (illustrated below). If a dishonest participant ${\ensuremath{\mathcal{M}}}$ starts a session with ${\ensuremath{\mathcal{S}}}$, then ${\ensuremath{\mathcal{M}}}$ is able to impersonate ${\ensuremath{\mathcal{S}}}$ in a subsequent session he starts with ${\ensuremath{\mathcal{C}}}$. At the end of the protocol ${\ensuremath{\mathcal{C}}}$ believes that he shares the secret $s$ with ${\ensuremath{\mathcal{S}}}$, while he actually shares $s$ with ${\ensuremath{\mathcal{M}}}$.
The protocol can easily be corrected by adding the identities of the intended participants to the data that is signed in the first message:
c@width 1pt\> X@width 1ptc &&
&
&
&
&&
With this correction, ${\ensuremath{\mathcal{M}}}$ is not able to re-use the signed key from ${\ensuremath{\mathcal{S}}}$ in his session with ${\ensuremath{\mathcal{C}}}$.
# Applied pi calculus
**\[tex2md\] this section could not be converted; its LaTeX follows verbatim:** `Error at (line 878, column 1): unexpected \hskip expecting \end{center} \begin{prooftree} ^`
``` latex
\section{Applied pi calculus}
The applied pi calculus~\cite{AppliedPi} is a language for describing
concurrent processes and their interactions. It is based on the pi
calculus but is intended to be more convenient to use, and it is
specifically targeted at modelling security protocols. In this
respect the applied pi calculus also has similarities with the spi
calculus~\cite{SpiCalculus}. The key difference concerns the way in
which cryptographic primitives are handled. The spi calculus has a
fixed set of primitives built-in (namely, symmetric and public key
encryption), while the applied pi calculus allows a wide variety of
more complex primitives (including, for example, non-deterministic encryption,
digital signatures, and proofs of knowledge) to be defined by means of an
equational theory.
\subsection{Syntax and informal semantics}\label{sec:syntax}
The calculus assumes an infinite set of names, an infinite set of
variables, and a signature~$\Sigma$ consisting of a finite set of
function symbols each with an associated arity. Function symbols
capture primitives used by cryptographic protocols (for example:
one-way hash functions, encryption, digital signatures, and data
structures such as pairing). A function symbol with arity~$0$ is a
constant. Terms are built by applying function symbols to names,
variables and other terms:
\begin{center}
\begin{minipage}{\textwidth}
\begin{tabbing}
XX\=XXXXXXXXXXXXXXXXxx\=XX\=\kill %Set tab sizes
$L,M,N,T,U,V ::=$ \> \> terms \\
\> $a,b,c,\ldots,k,\ldots,m,n,\ldots,s$ \>\> name \\
\> $x,y,z$ \>\> variable \\
\> $g(M_1,\ldots,M_l)$ \>\> function application
\end{tabbing}
\end{minipage}
\end{center}
\noindent where $g$ ranges over the functions of $\Sigma$ and $l$ is
the arity of $g$. We use metavariables $u,v,w$ to range over both
names and variables. Tuples $u_1,\ldots,u_l$ and $M_1,\ldots,M_l$ are
occasionally abbreviated $\tilde{u}$ and $\tilde{M}$.
%\sout{We write
%$\activesubst{M}{x}$ for the \emph{syntactic substitution} (usually just
%called \emph{substitution}) that
%replaces the variable $x$ with the term $M$.
%Similarly, we write $\activesubst{m}{n}$
%for the substitution that replaces the name $n$ with the name $m$.
%Arbitrarily large
%substitutions can be
%written as
%$\{\subst{M_1}{x_1},\ldots,\subst{M_l}{x_l}\}$ or
%$\activesubst{\tilde{M}}{\tilde{x}}$.
%The letters $\sigma$ and $\tau$
%range over substitutions. We write
%$N\sigma$ for the result of applying $\sigma$ to the variables (or names)
%of $N$.}
A term is ground when it does not contain variables.
%In practice it is common to stray away from the formally defined set of names and opt for more informative descriptors such as $sk_A$ for the secret key of principle $\Alice$. This informal approach will be adopted in this chapter for examples.
%\marginpar{MDR: I disagree. $sk_A$ is a perfectly good name. I don't see anything informal about it. BAS: It isn't in the grammar?}
We assume a type system (also known as a sort system) for terms generated by a set of base types $\mathcal{S}$, which includes the universal type $\TypeBase$. In addition, if $\omega$ is a type, then $\TypeChannel{\omega}$ is a type too. Formally, the set of types generated by the base types $\mathcal{S}$ is the smallest set $\Omega$ satisfying: 1) $\mathcal{S} \subseteq \Omega$; and 2) if $\omega \in \Omega$ then $\TypeChannel{\omega} \in \Omega$. Names and variables can have any type. By convention we use $a,b,c$ for channel names, $k,s$ as names of base type and $m,n$ for names of any type. A channel of type $\TypeChannel{\omega}$ may communicate messages of type $\omega$. For simplicity, function symbols can only be applied to, and return, terms of base type. We always assume that terms are well-typed. %\sout{ and that syntactic substitutions preserve types}.
%The type system on terms adds to the richness of the calculus by facilitating the definition of processes and their interactions.
%\footnotetext{\textbf{TYPE OR SORT?} I want to use either type or sort, not both. MDR: Comments? Which do you prefer? I'm slightly leaning towards type, because this is more familiar to new PhD students (i.e. me!) Which is more widely used in literature? Scholar ``sort system" = 661, ``type system = ``131,000". Google ``sort system" = 124,000, ``type system" = 1,840,000. Does this apply to the formal methods field too?}
\pagebreak
The grammar for \emph{processes} is shown below:
\begin{center}
\begin{minipage}{\textwidth}
\begin{tabbing}
XX\=XXXXXXXXXXXXXXXXxx\=XX\=\kill %Set tab sizes
$P,Q,R ::=$ \> \> processes (or plain processes) \>\\
\> $\nill$ \> \> null process \\
\> $P \mid Q$ \> \> parallel composition \\
\> $!P$ \> \> replication \\
\> $\new{n}.P$ \> \> name restriction \\
\> $\Ifthenelse{M}{N}{P}Q$ \> \> conditional \\
\> $\In[u]{x}.P$ \> \> message input \\
\> $\Out[u]{M}.P$ \> \> message output
\end{tabbing}
\end{minipage}
\end{center}
\noindent
The null process $\nill$ does nothing; $P \mid Q$ is the parallel composition of processes $P$ and $Q$,
used to represent participants of a protocol running in parallel;
and replication $!P$ is the infinite composition $P \mid P \mid \ldots$, which is often used to
capture an unbounded number of sessions.
Name restriction $\new{n}.P$ binds $n$ inside $P$, the introduction
of restricted names (or private names) is useful to capture both fresh random numbers
(modelling nonces and keys, for example) and private channels.
The conditional
$\Ifthenelse{M}{N}{P}Q$ is standard, but we stress $M = N$ represents
equality (modulo an equational theory) rather than strict syntactic
identity. For convenience we abbreviate conditionals as
$\Ifthen{M}{N}{P}$, when $Q$ is the null process. Finally,
communication is captured by message input and message output. The
process
$\In[u]{x}.P$
awaits a message from channel $u$ and then behaves as $P$ with the
received message bound to the variable $x$; that is, every free occurrence
of $x$ in $P$ refers to the message received.
The process $\Out[u]{M}.P$ is ready
to send $M$ on channel $u$ and then run $P$. In both of these cases we
may omit $P$ when it is $\nill$.
We write $P\activesubst M x$ for $P$ with all free occurrences of $x$
replaced by $M$ and sometimes we write $\Letin{x}{M}P$ instead of $P\activesubst M x$; in such substitutions, we insist that no name or variable occurring in $M$ becomes bound by a restriction occurring in $P$ (for example,
$\Letin{x}{c}\new c.\Out{x}$
is not allowed, but $\Letin{x}{c}\new a. \Out[a]{x}$ is permitted).
Bracketing must be used to avoid ambiguities in the way processes are written down. For example, the process $!\,P\mid Q$ might be interpreted as $(!P)\mid Q$ or as $!(P\mid Q)$. These processes are different. To avoid too much bracketing, we adopt conventions about the precedence of process operators.
Unary operators $!$, $\new{n}$, $\In[u]{x}$, and $\Out[u]{M}$ bind more closely than binary operators; and the binary if-then-else operator binds more closely than the binary operator $\mid$. It follows that the expression $\In{x}.\Ifthen{x}{M}P \mid {!Q} \mid R$ means $(\In{x}.\Ifthen{x}{M}P) \mid (!Q) \mid R$.
We remark that different conventions are used elsewhere, for example~\cite{BlanchetSmyth2010}.
The expression $P\mid Q\mid R$ is also ambiguous, since it could mean
either $(P\mid Q)\mid R$ or $P\mid (Q\mid R)$. However, we will later
see that these processes are semantically identical, so we tolerate
the ambiguity in the syntax. Another possible ambiguity arises because
of the convention of omitting ``else 0'' in the if-then-else construct: it is not clear which ``if'' the ``else'' applies to in the expression:
\[\Ifthenelse M N {\Ifthen K L Q} R.\]
In absence of brackets indicating the contrary, we adopt the convention that the else branch belongs to the closest if and hence the statement should be interpreted as $\Ifthen M N (\Ifthenelse K L Q R)$.
%so we must make sure that brackets are added to make it clear.
Processes are extended with \emph{active substitutions} to capture the knowledge exposed to the adversarial environment:
\begin{center}
\begin{minipage}{\textwidth}
\begin{tabbing}
XX\=XXXXXXXXXXXXXXXXxx\=XX\=\kill %Set tab sizes
$A,B,C ::=$ \> \> extended processes \\
\>$P$ \> \> plain process \\
\>$A \mid B$ \> \> parallel composition \\
\>$\new{n}.A$ \> \> name restriction \\
\>$\new{x}.A$ \> \> variable restriction \\
\>$\activesubst{M}{x}$ \> \> active substitution
\end{tabbing}
\end{minipage}
\end{center}
\noindent The active substitution $\activesubst{M}{x}$ represents a process
that has previously output $M$.
The value $M$ is now available to the
environment by reference to the `handle' $x$. The active substitution
$\activesubst{M}{x}$ can replace the variable $x$ for the term $M$ in
every process it comes into contact with (formally this
is captured by the operational semantics). This behaviour can be
controlled by restriction, and the process $\new{x}.(\activesubst{M}{x} \mid P)$
corresponds exactly to $\Letin{x}{M}P$.
%\tred{For convenience we permit
%$\Letin{x}{M}P$ in plain processes as an abbreviation for
%$\new{x}.(\activesubst{M}{x} \mid P)$.} \tblue{The active substitution
%$\activesubst{M}{x}$, where $x$ is not under restriction, controls the
%manner in which the term $M$ is exposed to the environment: $M$ is
%accessible \emph{`by reference'} to the variable $x$.}
%\marginpar{\tblue{blue text marks duplication}}
This allows access to terms which the environment cannot construct;
such a scenario may arise, for example, when the environment does not
know all of the names occurring in a term. Arbitrarily large active
substitutions can be obtained by parallel composition and we
occasionally abbreviate
$\activesubst{M_1}{x_1}\mid\ldots\mid\activesubst{M_l}{x_l}$ as
$\{\subst{M_1}{x_1},\ldots,\subst{M_l}{x_l}\}$ or
$\activesubst{\tilde{M}}{\tilde{x}}$.
The letters $\sigma$ and $\tau$
range over substitutions. We write
$N\sigma$ for the result of applying $\sigma$ to the variables of $N$.
Active substitutions are always assumed to be cycle-free:
given substitution $\sigma$, the repeated application of $\sigma$
to itself may only result in a bounded number of replacements.
For example, the substitution $\{\subst{g(y)}{x},\subst{n}{y}\}$
is cycle-free; but $\{\subst{g(y)}{x},\subst{x}{y}\}$ is not and
repeated application could result in terms of unbounded length.
%$\{\subst{g(y)}{x},\subst{x}{y}\}$ will result in the
%variable $y$ referring to a term of infinite length.
Extended processes must have at
most one active substitution for each variable and there is exactly
one when the variable is under restriction.
In particular, this means that $\new{x}$ can only occur if there is an
active substitution $\activesubst{M}{x}$ in its scope.
Finally, we write
$\new{\tilde{u}}$ for the (possibly empty) series of pairwise-distinct
binders $\new{u_1}.\new{u_2}.\cdots.\new{u_l}$.
%\marginpar{MDR wrote: here you emphasis the empty possibility and the pairwise distinction although you didn't emphasise it for other cases where tilde is used. (Is there a reason for the pairwise distinction? Would it matter if there is a repetition?) BAS: Tuples $\tilde{M}$ may not be pairwise distinct, but they could be empty.}
%\sout{Active substitutions are different from syntactic substitutions.
%Firstly, active substitutions are processes, whereas syntactic
%substitutions are not. In addition, their semantic behaviours differ.
%Syntactic substitutions can be applied directly to processes; for example,
%the application of a syntactic substitution $\sigma$ to the free variables
%of an extended process $A$ is written $A\sigma$. By contrast, active
%substitutions cannot be applied directly to processes.
%Active
%and syntactic substitutions are always assumed to be cycle-free:
%given substitution $\sigma$, the repeated application of $\sigma$
%to itself may only result in a bounded number of replacements.
%For example, the substitution $\{\subst{g(y)}{x},\subst{n}{y}\}$
%is cycle-free; but $\{\subst{g(y)}{x},\subst{x}{y}\}$ is not,
%since $\{\subst{g(y)}{x},\subst{x}{y}\}$ will result in the
%variable $y$ referring to a term of infinite length.}
%We write $\sigma$, $\tau$, $\activesubst{M}{x}$, $\activesubst{\tilde{M}}{\tilde{x}}$ for (plain) substitions and $N\sigma$ for the result of applying $\sigma$ to the free variables of $N$. Similarly we write $A\sigma$ for the result of applying $\sigma$ to the free variables in $A$\sout{, including those which appear inside terms}. This contrasts with active substitutions which cannot be applied to terms or processes. Active substitions may only occur in extended processes, distinguishing our two types of substitution. Active and plain substitutions are always assumed to be cycle-free: given substitution $\activesubst{M}{x}$ the variable $x$ does not occur in $M$.
%This distinguishes plain and active substitutions. Active substitutions cannot be applied to terms or processes, and may only occur in extended processes.
%The distinction between active and plain substitutions is a common cause for confusion. A plain substitution $\activesubst{M}{x}$ can be applied to either a process $A$ or a term $N$ written as $A\activesubst{M}{x}$ and respectively $N\activesubst{M}{x}$. By comparision an active substitution is forbidden from occurring in this manner and may only occur in extended processes. %We will discuss how an active substitution achieve
The type system for terms is extended to processes. It enforces that
$M,N$ are of the same type in the conditional expression
$\Ifthenelse{M}{N}{P}Q$; message input $\In[u]{x}$ is defined only
where $u$ is of type $\TypeChannel{\omega}$ and $x$ is of type
$\omega$; and similarly message output $\Out[u]{M}$ requires $u$ of
type $\TypeChannel{\omega}$ and $M$ of type $\omega$. In addition, we
assume that in active substitutions $\activesubst{M}{x}$, the term $M$
and the variable $x$ are of the same base type.
This assumption was not explicitly stated in~\cite{AppliedPi} but its
necessity has been confirmed~\cite{AppliedPiEmail} and is essential
for the validity of
Theorem~\ref{theorem:obsLabelled}~\cite{AppliedPiCounterExample}.
Finally, we assume extended processes are well-typed.
%\marginpar{Bound/free names/variables could be more formal?}
The \emph{scope} of names and variables are delimited by binders
$\In[u]{x}$ and $\new{u}$.
The set of bound names $\bn{A}$ contains every name $n$
which is under restriction $\new{n}$ inside $A$. The set of bound
variables $\bv{A}$ consists of all those variables $x$ occurring in $A$
that are bound by restriction $\new{x}$ or input $\In[u]{x}$. We
also define the set of free names and the set of free variables. The set
of free names in $A$, denoted $\fn{A}$, consists of those names $n$
occurring in $A$ not in the scope of the binder $\new{n}$. The set of
free variables $\fv{A}$ contains the variables $x$ occurring in $A$ which
are not in the scope of a restriction $\new{x}$ or input $\In[u]{x}$.
Note that a name or variable can occur both free and bound in $A$.
Thus, the sets $\fv{A}\cap\bv{A}$ and $\fn{A}\cap\bn{A}$ may be
non-empty. We occasionally write $\fn{M}$ and $\fv{M}$, for the set
of names, respectively variables, which appear in term $M$.
% \marginpar{Suggest citing Iliano Cervesato's lecture notes on
% "Binding and Scope," possibly making a copy available (with
% permission) on the book's webpages.\\ Notes:
% \url{http://www.qatar.cmu.edu/cs/15312/handouts/binding.pdf}. Steve
% suggested that we should cite a textbook. This is fine (and more
% traditional) but lacks immediate access. I conjecture the majority
% of our readers will access our chapter via the free digital copy we
% make available on our webpages.}
%% Reply by Mark: Steve's idea if I understand it is that the chapter
%% is persistent, whereas lecture notes are transient.
The concept of bound and free
values is similar to local and global scope in programming languages.
An extended process is \emph{closed} when every variable $x$ is either bound or
defined by an active substitution, (that is, the process contains $\activesubst{M}{x}$
for some term $M$). Example~\ref{ex:scope} demonstrates
name and variable scope. Bound names and bound variables are subject to
$\alpha$-conversion (also called $\alpha$-renaming); that is, they
may be uniformly renamed without changing the meaning of the process, as demonstrated in Example~\ref{ex:renaming}.
%Names and variables have scopes. The set of bound variables $\bv{A}$, respectively names $\bn{A}$, are those variables and names occurring in $A$ such that they are bound by restriction $\new{u}$ or inputs $\In[u]{x}$. All remaining names and variables are free. Formally we define the sets of free variables $\fv{A}$ and names $\fn{A}$ as those not bound in $A$.
%
%We write~$\fv{A}$, $\bv{A}$, $\fn{A}$, $\bn{A}$ for the sets of free and bound variables, respectively names, in~$A$. Bound values $\bv{A},\bn{A}$ are names and values which occur in $A$
%
%those under restriction $\new{u}$ or inputs $\In[u]{x}$.
A \emph{frame}, denoted $\varphi$ or $\psi$, is an extended process built from $\nill$ and active substitutions $\activesubst{M}{x}$; which are composed by parallel composition and restriction. The \emph{domain} $\dom{\varphi}$ of a frame $\varphi$ is the set of variables that $\varphi$ exports; that is, the set of variables $x$ for which $\varphi$ contains an active substitution $\activesubst{M}{x}$ such that $x$ is not under restriction. Every extended process $A$ can be mapped to a frame $\varphi(A)$ by replacing every plain process in $A$ with $\nill$. The frame $\varphi(A)$ represents the static knowledge output by a process to its environment. The domain $\dom{A}$ of $A$ is the domain of $\varphi(A)$.
\begin{example}[Name and variable scope]\label{ex:scope}
Consider the closed process $A \pdef \new{x}.((\In{y}.\allowbreak
\overline{c}\langle\mathsf{aenc}(\allowbreak\Pair{x}{z},y)\rangle) \mid
(\new{s}.\activesubst{s}{x}) \mid \activesubst{h(x,s')}{z})$ defined with respect to the
signature $\Sigma = \{\mathsf{aenc},\mathsf{h},\mathsf{pair}\}$ where $\mathsf{aenc},\mathsf{h},\mathsf{pair}$ are
all binary functions. The occurrences
of the variable $x$ are bound by the variable restriction $\new{x}$ and
those of $y$ are bound by the input $\In{y}$. The name $s$ is bound
by the name restriction $\new{s}$. The remaining name $s'$ and
variable $z$ occur free. To summarise, we have $\fv{A} = \{z\}$,
$\bv{A} = \{x,y\}$, $\fn{A} = \{s'\}$ and $\bn{A} = \{s\}$.
Now let $A'
\pdef A \mid \activesubst{s}{y}$, and observe that the occurrences of $s$ and
$y$ in the active
substitution $\activesubst{s}{y}$ are free.
They have no relation to the bound values
$s,y$ which occur in $A$.
% \marginpar{``It follows that for all frames $\varphi,\psi$ we have $\bn{\varphi}
% \cap \bn{\psi} = \emptyset$.'' -- incorrect!!} \marginpar{``We also remark $|\bn{\new{n}.\new{n}}|
% = 2$.'' This doesn't mean anything. But $|\bn{\new{n}.\new{n}.0}|$
% which i guess is what you meant is equal to zero, since there are no
% occurrences of n other than in the binder.}
To avoid confusion it is good practice to use distinct
identifiers for free and bound, names and variables.
%\begin{exercise}{Free and bound names in frames}
% Identify the free and bound names presented in the frames expressed
% in Example~\ref{ex:staticEquivalence}.
%\end{exercise}
\end{example}
\begin{example}[$\alpha$-conversion]\label{ex:renaming}
$\alpha$-conversion means renaming a bound name or variable without
changing the semantics. This is also done in logic (the statements
$\forall x.P(x)$ and $\forall y.P(y)$ are equivalent), and in
programming (the programs
$\texttt{for i in I do P(i)}$ and $\texttt{for j in I do P(j)}$
are equivalent).
In the applied pi calculus, the process
$\new{k}.\In[c]{x}.\Out[c]{\allowbreak\Senc{k}{x}}$ is equivalent
to $\new{s}.\In[c]{y}.\Out[c]{\allowbreak\Senc{s}{y}}$; we have $\alpha$-renamed all occurrences of the name $k$
to the name $s$ and similarly the variable $x$ has been renamed $y$.
But,
$\new{k}.\In[c]{x}.\new{k}.\Out[c]{\Senc{k}{x}}$
is not $\alpha$-equivalent to
$\new{k}.\In[c]{y}.\new{s}.\Out[c]{\allowbreak\Senc{k}{y}}$.
\end{example}
\subsubsection{Modelling the Handshake protocol}\label{sec:model}
The Handshake protocol (Section~\ref{sec:handshakeprotocol}) is defined with respect to the signature $\SigmaP$, which is used to capture primitives modelling cryptographic operators, data structures and constants:
$
\SigmaP = \{\true,\mathsf{fst},\mathsf{snd},\mathsf{hash},\mathsf{pk},\mathsf{getmsg},\mathsf{pair},\mathsf{sdec},\mathsf{senc},\allowbreak\mathsf{adec},\mathsf{aenc},\mathsf{sign},\mathsf{checksign},\mathsf{mac}\}
$
where $\true$ is a constant; $\mathsf{fst},\mathsf{snd},\mathsf{hash},\mathsf{pk},\mathsf{getmsg}$ are unary functions; and $\mathsf{pair},\mathsf{sdec},\mathsf{senc},\mathsf{adec},\mathsf{aenc},\mathsf{sign},\mathsf{checksign},\allowbreak\mathsf{mac}$ are binary functions. The behaviour of these functions is captured by the smallest equational theory $\EEP$ satisfying the following equations over variables $x,y$:
\[
\begin{array}{lcl}
\Fst{\Pair{x}{y}} &=& x \\
\Snd{\Pair{x}{y}} &=& y \\
\Sdec{x}{\Senc{x}{y}} &=& y \\
\Adec{x}{\Aenc{\Pk{x}}{y}} &=& y \\
\Getmsg{\Sign{x}{y}} &=& y \\
\Checksign{\Pk{x}}{\Sign{x}{y}} &=& \true
\end{array}
\]
%\tblue{Do we want $\Checksign{\Pk{x}}{\Sign{x}{y}} = \true$ or $\Checksign{\Pk{x}}{\Sign{x}{y}} = y$? Obviously the former!}
This theory allows us to model: pairing, both symmetric and asymmetric cryptography, digital signature schemes with message recovery, hash functions and message authentication codes. For example, in order to express that the application of the symmetric decryption function $\mathsf{sdec}$ to the term modelling a symmetric encryption $\Senc{k}{m}$ should return the plaintext $m$ if the correct key $k$ is supplied, we use the equation $\Sdec{x}{\Senc{x}{y}} = y$. The absence of any equational theory associated with the $\mathsf{hash}$ function ensures preimage resistance, second-preimage resistance and collision resistance properties of cryptographic hash functions (in fact, far stronger properties are ensured); and similar properties for the function $\mathsf{mac}$. Observe that a tuple $M_1,\ldots,M_l$ of an arbitrary length $l$ can be constructed by pairing $\Pair{M_1}{\Pair{M_2}{\Pair{\ldots}{\Pair{M_{l-1}}{M_l}\ldots}}}$ and an element can be extracted using the equations defined for $\mathsf{fst}$, $\mathsf{snd}$.
%In the remainder of this chapter all examples consider the equational theory defined in Example~\ref{ex:equationalTheory}.
%\marginpar{Do we need to elaborate upon our example further? e.g. why only consider one client? why only one secret?}
The Handshake protocol
can now be captured in our calculus
as the process $P$, defined as follows.
%
\[
\begin{array}{llcl}
& P &\pdef& \new{sk_{\Alice}}.\new{sk_{\Bob}}.\new s.\\
&&& \Letin{pk_{\lAlice}}{\Pk{sk_{\Alice}}} \Letin{pk_{\lBob}}{\Pk{sk_{\Bob}}}\\
&&& (\Out{pk_{\lAlice}} \mid \Out{pk_{\lBob}} \mid {!P_{\Alice}} \mid {!P_{\Bob}})\\
%\text{where}\\
\\
& P_{\Alice} &\pdef& \In{x\_pk}.\new{k}.\Out{\Aenc{x\_pk}{\Sign{sk_{\Alice}}{k}}}.\\
& && \In{z}.\Ifthen{\Fst{\Sdec{k}{z}}}{tag}Q\\
\\
& P_{\Bob} &\pdef& \In{y}.\Letin{y'}{\Adec{sk_{\Bob}}{y}}\Letin{y\_k}{\Getmsg{y'}}\\
& && \Ifthen{\Checksign{pk_{\lAlice}}{y'}}{\true}\\
%& && \Ifthen{pk_{\lAlice}}{x\_pk_A}\\
& && \Out{\Senc{y\_k}{\Pair{tag}{s}}}\\
\end{array}
\]
%
The process begins by constructing the private keys $sk_{\Bob}$, $sk_{\Alice}$ for
principals $\Bob$, $\Alice$ respectively. The public key parts $\Pk{sk_{\Bob}}$,
$\Pk{sk_{\Alice}}$ are then output on the public communication channel $c$,
ensuring they are available to the adversary. (Observe that this is done using
handles $pk_{\lBob}$ and $pk_{\lAlice}$ for convenience.)
The protocol then
launches multiple copies of processes $P_{\Bob}$, $P_{\Alice}$ representing
multiple sessions of the roles of
$\Bob$ and $\Alice$.
Note that syntactic scope does not represent the knowledge of a protocol's
participants. For example, the server's private key $sk_{\Alice}$ is assumed not to be known
by the client $\Bob$ (hence it does not occur in $P_{\Bob}$), even though $sk_{\Alice}$ is in the scope of $P_{\Bob}$.
% We remark that the restricted name $s$ is used to model the client's secret.
We assume that $\Alice$ is willing to run the protocol
with any other principal; the choice of her interlocutor will be made by the
environment. This is captured by modelling the first input $\In{x\_pk}$
to $P_{\Alice}$ as the interlocutor's public key.
$\Bob$ on the other hand only wishes to share his secret $s$ with $\Alice$,
and $\Bob$ is assumed to know $\Alice$'s public key;
accordingly, %he is only willing to run the protocol with $\Alice$, and
$\Alice$'s public key is hard-coded into the process $P_{\Bob}$.
We additionally assume
that each principal is willing to engage in an unbounded number of
sessions and hence $P_{\Bob}$, $P_{\Alice}$ are under replication.
On request from her interlocutor, server $\Alice$ starts the
protocol by selecting key $k$ and outputting
$\Aenc{x\_pk}{\Sign{sk_{\Alice}}{k}}$; that is, her signature on the key
$k$ encrypted with her interlocutor's public key $x\_pk$. Meanwhile
$\Bob$ awaits the input of his interlocutor's signature on the key $k$
encrypted using his public key. $\Bob$ decrypts the message and
verifies the signature. Next, if $\Bob$ believes he is indeed talking
to $\Alice$, he outputs his secret $s$ encrypted with the symmetric
key $k$. Note that he inserts a tag (modelled as a free name),
so that the decryptor can verify
that the decryption has worked correctly.
Principal $\Alice$ inputs $z$ and confirms the
presence of the tag. Finally, principal $\Alice$ executes
the process $Q$. The description of $Q$ is independent of the
protocol, but one would expect the recovery of the interlocutor's
secret; that is, $Q$ is defined by the process
$\Letin{z\_s}{\Snd{\Sdec{k}{z}}} Q'$ for some $Q'$. %For modelling
%purposes we will assume $Q \pdef \nill$.
The purpose of the protocol is to establish a session key to transport the secret represented by $s$. We abstract away from the details of what $s$ is, and how many such secrets there are, by modelling it simply as a restricted name.
\subsection{Operational semantics}\label{sec:operationalSemantics}
The signature~$\Sigma$ is equipped with an equational theory $\EE$,
that is, a set of equations of the form $M = N$, where terms $M,N$
are defined over the signature $\Sigma$ (sometimes written $M,N\in T_\Sigma$).
This allows us to
capture relationships between primitives defined in $\Sigma$.
We define equality modulo the equational
theory, written $=_\EE$, as the smallest
equivalence relation on terms, that contains $\EE$ and is closed under
application of function symbols, substitution of terms for variables and
bijective renaming of names.
%We write $M =_\EE N$ when $M = N$ is in the theory $\EE$.
The properties of $=_\EE$ are summarised in Figure~\ref{fig:equationalTheories}.
We write $M =_\EE N$ when the equation $M = N$ is in the theory $\EE$ and keep
the signature implicit.
When $\EE$ is clear from the context we may abbreviate $M =_\EE N$ as $M = N$.
The negation of $M =_\EE N$ is denoted $M \not=_\EE N$ (and similarly abbreviated
$M \not= N$).
For further discussion on equational theories see~\cite[\S3]{AppliedPi} and~\cite{Abadi06}.
% and Exercise~\ref{ex:equationalTheoryReasoning} demonstrates how to reason about equality modulo the equational theory.
\begin{figure}
\begin{minipage}{\linewidth}
%\raggedright
Given an equational theory $\EE$ the following properties are satisfied for all terms $L,M,N$, functions $f$ of arity $l$, substitutions $\sigma$ and names $m,n$:
\begin{enumerate}
\item $M = N \in \EE \Rightarrow M =_\EE N$
\item Equivalence relation:
\begin{itemize}
\item Reflexivity: $M =_\EE M$
\item Symmetry: $M =_\EE N \Rightarrow N =_\EE M$
\item Transitivity: $L =_\EE M \wedge M =_\EE N \Rightarrow L =_\EE N$
\end{itemize}
\item Application of function symbols: $M_1 =_\EE N_1 \wedge \dots \wedge M_l =_\EE N_l \Rightarrow f(M_1,\dots,M_l) =_\EE f(N_1,\dots,N_l)$
\item Substitution of terms for variables: $M =_\EE N \Rightarrow M\sigma =_\EE N\sigma$
\item Bijective renaming of names: $M =_\EE N \Rightarrow M\activesubst{m}{n} =_\EE N\activesubst{m}{n}$,
where %$m\not\in(\fn{M}\cup\fn{N})$
$M\activesubst{m}{n}$ (respectively $N\activesubst{m}{n}$) is the term $M$ (respectively $N$) with every name $n$ replaced by $m$.
\end{enumerate}
\end{minipage}
\caption{Properties of equality modulo the equational theory}
\label{fig:equationalTheories}
\end{figure}
\pagebreak
\begin{example}[Reasoning with equational theories] Consider the signature $\SigmaP$ and the equational theory $\EEP$. Show that each of the following equalities hold: %with respect to the equational theory $\EE$ defined in Example~\ref{ex:equationalTheory}:
\begin{enumerate}
\item $\Sdec{k}{\Senc{k}{L}} =_\EEP L$
%\item $M =_\EE \Fst{\Pair{M}{N}}$
\item $\Pair{M}{N} =_\EEP \Pair{\Sdec{k}{\Senc{k}{\Fst{\Pair{M}{N}}}}}{N}$
\item $\Fst{\Sdec{\Snd{\Pair{K}{L}}}{\Senc{\Fst{\Pair{L}{N}}}{\Pair{M}{K}}}} =_\EEP M$
\end{enumerate}
Hint. Figure~\ref{fig:equationalTheories} may be helpful.
\end{example}
Contexts may be used to represent the adversarial environment in which a process is run; that environment provides the data that the process inputs, and consumes the data that it outputs. We define \emph{context} $\context$ to be an extended process with a hole. We obtain~$\context[A]$ as the result of filling~$\context$'s hole with the extended process~$A$. An \emph{evaluation context} is a context whose hole is not in the scope of a replication, a conditional, an input, or an output. A context $\context$ closes $A$ when $\context[A]$ is closed.
\subsubsection{Structural equivalence}\label{sec:structuralEquivalence}
Informally, two processes are structurally equivalent if they model the
same thing, but the grammar permits different encodings. For
example, to describe a pair of processes $A,B$ running in parallel,
the grammar forces us to put one on the left-hand side, and one on the right-hand side of the
parallel operator;
that is, we have to write either $A \mid B$ or $B \mid A$. These two processes
are said to be structurally equivalent.
Formally, \emph{structural
equivalence}~($\equiv$) is the smallest equivalence relation on
extended processes that is closed by $\alpha$-conversion of both bound
names and bound variables, and closed under application of evaluation contexts such that:
\[
\begin{array}{lrcl}
\ParI & A & \equiv & A \mid \nill \\
\ParA & A\mid(B \mid C) & \equiv & (A \mid B) \mid C \\
\ParC & A \mid B & \equiv & B \mid A \\
\Repl & !P & \equiv & P \mid {!P} \\
\\
\NewI & \new{n}.\nill & \equiv & \nill \\
\NewC & \new{u}.\new{w}.A & \equiv & \new{w}.\new{u}.A \\
\NewPar& A\mid\new{u}.B & \equiv & \new{u}.(A \mid B) \\
& & & \textrm{where } u\not\in \fv A \cup \fn A\\
\\
\Alias & \new{x}.\activesubst{M}{x}& \equiv & \nill \\
\Subst & \activesubst{M}{x} \mid A & \equiv & \activesubst{M}{x} \mid A\activesubst{M}{x} \\
\Rewrite& \activesubst{M}{x} & \equiv & \activesubst{N}{x} \\
& & & \textrm{where } M =_\EE N
\end{array}
\]
The rules for parallel composition, replication and restriction are self-explanatory.
$\Alias$ enables the introduction of an arbitrary active
substitution with restricted scope. $\Subst$ describes the application of an active
substitution to a process that it comes into contact with,
%\sout{. The rule
%helps demonstrate the distinction between syntactic and active
%substitutions with respect to processes. In the process
%$\activesubst{M}{x} \mid A$, the expression
%$\activesubst{M}{x}$ is a subprocess, whose meaning is that $x$ is a
%handle for the environment to refer to $M$. In the process
%$A\activesubst{M}{x}$, the expression
%$\activesubst{M}{x}$ is a substitution meaning that free occurrences
%of $x$ in $A$ should be replaced by $M$ (in such a way that no names
%or variables in $M$ become bound).}
where
$A\activesubst{M}{x}$ is $A$ with all free occurrences
of $x$ replaced by $M$ (in such a way that no names
or variables in $M$ become bound).
The final rule,
$\Rewrite$, allows terms that are equal modulo the equational theory
to be swapped as desired.
Structural equivalence allows every closed extended process $A$ to be rewritten as a substitution and a closed plain process with some restricted names: $A \equiv \new{\tilde{n}}.(\activesubst{\tilde{M}}{\tilde{x}} \mid P)$ where $\fv{\tilde{M}} = \fv{P} = \emptyset$ and $\tilde{n} \subseteq \fn{\tilde{M}}$. It follows immediately that every closed frame $\varphi$ can be rewritten as a substitution with some restricted names: $\varphi \equiv \new{\tilde{n}}.\activesubst{\tilde{M}}{\tilde{x}}$ where $\fv{\tilde{M}} = \emptyset$ and $\tilde{n} \subseteq \fn{\tilde{M}}$. We note that the domain of $\varphi$ is $\tilde{x}$.
\subsubsection{Internal reduction.}\label{sec:internalReduction}
%\tblue{I don't like ``without contact with its environment," since the process $P$ has contact with the environment $C[\_]$ in the process $C[P]$}
A process can be executed without contact with its environment; either because if-statements are evaluated and
the then- or else-branch is taken, or because internal subprocesses
communicate with each other. The execution of a process with respect
to control flow and communication is captured by \emph{internal
reduction}. Formally, internal reduction~($\reduc$) is the smallest
relation on extended processes closed under structural equivalence and
application of evaluation contexts such that:
\begin{center}
\begin{minipage}{\linewidth}
\begin{tabbing}
XXXXXX\=X\=\kill %Set tab sizes
$\Comm$ \> $\Out{M}.P\mid\In{x}.Q \reduc P \mid Q\activesubst{M}{x}$ \\[0.2cm]
$\Then$ \> $\Ifthenelse{N}{N}{P}{Q} \reduc P$ \\[0.2cm]
$\EElse$ \> $\Ifthenelse{L}{M}{P}{Q} \reduc Q$ \\
\>\> for ground terms $L,M$ where $L \not=_\EE M$
\end{tabbing}
\end{minipage}
\end{center}
\noindent
We write $\reduc^*$ for the reflexive and transitive closure of $\reduc$.
\iffalse
Communication ($\Comm$) is defined on variables, making it
look rather restricted. However, this entails no loss of generality
because $\Alias$ and $\Subst$ can be used to allow communication of
an arbitrary term $M$ instead of a variable $x$. To see how this works, consider
the process $\Out{M}.P\mid\In{x}.Q$. We can suppose that $x$ is not in $\fv
P$ (if it is, pick any $x'\not\in\fv P$ and $\alpha$-rename
the bound variable $x$ to $x'$
in $\In{x}.Q$). Then $\Out{M}.P\mid\In{x}.Q \equiv
\new{x}.(\Out{x}.P\mid\In{x}.Q\mid\activesubst{M}{x})$.
Since $\Out{x}.P\mid\In{x}.Q \reduc P \mid Q$ by $\Comm$, we derive
$P \mid
Q\activesubst{M}{x}$ by application of an evaluation
context. To see this step in more detail, consider $C[\_] = \new{x}.(\_\mid\activesubst{M}{x})$
and observe $\new{x}.(\Out{x}.P\mid\In{x}.Q\mid\activesubst{M}{x}) = C[\Out{x}.P\mid\In{x}.Q] \reduc C[P \mid Q]$
which is structurally
equivalent to $P \mid
Q\activesubst{M}{x}$. Since $\reduc$ is closed under structural equivalence, we have
$\Out{M}.P\mid\In{x}.Q \reduc P \mid
Q\activesubst{M}{x}$.
\fi
The original presentation~\cite{AppliedPi} defined a variant of the
communication ($\Comm$) rule
on variables rather than terms without loss of generality,
since active substitutions were defined over all types and, hence,
structural equivalence could be used to allow communication of an arbitrary term
instead of a variable. However, as noted in Section~\ref{sec:syntax},
we restrict active substitutions to terms of base type and to avoid losing
generality we define communication ($\Comm$) on terms.
Conditionals ($\Then$ and $\EElse$) are
dependent on the equational theory.
The rule $\Then$ is defined for
syntactically identical terms $N$, making it look rather restricted.
However, this entails no loss of generality
because structural equivalence allows us to replace a term $M$ with $N$, when $M =_\EE N$.
%
%% This is incomplete
%
%To see how this works, consider a process
%By $\Alias$ we have $P \equiv \new x.\activesubst{M}{x} \mid
%\Ifthenelse{x}{N}{Q}{R}\activesubst{M}{x}$ for some fresh variable $x$. \sout{Since
%$\equiv$ is transitive and closed under the application of evaluation contexts,} It follows
%by $\Subst$ that $R \equiv \new x.\activesubst{M}{x} \mid \Ifthenelse{x}{N}{Q}{R}$,
%moreover, by $\Rewrite$ we have $R \equiv \new x.\activesubst{N}{x} \mid \Ifthenelse{x}{N}{Q}{R}$.
%Similarly, by $\Subst$ we have $R \equiv \new x.\activesubst{N}{x} \mid\Ifthenelse{x}{N}{Q}{R}\activesubst{N}{x}$
%and by $\Alias$ we have $R \equiv \Ifthenelse{N}{N}{Q}{R}$.
%
%% The following is better.
%
For instance, given a process $\Ifthenelse{M}{N}{P}{Q}$ such that $M =_\EE N$
and a fresh variable $x$, we have:
\[
\begin{array}{lclcl}
\Ifthenelse{M}{N}{P}{Q} &\equiv& \Ifthenelse{M}{N}{P}{Q} \mid \nill &\qquad & \textrm{by $\ParI$}\\
&\equiv& \Ifthenelse{M}{N}{P}{Q} \mid \new{x}.\activesubst{M}{x} && \textrm{by $\Alias$}\\
&\equiv& \new{x}.(\Ifthenelse{M}{N}{P}{Q} \mid \activesubst{M}{x}) && \textrm{by $\NewPar$}\\
&\equiv& \new{x}.(\activesubst{M}{x}\mid \Ifthenelse{M}{N}{P}{Q}) && \textrm{by $\ParC$}\\
&\equiv& \new{x}.(\activesubst{M}{x}\mid \Ifthenelse{x}{N}{P}{Q}) && \textrm{by $\Subst$}\\
&\equiv& \new{x}.(\activesubst{N}{x}\mid \Ifthenelse{x}{N}{P}{Q}) && \textrm{by $\Rewrite$}\\
&\equiv& \new{x}.(\activesubst{N}{x}\mid \Ifthenelse{N}{N}{P}{Q}) && \textrm{by $\Subst$}\\
&\equiv& \new{x}.(\Ifthenelse{N}{N}{P}{Q} \mid \activesubst{N}{x}) && \textrm{by $\ParC$}\\
&\equiv& \Ifthenelse{N}{N}{P}{Q} \mid \new{x}.\activesubst{N}{x} && \textrm{by $\NewPar$}\\
&\equiv& \Ifthenelse{N}{N}{P}{Q} \mid \nill && \textrm{by $\Alias$}\\
&\equiv& \Ifthenelse{N}{N}{P}{Q} && \textrm{by $\ParI$}
\end{array}
\]
Structural equivalence may also be required by the $\EElse$ rule
to ensure terms $L$ and $M$ are ground by applying active substitutions
that appear in the context.
%Example~\ref{ex:internalReduction2} demonstrates the application of
%the operational semantics using a simple but practical protocol and
%Example~\ref{ex:internalReduction} shows how to reason with more
%complex processes.
%\begin{example}[Key distribution protocol]
%Consider the closed process $\new{a}.(\new{k}.\Out[a]{k}.P\mid\In[a]{x}.Q)$ which models the distribution of key $k$ using private channel $a$. We have $\new{a}.(\new{k}.\Out[a]{k}.P\mid\In[a]{x}.Q) \equiv \new{x}.(\activesubst{k}{x}\mid\new{a}.\new{k}.(\Out[a]{x}.P\mid\In[a]{x}.Q))$ where $k\not\in\fn{Q}$. We can now model the communication using the $\textrm{COMM}$ rule $\new{x}.(\activesubst{k}{x}\mid\new{a}.\new{k}.(\Out[a]{x}.P\mid\In[a]{x}.Q)) \reduc \new{x}.(\activesubst{k}{x}\mid\new{a}.\new{k}.(P \mid Q)) \equiv \new{k}.(P \mid Q\activesubst{k}{x})$ where $a\not\in\fn{P} \cup \fn{Q}$ and hence process $Q$ learns key $k$.
%\end{example}
\subsubsection{Labelled reductions}
%The semantics in Section~\ref{sec:internalReduction}
%allow us to reason about protocols with an adversary represented by a
%context. In order to prove that security properties hold for all
%adversaries, quantification over all contexts is typically required,
%which can be difficult in practice. The labelled operational semantics
%we now present aims to eliminate universal quantification of the
%context.
The labelled semantics defines a ternary relation written, $A
\reduc[\alpha] B$, where $\alpha$ is a \emph{label} of the form
$\In{M},$ $\Out{u},$ or $\new{u}.\Out{u}$ such that $u$ is either a
channel name or a variable of base type.
The transition $A \reduc[\In{M}] B$ means that the process $A$
performs an input of the term $M$ from the environment on the
channel $c$, and the resulting process is $B$.
The situation for output is a bit more complicated, since there are
several cases.
If the item is a free variable $x$ or a free
channel name $d$, then the label $\Out{x}$, respectively $\Out{d}$, is
used. If the item being output is a restricted channel name $d$, then
the label $\new{d}.\Out{d}$ is used. Finally, if the item is a term $M$, then
the label $\new{x}.\Out{x}$ is used, after replacing the occurrence of
the term $M$ by $x$ and wrapping the process in $\nu x.(\activesubst M x
\mid \_)$.
The operational semantics of
\S\ref{sec:structuralEquivalence} are extended to include the following
rules:
%
\[
\begin{array}{lc}
\IIn & \In{x}.P \reduc[\In{M}] P\activesubst{M}{x} \\[0.3cm]
\OutAtom & \Out{u}.P \reduc[\Out{u}] P \\[0.3cm]
\OpenAtom & \dfrac{A \reduc[\Out{u}] A' \qquad u \not= c}
{\new{u}.A \reduc[\new{u}.\Out{u}] A'} \\[0.5cm]
\Scope & \dfrac{A \reduc[\alpha] A' \qquad \textrm{$u$ does not occur in $\alpha$}}
{\new{u}.A \reduc[\alpha] \new{u}.A'} \\[0.5cm]
\Par & \dfrac{A \reduc[\alpha] A' \qquad \bv{\alpha} \cap \fv{B} =
\bn{\alpha} \cap \fn{B} = \emptyset}
{A \mid B \reduc[\alpha] A' \mid B} \\[0.5cm]
\Struct & \dfrac{A \equiv B \qquad B \reduc[\alpha] B' \qquad B' \equiv A'}
{A \reduc[\alpha] A'}
\end{array}
\]
%
The rule $\OpenAtom$ is used in two ways: 1) to output a
restricted channel; and 2) to output a term.
The first instance is straight forward and one may prove that $\nu d.\Out{d}.P\reduc[\nu
d.\Out d] P$, provided $c\ne d$.
The latter is a little more complicated since it requires the use of
structural equivalence rules. Observe that
$\Out M.P \reduc[\nu x.\Out x] P\mid\activesubst M x$, where $x\not\in\fv{P}$, by first
writing $\Out M.P$ as $\nu x.( \Out x.P\mid\activesubst M x)$.
The full derivation is given below:
\begin{center}
\begin{prooftree}
\Out{M}.P\ \equiv \
\[
\[
\[
\justifies
\Out{x}.P \reduc[\Out{x}] P
\using\OutAtom
\]
\justifies
\Out{x}.P\mid\activesubst{M}{x} \reduc[\Out{x}] P\mid\activesubst{M}{x}
\using\Par
\]
\justifies
\new{x}.(\Out{x}.P\mid\activesubst{M}{x}) \reduc[{\new{x}.\Out{x}}] P\mid\activesubst{M}{x}
\using\OpenAtom
\]
\
\equiv\ P\mid \activesubst{M}{x}
\justifies
\Out{M}.P \reduc[{\new{x}.\Out{x}}] P\mid \activesubst{M}{x}
\using\Struct
\end{prooftree}
\end{center}
Note that the fact $x\not\in\fv{P}$ is needed for the first of the two structural equivalences in the occurrence of $\Struct$.
\begin{example}[Labelled semantics]
Consider the process $A \pdef \Out{m}.\Out{m}$. Show the reductions
$A\reduc[\new{x}.\Out{x}]\reduc[\new{y}.\Out{y}]\activesubst{m}{x}\mid\activesubst{m}{y}$.
Also show the reductions
$A\reduc[\new{x}.\Out{x}]\reduc[\Out{x}]\activesubst{m}{x}$. (Hint.
The last one involves an application of $\Subst$.)
\end{example}
\subsubsection{Names and the environment}
\label{sec:namesEnv}
The reduction $\new{\tilde n}.\Out M.P \reduc[\nu x.\Out x]
\new{\tilde n}.(P\mid\activesubst M x)$ represents an important idiom
of the applied pi calculus. It is the way that an arbitrary term $M$
is output to the environment. This illustrates the way that
the environment's use of names is controlled.
If $s$ is a restricted name in a process then the environment cannot
use that $s$ to construct a term. Moreover, if the environment uses
the name $s$, then it
is not the same as the one in the process. Consider
for example the process
\[
A\pdef\new s. (\In x. \Ifthen x s {\Out{i\_got\_s}})
\]
This process can never output $i\_got\_s$, because no term input as
$x$ can be equal to the `new' $s$ created by the process.
More precisely, there is no
sequence of reductions
\[ A \reduc^*\reduc[\alpha]\reduc^* \dots
\to^*\reduc[\alpha]\to^*
B\mid\activesubst {i\_got\_s}{y}\]
for some process $B$ and variable $y$.
Now suppose the process $A'$ creates a new $s$ and outputs some term
containing $s$:
\[
A'\pdef\new s. (\Out{\Hash{s}}.B')
\]
We have $A'\reduc[\new x.\Out x] \new s.(B'\mid\activesubst{\Hash{s}}{x})$.
This process exposes
$\Hash{s}$ to the environment, by reference to the handle $x$. Although the
environment still does not have $s$, it can
use $\Hash{s}$ in an expression, simply by using $x$ in its
place. For
example, it can use $x$ to construct input in $B'$.
Now consider the process $A''$ which creates a new $s$,
outputs the encryption of $s$ by a (free) key $k$, and then accepts an
input and tests if the input is $s$.
\[
A''\pdef\new s. (\Out{\Senc{k}{s}}.\In x. \Ifthen x s {\Out{i\_got\_s}})
\]
This test can succeed; the process can output $i\_got\_s$, as shown by the following execution:
\[\begin{array}{rr@{\quad}l}
A''&\reduc[\new y.\Out y]&\new s.( \In x . \Ifthen x s {\Out{i\_got\_s}}
\mid \activesubst{\Senc{k}{s}}{y})\\
&\reduc[\In {\Sdec k y}]&\new s.( \Ifthen {\Sdec k y} s {\Out{i\_got\_s}}
\mid \activesubst{\Senc{k}{s}}{y})\\
& \equiv & \new s.( \Ifthen {\Sdec k {\Senc{k}{s}}} s {\Out{i\_got\_s}}
\mid \activesubst{\Senc{k}{s}}{y})\\
& \equiv & \new s.( \Ifthen s s {\Out{i\_got\_s}}
\mid \activesubst{\Senc{k}{s}}{y})\\
& \reduc & \new s.( {\Out{i\_got\_s}}
\mid \activesubst{\Senc{k}{s}}{y})\\
& \reduc[\new z.\Out z] & \new s.(
\activesubst{\Senc{k}{s}}{y}\mid \activesubst{i\_got\_s}{z})\\
& \equiv & \new s.(
\activesubst{\Senc{k}{s}}{y})\mid \activesubst{i\_got\_s}{z}\\
\end{array}
\]
The first of the equivalences $\equiv$ holds by the rule $\Subst$; the
second one is by $\Rewrite$, using the equation $\Sdec k {\Senc{k}{s}} = s$.
Intuitively, the environment has taken the
encrypted output and decrypted it (since the key $k$ is a name known
to the environment). It can then input the result to the process,
which sees that it is indeed equal to $s$.
It is instructive to return to the process $A\pdef\new s. (\In x .\Ifthen x s {\Out{i\_got\_s}})
$ above, and consider
what happens if the environment gives it the name $s$ as input. As
stated earlier, intuitively this $s$ from the environment is
considered different from the $s$ that the process
constructs. Technically, this is handled as follows. If we try to
perform a transition $A\reduc[\In s]B$, we find that we cannot quite
use the expected combination of the rules $\IIn$ and $\Scope$, because $\IIn$ asks us to perform the substitution
\[\new s.(\Ifthen x s {\Out{i\_got\_s}}\activesubst s x)\]
which would insert the $s$ from the substitution into the scope of the
$\nu s$. As previously mentioned, such substitutions are not
allowed. We can resolve the situation by $\alpha$-renaming the bound $s$
first:
\[%\begin{array}{rr@{\quad}l}
A\equiv \new {s'}. (\In x . \Ifthen x {s'} {\Out{i\_got\_s}}).
%\end{array}
\]
Recall that $\Ifthen{M}{N}P$ is an abbreviation of
$\Ifthenelse{M}{N}{P}\nill$ and hence we have the reductions:
\[
\new {s'}. (\In x . \Ifthen x {s'} {\Out{i\_got\_s}}) \reduc[\In s] \Ifthen s {s'} {\Out{i\_got\_s}} \reduc 0.
\]
%\subsection{Automated reasoning***}
%\cblue{agree drop. Maybe elaborate slightly more on ``This analysis can sometimes be performed automatically, using the ProVerif software tool~\cite{BlanchetJCS09}." in introduction. I don't think we need to put ProVerif proofs online. Moreover, they may cause us future headaches?}
%The applied pi calculus is amenable to automated reasoning, for example by using the ProVerif software tool developed by Bruno Blanchet. Formal treatment of ProVerif is beyond the scope of this chapter, but we will occasionally use ProVerif to support our proofs. Our input scripts and additional material can be found online \url{http://www.bensmyth.com/...}.
%\subsection{Worked examples and exercises}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%=======================================
%%
%%\textbf{Alternative theory:}
%%\[
%%\begin{array}{lcl}
%%\Fst{\Pair{x}{y}} &=& x \\
%%\Snd{\Pair{x}{y}} &=& y \\
%%\Sdec{M}{y} &=& \begin{cases}
%% x \quad\textrm{if } M = \Senc{x}{y}\\
%% \perp\quad\textrm{otherwise}
%% \end{cases}\\[0.5cm]
%%\Adec{M}{y} &=& \begin{cases}
%% x \quad\textrm{if } M = \Aenc{x}{\Pk{y}}\\
%% \perp\quad\textrm{otherwise}
%% \end{cases}\\[0.5cm]
%%\Checksign{M}{N} &=&\begin{cases}
%% x \quad\textrm{if } M = \Sign{x}{y}, N = \Pk{y}\\
%% \perp\quad\textrm{otherwise}
%% \end{cases}
%%\end{array}
%%\]
%%
%%=======================================
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%\begin{example}[Key distribution protocol*** \tblue{not so convinced to drop, but no objections}]\label{ex:internalReduction2}
%% Consider the closed process
%% $\new{a}.(\new{k}.\Out[a]{k}.P\mid\In[a]{x}.Q)$ which models the
%% distribution of key $k$ using private channel $a$. Assume that
%% $x\not\in\fv P$. We have
%% $\new{a}.(\new{k}.\Out[a]{k}.P\mid\In[a]{x}.Q) \equiv
%% \new{x}.\new{k}.(\activesubst{k}{x}\mid\new{a}.(\Out[a]{x}.P\mid\In[a]{x}.Q))$
%% where $k\not\in\fn{Q}$. We can now model the communication using the
%% $\textrm{COMM}$ rule
%% $\new{x}.\new{k}.(\activesubst{k}{x}\mid\new{a}.(\Out[a]{x}.P\mid\In[a]{x}.Q))
%% \reduc \new{x}.\new{k}.(\activesubst{k}{x}\mid\new{a}.(P \mid Q))
%% \equiv \new{k}.(P \mid Q\activesubst{k}{x})$ where $a\not\in\fn{P}
%% \cup \fn{Q}$ and hence process $Q$ learns key $k$.
%%\begin{exercise}{Structural equivalence} Prove each of the following equivalences:
%%\begin{enumerate}
%%\item $(\new{n}.\new{m}.A) \mid (\new{x}.B) \equiv \new{x}.\new{n}.\new{m}.(A \mid B)$ where $n,m,x\not\in\fv{A}\cup\fn{B}$.
%%\item $A\activesubst{M}{x} \equiv \new{x}.(\activesubst{N}{x} \mid A)$ where $M =_\EE N$.
%%\item Identify and prove each instance of structural equivalence in Example~\ref{ex:internalReduction}.
%%\end{enumerate}
%%\end{exercise}
%%\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\marginpar{Example~\ref{ex:internalReduction} looks particularly ugly on the page!}%
%%\begin{example}[Execution of the handshake protocol with a passive attacker*** \tblue{Agree, drop}]\label{ex:internalReduction}
%%Let $P' = \new{sk_A,sk_B}.(\Out{\Pk{sk_A}} \mid \Out{\Pk{sk_B}} \mid P_A \mid P_B)$ be a single instance of the handshake protocol. We have $P' \reduc\reduc \new{sk_A,sk_B,k}.((\In{z}.\Ifthen{\Snd{z}}{\Mac{k}{\Fst{z}}}0) \mid (\Ifthen{\Checksign{\Sign{k}{sk_A}}{\Pk{sk_A}}}{true}\Out{\Pair{\Senc{s}{y\_k}}{\Mac{y\_k}{\Senc{s}{y\_k}}}}) \mid \Out{\Pk{sk_A}} \mid \Out{\Pk{sk_B}})$ by $\Comm$. We derive $\new{sk_A,sk_B,k}.((\In{z}.\Ifthen{\Snd{z}}{\Mac{k}{\Fst{z}}}0) \mid \Out{\Pair{\Senc{s}{y\_k}}{\Mac{y\_k}{\Senc{s}{y\_k}}}} \mid \Out{\Pk{sk_A}} \mid \Out{\Pk{sk_B}})$ by $\Then$. Finally, we derive $\new{sk_A,sk_B}.(\Out{\Pk{sk_A}} \mid \Out{\Pk{sk_B}})$ by $\Comm$ and $\Then$.
%%\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```
# Secrecy and correspondence properties
This section presents formal definitions of secrecy and correspondence in the presence of an adversary who has full control of the network. The attacker can therefore eavesdrop, replay, inject and block messages. Formally the attacker is captured as an arbitrary process and is sometimes called the Dolev-Yao adversary (**DY83?**).
## Secrecy
Intuitively, a protocol preserves the secrecy of some term $M$ if an adversary cannot obtain $M$ by constructing it from the outputs of the protocol (**BlanchetJACM05?**). We formalise the adversary as a process running in parallel with the protocol, that after constructing $M$ outputs it on a public channel. The adversary process does not have any of the protocol’s secrets.
A term may refer to names inside a process; to analyse secrecy of the term, it is important that these names appear unambiguously in the process. Otherwise it is not clear which name the term refers to. For example, if a name in the term is both bound and free in the process, then it is not clear whether the term refers to the free instance, or the bound instance. We formalise that by requiring the process to be “name distinct” for the names mentioned in the term.
**Definition 1** (name-distinct for $\tilde m$). *A closed plain process $P$ is *name-distinct* for a set of names $\tilde m$, if $\tilde m \cap \textnormal{fn}(P) \cap \textnormal{bn}(P) = \emptyset$ and for each name $n \in \tilde m\cap\textnormal{bn}(P)$ there is exactly one name restriction $\nu\,n$ occurring in $P$, and the restriction is not under replication “$!$”.*
**Definition 2** (Can output). *A plain process $P$ *can output the term* $M$ if there exists an evaluation context $C[\_]$, a channel name $c\not\in\textnormal{bn}(C)$ and process $R$ such that the reduction $P\xrightarrow{}^*C[\overline{c}\langle M\rangle.R]$ holds with no alpha-renaming of the names in $\textnormal{fn}(M)$.*
In Definition 2, the process $C[\overline{c}\langle M\rangle.R]$ is capable of outputting the term $M$ on the free channel $c$ in one further step. Note that the definition forbids renaming names in $M$ during the reduction $P\xrightarrow{}^*C[\overline{c}\langle M\rangle.R]$, because we must not change which names in $P$ are referred to by $M$. Thus, the process $\nu b.\overline{c}\langle b\rangle$ cannot output $s$; if we allowed renaming, we could write the process as $\nu s.\overline{c}\langle s\rangle$ and it would be able to output $s$.
**Definition 3** (Reachability-based secrecy). *Let $M$ be a term, and $P$ be a closed plain process that is name-distinct for $\textnormal{fn}(M)$. Then $P$ preserves the *reachability-based secrecy* of $M$ if there is no plain process $I$ such that $(\textnormal{fn}(I)\cup\textnormal{bn}(I))\cap\textnormal{bn}(P)=\emptyset$ and $P\mid I$ can output $M$.*
In the definition above, $I$ is the adversary (or *intruder*) process. Typically, it is built in order to receive the outputs from $P$, and then possibly to construct from them the secret term $M$, and output it. If there is no such intruder, then $P$ keeps $M$ secret. This definition is based on the one in (**BlanchetJACM05?**), but extends it to cope with bound names.
Execution of Handshake protocol (internal reduction)
**Example 1** (Reasoning with secrecy). *Consider the process $P$ corresponding to the Handshake protocol (Section [sec:model]) and the equational theory ${E_{H}}$. We show that $P$ does not preserve the secrecy of $s$, by presenting an adversarial process $$\begin{array}{lcl}
I &\triangleq& c(y\_pk).\overline{c}\langle{\ensuremath{\mathsf{pk}(sk_M)}}\rangle.c(x).\\
&&\overline{c}\langle{\ensuremath{\mathsf{aenc}(y\_pk,{\ensuremath{\mathsf{adec}(sk_M,x)}})}}\rangle.c(z).\\
&&\overline{c}\langle{\ensuremath{\mathsf{snd}({\ensuremath{\mathsf{sdec}({\ensuremath{\mathsf{getmsg}({\ensuremath{\mathsf{adec}(sk_M,x)}})}},z)}})}}\rangle
\end{array}$$ and demonstrating that $P\mid I$ can evolve to a process that can output $s$ on a public channel. To aid readability, we apply all the substitutions denoted by ‘let’ occurring in $P$, and we use the context $$C[\_]\triangleq\nu\,sk_{{\ensuremath{\mathcal{S}}}}.\nu\,sk_{{\ensuremath{\mathcal{C}}}}.\nu\,s.\left(\_ \mid {!P_{{\ensuremath{\mathcal{S}}}}} \mid {!P_{{\ensuremath{\mathcal{C}}}}}\right)$$ and write $P\equiv C[\overline{c}\langle{\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}}\rangle \mid \overline{c}\langle{\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}}\rangle\mid P_{{\ensuremath{\mathcal{S}}}}\mid P_{{\ensuremath{\mathcal{C}}}}]$. Since $sk_{{\ensuremath{\mathcal{S}}}},sk_{{\ensuremath{\mathcal{C}}}},s \not\in\textnormal{fn}(I) \cup \textnormal{fv}(I)$, we have $$\begin{array}{rcl}
P \mid I \equiv C[&\quad\\
&\multicolumn{2}{l}{ \overline{c}\langle{\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}}\rangle \mid \overline{c}\langle{\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}}\rangle}\\
&\mid& c(x\_pk).\nu\,k.\overline{c}\langle{\ensuremath{\mathsf{aenc}(x\_pk,{\ensuremath{\mathsf{sign}(sk_{{\ensuremath{\mathcal{S}}}},k)}})}}\rangle.\\
&& c(z).\textnormal{if } {\ensuremath{\mathsf{fst}({\ensuremath{\mathsf{sdec}(k,z)}})}}=tag \textnormal{ then }Q\\
&\mid& c(y).\textnormal{if } {\ensuremath{\mathsf{checksign}({\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}},{\ensuremath{\mathsf{adec}(sk_{{\ensuremath{\mathcal{C}}}},y)}})}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&& \overline{c}\langle{\ensuremath{\mathsf{senc}({\ensuremath{\mathsf{getmsg}({\ensuremath{\mathsf{adec}(sk_{{\ensuremath{\mathcal{C}}}},y)}})}},{\ensuremath{\mathsf{pair}(tag,s)}})}}\rangle\\
&\mid& I\\
]
\end{array}$$ The execution path which results in the adversary being able to output $s$ on a public channel is shown in Figure 1. Intuitively, the following sequence takes place (the item numbers correspond to the transitions in the figure):*
1. *${\ensuremath{\mathcal{C}}}$’s public key ${\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}}$ is published and hence made available to the adversary, who inputs it as $y_{pk}$.*
2. *The adversary provides her public key ${\ensuremath{\mathsf{pk}(sk_M)}}$ as ${\ensuremath{\mathcal{S}}}$’s interlocutor.*
3. *${\ensuremath{\mathcal{S}}}$ outputs her signature on $k$, encrypted for the adversary, and the adversary inputs it as $x$. (Observe that closure under structural equivalence is used to move the name restriction $\nu\,k$ outside of the context; more precisely, the rules ${\ensuremath{\mbox{\sc New-C}}}$, ${\ensuremath{\mbox{\sc New-Par}}}$ are applied.)*
4. *The adversary gives to ${\ensuremath{\mathcal{C}}}$ the value $k$ signed by ${\ensuremath{\mathcal{S}}}$, this time encrypted for ${\ensuremath{\mathcal{C}}}$.*
5. *The process is further rewritten using structural equivalence (essentially several occurrences of the rule ${\ensuremath{\mbox{\sc Rewrite}}}$ with respect to ${E_{H}}$). (Note that this rewriting could have been included in the previous step because internal reduction is closed under structural equivalence, but we explicitly present it for clarity.)*
6. *The conditional is evaluated and ${\ensuremath{\mathcal{C}}}$ sends the value ${\ensuremath{\mathsf{senc}({{{{k}}}},{\ensuremath{\mathsf{pair}(tag,s)}})}}$ to the adversary.*
7. *Observe that $\overline{c}\langle{\ensuremath{\mathsf{snd}({\ensuremath{\mathsf{sdec}(k,{\ensuremath{\mathsf{senc}({{{{k}}}},{\ensuremath{\mathsf{pair}(tag,s)}})}})}})}}\rangle \equiv \overline{c}\langle s\rangle$ and hence the adversary can obtain $s$ and publish the value on a public channel.*
## Correspondence properties
Correspondence properties are used to capture relationships between events that can be expressed in the form *“if an event $e$ has been executed then event $e'$ has been previously executed."* Moreover, these events may contain arguments, which allow relationships between the arguments of events to be expressed. To reason with correspondence properties we annotate processes with *events*, marking important stages reached by the protocol which do not otherwise affect behaviour. Events are analogous to breakpoints used in software development. In this chapter, we only consider basic correspondence properties, which are sufficient to model authentication. More elaborate formalisms can be found in (**Blanchet07?**; **BlanchetJCS09?**). Events are message outputs $\overline{f}\langle M\rangle$ where $f$ is an *event channel* (a name in a particular set, disjoint from the set of ordinary channel names). In labelled transitions, output labels for events use *event variables* $e$. Those event variables are not allowed to appear in input labels $u(M)$, so the adversary cannot use them. (This condition is important, since events are added just for checking correspondence properties; in particular an event $\overline{f}\langle M\rangle$ does not reveal M to the adversary.) Hence, the execution of the process $P$ after inserting events $\overline{f}\langle M\rangle$ is the execution of $P$ without events, plus the recording of events using labels $\nu\,e.\overline{f}\langle e\rangle$ and active substitutions $\{\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $e$}}\}$.
**Definition 4** (Correspondence property). *A *correspondence property* is a formula of the form: $\overline{f}\langle M\rangle \rightsquigarrow\overline{g}\langle N\rangle$.*
The property asserts that if the event $f$ has been executed in a trace with parameters $M$, then the event $g$ must have been previously executed with parameters $N$.
Authentication can be captured as a correspondence property. Recall that in addition to the secrecy property mentioned for the Handshake protocol in Section 1, there were also authentication properties. The protocol is intended to ensure that if ${\ensuremath{\mathcal{S}}}$ thinks she executes the protocol with ${\ensuremath{\mathcal{C}}}$, then she really does so, and vice versa. When we say ‘she thinks’ that she executes it with ${\ensuremath{\mathcal{C}}}$, we mean that the data she receives indicates that fact. Accordingly we annotate the Handshake protocol with events. To capture equality tests within events we include the binary function $\mathsf{eq}$ in the signature $\Sigma_{H}$ and extend the equational theory ${E_{H}}$ with the equation ${\ensuremath{\mathsf{eq}(x,x)}} = {\ensuremath{\mathsf{true}}}$.
**Example 2** (Annotated Handshake protocol). *The annotated Handshake protocol is presented below $$\begin{array}{llcl}
& P &\triangleq& \nu\,sk_{{\ensuremath{\mathcal{S}}}}.\nu\,sk_{{\ensuremath{\mathcal{C}}}}.\nu\,s.\\
&&& \textnormal{let } pk_{S}={\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}} \textnormal{ in } \textnormal{let } pk_{C}={\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}} \textnormal{ in }\\
&&& (\overline{c}\langle pk_{S}\rangle \mid \overline{c}\langle pk_{C}\rangle \mid {!P_{{\ensuremath{\mathcal{S}}}}} \mid {!P_{{\ensuremath{\mathcal{C}}}}})\\
\\
& P_{{\ensuremath{\mathcal{S}}}} &\triangleq& c(x\_pk).\nu\,k.\overline{startedS}\langle{\ensuremath{\mathsf{pair}(x\_pk,k)}}\rangle\\
& && \overline{c}\langle{\ensuremath{\mathsf{aenc}(x\_pk,{\ensuremath{\mathsf{sign}(sk_{{\ensuremath{\mathcal{S}}}},k)}})}}\rangle.\\
& && c(z).\textnormal{if } {\ensuremath{\mathsf{fst}({\ensuremath{\mathsf{sdec}(k,z)}})}}=tag \textnormal{ then }\\
& && \overline{completedS}\langle{\ensuremath{\mathsf{pair}(k,{\ensuremath{\mathsf{eq}(x\_pk,pk_{C})}})}}\rangle.Q\\
%\\
\end{array}$$ $$\begin{array}{llcl}
& P_{{\ensuremath{\mathcal{C}}}} &\triangleq& c(y).\textnormal{let } y'={\ensuremath{\mathsf{adec}(sk_{{\ensuremath{\mathcal{C}}}},y)}} \textnormal{ in }\textnormal{let } y\_k={\ensuremath{\mathsf{getmsg}(y')}} \textnormal{ in }\\
& && \overline{startedC}\langle y\_k\rangle \\
& && \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_{S},y')}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
%& && \textrm{\sout{$\Ifthen{pk_{\lAlice}}{x\_pk_A}$} \tblue{See comment \S2.1.1}}\\
& && \overline{c}\langle{\ensuremath{\mathsf{senc}(y\_k,{\ensuremath{\mathsf{pair}(tag,s)}})}}\rangle\\
& && \overline{completedC}\langle{\ensuremath{\mathsf{pair}(pk_{C},y\_k)}}\rangle\\
\end{array}$$ where the four events are interpreted as follows:*
- *$\overline{startedS}\langle{\ensuremath{\mathsf{pair}(x\_pk,k)}}\rangle$ means that ${\ensuremath{\mathcal{S}}}$ considers she has started the protocol with an interlocutor whose public key is $x\_pk$, and she has proposed $k$ as the session key.*
- *$\overline{startedC}\langle y\_k\rangle$ means that ${\ensuremath{\mathcal{C}}}$ considers he has started the protocol with the session key $y\_k$.*
- *$\overline{completedS}\langle{\ensuremath{\mathsf{pair}(k,t)}}\rangle$ means that ${\ensuremath{\mathcal{S}}}$ believes she has completed the protocol with session key $k$ and if $t =_{E_{H}}{\ensuremath{\mathsf{true}}}$, then the protocol was completed with ${\ensuremath{\mathcal{C}}}$.*
- *$\overline{completedC}\langle{\ensuremath{\mathsf{pair}(pk_{{\ensuremath{\mathcal{C}}}},y\_k)}}\rangle$ means that ${\ensuremath{\mathcal{C}}}$ considers he has successfully completed the protocol with ${\ensuremath{\mathcal{S}}}$ using session key $y\_k$, where $pk_{{\ensuremath{\mathcal{C}}}}$ is his public key.*
*Correspondence properties can now be defined to allow the analysis of authentication. Recall that the client ${\ensuremath{\mathcal{C}}}$ is only willing to share her secret with the server ${\ensuremath{\mathcal{S}}}$. We formalise the authentication of ${\ensuremath{\mathcal{C}}}$ using the correspondence property $$\overline{completedC}\langle{\ensuremath{\mathsf{pair}(x,y)}}\rangle \rightsquigarrow \overline{startedS}\langle{\ensuremath{\mathsf{pair}(x,y)}}\rangle.$$ In comparison, ${\ensuremath{\mathcal{S}}}$ is willing to run the protocol with any other principal. The correspondence property says that if she believes ${\ensuremath{\mathcal{C}}}$ was her interlocutor, then ${\ensuremath{\mathcal{C}}}$ must have completed the protocol with the suggested key. This is formalised as: $$\overline{completedS}\langle{\ensuremath{\mathsf{pair}(y,{\ensuremath{\mathsf{true}}})}}\rangle \rightsquigarrow \overline{startedC}\langle y\rangle$$ The subtle differences between the two correspondence properties is due to the differing authentication properties expected by participants ${\ensuremath{\mathcal{S}}}$ and ${\ensuremath{\mathcal{C}}}$.*
Formally we define the validity of a correspondence property in Definition 5. Intuitively, it ensures that if the event $f$ is executed, then the event $g$ must have been previously executed. Moreover, the parametrisation of the events must satisfy any relationships defined by $M,N$; that is, the variables $\textnormal{fv}(M) \cap \textnormal{fv}(N)$ must be parametrised in the same way.
**Definition 5** (Validity of correspondence property). *Let $E$ be an equational theory, and $A_0$ an extended process. We say that $A_0$ *satisfies the correspondence property* $\overline{f}\langle M\rangle \rightsquigarrow \overline{g}\langle N\rangle$ if for all execution paths $$A_0 \to^*\xrightarrow{\alpha_1}\to^*
A_1 \to^*\xrightarrow{\alpha_2}\to^*
\dots \to^*\xrightarrow{\alpha_n}\to^* A_n,$$ and all index $i\in \mathbb{N}$, substitution $\sigma$ and variable $e$ such that $\alpha_i=\nu\,e.\overline{f}\langle e\rangle$ and $e\varphi(A_i)=_EM\sigma$, there exists $j\in \mathbb{N}$ and $e'$ such that $\alpha_j=\nu\,e'.\overline{g}\langle e'\rangle$, $e'\varphi(A_j)=_EN\sigma$ and $j
**Example 3** (Reasoning with correspondence). *Consider the annotated Handshake protocol (Example 2). The first correspondence property, namely $$\overline{completedC}\langle{\ensuremath{\mathsf{pair}(x,y)}}\rangle \rightsquigarrow\allowbreak
\overline{startedS}\langle{\ensuremath{\mathsf{pair}(x,y)}}\rangle$$ is not valid. This can be observed by constructing an execution path in which the events $completedC$ and $startedS$ both occur, but with different arguments. To aid readability, we apply some of the substitutions denoted by ‘let’ occurring in $P$, and we reuse the context $C[\_]\triangleq\nu\,sk_{{\ensuremath{\mathcal{S}}}}.\nu\,sk_{{\ensuremath{\mathcal{C}}}}.\nu\,s.(\_ \mid {!P_{{\ensuremath{\mathcal{S}}}}} \mid \linebreak {!P_{{\ensuremath{\mathcal{C}}}}})$ from Example 1. The execution path is shown in Figures 2 & 3. Intuitively, the following sequence of actions takes place:*
1. *${\ensuremath{\mathcal{C}}}$’s public key ${\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}}$ is output, using the handle $y\_pk$. This public key is now available to the environment.*
2. *The environment provides the public key ${\ensuremath{\mathsf{pk}(sk_M)}}$ as ${\ensuremath{\mathcal{S}}}$’s interlocutor.*
3. *The event $\overline{startedS}\langle{\ensuremath{\mathsf{pair}(x\_pk,k)}}\rangle$ is executed with the environment’s public key ${\ensuremath{\mathsf{pk}(sk_M)}}$ assigned to parameter $x\_pk$.*
4. *${\ensuremath{\mathcal{S}}}$ outputs as $x$ the value $k$ signed by ${\ensuremath{\mathcal{S}}}$ and encrypted for the environment.*
5. *The environment gives to ${\ensuremath{\mathcal{C}}}$ the value $k$ signed by ${\ensuremath{\mathcal{S}}}$, this time encrypted for ${\ensuremath{\mathcal{C}}}$.*
6. *The process is rewritten using structural equivalence (essentially several occurrences of the rules ${\ensuremath{\mbox{\sc Subst}}}$ and ${\ensuremath{\mbox{\sc Rewrite}}}$).*
7. *The event $\overline{startedC}\langle y\_k\rangle$ is executed with $k$ as parameter $y\_k$.*
8. *The conditional is trivially evaluated and ${\ensuremath{\mathcal{C}}}$ outputs the value ${\ensuremath{\mathsf{senc}({{{{k}}}},{\ensuremath{\mathsf{pair}(tag,s)}})}}$ as $z$.*
9. *Finally, the event $\overline{completedC}\langle{\ensuremath{\mathsf{pair}(pk_{{\ensuremath{\mathcal{C}}}},y\_k)}}\rangle$ is executed with respect to the value $k$ assigned to parameter $y\_k$.*
*Thus, the conditions of Definition 5 are violated; we have $\overline{completedC}\langle e_3\rangle$, and although we do have a previous $\overline{startedS}\langle e_1\rangle$, it does not have the same arguments as can be observed from the frame.*
Execution of Handshake protocol, part II (labelled semantics)
### Injective correspondence properties
The definition of correspondence we have just discussed is insufficient to capture injective relationships between events; making it unsuitable for certain authentication properties. For example, consider a financial transaction in which a server requests payment from a client; the server should only complete a transaction, when that transaction was started by the client. (If this were not the case, the client could be charged for several transactions, even if the client only started one.) The situation is similar for access control and other scenarios. Further discussion can be found in (**Lowe97?**).
**Example 4**. *Consider the process $$\overline{start}\langle n\rangle.\overline{complete}\langle n\rangle.\overline{complete}\langle n\rangle$$ which satisfies the correspondence $\overline{complete}\langle x\rangle \rightsquigarrow\overline{start}\langle x\rangle$, but permits two occurrences of the event $\overline{complete}\langle n\rangle$ to be matched by a single event $\overline{start}\langle n\rangle$.*
Injective correspondence properties are denoted by the presence of the keyword $\mathsf{inj}$.
**Definition 6** (Injective correspondence property). *An *injective correspondence property* is a formula of the form: $\overline{f}\langle M\rangle \rightsquigarrow \mathsf{inj}\; \overline{g}\langle N\rangle$.*
Informally, it asserts that if a process executes event $f$, then there is a distinct earlier occurrence of the event $g$ and any relationship between the event parameters is satisfied. It follows immediately that the number of occurrences of the label $\nu\,e.\overline{g}\langle e\rangle$ is greater than, or equal to, the number of occurrences of $\nu\,e'.\overline{f}\langle e'\rangle$ for some event variables $e$, $e'$.
**Definition 7** (Validity of injective correspondence property). *Let $E$ be an equational theory, and $A_0$ an extended process. We say that $A_0$ *satisfies the injective correspondence property* $\overline{f}\langle M\rangle \rightsquigarrow \mathsf{inj}\;\overline{g}\langle N\rangle$ if for all execution paths $$A_0 \to^*\xrightarrow{\alpha_1}\to^*
A_1 \to^*\xrightarrow{\alpha_2}\to^*
\dots \to^*\xrightarrow{\alpha_n}\to^* A_n,$$ there exists a partial injective function $h:\{1,\ldots,n\} \xrightarrow{}\{1,\ldots,n\}$ such that for all $i\in\{1,\ldots,n\}$, substitution $\sigma$ and variable $e$ such that $\alpha_i=\nu\,e.\overline{f}\langle e\rangle$ and $e\varphi(A_i)=_EM\sigma$, then the following conditions are satisfied: (1) $h(i)$ is defined; (2) $\alpha_{h(i)}=\nu\,e'.\overline{g}\langle e'\rangle$ for some $e'$ such that $e'\varphi(A_{h(i)})=_EN\sigma$; and, (3) $h(i)
Returning to our Handshake protocol, observe that authentication of ${\ensuremath{\mathcal{C}}}$ is injective; that is, if ${\ensuremath{\mathcal{S}}}$ reaches the end of the protocol with the belief that she has session key $k$ with interlocutor ${\ensuremath{\mathcal{C}}}$, then she has indeed done so; and moreover, ${\ensuremath{\mathcal{C}}}$ has done so in this session (that is, there is an injective relationship).
**Example 5** (Reasoning with correspondence, revisited). *Consider the annotated Hand-shake protocol and observe the injective correspondence property $$\overline{completedS}\langle{\ensuremath{\mathsf{pair}(y,{\ensuremath{\mathsf{true}}})}}\rangle \allowbreak\rightsquigarrow \mathsf{inj}\;\overline{startedC}\langle y\rangle$$ is valid. To show this conclusively, one has to consider all the possible execution paths, and show that for each of them, whenever there is a label $\nu\,e.\overline{completedS}\langle e\rangle$ associated with the substitution $\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}(M,{\ensuremath{\mathsf{true}}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $e$}}\}$, then there is an earlier label $\nu\,e'.\overline{startedC}\langle e'\rangle$ and substitution $\{\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $e'$}}\}$; such that no two occurrences of the event $completedS$ are mapped to the same event $startedC$. ProVerif can be used to prove this result.*
## Fixing the Handshake protocol
As mentioned in Section 1, the man-in-the-middle attack that is illustrated in Figure 1 can be avoided by putting the participants’ public keys along with $k$ in the signature formed by ${\ensuremath{\mathcal{S}}}$. The resulting process looks like this: $$\begin{array}{llcl}
& P &\triangleq& \nu\,sk_{{\ensuremath{\mathcal{S}}}}.\nu\,sk_{{\ensuremath{\mathcal{C}}}}.\nu\,s.\\
&&& \textnormal{let } pk_{S}={\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{S}}}})}} \textnormal{ in } \textnormal{let } pk_{C}={\ensuremath{\mathsf{pk}(sk_{{\ensuremath{\mathcal{C}}}})}} \textnormal{ in }\\
&&& (\overline{c}\langle pk_{S}\rangle \mid \overline{c}\langle pk_{C}\rangle \mid {!P_{{\ensuremath{\mathcal{S}}}}} \mid {!P_{{\ensuremath{\mathcal{C}}}}})\\
\\
& P_{{\ensuremath{\mathcal{S}}}} &\triangleq& c(x\_pk).\nu\,k.\overline{c}\langle{\ensuremath{\mathsf{aenc}(x\_pk,{\ensuremath{\mathsf{sign}(sk_{{\ensuremath{\mathcal{S}}}},{\ensuremath{\mathsf{pair}(pk_{S},{\ensuremath{\mathsf{pair}(x\_pk,k)}})}})}})}}\rangle.\\
& && c(z).\textnormal{if } {\ensuremath{\mathsf{fst}({\ensuremath{\mathsf{sdec}(k,z)}})}}=tag \textnormal{ then }Q\\
\\
& P_{{\ensuremath{\mathcal{C}}}} &\triangleq& c(y).\textnormal{let } y'={\ensuremath{\mathsf{adec}(sk_{{\ensuremath{\mathcal{C}}}},y)}} \textnormal{ in }\textnormal{let } y''={\ensuremath{\mathsf{snd}({\ensuremath{\mathsf{getmsg}(y')}})}} \textnormal{ in }\\
& && \textnormal{if } {\ensuremath{\mathsf{fst}(y'')}}=pk_{C} \textnormal{ then }\\
& && \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_{S},y')}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
& && \overline{c}\langle{\ensuremath{\mathsf{senc}({\ensuremath{\mathsf{snd}(y'')}},{\ensuremath{\mathsf{pair}(tag,s)}})}}\rangle\\
\end{array}$$ As an exercise the reader may like to identify exactly which step of the attack of Figure 1 fails for the revised protocol.
We remark that the injective correspondence property $\overline{completedC}\langle{\ensuremath{\mathsf{pair}(x,y)}}\rangle \rightsquigarrow \mathsf{inj}\;\overline{startedS}\langle\allowbreak{\ensuremath{\mathsf{pair}(x,y)}}\rangle$ does not hold, because the client cannot ascertain as to whether the initial message he receives is fresh. However, this does not affect the security of the protocol’s high-level objective which is to enable the client ${\ensuremath{\mathcal{C}}}$ to share the secret $s$ with the server ${\ensuremath{\mathcal{S}}}$.
# Equivalence properties
The notion of indistinguishability is a powerful concept which allows us to reason about complex properties that cannot be expressed as secrecy or correspondence properties. Intuitively, two processes are said to be equivalent if an observer has no way to tell them apart. The processes may be handling different data, and internally performing quite different computations, but they look the same to an external observer. This notion allows us to define strong notions of secrecy and privacy.
A natural starting point for defining observational equivalence says that processes $A$ and $B$ are equivalent if they can output on the same channels, no matter what the context they are placed inside. Formally we write $A\Downarrow c$ when $A$ can evolve to a process that can send a message on channel $c$, that is, when $A\to^*C[\overline{c}\langle M\rangle.P]$ for some term $M$, process $P$ and evaluation context $C[\_]$ that does not bind $c$. This then allows us to characterise equivalence as follows: for all contexts $C[\_]$, we have $C[A]\Downarrow c$ if and only if $C[B]\Downarrow c$. One might think that this condition is too weak – it should say that $C[A]$ and $C[B]$ output the *same term* on the channel $c$ – but that is not necessary, since if two processes output different terms then a context that inspects the output could be constructed to distinguish them.
## Observational equivalence
In practice, the definition motivated above is hard to compute, and instead a stronger definition is often used. The stronger definition, called observational equivalence, has a recursive character. Roughly speaking, processes $A$ and $B$ are said to be observationally equivalent if they can output on the same channel for all contexts they are placed inside (as before); and also, for all contexts and every step made by $A$ inside the context, there exists a step that $B$ can make (inside the context), such that the resulting pair of processes are observationally equivalent (and vice-versa). We avoid the circularity of this informal characterisation, and define it rigorously as follows.
**Definition 1** (Observational equivalence). *Observational equivalence ($\approx$) is the largest symmetric relation $\mathcal{R}$ between closed extended processes with the same domain such that $A \mathrel{\mathcal{R}}B$ implies:*
1. * if $A\Downarrow c$, then $B\Downarrow c$;*
2. * if $A \xrightarrow{}^* A'$, then $B \xrightarrow{}^* B'$ and $A' \mathrel{\mathcal{R}}B'$ for some $B'$;*
3. * $C[A] \mathrel{\mathcal{R}}C[B]$ for all closing evaluation contexts $C[\_]$.*
Note that we insist that $\mathrel{\mathcal{R}}$ is symmetric, so we can state the Conditions 1 and 2 in a non-symmetric way (the symmetric part is guaranteed by the symmetry of $\mathrel{\mathcal{R}}$). Note also the added condition that the two processes have the same domain; this captures the ‘observable’ difference between processes in which the value of a variable appearing in one frame, is not defined in the other.
A classical example illustrates the difference between observational equivalence and the notion of equivalence mentioned at the start of Section 1 (sometimes called *trace equivalence*). Intuitively, trace equivalence checks that the outputs on the traces allowed by $C[A]$ are the same as those of $C[B]$, but it does not enforce that *decisions* inside $A$ and $B$ occur at the same point. Let us use the notation $A_1+A_2$ to mean the non-deterministic choice of $A_1$ or $A_2$. This is expressible in applied pi, as follows: $$A_1+A_2 \triangleq\nu\,a . (\overline{a}\langle\textrm{left}\rangle\mid\overline{a}\langle\textrm{right}\rangle\mid a(x).\textnormal{if } x=\textrm{left} \textnormal{ then } A_1 \textnormal{ else }A_2)$$ Here, left and right are names, and a scheduler chooses which message output $\overline{a}\langle\textrm{left}\rangle$ or $\overline{a}\langle\textrm{right}\rangle$ to perform, and hence whether $A_1$ or $A_2$ runs. Note that only one of $A_1$ and $A_2$ runs, in contrast with $A_1\mid
A_2$; moreover, only one of the outputs $\overline{a}\langle\textrm{left}\rangle$, $\overline{a}\langle\textrm{right}\rangle$ may occur, because there is only one input $a(x)$, and $a$ is restricted. Now consider the processes $A \triangleq\overline{d}\langle b_1\rangle.\overline{d}\langle b_2\rangle+\overline{d}\langle b_1\rangle.\overline{d}\langle b_3\rangle$ and $B \triangleq\overline{d}\langle b_1\rangle.(\overline{d}\langle b_2\rangle+\overline{d}\langle b_3\rangle)$. One can see that they are trace equivalent, by experimenting with a variety of contexts. However, in $A$ the decision between outputting $b_2$ or $b_3$ is taken earlier than it is in $B$. Observational equivalence captures this as an observable difference. Consider the context $C[\_]=\_\mid d(y)$. Although $C[A]$ and $C[B]$ have the same output capabilities, $C[B]$ can evolve to a process (namely $\overline{d}\langle b_2\rangle+\overline{d}\langle b_3\rangle$) which is not equivalent to any process that $C[A]$ can evolve to (namely, the processes $\overline{d}\langle b_2\rangle$ or $\overline{d}\langle b_3\rangle$).
## Labelled bisimilarity
The quantification over contexts makes the definition of observational equivalence hard to use in practice. Therefore, labelled bisimilarity is introduced, which is more suitable for both manual and automatic reasoning. Labelled bisimilarity relies on an equivalence relation between frames, called static equivalence, which we define first. Intuitively, two frames are statically equivalent if no ‘test’ $M=N$ can tell them apart, where $M$ and $N$ have variables that are substituted from the frame. Formally:
**Definition 2** (Static equivalence). *Two closed frames $\varphi$ and $\psi$ are statically equivalent, denoted $\varphi \approx_s \psi$, if $\textnormal{dom}(\varphi) = \textnormal{dom}(\psi)$ and there exists a set of names $\tilde n$ and substitutions $\sigma,\tau$ such that $\varphi\equiv \nu\,\tilde{n}.\sigma$ and $\psi
\equiv \nu\,\tilde{n}.\tau$ and for all terms $M,N$ such that $\tilde{n} \cap (\textnormal{fn}(M)
\cup \textnormal{fn}(N)) = \emptyset$, we have $M\sigma =_EN\sigma$ holds if and only if $M\tau =_EN\tau$ holds. We say two closed extended processes $A,B$ are statically equivalent, and write $A \approx_s
B$, when their frames are statically equivalent; that is, $\varphi(A) \approx_s
\varphi(B)$.*
The relation is called *static* equivalence because it only examines the current state of the processes (as represented by their frames), and not the processes’ dynamic behaviour (that is, the ways in which they may execute in the future). Thus, two processes are statically equivalent if they cannot be distinguished on the basis of their output so far. Static equivalence captures the static part of observational equivalence. More precisely, observational equivalence and static equivalence coincide on frames. Static equivalence can straightforwardly be shown to be closed under structural equivalence, internal reduction and application of closing evaluation contexts.
**Example 1** (Static equivalence). *In the following examples we assume the signature $\Sigma_S = \{\mathsf{hash},\mathsf{fst},\mathsf{snd},\mathsf{pair}\}$ and the smallest equational theory $E_S$ satisfying the equations ${\ensuremath{\mathsf{fst}({\ensuremath{\mathsf{pair}(x,y)}})}}=x$, ${\ensuremath{\mathsf{snd}({\ensuremath{\mathsf{pair}(x,y)}})}}=y$ over all variables $x,y$, where as expected $\mathsf{hash}$, $\mathsf{fst}$, $\mathsf{snd}$ are unary functions and $\mathsf{pair}$ is a binary function.*
- *$\nu\,m.\{\textnormal{\raisebox{2pt}{\footnotesize $m$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\} \approx_s
\nu\,n.\{\textnormal{\raisebox{2pt}{\footnotesize $n$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$; trivial, since they are structurally equivalent.*
- *$\nu\,m.\{\textnormal{\raisebox{2pt}{\footnotesize $m$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\} \approx_s
\nu\,n.\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{hash}(n)}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$.*
- *$\{\textnormal{\raisebox{2pt}{\footnotesize $m$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\} \not\approx_s \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{hash}(m)}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$. The first one satisfies $x=m$ but the second one does not.*
- *$\nu\,k.\{\textnormal{\raisebox{2pt}{\footnotesize $k$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid\nu\,s.\{\textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\approx_s\nu\,k.(\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{hash}({\ensuremath{\mathsf{pair}(a,k)}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{hash}({\ensuremath{\mathsf{pair}(b,k)}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}$.*
- *$\nu\,k.\{\textnormal{\raisebox{2pt}{\footnotesize $k$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid\nu\,s.\{\textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\not\approx_s\nu\,k.(\{\textnormal{\raisebox{2pt}{\footnotesize $k$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{hash}(k)}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\})$, since the second one satisfies ${\ensuremath{\mathsf{hash}(x)}}=y$ and the first one does not.*
- *$\nu\,s.\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}(s,s)}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\not\approx_s\nu\,s.\{\textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$, since the first one satisfies ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{fst}(x)}},{\ensuremath{\mathsf{snd}(x)}})}}=x$ but the second one does not.*
As mentioned, static equivalence captures the static part of observational equivalence. The following definition of labelled bisimilarity captures the dynamic part.
**Definition 3** (Labelled bisimilarity). *Labelled bisimilarity ($\approx_l$) is the largest symmetric relation $\mathcal{R}$ on closed extended processes such that $A \mathrel{\mathcal{R}}B$ implies:*
1. *$A \approx_s B$;*
2. *if $A \xrightarrow{}A'$, then $B \xrightarrow{}^* B'$ and $A' \mathrel{\mathcal{R}}B'$ for some $B'$;*
3. *if $A \xrightarrow{\alpha} A'$ and $\textnormal{fv}(\alpha) \subseteq \textnormal{dom}(A)$ and $\textnormal{bn}(\alpha) \cap \textnormal{fn}(B) = \emptyset$; then $B\xrightarrow{}^*\xrightarrow{\alpha}\xrightarrow{}^* B'$ and $A' \mathrel{\mathcal{R}}B'$ for some $B'$.*
Clauses 2 and 3 of this definition correspond to classical notions of bisimilarity (**Milner99?**). Notice the use of the “largest relation” construction, to allow us to insist that the processes $A'$ and $B'$ are again within the relation. Clause 1 asserts static equivalence at each step of the bisimulation.
Let us now consider the side condition of Clause 3. Recall that there are three possibilities for $\alpha$, namely $c(M)$, $\overline{c}\langle u\rangle$, and $\nu u.\overline{c}\langle u\rangle$, where $u$ is either a channel name or a variable of base type. In Clause 3, $\alpha$ can have free variables (in the cases $c(M)$ and $\overline{c}\langle u\rangle$), but any such variables must be defined by the frame of $A$ (and since $A \approx_s B$, also by the frame of $B$). Hence the condition $\textnormal{fv}(\alpha) \subseteq \textnormal{dom}(A)$. The label $\alpha$ can also have bound names (in the case $\nu d.\overline{c}\langle d\rangle$, where $d$ is a channel name), in which case the transition $A\xrightarrow{\alpha}A'$ has the effect of removing the restriction on a bound channel name. That channel must not occur free in $B$, to avoid confusing the restricted name with the global name; hence the condition $\textnormal{bn}(\alpha) \cap \textnormal{fn}(B) = \emptyset$. To see this in more detail, consider $A,B$ such that $A\approx_l B$, and suppose $a\in\textnormal{fn}(B) \backslash \textnormal{fn}(A)$. (For example, $A$ is $0$ and $B$ is $\textnormal{if } a=b \textnormal{ then }{\overline{c}\langle a\rangle}$.) Intuitively, we would like $A\mid(\nu a.\overline{c}\langle a\rangle)\approx_l B\mid(\nu a.\overline{c}\langle a\rangle)$. But to achieve that, we need the side condition, for otherwise the transition $A\mid(\nu a.\overline{c}\langle a\rangle) \xrightarrow{\nu a.\overline{c}\langle a\rangle}A$ would have to be matched on the right hand side by $B \mid (\nu a.\overline{c}\langle a\rangle) \xrightarrow{\nu a.\overline{c}\langle a\rangle} B$, which is false.
#### Working with labelled bisimilarity.
To show labelled bisimilarity of $A$ and $B$, it is necessary to find a symmetric relation $\mathrel{\mathcal{R}}$ that satisfies the conditions contained in Definition 3, such that $A\mathrel{\mathcal{R}}B$. Note that the $\mathrel{\mathcal{R}}$ we find is not required to be the largest one. That is because the set of relations that satisfies the conditions contained in Definition 3 is closed under union. Therefore, the largest one is the union of them all. *Any* relation satisfying the conditions of Definition 3 can serve as a witness to show that two processes are labelled bisimilar. Note also that, although labelled bisimilarity is easily seen to be an equivalence relation, the relation $\mathrel{\mathcal{R}}$ is merely required to be symmetric.
**Example 2** (Labelled bisimilarity). *We prove that for all closed processes $P_1,P_2,C$ and names $\tilde
n$ such that $c\in\tilde n$, we have $\nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C\approx_l
\nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C$. Intuitively, the equivalence holds because the only choice that the left side has, which the right side does not, is an internal reduction (private channel communication). Let $A\mathrel{\mathcal{R}}B$ hold if there exists a closed extended process $C'$ such that one of the following holds:*
- *$A\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $B\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$; or*
- *$B\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $A\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$; or*
- *$A\equiv B$.*
*One may show that $\mathrel{\mathcal{R}}$ satisfies the conditions contained in Definition 3. First, $\mathrel{\mathcal{R}}$ is easily seen to be symmetric. For the next part, suppose $A\mathrel{\mathcal{R}}B$.*
1. *We show $A\approx_sB$. There are three cases.*
1. *$A\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $B\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$. Since $\nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\approx_s\nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})$, we have $A\approx_s B$.*
2. *$B\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $A\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$. In this case, a similar argument applies.*
3. *$A\equiv B$ and hence we trivially have $A\approx_s B$.*
2. *Now suppose $A\to A'$. There are again three cases to consider.*
1. *$A\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $B\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$. If $A'\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$, then let $B'\triangleq B$. Otherwise, $A'\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C''$ for some $C''$, in which case let $B'\triangleq\nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C''$.*
2. *$A\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$ and $B\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid
C'$. Since $B\to A$, it follows that $B\to^*A'$, so let $B' \triangleq A'$.*
3. *$A\equiv B$ and hence the result follows trivially by $B' \triangleq A'$.*
*In all cases we have $A' \mathrel{\mathcal{R}}B'$, as required.*
3. *Now suppose $A\xrightarrow{\alpha} A'$. Again we have three cases:*
1. *$A\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C'$ and $B\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$. Since only the $C'$ part is able to make a labelled transition, $A'\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid C''$ for some $C''$, in which case let $B'\triangleq\nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C''$, and we have $B\xrightarrow{\alpha} B'$.*
2. *$A\equiv \nu\tilde n.(P_1\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\})\mid C'$ and $B\equiv \nu\tilde n.(\overline{c}\langle a\rangle.P_1\mid c(x).P_2)\mid
C'$. Since $B\to A$, it follows that $B\to^*\xrightarrow{\alpha}A'$, so let $B' \triangleq A'$.*
3. *$A\equiv B$ and hence the result is trivial by $B' \triangleq A'$.*
*In all cases we have $A' \mathrel{\mathcal{R}}B'$, as required.*
Abadi & Fournet (**AppliedPi?**) state the following useful results, although as far as we are aware fully detailed proofs have not yet been published.
**Lemma 1**. *Given closed extended processes $A,B$ and a closing evaluation context $C[\_]{}$, we have $A\approx_lB$ implies $C[A]\approx_l C[B]$.*
The condition stating that active substitutions are of base type (Section [sec:syntax]) is crucial to Theorem 1. Without this constraint, one would have the following counterexample: $\nu\,a.(\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid x(y).\overline{c}\langle n\rangle) \not\approx \nu\,a.\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$ (this can be seen using the closing evaluation context $C[\_] = \overline{x}\langle b\rangle\mid \_$); whereas $\nu\,a.(\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid x(y).\overline{c}\langle n\rangle) \approx_l \nu\,a.\{\textnormal{\raisebox{2pt}{\footnotesize $a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$.
## Strong secrecy
Our earlier definition of secrecy required that the secret was not obtained by the adversary. We will now use notions of equivalence to demonstrate a stronger notion of secrecy which states an adversary is unable to distinguish when the secret changes (**Abadi99?**; **CRZ07?**). Intuitively, this means the value of the secret should not effect the observable behaviour of the protocol. Strong secrecy is useful, for example, to capture the adversary’s inability to learn any partial information about the secret.
Strong secrecy is also useful to formalise ‘dictionary attacks’, also known as ‘guessing attacks’, in which the attacker tries all the possible values of the secret until he finds the right one. If a secret is chosen from a relatively small set of possible values, then such an attack might be possible; we call such a secret “weak”. Passwords are often examples of weak secrets. For example, a server which requires the user to send her password $s$, deterministically encrypted with server’s public key $pk$, that is, to send ${\ensuremath{\left\{\!\left|{s}\right|\!\right\}^{\mathsf a}_{pk}}}$, is vulnerable to guessing attacks on $s$. That is because an attacker in possession of ${\ensuremath{\left\{\!\left|{s}\right|\!\right\}^{\mathsf a}_{pk}}}$ can make a guess $s'$ of the password $s$, and check the validity of his guess by constructing ${\ensuremath{\left\{\!\left|{s'}\right|\!\right\}^{\mathsf a}_{pk}}}$ and comparing it with ${\ensuremath{\left\{\!\left|{s}\right|\!\right\}^{\mathsf a}_{pk}}}$. Suppose instead the server requires the user to include a random nonce in the encryption, that is, to send ${\ensuremath{\left\{\!\left|{{\ensuremath{\langle{s},{r}\rangle}}}\right|\!\right\}^{\mathsf a}_{pk}}}$, where $r$ is a nonce chosen from a large set. In that case the system is not vulnerable to guessing attacks.
This may be formalised by the following definitions (**baudet-ccs2005?**; **DelauneKremerRyan:compositionofpassword?**).
**Definition 4**. *Let $\varphi \equiv \nu{n}. \varphi'$ be a frame. We say that $\varphi$ is *resistant to guessing attacks* against ${n}$ if, and only if, $\nu {n}. (\varphi' \mid
\{\textnormal{\raisebox{2pt}{\footnotesize ${n}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize ${x}$}}\}) \approx_s \nu {n}'. \nu
{n}. (\varphi' \mid \{\textnormal{\raisebox{2pt}{\footnotesize ${n}'$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize ${x}$}}\})$ where ${n}'$ is a fresh name and ${x}$ is a variable such that $x\not\in \textnormal{dom}(\varphi)$.*
The definition says that the environment cannot distinguish between a situation in which he possesses the correct value of the secret, from another one in which he has some random value instead. This definition can be extended to the more general case.
**Definition 5** (Guessing attacks). *Let $A$ be a process and ${n} \in \textnormal{bn}(A)$. We say that $A$ is *resistant to guessing attacks* against ${n}$ if, for every process $B$ such that $A (\to^*\xrightarrow{\alpha}\to^*)^* B$, then we have that $\varphi(B)$ is resistant to guessing attacks against ${n}$.*
**Example 3** (TPM authentication (**ChenRyan:future?**)). *We consider a protocol where a client ${\ensuremath{\mathcal{A}}}$ shares a secret $s$ with a server ${\ensuremath{\mathcal{B}}}$ (the protocol is based on the one used in the Trusted Platform Module (**TCGspec?**)). In this example, the terms $M$ and $N$ are commonly used for tuples, so it is convenient to introduce a little syntactic sugar to express them. We write $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{M_1,\dots,M_n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$ to mean ${\ensuremath{\mathsf{pair}(M_1,{\ensuremath{\mathsf{pair}(M_2,{\ensuremath{\mathsf{pair}(\dots,{\ensuremath{\mathsf{pair}(M_{n},*)}}\dots)}})}})}}$, where $*$ is any constant. We also write ${\ensuremath{\mathsf{1st}(M)}}$, ${\ensuremath{\mathsf{2nd}(M)}}$, and ${\ensuremath{\mathsf{3rd}(M)}}$ to mean $\textnormal{fst}(M)$, $\textnormal{fst}(\textnormal{snd}(M))$, and $\textnormal{fst}(\textnormal{snd}(\textnormal{snd}(M)))$ respectively. Note that $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{M_1,\ldots,M_k}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$, ${\ensuremath{\mathsf{1st}(N)}}$, etc., are not new functions, but merely syntactic sugar for combinations of functions that we already have. The protocol proceeds as follows. The client sends commands to the server, and authenticates them by supplying a MAC of the command values, keyed on $s$. An additional nonce $n$ is supplied and used in the MAC, to ensure it has high entropy. More precisely, to run the command ‘comm’, ${\ensuremath{\mathcal{A}}}$ sends the message $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm}, n, {\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$. ${\ensuremath{\mathcal{B}}}$ checks the MAC by reconstructing it, and if it is correct, sends the response ‘resp’. This protocol may be modelled by the following process $P$, where we assume the signature $\Sigma_T = \Sigma_S \cup \{{\sf mac}\}$ and equational theory $E_S$ (recall that $\Sigma_S$ and $E_S$ were defined in Example 1, and note that binary function ${\sf mac}$ has no equations). $$\begin{array}{llcl}
& P &\triangleq& \nu\,s. ( {!P_A} \mid {!P_B})\\
\\
& P_A &\triangleq& \nu\,n. \overline{c}\langle\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},\, n,\, {\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}\rangle\\
\\
& P_B &\triangleq& c(x). \textnormal{if } {\ensuremath{\mathsf{3rd}(x)}}={\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{{\ensuremath{\mathsf{1st}(x)}},{\ensuremath{\mathsf{2nd}(x)}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}} \textnormal{ then }\overline{c}\langle\text{resp}\rangle
\end{array}$$ $P$ is vulnerable to guessing attacks on $s$. To see this, we consider the transition $$P\xrightarrow{\nu x.\overline{c}\langle x\rangle} \nu s.(\nu n.\{\textnormal{\raisebox{2pt}{\footnotesize $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},\, n,\, {\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\} \mid {!P_A} \mid {!P_B})$$ The frame of this latter process is vulnerable to guessing attacks on $s$, since we have $$\begin{array}{l}
\nu s.\nu n.(\{\textnormal{\raisebox{2pt}{\footnotesize $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},\, n,\, {\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid \{\textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\})\\
\qquad{}\not\approx_s
\nu s'.\nu s.\nu n.(\{\textnormal{\raisebox{2pt}{\footnotesize $\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},\, n,\, {\ensuremath{\mathsf{mac}(s,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{\text{comm},n}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}\mid \{\textnormal{\raisebox{2pt}{\footnotesize $s'$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\})
\end{array}$$ as witnessed by the test $${\ensuremath{\mathsf{3rd}(x)}} ={\ensuremath{\mathsf{mac}(z,\mbox{$(\mkern-2.8mu\rule[-.47ex]{.08ex}{2.10ex}\mkern 3mu$}{{\ensuremath{\mathsf{1st}(x)}},{\ensuremath{\mathsf{2nd}(x)}}}\mbox{$\mkern 3mu\rule[-.47ex]{.08ex}{2.1ex}\mkern-2.5mu)$})}}.$$*
#### A comparison of two views of secrecy.
The reachability-based secrecy introduced in Section [sec:secrecy] requires that the adversary should never learn secret values; the equivalence-based (strong) secrecy introduced in this section states that two executions of a protocol are indistinguishable regardless of the chosen secret values. The formulation of strong secrecy offers a higher degree of security, but reachability-based secrecy has been more widely studied resulting in more automated support. For further discussion on the relationship between these two styles of secrecy the reader is referred to (**CRZ07?**; **Abadi99?**), see also Blanchet for a more generic formalisation of strong secrecy (**Blanchet04?**).
## Vote privacy for electronic voting
Electronic voting systems are being introduced, or trialled, in several countries to provide more efficient voting procedures with an increased level of security. The applied pi calculus can be used to formalise the properties which an electronic voting scheme should satisfy (**SRK10?**; **SRKK10?**; **DKR09?**; **Backes08?**). For example, the property of vote privacy (or ballot secrecy) means that no-one (not even the election officers) can link a particular vote with the voter.
Consider the following protocol, which is a simplification of the one by Fujioka, Okamoto, and Ohta (**FujiokaOkamotoOhta92?**). We assume the signature $\Sigma_F = \{{\ensuremath{\mathsf{true}}},\mathsf{fst},\mathsf{snd},\mathsf{pk},\mathsf{getmsg},\allowbreak
\mathsf{pair},\mathsf{sign},\mathsf{checksign},\mathsf{blind},\allowbreak\mathsf{unblind}\}$, the arities of which are defined in the usual way; that is, ${\ensuremath{\mathsf{true}}}$ is a constant; $\mathsf{fst},\mathsf{snd},\mathsf{pk},\allowbreak\mathsf{getmsg}$ are unary functions; and $\mathsf{pair},\mathsf{sign},\allowbreak\mathsf{checksign},\mathsf{blind},\mathsf{unblind}$ are binary functions. The protocol (**FujiokaOkamotoOhta92?**) relies on *blind signatures*; with this cryptographic primitive, an election officer can sign a text without having seen it. The voter first blinds the text and the officer signs it. The voter can then unblind the message to recover the officer’s signature on the text. We do not need to consider how this cryptography actually works; we can encode the effect using the equation $${\ensuremath{\mathsf{unblind}(x,{\ensuremath{\mathsf{sign}(y,{\ensuremath{\mathsf{blind}(x,z)}})}})}}
= {\ensuremath{\mathsf{sign}(y,z)}}$$ which says that if one blinds a text $z$ using a blinding factor $x$, and then signs it with the private key $y$, and then unblinds it (again using $x$), then the result is the text $z$ signed by $y$ in the usual way. Blind signatures are useful in electronic voting because they allow the officer to sign a vote (thus establishing its eligibility for counting) without knowing what the vote is. The equations associated with the remaining functions in $\Sigma_F$ are defined in the usual way (see Section [sec:model]).
The protocol proceeds as follows. The voter wishing to vote for candidate $v$ creates a nonce $n$, and blinds the tuple ${\ensuremath{\langle{v},{n}\rangle}}$ using a random blinding factor $r$. She then signs this value and sends it to the election officer. The officer checks the voter’s eligibility and also checks she has not already voted. If these checks succeed, then the officer signs the blinded vote-nonce pair and sends it back to the voter. The voter can now unblind the signature, recovering the officer’s signature on the vote-nonce pair. Once all voters have obtained the officer’s signature in this way, they can anonymously submit the signed vote-nonce pair for counting. The protocol thus proceeds as follows:
c@width 1pt\> X@width 1ptc &&
&
&
&
&
&
&
&
&&
The purpose of the value $n$ is to allow the officer to count the signed vote only once. The synchronisation point, denoted $\text{synch}$, ensures that every voter receives the officer’s signature before any of them submit the unblinded value for counting. It is necessary to ensure vote privacy; without it, traffic analysis might link the voter’s signature in the first message with the anonymous submission in the third one. This protocol is inadequate for a real election, but it does satisfy the property of vote privacy.
We formalise this illustrative voting protocol in the applied pi calculus as follows. We assume a public channel $c$ for communication between the voter and the officer, and a channel $vote$ for the officer to declare the list of counted votes. $$\begin{array}{llcl}
& P &\triangleq& \nu\,sk_{1}\,\dots\, \nu\,sk_{n}.\; \nu\,sk_O.\\
&&& \textnormal{let } pk_1={\ensuremath{\mathsf{pk}(sk_{1})}} \textnormal{ in } \dots\ \textnormal{let } pk_n={\ensuremath{\mathsf{pk}(sk_{n})}} \textnormal{ in }\\
&&& \textnormal{let } pk_O={\ensuremath{\mathsf{pk}(sk_O)}} \textnormal{ in } \\
&&& (\overline{c}\langle pk_{1}\rangle \mid\dots\mid\overline{c}\langle pk_{n}\rangle \mid \overline{c}\langle pk_O\rangle \mid P_{V}\{\textnormal{\raisebox{2pt}{\footnotesize $sk_1$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_1$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\} \mid\dots \mid P_V\{\textnormal{\raisebox{2pt}{\footnotesize $sk_n$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_n$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\} \mid {!P_O} \mid S)\\
\\
& P_V &\triangleq& \nu n. \nu r.\textnormal{let } bvn={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}} \textnormal{ in }\\
&&& \overline{c}\langle{\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_V,bvn)}})}}\rangle.\\
&&& c(x). \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_O,x)}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } {\ensuremath{\mathsf{getmsg}(x)}}=bvn \textnormal{ then }\\
&&& \textit{synch.}\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,x)}}\rangle\\
\\
& P_O &\triangleq& c(y).\textnormal{if } {\ensuremath{\mathsf{checksign}({\ensuremath{\mathsf{fst}(y)}},{\ensuremath{\mathsf{snd}(y)}})}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } \mathsf{Eligible}({\ensuremath{\mathsf{fst}(y)}})={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \overline{c}\langle{\ensuremath{\mathsf{sign}(sk_O,{\ensuremath{\mathsf{getmsg}({\ensuremath{\mathsf{snd}(y)}})}})}}\rangle. \\
&&& c(w). \\
&&& \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_O,w)}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } \mathsf{NotSeen}(w)={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \overline{vote}\langle{\ensuremath{\mathsf{fst}({\ensuremath{\mathsf{getmsg}(w)}})}}\rangle
\end{array}$$ In the above process, we assume functions $\mathsf{Eligible}(x)$ and $\mathsf{NotSeen}(x)$ are available to the officer. $\mathsf{Eligible}(x)$ checks whether the voter with public key $x$ is eligible and hasn’t already voted; $\mathsf{NotSeen}(x)$ stores $x$ and returns true if it has not seen $x$ before; otherwise it returns false. The purpose of $\mathsf{NotSeen}(x)$ is to ensure that the voter can’t use the signed token twice. We also assume a subprocess $\textit{synch}$ which a voter uses to synchronise with other voters. This can be modelled by defining a process $S$ to coordinate the synchronisation. In the case of $n$ voters, the coordination process receives precisely $n$ tokens, and then sends them back. To synchronise with the other voters, a voter sends a token to this synchronisation coordinator and awaits its response. Thus, $$\begin{array}{rcl}
\text{synch}&\triangleq& \overline{syn}\langle*\rangle.syn'(o)\\
S &\triangleq& syn(x_1)\dots syn(x_n).\overline{syn'}\langle*\rangle\dots\overline{syn'}\langle*\rangle\\
\end{array}$$ where $syn,syn'$ are private channels shared between the voters and $S$, $*$ is any name and $o$ is a variable.
Now we define the property of vote privacy, and prove it. Since it should hold even if the officer is corrupt, we can suppose that the officer is part of the attacker, and we need not consider its formalisation as $P_O$ above. This means the secrecy of the officer’s key is not required for the vote privacy property, so we can treat it as a free name. Moreover, the voters’ secret keys are also not required to be kept secret in order to ensure the vote privacy property. They too can be treated as free names. (Of course, these keys *are* required to be secret for other properties.)
Consider two voters $\mathcal{A}$, $\mathcal{B}$ and two candidates $v_a$, $v_b$. Based upon (**DKR09?**), we formalise vote privacy for two voters with the assertion that the attacker (including the election officers) cannot distinguish between a situation in which $\mathcal{A}$ votes $v_a$ and $\mathcal{B}$ votes $v_b$, from another one in which $\mathcal{A}$ votes $v_b$ and $\mathcal{B}$ votes $v_a$. We will write this as the equivalence: $$\begin{gathered}
%\new{sk_{V1}}.\new{sk_{V2}}.\new{sk_O}.\Letin{pk_O}{\Pk{sk_O}}
\nu\,syn.\nu\,syn'.(
P_V\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}
\mid P_V\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}
\mid S)\\
\approx_l
\nu\,syn.\nu\,syn'.(
P_V\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}
\mid P_V\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}
\mid S)
\end{gathered}$$ To prove this equivalence, let us call the left hand side $\mbox{{\sc Lhs}}$, and the right hand side $\mbox{{\sc Rhs}}$. We need to show a relation $\mathrel{\mathcal{R}}$ satisfying the requirements of Definition 3 such that $\mbox{{\sc Lhs}}\mathrel{\mathcal{R}}\mbox{{\sc Rhs}}$. As we have seen, the idea of $\mathrel{\mathcal{R}}$ is to relate successors of $\mbox{{\sc Lhs}}$ and $\mbox{{\sc Rhs}}$ that are expected to correspond to each other in the bisimulation. As $\mbox{{\sc Lhs}}$ evolves, the corresponding evolution of $\mbox{{\sc Rhs}}$ is the one that mimics $\mathcal{A}$ moves in $\mbox{{\sc Lhs}}$ with $\mathcal{A}$ moves in $\mbox{{\sc Rhs}}$, and $\mathcal{B}$ moves in $\mbox{{\sc Lhs}}$ with $\mathcal{B}$ moves in $\mbox{{\sc Rhs}}$, up to the synchronisation. After the synchronisation, $\mathcal{A}$ moves in $\mbox{{\sc Lhs}}$ are mimicked by $\mathcal{B}$ moves in $\mbox{{\sc Rhs}}$, and $\mathcal{B}$ moves in $\mbox{{\sc Lhs}}$ are mimicked by $\mathcal{A}$ moves in $\mbox{{\sc Rhs}}$. The reason for the ‘swap’ in mimicking is to ensure that the static equivalences will hold; before the synchronisation, the output data produced by $\mathcal{A}$ on both the $\mbox{{\sc Lhs}}$ and $\mbox{{\sc Rhs}}$ are indistinguishable (and similarly for $\mathcal{B}$). Observe that the output data reveals the keys ${\ensuremath{\mathsf{pk}(sk_A)}}$, ${\ensuremath{\mathsf{pk}(sk_B)}}$ (matched by ${\ensuremath{\mathsf{pk}(sk_A)}}$, ${\ensuremath{\mathsf{pk}(sk_B)}}$) and the signed blind votes ${\ensuremath{\mathsf{sign}(sk_{A},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v_a,n)}})}})}}$, ${\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r',{\ensuremath{\mathsf{pair}(v_b,n')}})}})}}$ (matched by ${\ensuremath{\mathsf{sign}(sk_{A},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v_b,n)}})}})}}$, ${\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r',{\ensuremath{\mathsf{pair}(v_a,n')}})}})}}$) where names $n,n',r,r'$ are under restriction in both $\mbox{{\sc Lhs}}$ and $\mbox{{\sc Rhs}}$. Indistinguishability between the $\mbox{{\sc Lhs}}$ and $\mbox{{\sc Rhs}}$ with respect to the signed blind votes is due to the properties of blinding. After the synchronisation $\mathcal{A}$ will reveal $v_a$ on the $\mbox{{\sc Lhs}}$ and $v_b$ on the $\mbox{{\sc Rhs}}$ (similarly $\mathcal{B}$ will reveal $v_b$ on the $\mbox{{\sc Lhs}}$ and $v_a$ on the $\mbox{{\sc Rhs}}$). Hence after synchronisation the actions mimicked are swapped.
To define this formally, we first define some partial evolutions of $P_V$, as follows. $$\begin{array}{llcl}
& P_1 &\triangleq&
\nu n. \nu r.\\
&&& \overline{c}\langle{\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}\rangle.\\
&&& c(x). \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_O,x)}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } {\ensuremath{\mathsf{getmsg}(x)}}={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}} \textnormal{ then }\\
&&& \overline{syn}\langle*\rangle.syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,x)}}\rangle
\end{array}$$ $$\begin{array}{llcl}
& P_2 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& c(x). \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_O,x)}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } {\ensuremath{\mathsf{getmsg}(x)}}={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}} \textnormal{ then }\\
&&& \overline{syn}\langle*\rangle.syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,x)}}\rangle \big)
\end{array}$$ $$\begin{array}{llcl}
& P_3 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& \textnormal{if } {\ensuremath{\mathsf{checksign}(pk_O,m)}}={\ensuremath{\mathsf{true}}} \textnormal{ then }\\
&&& \textnormal{if } {\ensuremath{\mathsf{getmsg}(m)}}={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}} \textnormal{ then }\\
&&& \overline{syn}\langle*\rangle.syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,m)}}\rangle\big)
\end{array}$$ $$\begin{array}{llcl}
& P_4 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& \textnormal{if } {\ensuremath{\mathsf{getmsg}(m)}}={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}} \textnormal{ then }\\
&&& \overline{syn}\langle*\rangle.syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,m)}}\rangle\big)
\end{array}$$ $$\begin{array}{llcl}
& P_5 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& \overline{syn}\langle*\rangle.syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,{\ensuremath{\mathsf{sign}(sk_{O},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}\rangle\big)
\end{array}$$ $$\begin{array}{llcl}
& P_6 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& syn'(o).\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,{\ensuremath{\mathsf{sign}(sk_{O},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}\rangle\big)
\end{array}$$ $$\begin{array}{llcl}
& P_7 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& \overline{c}\langle{\ensuremath{\mathsf{unblind}(r,{\ensuremath{\mathsf{sign}(sk_{O},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}\rangle\big)
\end{array}$$ $$\begin{array}{llcl}
& P_8 &\triangleq&
\nu n. \nu r.\big( \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_V)}},{\ensuremath{\mathsf{sign}(sk_{V},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\\
&&& \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{unblind}(r,{\ensuremath{\mathsf{sign}(sk_{O},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}\big)
\end{array}$$ These are abbreviations that will be useful in our definition of the simulation relation. We define the relation $\mathrel{\mathcal{R}}$ as follows. Given closed extended processes $X$ and $Y$, $X\mathrel{\mathcal{R}}Y$ and $Y\mathrel{\mathcal{R}}X$ both hold if
- there exist integers $i,j$, variables $w,z$ and terms $M,N$ with $1\leq i,j\leq 6$ and $$\begin{array}{l}
X\equiv P_i\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}
\mid P_j\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $N$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid S_{i,j},\\
Y\equiv P_i\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}
\mid P_j\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $N$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid S_{i,j};\\
\end{array}$$ and if $i=4$ then ${\ensuremath{\mathsf{checksign}(pk_O,M)}}={\ensuremath{\mathsf{true}}}$, and if $j=4$ then ${\ensuremath{\mathsf{checksign}(pk_O,N)}}={\ensuremath{\mathsf{true}}}$; or
- there exist integers $i,j$, and variables $s,t,w,z$ with $6\leq i,j\leq 8$ and $$\begin{array}{l}
X\equiv P_i\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}
\mid P_j\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $t$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}\mid S_{i,j},\\
Y\equiv P_j\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $t$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}
\mid P_i\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}, \textnormal{\raisebox{2pt}{\footnotesize $s$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}\mid S_{i,j}.\\
\end{array}$$
Notice that the substitutions above are syntactic, and recall that in an active substitution, the variable in the domain is considered to occur free. Thus, $(A\mid\{\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\})\{\textnormal{\raisebox{2pt}{\footnotesize $x$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}=A\{\textnormal{\raisebox{2pt}{\footnotesize $x$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid\{\textnormal{\raisebox{2pt}{\footnotesize $M\{\textnormal{\raisebox{2pt}{\footnotesize $x$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $x$}}\}$; that is, the domain variable changed from $y$ to $x$.
In the definition of $\mathrel{\mathcal{R}}$, $S_{i,j}$ is whatever part of $S$ is left to execute. More precisely, $$S_{i,j}\triangleq\left\{\begin{array}{ll}
syn(x)syn(x).\overline{syn}\langle*\rangle\overline{syn}\langle*\rangle
&\text{if $i,j<6$}\\
syn(x).\overline{syn}\langle*\rangle\overline{syn}\langle*\rangle
&\text{if $i=6,j<6$ or $i<6,j=6$}\\
\overline{syn}\langle*\rangle\overline{syn}\langle*\rangle
&\text{if $i,j=6$}\\
\overline{syn}\langle*\rangle
&\text{if $i=6,j=7$ or $i=7,j=6$}\\
0
&\text{if $i,j\ge7$}\\
\end{array}\right.$$ We present a proof sketch that $\mathrel{\mathcal{R}}$ satisfies the requirements of Definition 3.
Static equivalence.
Consider, for example: $$\begin{gathered}
P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}\\
\mathrel{\mathcal{R}}\; P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}})\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}
\end{gathered}$$ The frame of the process on the left is $\nu n. \nu r. \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{B})}},{\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v_b,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\}$ while the one on the right is $\nu n. \nu r. \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{B})}},{\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v_a,n)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\}$. These differ only by the subterm $v_b$ on the left ($v_a$ on the right). Static equivalence holds because of the blinding. Consider $$\begin{gathered}
P_7\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid P_8\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $t$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}\mid S_{7,8}\\
\mathrel{\mathcal{R}}\; P_7\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid P_8\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $t$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $u$}}\}\mid S_{7,8}
\end{gathered}$$ The frame of the process on the left is structurally equivalent to $$\begin{array}{l}
\nu n_1.\nu r_1. \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{A})}},{\ensuremath{\mathsf{sign}(sk_{A},{\ensuremath{\mathsf{blind}(r_1,{\ensuremath{\mathsf{pair}(v_a,n_1)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $w$}}\}\mid{}\\
\nu n_2.\nu r_2.\big(\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{B})}},{\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r_2,{\ensuremath{\mathsf{pair}(v_b,n_2)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\}\mid{}\\\qquad\qquad
\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{unblind}(r_2,{\ensuremath{\mathsf{sign}(sk_O,{\ensuremath{\mathsf{blind}(r_2,{\ensuremath{\mathsf{pair}(v_b,n_2)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $t$}}\}
\big)
\end{array}$$ while the frame on the right is structurally equivalent to $$\begin{array}{l}
\nu n_1.\nu r_1. \{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{B})}},{\ensuremath{\mathsf{sign}(sk_{B},{\ensuremath{\mathsf{blind}(r_1,{\ensuremath{\mathsf{pair}(v_a,n_1)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $z$}}\}\mid{}\\
\nu n_2.\nu r_2.\big(\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{pair}({\ensuremath{\mathsf{pk}(sk_{A})}},{\ensuremath{\mathsf{sign}(sk_{A},{\ensuremath{\mathsf{blind}(r_2,{\ensuremath{\mathsf{pair}(v_b,n_2)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $w$}}\}\mid{}\\\qquad\qquad
\{\textnormal{\raisebox{2pt}{\footnotesize ${\ensuremath{\mathsf{unblind}(r_2,{\ensuremath{\mathsf{sign}(sk_O,{\ensuremath{\mathsf{blind}(r_2,{\ensuremath{\mathsf{pair}(v_b,n_2)}})}})}})}}$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $t$}}\}
\big)
\end{array}$$ These frames are statically equivalent.
Unlabelled transitions.
Suppose, for example, $A\xrightarrow{}A'$ and $$\begin{array}{rcl}
A &\equiv & P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid P_4\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $N$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid S_{3,4}\\
A'&\equiv & P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid P_5\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{3,5}
\end{array}$$ Then, by $\mathrel{\mathcal{R}}$, $$\begin{array}{rcl}
B &\equiv &P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}})\mid P_4\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $N$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}})\mid S_{3,4}\\
\end{array}$$ and ${\ensuremath{\mathsf{checksign}(pk_O,N)}}={\ensuremath{\mathsf{true}}}$. Since the transition $A\to A'$ was possible, we have ${\ensuremath{\mathsf{getmsg}(N)}}\linebreak={\ensuremath{\mathsf{blind}(r,{\ensuremath{\mathsf{pair}(v_b,n)}})}}$, where $r,n$ are the values used inside the occurrence of $P_4$. It follows that we have $N={\ensuremath{\mathsf{sign}(sk_O,{\ensuremath{\mathsf{getmsg}({\ensuremath{\mathsf{snd}(z)}})}})}}$. Therefore, the transition $B\to B'$ is possible, where $$\begin{array}{rcl}
B'&\triangleq& P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $M$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid P_5\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{3,5},
\end{array}$$ and we have $A'\mathrel{\mathcal{R}}B'$.
Labelled transitions.
Suppose, for example, $A\xrightarrow{\nu
w.\overline{c}\langle w\rangle} A'$ and $$\begin{array}{rcl}
A &\equiv & P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}\\
A'&\equiv & P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}, \textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{2,2}
\end{array}$$ Then, by $\mathrel{\mathcal{R}}$, $$\begin{array}{rcl}
B &\equiv &P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}
\end{array}$$ and so we set $$\begin{array}{rcl}
B'&\triangleq&P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $w$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{2,2}.
\end{array}$$ We have $A'\mathrel{\mathcal{R}}B'$.
Suppose, for example, $A\xrightarrow{c(T)}A'$ and $$\begin{array}{rcl}
A &\equiv & P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}\\
A'&\equiv & P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $T$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid S_{1,3}
\end{array}$$ Then, by $\mathrel{\mathcal{R}}$, $$\begin{array}{rcl}
B &\equiv & P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_2\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}}\}\mid S_{1,2}\\
\end{array}$$ and so we set $$\begin{array}{rcl}
B'&\triangleq& P_1\{\textnormal{\raisebox{2pt}{\footnotesize $sk_A$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_b$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}}\}\mid P_3\{\textnormal{\raisebox{2pt}{\footnotesize $sk_B$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $sk_V$}},\textnormal{\raisebox{2pt}{\footnotesize $v_a$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $v$}},\textnormal{\raisebox{2pt}{\footnotesize $z$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $y$}},\textnormal{\raisebox{2pt}{\footnotesize $T$}}/\textnormal{\raisebox{-1.5pt}{\footnotesize $m$}}\}\mid S_{1,3}
\end{array}$$ We again have $A'\mathrel{\mathcal{R}}B'$.
This concludes our proof sketch of the labelled bisimilarity that expresses the privacy property for two voters. To complete this proof formally, once would have to consider all the cases involved in showing that $\mathrel R$ satisfies the requirements of Definition 3.
# Outlook
This chapter studies the applied pi calculus and demonstrates its applicability for analysing secrecy, correspondence and observational equivalence properties in the context of security protocols. In this section we briefly refer to some on-going research about the calculus. Our discussion is neither exhaustive nor complete.
The ability to reason with security properties is largely dependent on being able to reason with the equational theory. Abadi & Cortier (**Abadi04b?**) have studied decidability of secrecy and static equivalence for a large class of equational theories in the presence of a passive adversary. Subsequent work by Baudet, Cortier & Delaune (**Baudet09?**) and Ciobâcă, Delaune & Kremer (**Ciobaca09?**) introduces automated tools for analysing static equivalence with respect to convergent equational theories.
For an active adversary, reachability properties, in particular secrecy, have been studied in (**Blanchet2001?**; **Abadi2002?**) with updated and extended versions (**BlanchetJACM05?**; **Blanchet2010?**). Strong secrecy has been considered in (**Blanchet04?**). Correspondence properties have been presented in the context of authenticity (**Blanchet2002?**), and subsequently extended upon and revised in (**BlanchetJCS09?**). Proofs of observational equivalence have been studied with respect to processes that differ only by the choice of the terms that they contain, using the notion of uniformity (**Blanchet05?**; **Blanchet07b?**). But this notion of uniformity is often too strict; for example, the voting process discussed in this chapter does not satisfy it. A practical approach to overcoming the problem is introduced (**DRS08?**), (**BenSmythThesis?**) (the technique defined by (**BenSmythThesis?**) has been implemented as a tool called ProSwapper (**Smyth10:ObsA?**)) and subsequently used (**Backes08?**; **Delaune10:Vanets?**). As an alternative to uniformity as a proof technique, a symbolic version of the applied pi calculus is introduced in (**DKR09symbolic?**); by treating inputs symbolically, it avoids potentially infinite branching of processes due to inputs from the environment. Cortier & Delaune (**Cortier09?**) have shown that observational equivalence coincides with trace equivalence for determinate processes; and based on the symbolic semantics, this yields a decision procedure for observational equivalence of finite determinate processes without replication.
# Acknowledgements
We are very grateful to Myrto Arapinis and the editors of (**ChapterVersion?**) for careful reading of a draft of this work. In addition, we are grateful to Jiangshan Yu and Takahiro Kubota for highlighting mistakes in an earlier version of this document. This work has been partly supported by the EPSRC projects: *UbiVal: Fundamental Approaches to Validation of Ubiquitous Computing Applications and Infrastructures* (EP/D076625/2); and *Verifying Interoperability Requirements in Pervasive Systems* (EP/F033540/1). This work was partly done while Ben Smyth was at CNRS, Département d’Informatique, École Normale Supérieure, Paris, France with support from the *Direction Générale pour l’Armement*.
[^1]: This work is an extended version of Mark D. Ryan and Ben Smyth (2011) *Applied pi calculus*. In V Cortier and S Kremer, editor, Formal Models and Techniques for Analyzing Security Protocols.
[^2]: This work is an extended version of Mark D. Ryan and Ben Smyth (2011) *Applied pi calculus*. In V Cortier and S Kremer, editor, Formal Models and Techniques for Analyzing Security Protocols.