1 00:00:00,000 --> 00:00:06,700 [No Audio] 2 00:00:06,701 --> 00:00:08,923 Welcome again in the new section of the course. 3 00:00:08,924 --> 00:00:10,651 This section is dedicated to 4 00:00:10,652 --> 00:00:12,800 Blockchain using Rust. The Blockchain 5 00:00:12,801 --> 00:00:15,266 technology help in securing transactions, 6 00:00:15,267 --> 00:00:17,766 reduce compliance cost, and speed up data 7 00:00:17,767 --> 00:00:21,366 transfer. These objectives are to a great 8 00:00:21,367 --> 00:00:23,900 extent aligned with the Rust objectives, that is 9 00:00:23,901 --> 00:00:26,800 security and speed. This makes Rust one of 10 00:00:26,801 --> 00:00:29,133 the perfect candidate for deploying and 11 00:00:29,166 --> 00:00:31,200 developing Blockchain as the underlying 12 00:00:31,201 --> 00:00:33,300 environment. Before jumping into the 13 00:00:33,301 --> 00:00:36,000 implementation details, it will be useful to 14 00:00:36,001 --> 00:00:38,633 cover some of the fundamentals of Blockchain. 15 00:00:39,900 --> 00:00:42,133 If you are already familiar with the basics, 16 00:00:42,134 --> 00:00:44,200 then you may skip these videos and jump into 17 00:00:44,201 --> 00:00:47,000 the implementation details directly. However, 18 00:00:47,001 --> 00:00:48,866 if you feel you are not comfortable with the 19 00:00:48,867 --> 00:00:50,733 basics, then I would strongly recommend you 20 00:00:50,734 --> 00:00:53,833 to cover these tutorials fully. The plan is 21 00:00:53,834 --> 00:00:56,066 to start by discussing the very fundamental 22 00:00:56,067 --> 00:00:58,800 building block of Blockchain called a Hash. 23 00:00:59,400 --> 00:01:01,700 Once we understand what a Hash is, then we 24 00:01:01,701 --> 00:01:04,333 will move on to see the detail on how these 25 00:01:04,334 --> 00:01:07,800 Hashes allow us to build a Blockchain. Once 26 00:01:07,801 --> 00:01:09,633 these fundamentals are covered, then we will 27 00:01:09,634 --> 00:01:11,900 move on to the implementation part and see 28 00:01:11,901 --> 00:01:14,500 the implementation in Rust. Let's begin by 29 00:01:14,501 --> 00:01:18,366 talking about Hashes. Consider a scenario in 30 00:01:18,367 --> 00:01:20,800 which you have a very large file, let's say 31 00:01:20,801 --> 00:01:23,933 one gigabyte of file, and you want to send it 32 00:01:23,966 --> 00:01:26,866 over to a friend across the globe. And now 33 00:01:26,900 --> 00:01:30,066 you do not trust the carrier of the file, you 34 00:01:30,067 --> 00:01:32,200 are not sure if the carrier will be able to 35 00:01:32,201 --> 00:01:35,033 deliver the file 100% intact to your friend 36 00:01:35,034 --> 00:01:39,000 or not. There might be some bit swapped, and 37 00:01:39,001 --> 00:01:41,400 you are very concerned about even one bit 38 00:01:41,401 --> 00:01:43,966 changing. We will explain why this is very 39 00:01:43,967 --> 00:01:46,666 important that not even a single bit changes 40 00:01:46,700 --> 00:01:49,366 in some data. But at the moment, consider the 41 00:01:49,367 --> 00:01:51,566 scenario that you are sending a very large 42 00:01:51,567 --> 00:01:54,200 file, and you don't want to send this file 43 00:01:54,233 --> 00:01:56,500 over a secure channel, because that would be 44 00:01:56,501 --> 00:01:59,500 very slow and very expensive. Instead, what 45 00:01:59,501 --> 00:02:02,233 you want to do is, you want to send this file 46 00:02:02,266 --> 00:02:04,900 over a normal channel. But then there is a 47 00:02:04,901 --> 00:02:07,066 problem of making sure at the other end, 48 00:02:07,067 --> 00:02:09,566 that the file has been received correct, so 49 00:02:09,567 --> 00:02:12,600 here's how you do it. You take this file, 50 00:02:12,601 --> 00:02:15,466 let's imagine that, this is that very big, 51 00:02:15,467 --> 00:02:18,133 large file. So the same concept is going to 52 00:02:18,166 --> 00:02:21,000 apply whether it's this piece of text, or it's 53 00:02:21,001 --> 00:02:24,566 a 1 GB file, or if it's even a larger file, 54 00:02:24,633 --> 00:02:26,966 the same concept is going to apply. So for 55 00:02:26,967 --> 00:02:28,900 the sake of simplicity, we are going to take 56 00:02:28,901 --> 00:02:32,100 just this text. So what you are going to do 57 00:02:32,101 --> 00:02:35,233 is that, you will take this file, and you are 58 00:02:35,234 --> 00:02:38,633 going to put it in a function, and that is 59 00:02:38,634 --> 00:02:40,933 going to compute a much much smaller 60 00:02:40,934 --> 00:02:43,700 representation of this whole text. Now that 61 00:02:43,701 --> 00:02:45,700 is being done using a complex algorithm 62 00:02:45,701 --> 00:02:49,033 called SHA or Secure Hash Algorithm, which 63 00:02:49,066 --> 00:02:51,300 applies several steps to compute the Hash 64 00:02:51,301 --> 00:02:54,533 corresponding to some given data. In simple 65 00:02:54,534 --> 00:02:56,966 words, the Hashes are just fingerprints of 66 00:02:56,967 --> 00:02:59,133 the data. The details of the algorithm are 67 00:02:59,134 --> 00:03:01,966 not very important in our context. What's 68 00:03:01,967 --> 00:03:04,500 important is that, this is going to be a fixed 69 00:03:04,501 --> 00:03:07,833 sized string. Typically, the variant of SHA 70 00:03:07,834 --> 00:03:10,566 called SHA256 algorithm is being used to 71 00:03:10,567 --> 00:03:13,233 generate 64 character long string containing 72 00:03:13,234 --> 00:03:16,066 some random numbers in hexadecimal format, 73 00:03:16,333 --> 00:03:19,033 which is referred to as Hash of the data. The 74 00:03:19,034 --> 00:03:21,066 essential characteristic of the algorithm is 75 00:03:21,067 --> 00:03:23,700 that, if you give it just one 76 00:03:23,701 --> 00:03:27,533 character, or give it a whole big file of one 77 00:03:27,534 --> 00:03:30,200 gigabyte, the output or Hash it will generate 78 00:03:30,201 --> 00:03:33,500 will always be a fixed size. Let me put in 79 00:03:33,501 --> 00:03:36,533 one character over here and compute the Hash. 80 00:03:37,733 --> 00:03:39,566 You may note that, this is simple one 81 00:03:39,567 --> 00:03:42,333 character and it is coming out as 64 82 00:03:42,334 --> 00:03:45,266 character long Hash. Now, let me put in some 83 00:03:45,267 --> 00:03:48,166 more text in the box, and it will still come 84 00:03:48,167 --> 00:03:50,433 out as 64 character long string. 85 00:03:51,266 --> 00:03:54,666 Intuitively, even if you put some large texts such 86 00:03:54,667 --> 00:03:57,533 as 15 GB file, it is still going to come out 87 00:03:57,534 --> 00:04:00,366 as 64 character long string. Please note that 88 00:04:00,367 --> 00:04:04,100 this is not a compression, you cannot go back 89 00:04:04,101 --> 00:04:06,200 from a Hash to the original data. This means 90 00:04:06,201 --> 00:04:08,900 that if you only have the Hash, you cannot 91 00:04:09,200 --> 00:04:11,800 somehow get the original data back from it. 92 00:04:12,133 --> 00:04:14,966 However, if you have the same data, whenever 93 00:04:14,967 --> 00:04:16,866 you put it into the algorithm, you will 94 00:04:16,899 --> 00:04:20,433 always get the same Hash value for it. You 95 00:04:20,434 --> 00:04:23,066 consider it as a blank box where you put 96 00:04:23,067 --> 00:04:25,233 in some piece of information and outcomes a 97 00:04:25,234 --> 00:04:28,333 fixed size number. In summary, if you change 98 00:04:28,334 --> 00:04:30,566 the input, the output is going to change. If 99 00:04:30,567 --> 00:04:32,733 you don't change the input, the output is not 100 00:04:32,734 --> 00:04:36,000 going to change. And if you feed in the same 101 00:04:36,001 --> 00:04:38,166 input, the same output is going to come, no 102 00:04:38,167 --> 00:04:41,600 matter wherever you compute it. And you 103 00:04:41,601 --> 00:04:43,666 cannot go back from a Hash to the data, 104 00:04:43,966 --> 00:04:46,500 that's the basic of Hash. Another point to 105 00:04:46,501 --> 00:04:48,533 note is that a single character change in the 106 00:04:48,534 --> 00:04:51,300 data will completely alter the Hash. Let me 107 00:04:51,301 --> 00:04:54,400 add a simple dot at the end of the text. You may 108 00:04:54,401 --> 00:04:56,866 note that the Hash completely changed. This 109 00:04:56,867 --> 00:04:59,333 makes it almost impossible to relate the 110 00:04:59,334 --> 00:05:01,833 changes in the to text with the Hash. The 111 00:05:01,834 --> 00:05:04,000 Hash is a kind of completely independent and 112 00:05:04,033 --> 00:05:05,866 almost impossible to relate it to the 113 00:05:05,867 --> 00:05:10,066 original text. So that is the essential idea, 114 00:05:10,067 --> 00:05:12,133 and all you need to understand at the moment. 115 00:05:12,134 --> 00:05:14,466 The Hash is a kind of a fingerprint of the 116 00:05:14,500 --> 00:05:17,866 digital data. The Hashes are not something 117 00:05:17,867 --> 00:05:20,066 which is new and has been used for a long 118 00:05:20,067 --> 00:05:23,433 time, and has uses beyond a Blockchain. A 119 00:05:23,434 --> 00:05:26,600 nice use case of Hashes would be that, for 120 00:05:26,601 --> 00:05:28,633 instance, you want to store some big file on 121 00:05:28,634 --> 00:05:31,100 some insecure data storage, and you do not 122 00:05:31,101 --> 00:05:33,600 need the same file right now. But in future, 123 00:05:33,601 --> 00:05:35,800 you may need it, and you don't know when 124 00:05:35,801 --> 00:05:38,500 exactly you will need it. So what you do is 125 00:05:38,501 --> 00:05:40,500 that, you compute the Hash of the file and 126 00:05:40,501 --> 00:05:42,800 store it with you. Since the size of the Hash 127 00:05:42,801 --> 00:05:45,866 is fairly small, so it won't create any issue 128 00:05:45,867 --> 00:05:49,966 at your end. Now, after 10 years or so, you 129 00:05:49,967 --> 00:05:52,000 would like to retrieve your files, but first, 130 00:05:52,001 --> 00:05:54,000 you want to make sure that your file is 131 00:05:54,001 --> 00:05:56,500 unaltered and contains exactly the same 132 00:05:56,501 --> 00:05:59,666 contents that you stored. So you will compute 133 00:05:59,667 --> 00:06:01,966 the Hash again and match the computed Hash 134 00:06:01,967 --> 00:06:04,566 that was stored locally with you. If both the 135 00:06:04,567 --> 00:06:06,333 Hashes matches, then you are sure that the 136 00:06:06,334 --> 00:06:09,400 file is not changed, and is the same file. That 137 00:06:09,401 --> 00:06:11,500 was all about the Hashes. In the next video, 138 00:06:11,501 --> 00:06:13,800 we will see how this simple concept can be 139 00:06:13,801 --> 00:06:16,966 used to build what we know as a Blockchain. 140 00:06:16,967 --> 00:06:19,678 See you again and other than happy Rust programming. 141 00:06:19,679 --> 00:06:25,266 [No Audio]