Basic Maths Behind ZKs 02: Modular arithmetics
Basic Maths Behind ZKs · 22:38
Milica teaches modular arithmetic in the second Basic Maths Behind ZKs lesson.
Speakers
Topics
From Basic Maths Behind ZKs, hosted by DappLearning.
Transcript
Yes. Alright, yeah, yeah, sure. So, to, everyone that's listening us, GM or a good evening wherever you are. So, welcome to the second lesson of basic maths behind Z case course. So my name is Minutes. I also know and in Xerox minutes through Twitter and other social accounts. And, yeah, last time we spoke about, what makes ZKK, And this time, We speak about modulus and modular.
So. Let's see if I can share my screen. And and my Yes, I might need the permission to have a. Hmm, yeah. I don't know guys, can you see my screen? Yes, we can see it very clearly.
All right. So. Welcome. Everyone. And, yeah, so, Something we usually You throughout the daily basis. But we're not always quite aware of it. So, usually every time we take a look at our watch. Our hand watch and if we're using a mechanical one and basically that's something that older people when we are telling the time as kids, we will, also, first, thought how to take a look at the mechanical one.
So, let's see and let me show you that you already know something of modulus. And you're not to, using it every day. So we'll create. Kind of a circle. Oh, you, we want to draw. Yeah, so basically a clock. Okay, so it will be divided into pieces. That's No. And let's cut it then into even small pieces.
Okay, now go with 7. Okay, this is not really equidistant. That's okay. Okay, the 2 points. And then let's say we want to say we want to tell it's like 30'clock. Usually. People know that this marks 30'clock right. But this can also be 3 am. And it can also be 3 pm. So what do we do? Like we know that like one day.
Equals 24 h. But, what we now is like, we didn't have 24 marks on clock, right? So when we say it's 15. 1500 that actually means it's 3 pm So how do we do that? We did that using modulus actually. So we want to divide. 15, right? We want to divide at what's 12 and in the world of.
Whole numbers that would be one with residual of 3. That residue we take as modulus. So that's like, you can you can tell that 15 is equal to 12 plus 3. That would be perfectly fine. And you can add up, numbers like that and always like if you do the modulus it will be always. Oh, this result. So we can say 15. Modulus 12 is 3. So this one says basically the same as the up one.
Okay, and you can tell like, yeah, it's. 3 PM. Yeah, it's like 15. 15 h. That means it's 3 PM. So, that's how you can tell that you already knew modulus before showing you this. So, we can also tell. That's, that you know, that you have seen modulus on a daily basis, right? So yeah, like, let's let's make another example. So.
Why is module is important? Because, if it would take, for example, if you would add 12 more to this. Like 15 plus 12. It will go to 27. And if we would do 27 modulus. 12, it'll also be 3. Because we have. 2 times 12 into 27. And that would definitely yield the same result. So. Doesn't matter how much you add up 12 because that is the modulus. So that is that is the base.
It will always use the same result. So you can say like 5. Modulus. 3. It would be too. Flat, so I would say like 8. Why do you think that would be also 2? Why is that? Because 8 is 3 plus 3. Plus 2. So you see like doesn't matter how many times You repeat this. The base of the modulus, it will always yield to the same result. So it means that if, you get the result of modules, and you say it's 2 and you have something like of.
Let me let me try. So if you have like a modulus 3, so something modules 3 equals 2. You don't know, like, you don't know how many times 3 repeated in itself. Like this can be also 2. But this can be also 5 and this can be also 8. And so on and so forth. Doesn't matter how many times we add 3, the model will always be the same, this kind of residual we have. From circle. So we can tell that this one is also congruent to 13. Sorry, it's it's also congruent to to to 13.
This is also congruent to 14. And yeah, you can tell that from 2. Yeah, it can be 2 a. M. But it also can be 14. Ours. So And a matter of fact, We all do modulus on a daily basis. So yeah. One thing. That we can also do modulus with negative numbers as well. In fact, modules can always and only be positive number, it can never be negative number. So let's say what's this. I don't know if you can see, but yeah, I suppose you can.
I come if we have Yeah, so let me write something. So if we have if it draw a line And then and then we can say okay. This is 0. This is one. This is 2, this is 3, I will. We're again talking about whole numbers. But if we want to Negative numbers. Okay, so it's minus one. Minus 2. Minus 3. So how do we calculate models in this case?
In this case what we do is we're adding up sorts of we're adding up this part until we reach the positive number. So for example, in this in this example of a clock. If we would say. Okay. If we would say, what is minus 3? On this chart okay so I had to do like minus 3 modulus 12 So what would that yield? So we can go like in the opposite direction. From. From our 0 to say so and we can count like 1 2 3 it will be 9 But how so?
You can tell it this way. So you can say like minus 3. Plus 12. Yeah, in the end it equals 9. So. Yeah, modules can never be negative. So this results. We, we had, they can never be negative numbers. But we can use negative numbers to. In modulus and make A good result, a positive one. Okay, so let's take a look at some more practical example and cryptography. So, guys, let's let me know if you can see the alphabet here. Like, do you see complete alphabet or do you see a part of it?
I can see a complete. Alphabet. Alphabatic. Okay, okay. Yeah, yeah, because I'm seeing a part of it, due to zoom. But yeah, so. Where is the application of modules? So in cryptography. We have Let's see. Cy for Methods. So with this, this is 1 one of the oldest. Math is in cryptography. So we're actually assigning other numbers. So I don't know if you can see, yeah, you should see that every every Well, that's of the alphabet has some assigned number.
And then, yeah, we do assign. And sign those numbers because we want to Let me see, check. So because we want to, Mix those and have something that is not in plain open message. So that's, let's say a general and a battle can have, different, different kind of message. But still be able to read it. Because they know the key. Alright. So. Let's see. So I have prepared something. So this So since we had 26 numbers of the alphabet So we can say we do modules by 26.
Alright, and. Yeah, since you can see the alphabet. Alright. Okay, so we can do, We can do. So we can do Caesar cipher. So Caesar cipher has A key of 3. What is that mean? That means that we're simply shifting. From, A, we're shifting to D and from D, we're shifting to G and then you have something that's encrypted message.
And it's completely scrambled, you cannot read it unless you know the method that is used and the key. And, and you can you can send a plain message but maybe someone can intercept it some kind of Eve cause there's always Alice and Bob in cryptography and so on wants to try to read it in a plain text. So you can, you can say, you can say like, okay, let me see, okay, let's. Oh, this way so everyone can see. Okay.
So you can say like Alice send some kind of message to Bob. It's Usually like that but some kind of Eve she wants to accept that. She wants to know what Alice sent to Bob. So, but Eve does not know about shifts, shifts I formatted and does not know about the key. So you will have, bad time trying to intercept the message. So we have we have here. Right. Message.
Yeah, write something about Z case, why not? So we can say ZK. Is Awesome. Do we all agree on this? We'll take a look at the table. And. The the numbers that for under our So we take a look at Z and we can say it's numbers 25. We can take a look at K here and we can tell it's time.
So we can take a look at I. And say it's okay it's The number is 8. For us, we have 18 for A, of course, we have 0 because that's why it begins. For W, it's 22 for E, it's 4 for S, it's again. 18 for all, we have. 14. For M we have 12 and for E we have 4. So this is a plain message. Everyone can read this. So we turn this into numbers.
So what are we going to do with Caesar's side for, with every of these numbers? We're adding 3. To all of those. So we'll end up with something like this. 2813. 1121. Okay, 25, 7, 21. So, 1715 and then 7. Okay, so if we Try to go from the last one to the first one even though that this North rule.
Well, and it's with something that's completely unreadable. So we'll end up with, so here is, right here is age. For 15 we have P for 17 we have R. Or 21 at 3. 4 7 it's H. 25 versus z. 3 21 V again. L for 11 for 13 we have N. And for 28, okay, when we take a look at our table, we don't have 28.
Right, so we have to do it modulus. And, with dad. So if we take a look at 25 in the end, so it's z. So we have to do some sort of shift. 3 times and then. Yeah, so, okay, sorry. So we have to do 28 modulus. 26. To see what it yields to. So like what?
Kind of. Later we're going to have out of this alphabet. So you can imagine it can go, so we have, we could have like the bigger keys like, 20 and then most of the alphabet will have those modules but they will not have you will not have like 40 but you'll have 40 modulus 26 So what's, this yields to, so yeah, like when we divide 28 with 26, we'll have one. And then the residue of that is 2. So, we know that, that's how we calculate modulus now. So we take a look, which 2. So we take a look at our table and say it's See, so this is our Sort of encrypted. Message. That Eve cannot read.
So you see it says like CN LD DZ H. The RPH. Doesn't say the DK is awesome, but in a way it does say because if if the other party if Bob Now that we're using Caesars. And a cipher method. So the shifting with the key of 3, he can definitely use the same thing and try to reverse it and it will have the message that still ZK is awesome. So. So I think. We, we can take some other methods too. Like, But I think, we might do this in other lessons too.
So, so far so great guys. Do you have any kind of questions? For me. Actually, I think it's very clear in simple for me to understand it. Thank you, Melissa. And I have no other questions and I'm really looking forward to the next lesson. Thank you. Yes, so for the next lesson we're going into polynomials. And, that would be then the third lesson of our, basic maths behind the case course and then we'll have the fourth one.
So yeah, like, guys, if you have anything else to ask and it does not come to your mind. Pride white, please write medium, telegram, Twitter, whatever. Where we find suitable and yeah. Till the next lesson. Sure. And if people have some questions they can leave the comment on YouTube or on or in the Wechat group and we can forward the message or forward the question to you. And every people feel free to ask anything one about the case.
Yeah, yeah, yeah, sure. I like, my Twitter DMs are open. So the privacy setting is open for everyone. To, sent. A message so Yeah. Yes. And I think. I think your lesson is clear enough and they don't have some questions. So let's wrap up the session and have a good day or have a good night. Yeah. Cool. Thank you.
Yeah, depending on the time zone you were in. Yeah. Thank you. Thank you all and to see you in the next lesson. Yeah, I see you in the next lesson. Goodbye. Bye bye, thank you.