Printing Protocol: Physical ZKPs for Decomposition Puzzles

Decomposition puzzles are pencil-and-paper logic puzzles that involve partitioning a rectangular grid into several regions to satisfy certain rules. In this paper, we construct a generic card-based protocol called printing protocol, which can be used to physically verify solutions of decompositon puzzles. We apply the printing protocol to develop card-based zero-knowledge proof protocols for two such puzzles: Five Cells and Meadows. These protocols allow a prover to physically show that he/she knows solutions of the puzzles without revealing them.


Introduction
Pencil puzzles are puzzles that can be solved by writing down the solution on a paper.They must be solved using only logical reasoning and do not require additional knowledge.Examples of pencil puzzles include Sudoku, Nonogram, Kakuro, and Slitherlink.
Pencil puzzles can be categorized into several types based on their core theme.One of the common themes is to partition a rectangular grid into several regions to satisfy certain rules.We call these puzzles decomposition puzzles.

Five Cells
Five Cells is a decomposition puzzle created by Nikoli, a Japanese publisher famous for developing many popular pencil puzzles.The puzzle consists of an m × n rectangular grid, with some cells containing a number.The player has to partition the grid into pentominoes.The number in each cell indicates the number of edges of that cell that are borders of pentominoes (including the outer boundary of the grid) [17].See Fig. 1.
Deciding solvability of a given Five Cells puzzle is NP-complete [11].

Meadows
Meadows is another decomposition puzzle consisting of an n × n square grid, with some cells containing a dot.The player has to partition the grid into squares such that each square contains exactly one dotted cell.See Fig. 2. The rules of Meadows are similar to those of Shikaku1 , a more well-known decomposition puzzle developed by Nikoli, so the puzzle may be considered a variant of Shikaku [12], which is also NP-complete [35].

Zero-Knowledge Proof
Suppose that Panthalassa, a puzzle expert, creates a pencil puzzle and challenges his friend Vodka to solve it.He wants to convince her that the puzzle indeed has a solution, but does not want to reveal the solution itself.A zero-knowledge proof (ZKP) makes this seemingly difficult task possible.
Formally, a ZKP is an interactive protocol between a prover P and a verifier V , where both are given a computational problem x, but only P knows its solution w.Also, the computational power of V is limited, so V cannot obtain w from x.A ZKP has to satisfy the following three properties.
2. Soundness: If P does not know w, then V rejects with high probability.(In this paper, we consider the perfect soundness property where V always rejects.) 3. Zero-knowledge: V learns nothing about w.Formally, there exists a probabilistic polynomial time algorithm S (called a simulator ) that does not know w but has an access to V , and the outputs of S follow the same probability distribution as the ones of the real protocol.
The concept of a ZKP was first introduced in 1989 by Goldwasser et al. [7].It has been proved that every NP problem has a ZKP [6], so a computational ZKP for any NP puzzle can be constructed via a reduction to another problem.Such construction, however, is unintuitive and looks unconvincing.Therefore, many researchers instead focused on constructing physical ZKPs using a deck of playing cards.These card-based protocols have benefits that they require only portable objects easily found in everyday life and do not require computers.They are also easy to understand and verify the correctness and security, even for non-experts, and thus can be used for didactic purpose.

Our Contribution
In this paper, we construct a generic card-based protocol called printing protocol.This protocol prints some numbers from the template onto a target area from the grid, and also verifies that the printed numbers do not overlap with the already existing numbers in that area.The printing protocol can be used to verify solutions of many decomposition puzzles.We show two applications of it by developing ZKP protocols for two such puzzles: Five Cells and Meadows.

Cards
Each card used in our protocol either has an integer written on the front side (e.g. 1 , 2 ) or is a blank card with nothing written on the front side ( ).All cards have indistinguishable back sides denoted by ? .

⇒
? ?????????????????????????????by putting all cards in each column into an envelope, and letting all parties take turns to apply Hindu cuts (taking some envelopes from the bottom and putting them on the top) to the pile of envelopes.Note that each card in M may be replaced by a stack of cards, and the protocol still works in the same way as long as every stack in the same row has the same number of cards.

Chosen Cut Protocol
Given a sequence C = (c 1 , c 2 , ..., c q ) of q face-down cards, a chosen cut protocol [13] allows P to select a desired card c i to use in other protocols without revealing i to V .Optionally, the protocol can also revert C back to its original state after P finishes using c i .
P performs the following steps (called the first part).
1. Construct the following 3 × q matrix M (see Fig. 4).(c) In Row 3, place a face-up 1 at Column 1 and a face-up 0 at each other column.
2. Turn over all face-up cards.Apply the pile-shifting shuffle to M .
3. Turn over all cards in Row 2 and locate the position of the only 1 .A card in Row 1 directly above this 1 will be the card c i as desired.
Optionally, if P wants to revert C back to its original state, P continues the following steps (called the second part) after finishing using c i in other protocols.4. Place c i back into M at the same position.Note that each card in C may be replaced by a stack of cards, and the protocol still works in the same way as long as every stack has the same number of cards.

Printing Protocol
Given a p × q matrix of cards called a template (which contains some non-blank cards, and possibly some blank cards) and another p × q matrix of cards representing an area from the puzzle grid, all known to P but not to V .A printing protocol verifies that positions in the area corresponding to non-blank cards in the template are initially empty (consisting of all blank cards).The protocol then places all non-blank cards from the template at the corresponding positions in the area, replacing the original blank cards (see Fig. 5) without revealing any card to V .
P performs the following steps.
1. Place each card from the template on top of each corresponding card from the area, creating pq stacks of two cards.
2. For each of the pq stacks, perform the following steps.
(a) Apply the first part of the chosen cut protocol to select a blank card.(If the preconditions are met, at least one card must be blank; if both cards are blank, P can select any of them.)(b) Reveal the selected card that it is a blank card (otherwise V rejects) and remove it from the stack.Figure 6: Templates of the X-shaped pentomino and the P-shaped pentomino After these steps, all non-blank cards from the template are placed at the corresponding positions in the area.V is also convinced that these positions in the area were initially empty (consisting of all blank cards) before the protocol.
Using the printing protocol, P can separately print each region in the partition onto the grid to construct P 's solution of a decomposition puzzle.V will be convinced that the regions do not overlap with one another.

ZKP Protocol for Five Cells
First, from the solution of Five Cells, one can fill a number on every cell according to the rule of the puzzle (the number in each cell being the number of edges of that cell that are borders of pentominoes).We call this instance an extended solution of the puzzle.
The key observation is that there are only Θ(1) different types of pentomino.Namely, there are 63 of them [18]. 3Furthermore, inside each type of pentomino in the extended solution, the number in each cell is fixed for that type.Therefore, we need to construct only 63 different templates.
In our protocol, P constructs 63 templates, one for each type of pentomino.Each template has size 5 × 5 (as the height and length of a pentomino are at most five), and the pentomino is placed at the top-left corner of the template.A cell inside the pentomino is represented by a card with a number equal to the number of edges of that cell that are borders of the pentomino, while a cell outside the pentomino is represented by a blank card (see Fig. 6).

Main Protocol
Initially, P publicly places a blank card on every cell in the grid.To handle edge cases, P publicly appends four rows and four columns of "dummy" blank cards to the bottom and to the right of the grid.Then, P turns all card face-down.We now have an (m + 4) × (n + 4) matrix of cards.
Observe that if we arrange all (m + 4)(n + 4) cards in the matrix into a single sequence A = (a 1 , a 2 , ..., a (m+4)(n+4) ), starting at the top-left corner and going from left to right in Row 1, then from left to right in Row 2, and so on, we can locate exactly where the four neighbors of any given card are.Namely, the cards on the neighbor to the left, right, top, and bottom of a cell containing a i are a i−1 , a i+1 , a i−n−4 , and a i+n+4 , respectively.Also, P constructs 63 templates of all 63 types of pentomino and lets V verify that all templates are correct (otherwise V rejects).
1. Apply the first part of the chosen cut protocol to select a 5 × 5 area containing pentomino B i in the same position as in its corresponding template.(To be precise, P selects just the top-left corner cell of the area, and the rest will follow as the chosen cut protocol preserves the cyclic order).
2. Apply the first part of the chosen cut protocol to select a template of a pentomino with the same type as B i .
3. Apply the printing protocol on the selected template and the selected area.Continue the second part of the chosen cut protocol invoked in Step 1 to revert the grid into its original state.
4. Reconstruct a template that has just been used and replenish the pile of templates with it.Let V verify again that all 63 templates are correct (otherwise V rejects).Note that V does not know which template has been used.
Finally, P reveals all cards on the cells that contain a number (in the original Five Cell puzzle).V verifies that the numbers on the cards match the numbers in the cells (otherwise V rejects).P also reveals all dummy cards that they are still blank.If all verification steps pass, then V accepts.

Proof of Correctness and Security
We will prove the perfect completeness, perfect soundness, and zero-knowledge properties of this protocol.
Lemma 1 (Perfect Completeness).If P knows a solution of the Five Cells puzzle, then V always accepts.
Proof.Suppose P knows an extended solution of the puzzle.Consider each i-th iteration of the main protocol.
• In Step 3, since B 1 , B 2 , ..., B k form a partition of the grid, B i does not overlap with B 1 , B 2 , ..., B i−1 .Thus, the printing protocol will pass, and the numbers in B i will be printed on the grid.
• In Step 4, P reconstructs a template that has just been used, so this step will pass.
Therefore, every iteration will pass.After k iterations, all numbers in P 's extended solution will be printed on the grid, so all numbers in the original puzzle will match the numbers on the corresponding cards.
Hence, we can conclude that V always accept.
Lemma 2 (Perfect Soundness).If P does not know a solution of the Five Cells puzzle, then V always rejects.
Proof.We will prove the contrapositive of this statement.Suppose V accepts, which means the verification passes in all steps.Consider the main protocol.Since Step 4 passes for every iteration, all 63 templates are correct after each iteration (and also at the beginning of the protocol), which implies the numbers printed in every iteration form a shape of a pentomino and follow the rule of the puzzle.
In Step 3, since the printing protocol passes for every iteration, B i does not overlap with B 1 , B 2 , ..., B i−1 for every i.Also, the combined area of B 1 , B 2 , ..., B k is 5k = mn, which implies B 1 , B 2 , ..., B k must form a partition of the grid.
Since the final verification passes, all numbers in the original puzzle match the numbers on the corresponding cards.
Hence, we can conclude that the original puzzle grid is partitioned into pentominoes according to the rule, which means P must know a valid solution of the puzzle.
Lemma 3 (Zero-Knowledge).During the verification, V obtains no information about P 's solution.
Proof.We will prove that the interaction between P and V can be simulated by a simulator S that does not know P 's solution.It is sufficient to show that all distributions of cards that are turned face-up can be simulated by S.
• In Steps 3 and 6 of the chosen cut protocol in Section 2.3, the 1 has probability 1/q to be at each of the q columns (due to the pile-shifting shuffles), so these two steps can be simulated by S.
• In Step 2(b) of the printing protocol in Section 3, there is only one deterministic pattern of the cards that are turned face-up (all blank cards), so this step can be simulated by S.
• In Step 4 of the main protocol, there is only one deterministic pattern of the cards that are turned face-up (all correct templates), so this step can be simulated by S.
Hence, we can conclude that V obtains no information about P 's solution.

ZKP Protocol for Meadows
The key observation is that there are only n different sizes of square in the solution of Meadows.Therefore, we need to construct only n different templates.
In our protocol, P constructs n templates, one for each size of square.Each template has size n × n, and the square is placed at the top-left corner of the template.A cell inside the square is represented by a 1 , while a cell outside the square is represented by a blank card (see Fig. 7).

Main Protocol
Initially, P publicly places a blank card on every cell in the grid.To handle edge cases, P publicly appends n − 1 rows and n − 1 columns of "dummy" blank cards to the bottom and to the right of the grid.Then, P turns all card face-down.We now have an (2n−1)×(2n−1) matrix of cards.
Also, P constructs n templates of all n sizes of square and lets V verify that all templates are correct (otherwise V rejects).
Let d 1 , d 2 , ..., d k be the dotted cells in the grid.Suppose that in P 's solution, the grid is partitioned into k squares B 1 , B 2 , ..., B k , with each square B i containing cell d i .For each i = 1, 2, ..., k, P performs the following steps.
1. Apply the first part of the chosen cut protocol to select an n × n area whose top-left corner is the top-left corner of square B i .(To be precise, P selects just the top-left corner cell of the area, and the rest will follow).
2. Apply the first part of the chosen cut protocol to select a template of a square with the same size as B i .
3. Apply the printing protocol on the selected template and the selected area.Continue the second part of the chosen cut protocol invoked in Step 1 to revert the grid into its original state.
4. Turn over cards on cells d i , d i+1 , ..., d k to show that the card on d i is a 1 , and the cards on d i+1 , d i+2 , ..., d k are all blank cards (otherwise V rejects).
5. Reconstruct a template that has just been used and replenish the pile of templates with it.Let V verify again that all n templates are correct (otherwise V rejects).Note that V does not know which template has been used.
Finally, P reveals all cards in the grid that they are all 1 s (otherwise V rejects).P also reveals all dummy cards that they are still blank.If all verification steps pass, then V accepts.

Proof of Correctness and Security
We will prove the perfect completeness, perfect soundness, and zero-knowledge properties of this protocol.
Lemma 4 (Perfect Completeness).If P knows a solution of the Meadows puzzle, then V always accepts.
Proof.Suppose P knows a solution of the puzzle.Consider each i-th iteration of the main protocol.
• In Step 3, since B 1 , B 2 , ..., B k form a partition of the grid, B i does not overlap with B 1 , B 2 , ..., B i−1 .Thus, the printing protocol will pass, and all 1 s in B i will be printed on the grid.
• In Step 4, since all 1 s inside B i have already been printed, and all 1 s inside B i+1 , B i+2 , ..., B k have not yet been printed, this step will pass.
• In Step 5, P reconstructs a template that has just been used, so this step will pass.
Therefore, every iteration will pass.After k iterations, all cells in the grid will be printed with 1 s, so the final verification will also pass.
Hence, we can conclude that V always accept.
Lemma 5 (Perfect Soundness).If P does not know a solution of the Meadows puzzle, then V always rejects.
Proof.We will prove the contrapositive of this statement.Suppose V accepts, which means the verification passes in all steps.Consider the main protocol.Since Step 5 passes for every iteration, all n templates are correct after each iteration (and also at the beginning of the protocol), which implies the 1 s printed in every iteration form a shape of a square.
Since Step 4 passes for every iteration, the square printed in each i-th iteration must contain exactly one dotted cell, which is d i .
In Step 3, since the printing protocol passes for every iteration, B i does not overlap with B 1 , B 2 , ..., B i−1 for every i.Also, since the final verification passes, the combined area of B 1 , B 2 , ..., B k must cover the whole grid, i.e.B 1 , B 2 , ..., B k form a partition of the grid.
Hence, we can conclude that the puzzle grid is partitioned into squares, with each one contaning exactly one dotted cell, which means P must know a valid solution of the puzzle.
Lemma 6 (Zero-Knowledge).During the verification, V obtains no information about P 's solution.
Proof.We will prove that the interaction between P and V can be simulated by a simulator S that does not know P 's solution.It is sufficient to show that all distributions of cards that are turned face-up can be simulated by S.
The zero-knowledge property of the chosen cut protocol and the printing protocol has been proved in the proof of Lemma 3, so it is sufficient to consider only the main protocol.
• In Step 4, there is only one deterministic pattern of the cards that are turned face-up, so this step can be simulated by S.
• In Step 5, there is only one deterministic pattern of the cards that are turned face-up (all correct templates), so this step can be simulated by S.
Hence, we can conclude that V obtains no information about P 's solution.

Future Work
We constructed the printing protocol, which can be used to develop ZKP protocols for decompositon puzzles. 4However, the limitation of this protocol is that the number of different possible types of region (which is equal to the number of templates we need to prepare) must be polynomially bounded.A possible future work is to find a technique to deal with decompositon puzzles which the number of different possible types of region are exponentially bounded, e.g.Fillomino.

Figure 1 :Figure 2 :
Figure 1: An example of a 5 × 5 Five Cells puzzle (left) and its solution (right)

Figure 3 :?Figure 4 :
Figure 3: A pile-shifting shuffle on a 5 × 6 matrix (a) In Row 1, place the sequence C. (b) In Row 2, place a face-down 1 at Column i and a face-down 0 at each other column.

Figure 5 :
Figure 5: Examples of a succesful printing of numbers from a 4 × 5 template onto a 4 × 5 area (top) and an unsuccessful printing because of overlapping numbers (bottom)