Hello and welcome to this fundamentals of cryptography.
Course, in the previous two sections in this course, we've been talking about encryption algorithms.
We talked about symmetric key and asymmetric key encryption algorithms, which, while different, are
designed to fulfill many of the same purposes.
In this section.
We're going to be switching gears entirely and starting to talk about hash algorithms, which are similar
to encryption algorithms, but designed for very different purposes.
In this video, we have three main topics of discussion.
We're going to start out with an introduction to hash functions.
Discuss some of the properties of hash functions.
And then finally discuss some of the potential high level applications of hash functions.
So what is a hash function, hash function?
These are a kind of an odd case in our discussion so far in that they're a cryptographic algorithm,
but not an encryption algorithm.
So one of the differences is they don't use a secret key when you're using a hash function.
All that goes into the hash function is the input and then it produces a hash output and hash functions
are actually deterministic.
So you can put the same input in any number of times and always produce the same output.
However, you don't need that secret key.
That's essential for confidentiality, which is good because hash functions actually are not designed
to provide confidentiality.
Instead, hash functions are focused on protecting integrity of data.
And then finally, and this is often a point of confusion.
Hash functions are not reversible.
So one of the important features of a cryptographic encryption algorithm is that it's reversible.
You take the plain text in a secret key, you produce a cipher text.
And then if you apply the appropriate secret key and decryption algorithm, you can get back to the
original plaintext.
And this is important because encryption algorithms are designed to let you securely transmit data over
an untrusted or insecure channel.
Hash functions have no desire to be reversible.
And in fact, throughout the next few videos, we'll talk about all the reasons why they actually can't
be reversible.
And this is an important fact to take away from this video is that hash functions one way, functions
not reversible.
So there's no way to undo a hash.
And so hash functions are like cryptographic algorithms in that they use many of the same principles
and mathematical functions and operators as an encryption RC rhythm.
So hash functions are cryptographic algorithms.
Know if you dig into the details of one, you'll see many of the building blocks of cryptography that
we looked at earlier in this course.
However, they have a very different goal from encryption algorithms.
And so now let's talk about some of the properties of hash functions.
So a hash function is designed to be a deterministic, a one way function.
So I mentioned this on the previous slide, but it's worth repeating.
Reversing a hash function is impossible.
And in fact, that one way nature of a hash function is essential to its security, because one of the
main goals of a hash function is to ensure that given an input, you can produce an output.
But given an output, you cannot reproduce the input.
This is essential for integrity, protection of hatt STADA.
And also, to an extent, protecting the confidentiality of data, for example, by hash, a piece of
data can only give you the output.
You don't know what the input that I used was.
Also, hash functions are deterministic.
And this means that harshing the same input always produces the same output.
So there's no randomness and a hash function.
They make a random looking output, but that output is actually deterministic.
And this is going to be important throughout our uses of hash functions throughout this section, because
hash functions are often used to protect integrity.
And so you have the data and provide the data alongside its hash.
And then at the other end, someone can hash that same data.
Compare the two hashes and make sure that they're getting the data that you originally sent.
Another concept with this integrity protection is collision resistance.
So hash functions are designed to be collision resistant.
And we're gonna dive into this a lot more deeply in a later video.
However, at a high level coalition, resistance means that it's hard defying two inputs that produce
the same output.
Mathematically, there are an infinite number of potential inputs that produce the same output.
A hash function can take anything as an input and produces a fixed sized output.
And so when you go from infinity to a finite set, you're mapping a smaller infinity, but still an
infinity of inputs to each of the possible outputs.
And so it's definitely possible to find two inputs that produce the same output.
Hash functions are designed to make that as hard as possible.
And so now let's talk about some applications of hash functions.
So I mentioned a few times so far in this video.
Hash functions are used to protect data integrity.
And the reason why is it's hard to find another value that produces the same hash.
So this protects against accidental changes.
If you're transmitting some data and one big gets flipped, it's going to produce a different hash,
makes it detectable.
If you're transmitting some data and someone modifies it or replaces it.
But the hash is not been replaced.
Then the data, when it reaches the other end, won't produce the original hash.
And so the modification will be detectable again.
And so, for an example of an application of hash functions in a theoretical concept text, let's talk
about Merkle trees.
So Merkle tree is built using hash functions.
So down at the very bottom of this tree, we see L1 through L4.
These are our data blocks.
So this is information that we are storing in this tree at each level above each of these data blocks
we see has zero zero, has zero one, has one zero and has one one.
Each of these are calculated by hashing the value below it.
And then at the next level up you get hash zero and hash one by concatenating the two values below it
and then pashing that to produce the new output, the top level.
You can capitate the two values and hash the result to produce the top hash.
So let's look at some of the advantages that this structure provides.
It protects data integrity.
And the reason why is I've got L one through L four and then assume I've got my top hash if I know what
l one through L four are and they're ordering.
Then I can recreate this Merkle tree from scratch and produce its top hash, which I can then compare
to the top hash that I've been provided, which is helpful for ensuring data integrity.
I can compare those.
I can assure nothing's been modified and that the four data blocks that I provided are the ones used
to originally build the tree.
It also can provide some level of confidentiality.
For example, let's say that I am creating a data structure with these four different data blocks.
And I want to prove to you that L one is in this tree, but not provide any other information.
I can do that.
What I could do is provide you with L one hash zero one and hash one from L. one.
You can produce hash zero zero and then you can build the rest of the tree from there.
You can produce has zero.
And in combining zero on one to produce the top hash, you can then compare that top hash to a top hash
that I provide to you.
And see that they match and do to how hash functions work.
That collision resistance that we mentioned.
There's no other version of the tree that I could easily find that does not contain the value.
One that still would create that valid tree that I've showed you.
And so if you trust that the top hash value is correct, and then you can easily verify that L L1 is
part of that tree.
And then finally, this is helpful because it provides a compact summary of data without one L two L
three L for these values could be huge.
However, by storing them in a Merkle tree, I can ensure data integrity as we've already discussed,
but also compactly summarize them because I can say this is the top hash of the data tree, all stored
that securely somewhere.
And then I'll store just the list of trend data blocks somewhere else.
And you can easily verify that those data blocks match up with the top hash I've stored in my more protected
or secured storage.
And so these are a few advantages of a Merkle tree that are provided by the use of hash functions.
And so now is a quick recap.
We talked about what hash functions are, how they're cryptographic algorithms, but not encryption
algorithms.
A few of the properties of hash functions, they're designed to be deterministic one way in collision
resistant.
And then we talked about how a hash function can be used in a Merkle tree to provide a few different
advantages.
Thank you.