A twist in rock paper scissors game

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the newline's Introduction to Privacy on Ethereum course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to newline's Introduction to Privacy on Ethereum, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course newline's Introduction to Privacy on Ethereum

So as you might have figured out already that just by doing a hash of rock, it is not much different to just saying 1, 2 or 3. Yes, we've done some obfuscation as there is no 1, 2, 3 anymore. But if you actually see what's actually stored here, if I did make it public, so we get a function where we can see the results, we should be able to see that they are actually always the same. So once you know that rock evaluates to a certain hexadecimal, you can still do the exact same attack as before. And this is often a mistake that a lot of people make, where they think that just by hashing something, it's secure, it's not, because once you know that rock is this, paper is this and scissors is this, it's no different to anything else, because you can call it a lot of times and it's always going to be this hash. It's not going to change, it's a one-rate function, which takes a string and then gives your result, and that's going to be always the same. So if I'm playing paper and everyone can see that I've played paper and then they can beat me, they can beat me with scissors always. And it's the same thing. So we have not actually improved whatsoever. And now you might be thinking, well, we really did a lot by adding a hash function and it's much more complicated than before, so why doesn't this get the job done? Well, in these systems, we have a lot of tools like hash functions, but if you don't use them correctly, then they don't really work. So in this case, we've used a hash function by it's really given us no privacy at all. Now, can you think of a way by using the existing setup that we can actually make it so that this becomes irrelevant? So when players play a move, they can play any of these three moves, but it's not possible to see until the evaluation point that they, what move they've played. So we're going to have to make quite a few changes, of course, but I want you to see how you could fix this problem by yourself. And I'll talk about the solution in the next video.