Copyright © 2017-2019 LHCrypto
All rights reserved.

Articles

Learn All the Necessary Information about Hashing

03/25/2019
|
  • mining_cryptocurrency
Articles list

Many of you have probably already heard about blockchain technology, but it is important to know about how hashing works in this system. Blockchain technology is one of the most innovative discoveries of the last century. We can say so without exaggeration, as we observe the influence it has had over the past few years and the influence it will have in the future. In order to understand the structure and purpose of the blockchain technology itself, we must first understand one of the basic principles of blockchain creation.

Blockchain and Hashing

Wikipedia defines a blockchain as a chain of transaction blocks. The word “blockchain” literally means a chain of blocks. But, this definition does not convey the whole essence of this new technology, on which Bitcoin cryptocurrency is built. So what exactly is a blockchain? And what are its advantages over other ways of organizing and storing data? To begin with, the blockchain is a distributed database, full copies of which are located on a set of servers (computers) integrated into a peer-to-peer network.

It follows from this that the blockchain cannot exist only on one computer (server).

A peer-to-peer network, also called a peer-to-peer (P2P) network, means that all computers integrated into it have the same rights and there is no main (central managing) server. The technology of the blockchain, as an organization of data, ensures safe and complete storage of information. Those. Any changes to transactions already recorded in the blockchain are impossible - you can neither delete nor correct them. And this is a very important point! Since we are dealing with financial transactions. And also there is no single trusted centre (bank) that would monitor the safety (immutability) of these transactions.

How is it organized in the blockchain? Let's try to figure it out. The hash code or simply the hash (hash) of an array of information is similar to the fingerprint of a person — it is a unique short character string that is inherent only in this array of incoming information. Just as a fingerprint is inherent in only one person and there are no people with the same fingerprints, the hash is inherent in only one set of input data.

So What Is Hashing?

Hashing is the calculation of the input data of a certain number used to control the transfer of data, search data in the table, the organization of password protection. Storing of large amounts of information requires organizing quick access to it. Hashing is one of the ways to organize such access. The basic idea of hashing is to compute a certain fixed-size number from the input data, which would indicate the address of the data in the table. In this case, such a number will be called a hash, and the function with the help of which it is calculated is a hash function. Since a function that will uniquely match data with hashes is difficult to select even for fairly large tables, special methods for resolving ambiguities, called collisions, are used.

The main property of all hash functions is their irreversibility, that is, according to the hash, it is impossible to restore the original data by which it is calculated. This feature allows hashing to be applied in such important areas of human activity as computer security and cryptography. At the same time, hash functions used in cryptography must meet the requirements of cryptographic robustness: it should be practically impossible to select a different data sequence for a given data with a matching hash function, and, in addition, it should be almost impossible to select at random two data sequences with a matching hash . The word "practically" implies a reasonable complexity of selection, defined mathematically.

The irreversibility of hashes allows them to be used for organizing password protection when passwords are not stored in the database, but their hashes. Thus, even if the attacker somehow succeeds in hacking the database and reading the hashes in some way, this will not help him in any way.

Hash functions are widely used for data verification. If the hashes of the transmitted and received data match, then the data transfer process is considered to be successfully completed. A simple example of hashing just from this area is the finding of the checksum of the message: in this case, the hash is the sum of the codes of all the characters it contains, from which the last few digits are taken.

Cryptographic Hash Functions

What are cryptographic hash functions? A cryptographic hash function takes data and, in fact, translates it into a string of letters and numbers. Have you ever used URLs like Bitly or TinyURL? This is something similar. You enter something long, and the output is something short, which personifies something long. Only in the case of cryptographic hash functions, the input does not have to belong. It can be something very short (for example, the word "dog") or almost infinitely long (for example, the entire text of "A Tale of Two Cities"), and at the output, you will receive a unique string of a prescribed length. In addition, unlike reference shorteners, hash functions used in Bitcoin operate in one direction only. Although the same data will always give the same hash, it is impossible to reproduce the original data on the hash derived from them.

o, the data is entered into the hash function, the function is executed and a string of letters and numbers is obtained. This string is called a hash. In the Bitcoin blockchain, hashes consist of 256 bits or 64 characters.

It may seem impossible that a nearly infinite amount of data could be sequentially transferred to a unique string of just 64 characters, but cryptographic functions work in just such a wonderful way. With this incredible technology, whole books filled with text can be translated into one line of 64 numbers and letters. And each time you enter the same data, you will receive not only the same hash but unique and different from any other hash.

How Cryptographic Hash Functions Work

There are different types of cryptographic hash functions, and each of them works differently. The hash function used above — SHA-256, the hash function used in Bitcoin — works on the basis of an incredibly complex formula related to the reflection of light from ellipses. You should not worry too much about it. The bottom line is that cryptographic hash functions are damn magic, and you never fully understand them unless you're a mathematician.

We formulate the basic requirements for cryptographic hash functions:

  • the hash function must be applicable to a message of any size;
  • the calculation of the function value should be performed fairly quickly;
  • with a known hash function, it should be difficult (almost impossible) to find a suitable prototype;
  • with a known message, it should be difficult to find another message with the same hash function as the original message;
  • it should be difficult to find any pair of random different messages with the same hash value.

Creating a hash function that satisfies all the listed requirements is not an easy task. It should also be remembered that data of arbitrary size is received at the input of a function, and the hash result should not be the same for data of different sizes.


How Hash Functions Are Used in the Blockchain

For the blockchain to work, it must be updated. Like a bank, it must keep current records of all transactions and assets (for example, bitcoins) that each member of the network has. It is when updating transactional information that any authenticating system is vulnerable to attack. The bank mitigates this risk by having a strict centralized hierarchy that guarantees authenticity at its own risk. So how does the blockchain manage to be updated while remaining decentralized? It uses a cryptographic probabilistic hash game called Proof of Work.

The ideal cryptographic hash function has the following properties:

  • Speed. The hash calculation speed for any input data should be as high as possible;
  • Single direction. There should be no way to calculate the input from the hash;
  • Presence of avalanche effect. The smallest change in the input data should drastically change the hash, without any reference to the previous hash;
  • Resistance to collisions;
  • Resistance to attacks.

A cryptographic hash function guarantees the security of use in exchange for speed, while a regular hash function can be faster than a cryptographic one, but it can be significantly safer to play. With increasing computing power, hash functions become easier to crack. Hash functions that were considered safe yesterday and owned all cryptographic properties can now be included in the list of common hash functions.

It is almost impossible to determine the input of any hash function unless you possess immense calculating power. The reason for this is quite simple as the only way to crack such function is by “brute forcing” it. Brute-force has its name for a reason as the whole process is nothing but simply picking options until you reach the result that will have the same exact hash as the one you’re trying to crack. Taking into the account the fact that typical hash is 256 bit long it would take a lot of time to do that.

Nevertheless, there’s always a possibility that the input will be determined on the first attempt, or in the very beginning of the process, the chances of this actually happening are so small that you’re more likely to win a jackpot in a lottery with a first ticket you’ve bought in your entire life. The same way you may be unlucky and get the result at the very end of the calculation. That’s why the most realistic outcome is getting it somewhere in the middle, however, that would still consume a lot of time considering the fact that you have enough calculating power.

There is much more that can be said about the hashing and hash functions in general, but the terms are not of any help to an ordinary user that is why it’s not really useful to mention them or explain in more detail how they operate. The main point is that this method is used in cryptocurrency for a reason and this reason is that it’s almost impossible to break it somehow or crack it.

Hashing and Structures of Data

The data structure is a specialized way to store data. If you want to understand how the blockchain system works, then there are two basic properties of the data structure that can help you with this:

  1. Pointers;
  2. Related listings.

Pointers

The pointer is a variable whose value is the address of the memory cell. That is, the pointer refers to the data block from the memory area, and to its very beginning. A pointer can refer to a variable or function. For this, you need to know the address of a variable or function. For example, the record int a = 10 means that there is a certain variable “a”, which stores an integer value equal to 10. This is how a standard variable looks. However, instead of storing values, pointers store the addresses of other variables. That is why they got their name because they literally indicate the location of other variables.

Linked Lists

The main purpose of the linked list is to provide a mechanism for storing and accessing an arbitrary amount of data. As the name suggests, this is achieved by linking data together into a list. This is a great way to store data. Most programming languages ​​allow one way or another to allocate memory as an array and manipulate its contents. Sequential data storage increases performance (data locality), makes it easy to iterate through the content and access an arbitrary item by index.

It is important to note that the pointer inside each block contains the address of the previous one. So the chain is formed. The question arises, what does this mean for the first block in the list and where is its pointer located? The first block is called the “genesis block”, and its index is in the system itself. If you are interested in what “hash pointer” means, then we will be happy to explain. As you already understood, the blockchain structure is based on this. A chain of blocks is a linked list.

In hashing it is used the following way:

  • A hash chain (chain of hashes) is a representation of data as a chain with the first and subsequent links. Each link contains a unique name and data fields.

Building a hash chain:

  • Each link is called the result of the hash function over the data fields of this link;
  • Each link except the first one must have a data field with the name of the previous link.

Thus, the whole chain has a through relationship directed to the first link, the hash of the last link is actually a digital fingerprint of the entire chain, with low collision rates in the algorithm of the hash function used, it is almost impossible to replace the chain link so that all subsequent links are linked into a hash chain.

  1. A hash tree - a representation of data in the form of a tree with roots, branches, and leaves.

Building a tree:

  • Each leaf of the tree is called the result of the hash function over the data block of this leaf;
  • Each branch and root of the tree is called the results of a hash function over the list of all names of direct descendants and a block of related data if any.

Hash trees are a generic view for hash lists and hash chains. Hash trees provide an efficient and secure method for checking large data structures. Verifying the authenticity and ownership of a leaf of a tree requires data processing in proportion to the logarithm of the number of tree nodes; for hash lists, it is necessary to process all nodes of the list.

Hashing in Mining: Crypto Puzzles

When we say “mining”, basically, it means finding a new block that will be added to the blockchain. Miners around the world are constantly working to make sure that the chain continues to grow. Previously, people found it easier to work using only their laptops for mining, but over time they began to form "pools", combining the power of computers and miners, which could be a problem. There are restrictions for each cryptocurrency, for example, for Bitcoin, they are 21 million. Between the creation of each block, there must be a specific time interval specified by the protocol. For bitcoin, the time between creating a block takes only 10 minutes. If blocks were allowed to be created faster, this would result in:

  • A lot of collisions: more hash functions will be created that will inevitably cause more collisions;
  • To a large number of abandoned blocks: If many miners go ahead of the protocol, they will at the same time randomly create new blocks without preserving the integrity of the main chain, which will lead to “orphaned” blocks.

Thus, to limit the creation of blocks, a certain level of complexity is established. Mining is a bit like a game: you solve a problem and you get a reward. Increasing complexity makes solving a problem much more difficult and, consequently, it takes more time to complete. WRT, which starts with a set of zeros. As the level of difficulty increases, the number of zeros increases. The level of difficulty changes after every 2016 block.

Mining Process

When the Bitcoin protocol wants to add a new block to the chain, mining is the procedure it follows. Whenever a new block appears, all its contents are first hashed. If the selected hash is greater than or equal to the complexity level set by the protocol, it is added to the blockchain, and everyone in the community recognizes the new block.

However, it is not so simple. You must be very lucky to get a new unit in this way. Since it is here that a unique symbol is assigned. A unique character (nonce) is a one-time code that is combined with a block hash. Then this line is again changed and compared with the level of complexity. If it corresponds to the level of complexity, then the random code changes. This is repeated a million times until the requirements are finally met. When this happens, the block is added to the blockchain.

Imagine that the Bitcoin protocol issued a task - to guess the number 5, and the total numbers - a million. Your chances of solving this problem are 1 in a million. If the network wants to simplify the task, it sets a range of numbers, say from 1 to 100, and your chances are already 100 to a million. If it is necessary to complicate the task, we expand the range, and now you need to guess one digit not from a million, but from a billion values. This is exactly the mathematical task - the number that corresponds to a particular hash is needed. The hash is updated every 10 minutes, and the first computer that solved the problem receives a reward.

But today the range of numbers from which you need to find the right one is huge. All world Bitcoin miners jointly process approximately 50,000,000,000,000,000 input values ​​per second in an attempt to match the key to a given hash. Bitcoin network regularly tracks the speed of solving the problem, and if it was solved much faster than 10 minutes, they make the next one more difficult. If you don’t invest in 10 minutes, the next one will be easier. As soon as the first computer solved the problem, it shows its solution to all participants who check this solution, and when it confirms that the number matches the hash, it receives an award, and a new cycle begins.

Summing up:

  • A hash of the contents of the new block is being executed;
  • A nonce (special character) is added to the hash;
  • The new line is hashed again;
  • The final hash is compared with the level of complexity to check whether it is less or not;
  • If not, the nonce changes and the process repeats again;
  • If so, the block is added to the chain, and the publicly accessible book (blockchain) is updated and informs the nodes that a new block has been attached;
  • Miners responsible for this process are awarded Bitcoins.

The whole process is completely random, based on the generation of random numbers, following the Proof Of Work protocol and meaning:

  • Problem-solving should be difficult;
  • However, checking the answer should be easy for everyone. This is done to ensure that unauthorized methods are not used to solve the problem.

What Is Hash Rate?

The hash rate depends on a number of key parameters, including the chosen cryptocurrency mining algorithm. For example, some devices provide maximum performance within networks with the SHA algorithm (Bitcoin, Namecoin, Peercoin, etc.), but their efficiency will be significantly lower on the network using the Scrypt algorithm (Litecoin, Dogecoin, Gridcoin, etc.).

Also, equipment specifications that vary depending on the manufacturer. Those who plan to do mining, it is recommended to study the information about the power of a device to help in choosing the most optimal and cost-effective option. Do not forget the popularity of the cryptocurrency: the more popular it is, the more miners interested in its production. They connect their computing power to the network, thereby increasing its hash rate and, accordingly, the complexity of mining.

Those who distribute files on a torrent tracker resemble miners. It is no secret that thanks to them the work of the p2p network is ensured. Thanks to this, anyone can download your favorite music album or movie. And for downloading the visitor increases its rating. Increasing the rating makes it possible in the future to download your favorite movie or music. Miners, in the case of Bitcoin, ensure the functioning of the monetary system, as well as carry out an infinite number of transactions. For the time and resource spent, miners receive not a virtual rating, but quite tangible banknotes.

More and more “players” join the “game” and bring more power, hence the complexity. At the initial stage, the digital miner was satisfied with the home computer, then the top-end video cards went into action. Today, specialized mining devices have been developed, they are commonly called ASIC miners. The main hardware problem is the high-speed calculation of hashes with the lowest possible power consumption.

However, it’s necessary to mention that nowadays the ASIC miners have become the only way of mining the Bitcoin and most of the people around the world do not have a possibility to participate in the process without investing an immense amount of money in it. The mining of Bitcoin is mostly done by a few huge companies that possess the most of the computing power and this actually is a threat to one of the most important Bitcoin principles which are decentralization.

Conclusion

Hash and the process of its creation are used in various ways, and were popular a long time ago when nobody heard about the blockchain and Bitcoin was never a thing. Nowadays, it’s found its use in this new groundbreaking world of cryptocurrencies and is used there as a basis for all of the operation and we might say that all of the blockchain principles are dependant on the hash. It is indeed fundamental to the creation of blockchain technology. And if someone wants to understand what a blockchain is, he should start by understanding what hashing means.

Are you ready to start?
Open Account Be a Partner

LH-CRYPTO is an online service for crypto-traders

LH-CRYPTO is an online service for crypto-traders. The service is available to everyone, except for the citizens of particular countries and several categories of people listed in the License Agreement. LH-CRYPTO is a free software for making conversion operations with CFDs on various financial assets nominated in cryptocurrencies.

The project does not manage funds and does not guarantee profits. The project only offers a service that allows to make conversion operations with cryptocurrencies on a specially configured software.

This website is maintained and supported by the following legal body:

LARSON AND HOLZ IT LTD

All the settlements in this project are processed solely in cryptocurrencies. Conversion operations are processed on the terms of margin trading without a direct supply of underlying assets. According to the generally accepted term, these operations are called operations with OTC (over the counter) CFDs (contracts for difference).

Trading with OTC CFDs involves considerable risks. We recommend you pay the utmost attention to both theory and practice of margin trading before making any of such operations.

The services provided by this project are not available for: residents of USA, North Korea, Sudan and Syria.

visa mastercard 3D secure visa 3D secure mastercard