Score:1

What are the equations (Gen, Enc, Dec) for the vigenere cipher?

nc flag

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.

Score:2
ru flag

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*}

fgrieu avatar
ng flag
[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...
Daniel S avatar
ru flag
@fgrieu Certainly not unambiguously. Galbraith omits the dollar sign in [his book](https://www.math.auckland.ac.nz/~sgal018/crypto-book/notation.pdf). 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.
fgrieu avatar
ng flag
I checked standard references and you are right, my usage is kinda marginal. Plus I discovered the hard way that `\$` [causes trouble](https://meta.stackexchange.com/q/369908/184379) 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 `\bmod`rather than `\pmod`, because only the former is an operator, and insures the outcome is in $[0,t)$ or $[0,26)$.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.