Implementing privacy on the smart contract
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo 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.
Get unlimited access to newline's Introduction to Privacy on Ethereum, plus 70+ \newline books, guides and courses with the \newline Pro subscription.
[00:00 - 00:09] 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.
[00:10 - 00:22] 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.
[00:23 - 00:34] 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.
[00:35 - 00:53] 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.
[00:54 - 01:10] 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.
[01:11 - 01:22] 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.
[01:23 - 01:26] So we can now do this. Of course, they're not all rock.
[01:27 - 01:37] Some of them are papers and some of them are scissors. And of course, it's gonna complain because the tags are wrong.
[01:38 - 01:47] So what we wanna do is actually make it Bix32. And Bix32 is actually a great type that sort of supports.
[01:48 - 01:58] And all the hash of that is always gonna be that. So the hash of any string is always Bix32.
[01:59 - 02:14] 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.
[02:15 - 02:20] So we are going to change that. And say that now people have to play Bix32 choice.
[02:21 - 02:34] 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.
[02:35 - 02:48] 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.
[02:49 - 02:54] So that's gonna be Bix32 as well. And now it's stopped complaining.
[02:55 - 03:00] So everything is now fine. And we don't have to do anything.
[03:01 - 03:12] 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.
[03:13 - 03:22] To get to make it, so now people have to know what this means. So they have to know.
[03:23 - 03:36] 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.
[03:37 - 03:44] But as you may have already noticed, there is a big problem lying around somewhere. See if you can spot it.
[03:45 - 04:13] And I'll talk about it more in the next video. [ Silence ]