Hey everyone. Ed Amoroso here and in this video, we can call this part two of our discussion in and around block chain. Now let's go back. In the 1970s, we had this problem with block ciphers, block encryption, where a block of bits, say 64 bits in the data encryption standard or similar algorithms. You had 64 bits you'd encrypt it, and you get 64 bit output, then 64 bits you'd encrypted gets 64 bit output, and there wasn't such a great idea because you could potentially signal Alice doing that to Bob, could signal Eve by fixing the 64 bit patterns, like 64 zeros encrypts to something, then 64 zeros encrypts to something, then 64 ones encrypts to something different and so on, and it creates a covert channel. So the designers at the time had come up with this idea that maybe by linking the cryptography and subsequent blocks, you could close the covert channel. And that was the main reason you did it at the outset. If we turn the clock back 40 years or so, we'd be talking about block chaining, cipher block chaining, we called that CBC, really is a way of tightening that channel. And most of the cryptographers at the time would have told you, that's an obscure aspect of cryptographic design. When this thing that you'd be talking about on television, and reading about in articles, and they would be astounded if they knew that some number of decades later, we all came to this amazing conclusion that chaining was useful to our society. Astounded. But here's how it outworks. So let's start with the concept that we introduced in part one of our block chain discussion, where we have a data record. Again, we'll assume that it's financial and somebody is giving money to someone else, and we're going to have a nonce. And in the previous video, remember, we said the nonce and the data record, we'd encrypt to produce the hash value. And we decided we wanted that to start with four zeros. Well, now to cover the chaining case, which we'll get to in a second, what we're going to do is add yet another component to the hash, and keep in mind I'm just composing a bunch of zeros and ones. So when I take a nonce, it's a number, when I take the data record, that's a number. And I'm going to add another number which I'm going to call, in some sense the previous hash, and I'm going to take those three components composed, hash the thing, and produce the value. That as I flip the nonce again, has to start with four zeros. Okay. Now, the problem that you have when you ever design an algorithm that reaches back to the previous one is that once you roll in your role, there's no problem. If I'm looking at a train rolling by and I point to a train car and I say, what was the previous one, you go with that one, the one that came before. But the problem is, the first one never has a previous one. Right? So what we have in block chaining is the idea or concept of a genesis block, which we just make up, it's another nonce. It's something we make up as if it were the hash of a previous value. But if we haven't hashed a previous value, we won't have a hash genesis. So, in this first example, we've got nonce, we have data, and we have this genesis previous block. I'm going to go ahead and spin the nonce, do it over and over and over again, keep hashing until I get a value and output that has the four zeros and some arbitrary pattern afterwards. I'm happy, I get it good. I call this in some sense a mind block. I'm good. Now, another record comes along. Somebody is doing some financial thing. It's somebody else transferring money to somebody else. But what I'm going to do now is instead of doing the hash of that in a context free manner, I'm going to do it in a context sensitive manner, by taking the output, that hash that I produced with the previous block, and I'm going to use that now as the previous value in the new hash. So now, I've got a new nonce. I've got the new data record and I've got the previous value from the previous one. I did put those things together, compose them, take a hash of that, spin the nonce, keep going and eventually, I get four zeros and I stop and I go, okay we're good. So now I've got two records, and they both have been mined in a sense. We're really good shape. They both have the right output and they're chained together right. Meaning if I make changes, that could have unusual consequences which we'll get to. Let's do another, the third record comes along. Somebody doing some financial thing. I do the same thing. I take the output, the hash of the previous block that gets used in the computation for the present block. I mine using the spinning the nonce, I finally get some sort of output, I'm totally psyched, this looks great. I've got three records here, got three outputs. We're in good shape. I can do a fourth one. Fourth one, you see, you can change forever in this manner, that makes sense. So four blocks, a chain set of records here and it's indicative of that early conceptualization, the CBC that we had from IBM in the 1970s, and yes it certainly closes covert channels if that was something you were worried about. But the reason this is cool, is because watch. If I go back, let's say I'm a hacker, and I go back to the second block, the second transaction that we talked about in our progression, and I changed some value, financial value of a bigger number. What happens is, it messes everything up in a subsequent manner. Meaning, by changing the value of the record, I've now messed up the hash that corresponds to that record. The nonce is the same, the previous block is the same, the data record is changed. So now as that gets re-computed, just continual recompute on change. Now what? Now I've got a problem and it cascades out because now that I've changed the hash value that feeds the next record, the hash value is different now. It's been changed so re-compute it. Now that is no longer valid, and on and on and on, let's gives some of the colossally lucky case where something does happen to be four zeros, is very unlikely. You pretty much have a mess. So what do I have to do now? I have to go back to block two, get if from the bad guy. I have to go back. And I say, all right I want to leave the record, I want the more money there. So what do I do? I go through and I constantly change the nonce, changing, changing, and eventually get to a bunch of zeros, four zeros but a new pattern. Okay. And that new pattern now feeds the next record which will again not be valid. You have to go into the next record and fix that one. I've got to go through and do the nonce, spinning the nonce until I get through. Now keep in mind, this is taking some time right? And while you're doing this, the whole chain might be continually growing. Let's say the chain has a bazillion entries, and you're going way back to half a bazillion. In order to change, you now have to go half a bazillion out to catch up, and it might still be growing, get the point? Big problem there. Then finally, I might eventually catch up to those four blocks, but you see how the amount of work here to do this, could be set up such that the likelihood of you being able to catch up is low. And also, I am changing that hash chain. There's no question that the output values here from a hashing perspective are going to be different. And we don't have a lot of time here in these videos, but as you go off and if you investigate and learn more about block chain, I hope you do, I hope this jogs your interest, and an introduction to a topic that's very rich. You'll see that architecturally, the way multiple block chains can be set up, is that they in some sense can be providing validation on each other when something changes. Very, very cool, very deep concept and something that I think has been an interesting contribution to computer security and to computer science. Now, as an individual or as a little individual, additional consideration for you to keep in mind as you think about this, I want you to think about that concept of an amount of work being in some sense a safeguard. Right. If you do something bad, that the way to recover from your attack so that you don't get caught, is you have to do a bunch of work. And an interesting thing about block chain is it uses that amount of work as a type of safeguard. Think about that. It's a pretty good idea. You know that if you're going to do something bad, it's not going to be easy for you to recover. I'm not going to make it easy for you. I think that's a good design goal or design concept as we build cyber security systems for enterprise, for infrastructure, and even for your individual PC. So, I hope this has been a fun introduction to block chain and I hope it inspires you to go in and dig and learn a little bit more. I'll see you in the next video.