1 00:00:00,150 --> 00:00:06,120 Now coming to finding the Modula involved, now to calculate the Modula involved, to determine the 2 00:00:06,120 --> 00:00:12,740 decryption key, you could take a brute force approach and stop testing the integer one and then two 3 00:00:12,750 --> 00:00:13,800 and three and so on. 4 00:00:14,250 --> 00:00:18,850 But this is the time consuming for large keys if you have some very light. 5 00:00:19,410 --> 00:00:25,800 So fortunately, you can use the Euclid's extended algorithm to find the modular inverse of a number, 6 00:00:25,800 --> 00:00:31,620 which is a pipe which in Python basically looks like we will use it by defining a particular method. 7 00:00:32,470 --> 00:00:42,490 OK, just for your understanding, if we define here, say we find more inverse which stick to a common 8 00:00:42,570 --> 00:00:51,550 aim as the parameters and here we check if gcd acoma am ok. 9 00:00:51,840 --> 00:01:00,180 If that is not equal to one, then we are seeing Halyburton none and then we use he'll say you want 10 00:01:01,020 --> 00:01:06,540 you to Yewtree as equal to one zero eight respectively. 11 00:01:06,870 --> 00:01:14,300 Similarly say v1 v2 v three equal to zero one for example. 12 00:01:14,610 --> 00:01:18,450 And we say Hyle V three is not equal to zero. 13 00:01:18,540 --> 00:01:27,330 We are putting it in two is equal to say you three and we are saying we want we to be three. 14 00:01:27,820 --> 00:01:35,530 You want you to use three is equal to say you one minus you multiply it by one. 15 00:01:36,120 --> 00:01:47,970 Similarly next you two minus, you multiply it by two and next so you three minus skew multiplied by 16 00:01:48,420 --> 00:01:55,090 V three and one comma with two comma V three. 17 00:01:58,110 --> 00:02:02,690 OK, and then finally we say return. 18 00:02:03,180 --> 00:02:05,700 You want Modula and OK. 19 00:02:05,740 --> 00:02:11,880 Now in this basic example that we have done, you need to understand how the Euclid's extended algorithm 20 00:02:11,880 --> 00:02:12,390 works. 21 00:02:12,390 --> 00:02:18,480 OK, now as long as you have two arguments to posit to define more inverse function, which are relatively 22 00:02:18,480 --> 00:02:23,100 bright, it will return the modular inverse of the given of particular parameter. 23 00:02:23,530 --> 00:02:28,920 So succumbing to the integer division operation, we won't see if this is just for your understanding 24 00:02:28,930 --> 00:02:29,410 corpus. 25 00:02:29,920 --> 00:02:37,140 OK, now you may notice that the double slash operator is used in the if you just look at this, you 26 00:02:37,140 --> 00:02:44,180 must have noticed here of you have made a mistake that the skill is equal to we have to do you three. 27 00:02:44,550 --> 00:02:47,220 Now, that is double slash V three. 28 00:02:47,640 --> 00:02:54,870 OK, now if you have noticed that we have used the double slash operator, OK, now we divide two numbers 29 00:02:54,870 --> 00:02:59,670 and rounds down to the nearest integer if we want to see how this operator looks. 30 00:02:59,670 --> 00:03:07,140 OK, if we go back to our interactive shell and if we say, for example, thirty one divided by seven, 31 00:03:07,140 --> 00:03:09,390 we get some numbers in the numbers. 32 00:03:09,660 --> 00:03:16,380 But if we say the decimal numbers, if we say double backslash seven, we get it rounded off to four 33 00:03:16,650 --> 00:03:21,120 or we get to see then by five that already comes to two. 34 00:03:21,420 --> 00:03:27,320 OK, so over here variable, you are getting the equation or whatever that expression is evaluating 35 00:03:27,330 --> 00:03:28,430 the decimal point. 36 00:03:28,680 --> 00:03:32,920 If we use a double backslash, OK, you are getting a whole number of it. 37 00:03:33,300 --> 00:03:36,090 So a division expression that do not divide evenly. 38 00:03:36,090 --> 00:03:40,540 The double slash operator is useful for getting the whole number part of the answer. 39 00:03:40,920 --> 00:03:43,150 This is sometimes also called the ocean. 40 00:03:43,410 --> 00:03:49,580 Now, while the percentage operator gets the remainder, an expression that uses double digit division 41 00:03:49,590 --> 00:03:53,090 operator always evaluates to an end, not of look. 42 00:03:53,400 --> 00:04:01,950 OK, so for example, if we said then divide by five point the same thing, if we say then divide by 43 00:04:01,950 --> 00:04:04,080 five, we get only two two point zero. 44 00:04:04,500 --> 00:04:08,040 So now let us write down a source code for a math. 45 00:04:09,330 --> 00:04:15,420 We would be using a juked and the Finemore inverse method only when Mausi for programs later. 46 00:04:15,750 --> 00:04:18,930 But over here we would put both of these functions into a module. 47 00:04:19,200 --> 00:04:24,420 So as we have created this way, we have already defined the Finemore in. 48 00:04:24,690 --> 00:04:32,970 The first thing we will try out over here is we will define the GCD pass A comma, B and as the parameter. 49 00:04:33,210 --> 00:04:44,460 And here we would say while A is not equal to zero, we are seeing a comma, B is equal to B modulo 50 00:04:44,580 --> 00:04:52,380 E and A, and then we use on the value of B that we end this function. 51 00:04:52,620 --> 00:04:57,420 Then we have defined more involved which is taking again and amosite parameter. 52 00:04:57,810 --> 00:04:59,580 And here we are checking if. 53 00:05:00,600 --> 00:05:09,420 My aim is not equal to one then we are saying return not OK, otherwise we are calculating the extended 54 00:05:09,900 --> 00:05:13,070 Euclidean algorithm and we are seeing here. 55 00:05:13,290 --> 00:05:14,790 See you and you two. 56 00:05:14,790 --> 00:05:16,800 You three is equal to one zero eight. 57 00:05:17,070 --> 00:05:19,440 And we want to be three is equal to zero one. 58 00:05:19,440 --> 00:05:20,790 And then we say height. 59 00:05:21,210 --> 00:05:22,870 We three is not equal to zero. 60 00:05:22,890 --> 00:05:27,060 We are saying give you three double more slash V three. 61 00:05:27,660 --> 00:05:34,920 And now here we have uses integer division operator and then we have used this assignment operator. 62 00:05:34,920 --> 00:05:42,060 We are going to use one model and now this program contains the GCD function described earlier and defined 63 00:05:42,060 --> 00:05:49,150 more inverse function also, which implements your Euclid's extended algorithm now after importing this. 64 00:05:49,240 --> 00:05:56,460 Now suppose we save this say are saving it in our intermediate level for long and we give it a name 65 00:05:56,460 --> 00:06:00,820 C Cryptome at one be OK. 66 00:06:01,110 --> 00:06:07,200 And now if you have to suppose, go to the interactive shell here and the first thing you'll see is 67 00:06:07,200 --> 00:06:13,650 import C Cryptome up one dot or import Cryptome that one. 68 00:06:14,500 --> 00:06:20,020 Also this import Krypto math one. 69 00:06:20,230 --> 00:06:31,380 OK, and now if we see Krypto that one dot we use to find out some number, we get the values. 70 00:06:31,650 --> 00:06:38,910 Similarly, let's use one more C Cryptome, that one or GCD some different number. 71 00:06:39,720 --> 00:06:40,620 We still get it. 72 00:06:40,890 --> 00:06:53,040 Or if we try to use Cryptome at one dot say find more inverse, forgive FF7 comma twenty six or if we 73 00:06:53,040 --> 00:07:01,860 try Cryptome that one or find more in what we give the higher number. 74 00:07:02,430 --> 00:07:04,050 OK, let's see 75 00:07:06,910 --> 00:07:10,450 one find more inverse. 76 00:07:11,130 --> 00:07:17,060 We give you say eight nine five three eight five one C twenty six. 77 00:07:17,760 --> 00:07:18,180 Yeah. 78 00:07:18,270 --> 00:07:19,530 You get the particular value. 79 00:07:19,690 --> 00:07:26,550 OK, so in this way you can see you can call the function also and you find more inverse function to 80 00:07:26,550 --> 00:07:33,370 find the jackdaw modular inverse for you will know this particular file we would be using in our next 81 00:07:33,370 --> 00:07:34,900 session for implementing. 82 00:07:34,900 --> 00:07:36,030 We are fine cyphers.