Whenever cryptographers start talking, I feel like it’s something not meant for the mind of mortal man. I basically just hear “... and then using black magic, we did the thing!”. But now that zero-knowledge proofs (ZKPs) are one of the most promising ideas in compute verification, I figured it was worth the time to understand them, ideally without going crazy.[1] I know the cryptographers say zero-knowledge, but how?
The simplest possible example is this: you’d like to convince someone that you’re holding a red card, but you don’t want to expose your card value. An alternate method is that you could go through the deck and show them all the black cards; they wouldn’t know what the value of your card was, but you would have proved that it was indeed red.[2]
If that example is good enough to convince you, by all means stop now. But if not... then read on, if you dare!
Sudoku in Arkham
Sudoku has a surprising number of variants (e.g. the famed XKCD version), but works well with any square number. So I’m going to walk you through the simplest nontrivial sudoku, and hope to convince you of ZKP along the way.
The simplest nontrivial sudoku is 4x4; just as in normal 9x9 sudoku, every row, column, and block must contain each of the possible digits (1-4) exactly once. Here’s one starting board:
The puzzle. Grey cells are the given starting cells.
The grey squares are the given starting cells. Normally the digits would be black, but because much of the trick to ZKP involves relabeling, I’m going to use colors to make it easier to keep track of. We’re also going to use a bit of cryptospeak, and call my role Prover, and the other role Verifier.
Now, imagine that I have solved this sudoku, and want to convince you that I have the solution; the obvious way would be to fill it out and show the Verifier the answer, but cryptographers hate revealing any information, ever. So in this example, crucially, I have to prove to the Verifier that I know the solution, but don’t want to help them find the solution at all.
The prover’s solution.
Above is the solution which you, Dear Reader, are privy to, but which I would never reveal to the Verifier. To make the games easier to follow, I’m using my crayons[3] to color in the digits (which are fixed) and the letters (which change each round) such that the color always matches the digit.
From here out I will do as many rounds of Proving as the Verifier wants, but the flow remains the same each time. I will:
put up a screen between myself and the Verifier, so they can’t see me working
use playing cards labeled “a, b, c, d”, map them to my solution, and then place them face down
I then draw back the veillift the screen so that both the Verifier and I can see my face-down cards; I’ve now committed to this setup and can’t change it
the Verifier can then choose to ask one question, and I must flip over and reveal either:
a single row (4)
a single column (4)
a single block (4)
the given starting cells (1)
the Verifier can inspect the result and confirm that it matches what a solution would output (e.g. no repeated values)
this hopefully makes my purported knowledge of a solution marginally more plausible to the Verifier
We can play many rounds, but each round I put up the screen, relabel the digits, and place the cards face-down again; since the Verifier waits until after my commitment to choose which of the 13 questions to ask, I can’t change my answers to match the question.
Let’s walk through a few rounds:
Round 1
Round 1, behind the screen.
I choose my mapping, and apply my solution (behind the screen)
I then flip all the cards face-down, and remove the screen, so the Verifier knows I can’t change my answers anymore; I have committed my result.
The committed grid, face down.
The Verifier can then choose any one question to ask; in this case they say “Show me Row 2”:
Round 1: row 2 revealed.
I flip over the cards along Row 2, and the Verifier can see that each letter occurs exactly once. While I might have just randomly distributed the cards and gotten lucky, I’ve shown that at least this round was consistent with a solution. I might or might not have the rest of the solution, but the Verifier must conclude that at least one of their checks passed, so I can be lying with at most 12/13 probability.
Recall that the colors will always match the digit:
1 – will always be 🟥 RED
2 – will always be 🟨 YELLOW
3 – will always be 🟩 GREEN
4 – will always be 🟦 BLUE
The colors will hopefully help you track the relabeling next round.
Round 2
I put up the screen, and relabel my solution again, producing this:
Round 2, behind the screen.
Then I turn them face down and lift the screen, showing the Verifier that I have committed to this arrangement. The Verifier can choose to ask any one question again; this time say “Column 3”
Round 2: column 3 revealed.
Notice that the Verifier has learned only that my arrangement was consistent with having a correct solution, but because I’ve swapped the letters around, they’ve learned nothing about the actual answer! But now that I’ve revealed this Euclidean column, it means either I really do know the solution, or I’ve gotten lucky twice. Since there are 13 things the Verifier could ask each round (4 rows, 4 columns, 4 blocks, or the given starting cells), the chance of getting lucky twice is 85%[4].
Round 3
Once again, I put up the screen, and relabel my solution:
Round 3, behind the screen.
I then turn the cards face-down again, and let the Verifier choose a new question to ask. They might think that while I’ve shown that I probably have a solution, I haven’t proven that I have the solution to this particular puzzle. So the Verifier demands that I reveal the given starting cells, and I show them:
Round 3: the given starting cells revealed.
Since my relabeling has the same cards in the upper-left and lower-right corners, it’s likely that I really do know something they don’t. While the Verifier can clearly determine my mapping between the digits and the letters in this round, that knowledge does them no good the next round, because I will have relabeled the digits once more. Even if they ask me to revisit one of the rows or columns that I’ve shown before, they still learn absolutely nothing, because the letters might be completely different that round. They only learn that my revelation is consistent with a solution, but not the solution itself.
Round N: more sanity checks
We can keep doing this as long as it takes for the Verifier to be convinced. The chance that I could have just gotten lucky goes down by 8% each round, and after 10 rounds the chance that I’m faking it has gone down to (12 in 13)**10, which is less than 50%. If we do it 100 times, then it’s well under a 0.1% chance that I’m lying. Eventually this should be very convincing to the Verifier! And hopefully my explanation has also been convincing to you, Dear Reader, that there really has been “zero-knowledge” leaked.[5] But notice that this was a lot of effort! Every round I had to relabel, commit, and reveal.
This same underlying logic holds true when we do it in code as well, but instead of just checking every row/column/box possibility that the Verifier might check on (which doesn’t take long in 4x4 sudoku), the Verifier is going to want to check on trillions of parameters inside a modern shoggothfrontier model. The digital equivalent of figuring out every possible question, relabeling the cards, and committing the face-down setup... that all takes time. So overall ZKP is generally much slower than whatever scenario we’re proving. Some of my co-Residents at FASR have done an amazing job of speeding up ZKPs for compute verification, and have gotten the time to conduct a single proof down a lot: from over an hour, to under one minute.
But that, Dear Reader, is a story for another day. Assuming they let me out.[6]
Related posts
Zero-Knowledge Training Pause — David Zeidler. The same commit-then-spot-check idea scaled from sudoku to verifying a training pause, building up to a toy ZK proof for matrix multiplication.
Make Powerful Machines Verifiable — Naci Cankaya. The policy case that powerful actors should accept verification that proves specific properties while keeping real secrets hidden.
Sounds insane, but they really are exactly what they say on the tin.
In alignment with our AI Usage policy, the Pangram score of this piece: 100% human.
Crossposted from canaryinstitute.ai/blog/zero-sudoku.
Whenever cryptographers start talking, I feel like it’s something not meant for the mind of mortal man. I basically just hear “... and then using black magic, we did the thing!”. But now that zero-knowledge proofs (ZKPs) are one of the most promising ideas in compute verification, I figured it was worth the time to understand them, ideally without going crazy. [1] I know the cryptographers say zero-knowledge, but how?
The simplest possible example is this: you’d like to convince someone that you’re holding a red card, but you don’t want to expose your card value. An alternate method is that you could go through the deck and show them all the black cards; they wouldn’t know what the value of your card was, but you would have proved that it was indeed red. [2]
If that example is good enough to convince you, by all means stop now. But if not... then read on, if you dare!
Sudoku in Arkham
Sudoku has a surprising number of variants (e.g. the famed XKCD version), but works well with any square number. So I’m going to walk you through the simplest nontrivial sudoku, and hope to convince you of ZKP along the way.
The simplest nontrivial sudoku is 4x4; just as in normal 9x9 sudoku, every row, column, and block must contain each of the possible digits (1-4) exactly once. Here’s one starting board:
The puzzle. Grey cells are the given starting cells.
The grey squares are the given starting cells. Normally the digits would be black, but because much of the trick to ZKP involves relabeling, I’m going to use colors to make it easier to keep track of. We’re also going to use a bit of cryptospeak, and call my role Prover, and the other role Verifier.
Now, imagine that I have solved this sudoku, and want to convince you that I have the solution; the obvious way would be to fill it out and show the Verifier the answer, but cryptographers hate revealing any information, ever. So in this example, crucially, I have to prove to the Verifier that I know the solution, but don’t want to help them find the solution at all.
The prover’s solution.
Above is the solution which you, Dear Reader, are privy to, but which I would never reveal to the Verifier. To make the games easier to follow, I’m using my crayons [3] to color in the digits (which are fixed) and the letters (which change each round) such that the color always matches the digit.
From here out I will do as many rounds of Proving as the Verifier wants, but the flow remains the same each time. I will:
draw back the veillift the screen so that both the Verifier and I can see my face-down cards; I’ve now committed to this setup and can’t change itWe can play many rounds, but each round I put up the screen, relabel the digits, and place the cards face-down again; since the Verifier waits until after my commitment to choose which of the 13 questions to ask, I can’t change my answers to match the question.
Let’s walk through a few rounds:
Round 1
Round 1, behind the screen.
I choose my mapping, and apply my solution (behind the screen)
I then flip all the cards face-down, and remove the screen, so the Verifier knows I can’t change my answers anymore; I have committed my result.
The committed grid, face down.
The Verifier can then choose any one question to ask; in this case they say “Show me Row 2”:
Round 1: row 2 revealed.
I flip over the cards along Row 2, and the Verifier can see that each letter occurs exactly once. While I might have just randomly distributed the cards and gotten lucky, I’ve shown that at least this round was consistent with a solution. I might or might not have the rest of the solution, but the Verifier must conclude that at least one of their checks passed, so I can be lying with at most 12/13 probability.
Recall that the colors will always match the digit:
The colors will hopefully help you track the relabeling next round.
Round 2
I put up the screen, and relabel my solution again, producing this:
Round 2, behind the screen.
Then I turn them face down and lift the screen, showing the Verifier that I have committed to this arrangement. The Verifier can choose to ask any one question again; this time say “Column 3”
Round 2: column 3 revealed.
Notice that the Verifier has learned only that my arrangement was consistent with having a correct solution, but because I’ve swapped the letters around, they’ve learned nothing about the actual answer! But now that I’ve revealed this Euclidean column, it means either I really do know the solution, or I’ve gotten lucky twice. Since there are 13 things the Verifier could ask each round (4 rows, 4 columns, 4 blocks, or the given starting cells), the chance of getting lucky twice is 85% [4] .
Round 3
Once again, I put up the screen, and relabel my solution:
Round 3, behind the screen.
I then turn the cards face-down again, and let the Verifier choose a new question to ask. They might think that while I’ve shown that I probably have a solution, I haven’t proven that I have the solution to this particular puzzle. So the Verifier demands that I reveal the given starting cells, and I show them:
Round 3: the given starting cells revealed.
Since my relabeling has the same cards in the upper-left and lower-right corners, it’s likely that I really do know something they don’t. While the Verifier can clearly determine my mapping between the digits and the letters in this round, that knowledge does them no good the next round, because I will have relabeled the digits once more. Even if they ask me to revisit one of the rows or columns that I’ve shown before, they still learn absolutely nothing, because the letters might be completely different that round. They only learn that my revelation is consistent with a solution, but not the solution itself.
Round N: more sanity checks
We can keep doing this as long as it takes for the Verifier to be convinced. The chance that I could have just gotten lucky goes down by 8% each round, and after 10 rounds the chance that I’m faking it has gone down to (12 in 13)**10, which is less than 50%. If we do it 100 times, then it’s well under a 0.1% chance that I’m lying. Eventually this should be very convincing to the Verifier! And hopefully my explanation has also been convincing to you, Dear Reader, that there really has been “zero-knowledge” leaked. [5] But notice that this was a lot of effort! Every round I had to relabel, commit, and reveal.
This same underlying logic holds true when we do it in code as well, but instead of just checking every row/column/box possibility that the Verifier might check on (which doesn’t take long in 4x4 sudoku), the Verifier is going to want to check on trillions of parameters inside a modern
shoggothfrontier model. The digital equivalent of figuring out every possible question, relabeling the cards, and committing the face-down setup... that all takes time. So overall ZKP is generally much slower than whatever scenario we’re proving. Some of my co-Residents at FASR have done an amazing job of speeding up ZKPs for compute verification, and have gotten the time to conduct a single proof down a lot: from over an hour, to under one minute.But that, Dear Reader, is a story for another day. Assuming they let me out. [6]
Related posts
Seriously, look up "homomorphic encryption". ↩︎
Although maybe your card is actually a Joker! Catching edge cases like this is an important part of ZKP. ↩︎
I’m not allowed to have sharp objects in here. ↩︎
That’s (12/13)**2, for those still keeping score at home. ↩︎
This has other practical applications; e.g. it’s possible for websites to verify someone’s age without knowing their birthdate. ↩︎
But in the meantime, see Matthew Green, “Zero Knowledge Proofs: An illustrated primer” (2014). ↩︎