Cracking license plate checksum

178 Views Asked by At

Suppose a city has license plates assigned to cars with 7 digits $a_1$ to $a_7$ and a checksum calculated by the following algorithm: ($m_k$ are integers) $$m_1a_1+m_2a_2+\cdots+m_7a_7\mod 28$$ (which is then encoded as an alphanumeric character)

The city administration keeps secret $m_1$ to $m_7$.

Given many different license plates, how do I create an algorithm equivalent to this?

2

There are 2 best solutions below

2
On BEST ANSWER

You need 7 different license plates such that, when you form the matrix $A = (a_{ij})$ whose rows correspond to license plates, $\rm{det}(A)$ is relatively prime to $28$.

Then let $m$ be a column vector whose $i$th entry is $m_i$, and place the checksums corresponding to each plate in another column vector $x$, so that we have:

$$ A m \equiv x \pmod{28} $$ Then in the matrix ring $\mathbb{M}_7(\mathbb{Z}/28\mathbb{Z})$, $A$ is invertible, so we can compute $m \pmod{28}$: $$ m \equiv A^{-1} x \pmod{28} $$

2
On

What the city administration hides is a group homomorphism $f\colon (\mathbb Z/28\mathbb Z)^7\rightarrow \mathbb Z/28\mathbb Z$, that is given by $f(a_1,\dots,a_7) = m_1a_1+\dots+m_7a_7$. Note that $(\mathbb Z/28\mathbb Z)^7$ has generating families of size $7$. This means that given seven linearly independent elements (over $\mathbb Z/28\mathbb Z$) of this module, say $a^1,\dots,a^7$ (which are all $7$-elements tuples), we can generate all the other elements by taking linear combinations. For example, the family $\{(1,0,0,0,0,0,0),(0,1,0,0,0,0,0),(0,0,1,0,0,0,0),(0,0,0,1,0,0,0),(0,0,0,0,1,0,0),(0,0,0,0,0,1,0),(0,0,0,0,0,0,1)\}$ generates the module.

Thus, if we want to know the value $f(b_1,\ldots,b_7)$, we know that $b=\sum_{i=1}^7 \lambda_i a^i$ for some $\lambda_i\in\mathbb Z$, and then by linearity $f(b)=\sum_{i=1}^7\lambda_i f(a^i)$. Therefore, if you look at the cars and find seven plates which are linearly independent as elements of $(\mathbb Z/28\mathbb Z)^7$, you can determine the checksum for all the possible plates.