Implementing privacy on the smart contract

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

Okay, so let's think about the solution. So the reason that they can now see what the moves are is because they can say that's just one, two, three. Well, we can make slightly complicated and see if that helps. So for example, what we can do is instead of using a Uint8, we can now use Bix32. So of course, Bix32 is, you know, just hexadecimal and what we can do is we can hash somewhere. So we can use KK-256, which is a hash function. And we're gonna talk a lot more about all of these cryptographic primitives in the next modules, how they work, what their advantages and disadvantages are, where to use them, and why if one of them is good ideas and where not to use them. But let's just do this for now. So ABI.encode fact, because we are going to be using, we are going to be using a string. So, and we can now do, for example, that this is rock. So we can do the same thing for everything else. So I'm just gonna copy this across, just because I'm lazy and I don't want to type. So we can now do this. Of course, they're not all rock. Some of them are papers and some of them are scissors. And of course, it's gonna complain because the tags are wrong. So what we wanna do is actually make it Bix32. And Bix32 is actually a great type that sort of supports. And all the hash of that is always gonna be that. So the hash of any string is always Bix32. And this is why there is the hash collision problems that you see. And now it's going to complain that you are trying to compare a Bix32 choice to a UN8 choice, which is not what you should be doing. So we are going to change that. And say that now people have to play Bix32 choice. Or actually, actually what we can do is we can allow them to play a string choice. And so they can say, well, they're playing that, but again, if we allow string, then it's just open. So what we are going to say is that people are going to be now playing in Bix32 choices. And if they're gonna be playing in Bix32 choice, then we also have to update the mapping to match that. So that's gonna be Bix32 as well. And now it's stopped complaining. So everything is now fine. And we don't have to do anything. So what we can do now is we can delete the contract, which was deployed before. And again, we're gonna use two addresses and you can now do this. To get to make it, so now people have to know what this means. So they have to know. So now anyone who's playing has to know what the rock paper and scissors are and they have to play. And you're not just simply one, two and three. But as you may have already noticed, there is a big problem lying around somewhere. See if you can spot it. And I'll talk about it more in the next video. [ Silence ]