# What are requirements for this grille?

I'm trying to program a Cardan grille, but I can't find requirements for grille. In my case, grille is square matrix A with $N$ x $N$ size, and elements are $0$ or $1$ (where $1$ means that it is hole).

I realized that if $N$ is odd, central element of matrix can not be $1$.

But what are the other requirements?

UPD 30.09.13

Wiki article in russian describes that, if matrix is square, it can be rotated four times around the center.

For example (If I understand correctly):
HELLO and matrix 3x3 with two holes

1 0 0 | H 0 0
0 0 0 | 0 0 0
0 1 0 | 0 E 0

0 0 1 | H 0 L
1 0 0 | L 0 0
0 0 0 | 0 E 0

0 1 0 | H O L
0 0 0 | L 0 0
0 0 1 | 0 E 0

0 0 0
0 0 1
1 0 0

In this expamle three rotations are enough.

As result we have matrix

H O L
L 0 0
0 E 0

And 0 will be replaced by the symbols A-Z. It isn't Cardan grille? What it is name of these method?

If we have central element 1, that symbol well be replaced by other.

1 0 0 | H 0 0
0 1 0 | 0 E 0
0 0 0 | 0 0 0

0 0 1 | H 0 L
0 1 0 | 0 L 0
0 0 0 | 0 0 0

...

So, matrix has some requirements, which I'm trying to find.

I don't know where you get that the central element can not be $1$, because the Cardan grille does not have any special "requirements" as you're implying. In the original version, a piece of cardboard has several holes cut in it (= the grille) and when it is placed over an innocent looking message, the holes cover all but specific letters spelling out the secret message.

Simpler put: the holes you are cutting, identify the letters of the secret message. The other parts (which are covered) are the text to be ignored.

Let me give you a hint by providing you with a practical example…

The harmless looking, to-be-transmitted message could read:

ALL THOSE TEENIES ARE CRAZY KIDS!


and (taking your boolean $1$ and $0$ approach) the grille could look like this:

100010000010000000100010000010001


then the hidden message would be readable by applying the grille like this:

ALL THOSE TEENIES ARE CRAZY KIDS!
100010000010000000100010000010001
A...T.....T.......A...C.....K...!

ATTACK!


That's all that's to it. So, there are no other requirements but the obvious one: if someone puts the grille on your text, only the hidden message should be readable…

In other words (and to answer your question by the letter): the only requirement of the grille is to have "holes" where the hidden message's letters, numbers, and/or symbols are located, so that when the grille is applied to a harmless looking message (like a letter or book page), the hidden message is the only thing that remains visible because everything else is covered by the grille.

You might want to check Wikipedia's related article if you need another, more classical example.

EDIT

Looking at your edit, it becomes obvious that there's an additional step you're talking about... meaning we're indeed not talking about a pure "Cardan grille". A pure "Cardan grille" would not touch/change the text the grille is applied to. It's just a paper with holes showing you what letters of the plaintext are the secret message.

The rotating matrix your latest edit shows is something completely different. It could be called a grille cipher, but it's definitely not a Cardan grille… it could be a derived Fleissner grille (also known as "turning grille"), but I would need to be able to check the article you've been reading (see my link-request). It could well be that the article you've been reading talks about multiple grille cyphers; maybe even a combination of them. Until I've read that article , I can only guess… Fleissner grille.

If it's a Fleissner grille (or derivate), you might want to look at this related PDF which explains them (as well as attacks on it). Besides that, this website practically explains the Methods of Transposition as used in the Turning grille, including the center symbol thing you've noticed and are asking about.

You'll notice this image of a turning grille in action also has that 3x3 matrix in it's inner ring.

As for the 3x3 matrix itself, it's logical that if you rotate it around the middle, the symbol at the center will not move/change. Yet, I expect that what your edit shows is just part of multiple steps of remixing the 3x3 matrix. Otherwise, you're indeed correct - the non-changing center symbol would be one of the weakest parts of the matrix-mixing process.

As for the requirements of mixing, rotating and shifting a matrix… that is defined by the individual cipher implementation, not via generalized rules that apply to every cipher.

I think you're referring to Fleissner grilles, which are kind of a subset of Cardan grilles. According to wikipedia, to construct one you "make 16 perforations in an 8x8 grid – 4 holes in each quadrant. If the squares in each quadrant are [identically] numbered 1 to 16, all 16 numbers must be used once only. This allows many variations in placing the apertures." That's likely the requirement you're trying to find.

I edited your question to change the title from "Cardan grille" to "Fleissner grille". The use of the incorrect name has led people to make incorrect assumptions about what you're trying to accomplish.

The difference between the two is important. Traditional Cardan grilles are used to hide a few secret letters inside a large body of plaintext. The author writes the secret message through the holes, then adds innocuous text to disguise the hidden message, perhaps as a letter to a loved one. It's primarily a form of steganography, which hides the fact that there is a secret message. The Fleissner grille makes no pretense of wearing a disguise - it's a square of meaningless-looking letters. To anyone reading your mail, it's a very suspicious thing to find.

All grilles are simply transposition ciphers. The reason for using the grille is to make the task of encoding and decoding easier for the human operator. Without the grille, encoding and decoding instructions become a list of characters: row 1 column 8, row 2 column 12, etc., which are tedious for a human to use. That's especially a problem under the stress of hurriedly writing a secret message that could bring a charge of treason should you be caught!