0

I'm working on a cryptography programming puzzle. I've worked out that the basic formula to generate a character is $$(x \cdot 2^i)\bmod 67 = character.$$

In order to decode, I need to work out what are the possible values for x, with $1 \leq x \leq 67$.

Here are some example equations and their solutions from WolframAlpha:

$2x \bmod 67 = 1 \implies x = 67n +34$

$4x \bmod 67 = 20\implies x = 67n + 5$

$8x \bmod 67 = 29\implies x = 67n + 12$

I want to understand what steps WolframAlpha is doing: How do I take the forms on the left and put them in the forms on the right?

This post on StackOverflow was helpful, but I didn't understand it well enough to generalize the approach. I studied some modular arithmetic, couldn't find the part that would help me here.

Arturo Magidin
  • 398,050
  • Do you ask for general $i$, or are you trying to solve for every $i$ as individual cases? This may help: https://en.wikipedia.org/wiki/Modular_multiplicative_inverse – insipidintegrator Aug 15 '22 at 15:19
  • Since $~2 \times 34 = 68 \equiv 1 \pmod{67},~$ you have that the first equation is solved by $~x \equiv 34 \pmod{67}.~$ Similarly, since $~4 \times 5 \equiv 20 \pmod{67},~$ you have that the second equation is solved by $~x \equiv 5 \pmod{67}.$ – user2661923 Aug 15 '22 at 15:30
  • Re previous comment, note that for any positive integer $(i)$, that $2^i$ is relatively prime to $(67)$. Therefore, for any of the corresponding equations, there will always be exactly one unique value of $x$ (within a modulus of $67$) that satisfies the corresponding equation. – user2661923 Aug 15 '22 at 15:32
  • By here, if $,0\le b< n,$ then $\ ax\bmod n = b!\iff! ax\equiv b\pmod{! n}.,$ The linked dupes explain how to solve such linear congruences (generally, as here, it is usually proves easiest to convert mod operations into equivalent but more (arithmetically) convenient congruences). – Bill Dubuque Aug 15 '22 at 15:40
  • This answer shows how to easily do modular division by $2$. Iterating that you can divide by any power of $2$ so you can compute your $,x \equiv c/2^i\pmod{67}\ \ $ – Bill Dubuque Aug 15 '22 at 15:43
  • @insipidintegrator, I don't understand your question (are you looking for general i?). I'm looking for what generalized methods I can use to take the formulas in the second section from the left side to the right side. I'll take a look at the wiki article. – Nicholas Weber Aug 15 '22 at 15:51
  • I'm afraid that the formula at the top was taken as a red herring. I wanted to show the encoding formula. For decoding, i is known, the the second part of the question is the important part, how to go from left to right. – Nicholas Weber Aug 15 '22 at 15:55
  • For your linked SO example, a simple proof is, given $,0\le b < m,$ $$\begin{align} (a+x)\bmod m &,=, b\[.2em] \color{#c00}\iff\qquad\quad\ \ \ a+x&,\equiv, b\ \ \ \ \ ,\pmod{! m}\[.2em] \iff\qquad\qquad\quad\ , x&,\equiv, b-a!!\pmod{! m}\[.2em] \color{#0a0}\iff\qquad x\bmod m&,\equiv, (b-a)\bmod m\end{align}\qquad$$ – Bill Dubuque Aug 15 '22 at 16:03
  • The $\rm\color{#c00}{first!! \iff}$ arrow converts from mod operator to congruence form using the first displayed equivalence here, the second solves the congruence by adding $-a$ to both sides using the Congruence Sum Rule, and the $\rm\color{#0a0}{last\ arrow}$ converts from congruence back to mod operators using the prior-linked equivalence between the two. – Bill Dubuque Aug 15 '22 at 16:03

0 Answers0