In many books on Cryptography, we refer to probability distributions over the key space $\mathcal{K}$, over the plaintext space $\mathcal{M}$ and over the ciphertext space $\mathcal{C}$.
Then, we let $K$ be the random variable denoting the value of the key output by $\mathsf{Gen}$, so for any $k\in \mathcal K$, then $\mathrm{Pr}(K=k)$ is the probability of the event that after, running $\mathsf{Gen}$, to pick the key $k\in \mathcal K$. Likewise, we let $M$ be the random variable denoting the message being encrypted, so $\mathrm{Pr}(M=m)$ denotes the probability that the message takes the value $m\in \mathcal M$. Lastly, we let $C$ be the random variable denoting the resulting ciphertext, so $\mathrm{Pr}(C=c)$ denotes the probability that the ciphertext is equal to the fixed value $c\in \mathcal C$.
$\color{blue}{\textrm{Questions.}}$
From maths, we know that a random variable is a function $X:\Omega \longrightarrow V$. In the textbooks, I observed that the authors avoid to explicitely define abovementioned random variables. So:
- What are $K,P,C$ as functions? What are their domains and codomains?
- Later, the books also introduce new random variables, when they discuss about perfect secrecy. These are $\mathsf{Enc_K}(M)$ and $\mathsf{Enc_K}(m)$ for some fixed $m\in \mathcal M$. Again, what are their domains and codomains of these random variables?
$\color{blue}{\textrm{Thoughts.}}$
- Firstly, it seems that $K$ is the identity function. That is, $$K=\mathrm{Id_\mathcal{K}}:\mathcal{K}\longrightarrow \mathcal{K},\quad k\longmapsto k.$$ So, formally when $K$ follows the uniform distribution over $\mathcal{K}$, we have $$ \mathrm{Pr}(K=k)= \mathrm{Pr}(\{x\in \mathcal K: K(x)=k\})=\mathrm{Pr}(\{k\})=\frac{1}{|\mathcal{K}|}. $$ In addiction, I would say that we have \begin{gather*} M:\mathcal{K}\times \mathcal{M}\longrightarrow \mathcal{M},\quad (k,m)\longmapsto m, \newline C:\mathcal{K}\times \mathcal{M}\longrightarrow \mathcal{C},\quad (k,m)\longmapsto \mathsf{Enc}_k(m). \end{gather*}
- I would say that, fixing some $m_1\in \mathcal M$, \begin{gather*} C=\mathsf{Enc}_K(M):\mathcal{K}\times \mathcal{M}\longrightarrow \mathcal{M},\quad (k,m)\longmapsto m, \newline \mathsf{Enc}_K(M):\mathcal{K}\times \{m_1\}\longrightarrow \mathcal{C},\quad (k,m_1)\longmapsto \mathsf{Enc}_k(m_1). \end{gather*} So, later, when we define perfect secrecy, we will have \begin{eqnarray*} \mathrm{Pr}(\mathsf{Enc}_K(m_1)=c) &=& \mathrm{Pr}(\{(k,m_1)\in \mathcal K \times \{m_1\}: \mathsf{Enc}_k(m_1)=c \}) \newline &=&\frac{|\{(k,m_1)\in \mathcal K \times \{m_1\}: \mathsf{Enc}_k(m_1)=c \}|}{|\mathcal K \times \{m_1\}|} \newline &=&\frac{|\{k \in \mathcal K : \mathsf{Enc}_k(m_1)=c \}|}{|\mathcal K|}. \end{eqnarray*}
Are my thoughts correct? Any addition is more than welcome!
Reference: Introduction to Modern Cryptography, J. Katz and Y. Lindell.