Long story short, trying to understand how I would write the vigenere cipher mathematically when using Gen, Enc, Dec and I can't figure it out. This is what I've come up with so far.

$$\mathrm{Gen}: k ={0…25}^t$$

$$\mathrm{Enc}: c_i = (p_i + k_i) \pmod {26}$$

$$\mathrm{Dec}: p_i = (c_i – k_i) \pmod {26}$$

It doesn't really seem right though, so that's why I'm asking.


The only way I'd change it is to make it explicit that $k$ is sampled from that set rather than is equal to it and to note that the key is used cyclically: \begin{eqnarray*} \mathrm{Gen}:&&k\leftarrow \{0,\ldots,25\}^t\\ \mathrm{Enc}:&&c_i=p_i+k_{i\pmod t}\pmod{26}\\ \mathrm{Dec}:&&p_i=c_i-k_{i\pmod t}\pmod{26} \end{eqnarray*}

  • $\begingroup$ [Retracted] Does $\gets$ unambiguously mean sampled from? I tend to use $\overset{\$}\gets$ for this, and use $\gets$ for affectation, where some language like Pascal use := in order to distinguish from the comparison operator. Maybe I'm wrong... $\endgroup$
    – fgrieu
    Sep 16 at 6:28
  • $\begingroup$ @fgrieu Certainly not unambiguously. Galbraith omits the dollar sign in his book. Katz and Lindell tend to just say "Choose". Boneh uses $R$ instead of dollar and specifies uniformity. I dislike the dollar sign for TeX reasons, but it is widespread. $\endgroup$
    – Daniel S
    Sep 16 at 6:40
  • 3
    $\begingroup$ I checked standard references and you are right, my usage is kinda marginal. Plus I discovered the hard way that \$ causes trouble in the rendering. So in the end I propose$$\begin{eqnarray*} \mathrm{Gen}:&&k\gets\{0,\ldots,25\}^t\\ \mathrm{Enc}:&&c_i=p_i+k_{i\bmod t}\bmod{26}\\ \mathrm{Dec}:&&p_i=c_i-k_{i\bmod t}\bmod{26} \end{eqnarray*}$$ with \bmodrather than \pmod, because only the former is an operator, and insures the outcome is in $[0,t)$ or $[0,26)$. $\endgroup$
    – fgrieu
    Sep 16 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.