What You Need To Know To Understand Blockchain Technology Part 3

Mathematical functions. Hashing functions.

Not only do blockchains secure transactions with public and private cryptography keys, but they also secure the blocks of blockchains with cryptography hashes.

Brief introduction to mathematical functions

In cryptography, a hash is a function that turns a large set of data into a much smaller set of data.

You use mathematical functions similar to hashing on a daily basis. A function is something that takes an input and creates an output. For instance, you use the function of addition all the time. When you add two and two, you get four. Mathematically speaking, you are applying the function of addition to two elements: 2 and 2. The result of the application of the function, is one element: number 4. Another way to record the function and its result would be add(2, 2)=4

You also use the function of subtraction all the time.

When you say that, for example, seven minus three equals four, you apply the function of subtraction to two elements and get one element as a result. Here’s how the record of this would look: subtract(7, 3)=4. With most functions that people use on a daily basis, it is possible to apply them to a number of elements. You can add three, five, twenty, one hundred different numbers and you will end up with just one number.

Hashing functions

Hashing works in a similar way. Examples of popular hashing functions are SHA-224, SHA-512, SHA-256, MD5 and others.

Just like the function of addition, the hash function can process a set of data of any length.

The difference between addition and hashing is that hashing works with any kind of elements, be it numbers, letters or other symbols.

The result of a certain hashing function will always have the same length. For example, let’s say the result of the imaginary hashing function IHF1 is always equal to four symbols. This means that no matter what set you put into the function, you will always get four symbols. For example, IHF1 (1,2,3,4) could be XX02, and IHF1 (1,2,3,4,67,7) could be QaaB.

The strings on real blockchains are longer, but they work in this very way. For example, block #528703 of the Bitcoin blockchain contains information about 1,600 transactions, yet the hash for these transactions under SHA-256, which is the hashing function that the Bitcoin network uses, is 000000000000000000222c3efad550836474f7bea3b5285a38cc6574c57d1069. You can see this and other information about block #528703 of the Bitcoin blockchain on the Bitcoin blockchain explorer at https://blockchain.info/block/000000000000000000222c3efad550836474f7bea3b5285a38cc6574c57d1069.

Properties of hashing functions

Whoever has a set of data and access to a hashing function can easily produce the function for the data.

This is the reason why the Bitcoin network has the difficulty parameter. Without this parameter, creating blocks and hashes for the blocks would be an easy task for most modern computers. This means that without difficulty and consensus algorithms, attackers could try and modify transactions on the networks and then create new hashes for them and seal them in the same way that the Bitcoin network or some other network seals and connects hashes. This could easily lead to the existence of almost an infinite number of blockchains and the network not being able to tell which one is the legitimate one and which ones are not. The existence of difficulty on the Bitcoin network solves this issue.

The next property of hashing functions is that a hashing function will produce one and only one hash for one set of data. Also, even very similar sets of data will have very different-looking hashes even using one hashing function. Practically speaking, this means that a hash to a set of data is what a fingerprint is to a person.

Having an access to a highly secure hashing function such as SHA-256 is a great way to verify the validity of data. Let’s say a user A needs to send some information to user B. The information is highly sensitive, so both A and B want to make sure that nothing is lost or damaged in transmission. To check the validity, user A can generate a hash for the information and send it to user B in a separate message. Not only that, but he also doesn’t even have to send the hash in a secure way without by itself a hash is completely useless. After receiving the information, user B can run it through the same hashing function as user A did and then compare the hashes. If the hashes match, it means that the information has arrived undamaged. If the hashes do not match, it means that there has been a problem on the way.