o1-labs / proof-systems

The proof systems used by Mina
https://o1-labs.github.io/proof-systems/
Apache License 2.0
414 stars 96 forks source link

Tic-Tac-Toe example with Kombucha #624

Closed querolita closed 2 years ago

querolita commented 2 years ago

We would like to have a number of circuits written using our kombucha circuit writer for different purposes: examples in the readme file, a blogpost, documentation, etc. A visual set of circuits related to games is interesting as they are normally well-known and are friendlier for a broader audience than something more mathematical in nature.

The idea would be to simulate a 2-party interaction where players are playing a tic-tac-toe game. The goal of the winning party would be to prove that they won the match by encoding the witness (the state of the board) in our circuit.

fabrizio-m commented 2 years ago

If I understand correctly it will be a circuit to verify that some board represents a winning state, right? Will it require ZK? could the board be a Merkle root as public input?

querolita commented 2 years ago

Yes, you're right. In the best case, it would be zero knowledge. This should be obtained with the zk rows at the end of the gates. Regarding the specific strategy, whatever helps you think how to model it should be fine. But using merkle trees may be too complex and would require to write plenty of auxiliary methods (which, on the other hand, we may want to have at some point, but likely not necessary for this example).

mimoo commented 2 years ago

If I understand correctly it will be a circuit to verify that some board represents a winning state, right?

you could also have a circuit that takes a state, and returns a new state that also changes who can play next. And at each transition the circuit could check if someone won.

fabrizio-m commented 2 years ago

I think we have two simple options:

And then the more complex of a complete game, I can think of a way without recursion but without perfect ZK:

And at the end there will be about 9 proofs, I think that it has an acceptable complexity, but maybe for examples it could be better to have a few simpler circuits instead of one for a complete game.

fabrizio-m commented 2 years ago

It should have perfect ZK now that I think about, initially I put the turn as a public input but later move it to the game state so the number of turns should be secret now, the problem is that without recursion someone can count the number of proofs and get the number of turns, it could be padded but will make everything more complex.

github-actions[bot] commented 2 years ago

Stale issue message