Image methods Scrambling
Arnold's cat map
Arnold’s cat map comes from dynamical systems theory. The mathematician Vladimir Arnold illustrated it in the 1960s with the drawing of a cat, hence the name. Applied to a digital image, it gives a spectacular scramble, and a surprise.
How does Arnold’s cat map work?
The image must be square, of side N. Each pixel at (x, y) is sent to:
x' = (x + y) mod N
y' = (x + 2y) mod N Geometrically, the image is sheared into a stretched parallelogram, then the parts sticking out are folded back into the square (that is the job of the modulo).
The map is a bijection: each pixel has one destination and no position is left out. It is therefore a pixel permutation, fixed by a formula instead of a key. To go back, apply the inverse map:
x = (2x' − y') mod N
y = (y' − x') mod N What does an image processed with Arnold’s cat map look like?
After one iteration, the image is stretched into diagonal bands, still recognisable. After a few, it looks like noise. Then, now and again, ghosts of the image appear, as several reduced copies. And finally the image returns exactly to its starting state.
That return is inevitable: there are only finitely many ways to arrange N × N pixels. The number of iterations needed, the period, depends on N irregularly:
| Side N | Period |
|---|---|
| 100 | 150 |
| 101 | 25 |
| 128 | 96 |
| 256 | 192 |
| 300 | 300 |
It never exceeds 3N.
What are the weaknesses of Arnold’s cat map?
Strengths
- No table to store: two additions and a modulo per pixel.
- Lossless and perfectly reversible.
- Highly instructive: it shows that a chaotic-looking mix can be entirely deterministic.
Weaknesses
- Tiny key space. The only “key” is the number of iterations, below the period: a few hundred tries at most.
- Just keep going. Applying the map again and again must land back on the image.
- Unchanged histogram, as with any permutation.
- Square images only, unless padded or cropped.
- Destroyed by JPEG.
How do you recover the image without knowing the number of iterations?
Apply the map (or its inverse) step by step and look at the result. A simple measure automates the choice: in a natural image, neighbouring pixels look alike. The iteration where the sum of differences between neighbours is lowest is the right one.
What are the variants of Arnold’s cat map?
- Generalised cat map — replace the matrix with
[[1, a], [b, ab + 1]]. The integersaandbbecome a real key, and the period changes with them. - Baker’s map — stretch, then cut and stack, like puff pastry; same family, different geometry.
- Arnold then XOR — the most common design in the literature: the map scrambles positions, a chaotic stream scrambles values.
- 3D version — extend the mixing to the three colour channels.
In CipherChronicle
The workbench asks for a number of iterations, from 1 to 100: that is what you give back to decrypt. On a rectangular image, only the central square is transformed and the margins stay put; for a full scramble, start from a square image.
Demonstration
The CipherChronicle artwork is encrypted then decrypted right here, in your browser, with the same engine as the workbench. Drag the bar to compare.