Contacts

What is hash rate? Hash function: what it is, why it is needed and what it is. Substring hash and its fast calculation

Let's try to understand what the complexity of the network is, which scares all new miners, and what kind of network hashrate this is.

Nowadays there are a lot of chats about cryptocurrency mining and trading. Every newbie question “which ASIC to buy or which farm to build” is accompanied by the answer... “Look at how the complexity of the network is growing and don’t even think about getting involved in this matter!”

For simplicity, we will consider the complexity and hashrate of the network using the example of a coin (analogue of Ethereum, using a similar algorithm). The numbers are smaller and, I hope, it will be easier for me to explain the essence to you.

The network of each cryptocurrency has such a parameter as “block creation time”. In the case of Musicoin, this is 15 seconds. Every 15 seconds, one of the miners must find a solution to create a block.

How to keep this parameter at 15 seconds, regardless of the number of miners that are connected to the network? After all, if there are many miners, they will find blocks too often (here is an example of an empty block in the UBIQ network http://www.ubiq.cc/block/212214), and if there are few miners, then blocks will be found rarely and network transactions will continue a very long time.

For finding 1 block in the Musicoin network, a miner or pool (many miners together) receives 309 Musicoin coins = $13 at today's rate.

Retreat. In the Ethereum network, they pay 5 ETH = $1900 for finding one block, in the Ethereum classic network 5 ETC = $75. But, unfortunately, the complexity and hashrate of the networks in these coins are many times greater.

If miners produce empty blocks and receive money for it, the coin will depreciate, and if blocks are found slowly, transactions will stop... again, the coin will depreciate.

This is where Complexity comes into play. To put it simply, this is simply the complexity of the problem that miners need to solve to create a block, and it can change. The difficulty depends on the network hashrate (the number of miners connected to the network of a given coin). If there are few miners, the difficulty drops, if there are many miners, the difficulty begins to increase and it is more difficult for one specific miner to find a block...

Miners receive rewards in coins from the network itself, but all miners love good cars, food and rags. Therefore, it is important for them how much it is in US dollars, because if the price of a coin has increased on the exchange, then the value of the reward for finding a block has become greater in the notorious US dollars.

The other day, on August 27 (see chart above), the price of the musicoin coin increased significantly, miners who were busy mining coins Zcash, Ethereum, Monero... gasped in anticipation of more profits and switched their farms to the musicoin coin. At the same time, the musicoin network itself, of course, reacted with a sharp increase in complexity.

Difficulty is measured in hashes (usually TH terrahashes), and when applied to mining, it is a unit of work completed. Network power (number of miners) is measured in hashes per second (TH/s). The network itself adjusts the difficulty so that Difficulty/network power = time until the next block (in the case of Musicoin 15 seconds).

On August 27, before the price soared, the network complexity was: 7.5 TH on average, and the network hashrate: 500 GH/s (approximately 16,000 video cards), then after the price soared, the network hashrate increased to: 1.12 TH/s (1120 GH/s) (approximately 35,000 video cards), and the difficulty soared to 16.728 TH.

As a result, the profit of the farm that mined the coin BEFORE the price soared and AFTER the price soared did not change. The farm began to produce fewer coins, but at a higher price (it doesn’t matter whether it’s a farm or a whole pool of farms).

This is a key point that many people do not understand. Yes, you can snatch a couple of bucks from these rate-difficulty jumps, but, as a rule, everything settles down in a couple of hours and it doesn’t matter what currency you will mine using the same algorithm. The exhaust will be the same. Of course, if you are waiting for a particular currency to take off, dig it.

Here we need to make another digression, there are people who closely monitor the complexity and hashrate... of all networks around the clock and at moments when the hashrate drops or the difficulty sags, they buy power on Nicehash and send it to the network of the sagging coin. And they catch a lot of blocks.

Actually, the conclusion: Let's imagine that there is only one currency, Ethereum. The hashrate of the Ethereum network is constantly growing, more and more new miners are coming. If the Ethereum rate falls, and the number of miners remains unchanged (or even worse, grows), mining will come to the level of the outlet (how much $ you mined, how much $ you paid for electricity). In this situation, farms will begin to be switched off and sold, complexity will begin to fall, and income will rise again.

The survival of the fittest and the one who has money sometimes wait and mine for the socket.

Today, it is perhaps difficult to find a person who does not know what cryptocurrency is. This innovative product literally blew up the Internet, attracting the attention of millions of people. Mining digital coins is one of the few ways to become the owner of cryptocurrency. However, the complexity of the network of popular platforms has increased so much that the hashrate of conventional processors and video cards is not enough to mine expensive “coins”.

Hashrate is a unit of measurement that allows you to determine the effective computing power of the equipment involved in the mining of cryptocurrencies. Hashrate can be expressed in the following units:

  • hash/second (H/s);
  • megahash/second (MH/s);
  • gigahash/second (GH/s);
  • terahash/second (TH/s);
  • petahash/second (PH/s).

It is worth noting that the H/s unit is not found in any peer-to-peer network. This is explained by the fact that the complexity of mining is constantly growing, and the extraction of cryptocoins requires equipment with more serious computing power.

What is the mining process based on?

Mining is a rather complex process, the essence of which is that the equipment involved in supporting the stable and correct operation of the peer-to-peer network must solve mathematical problems. When the correct answer is found, the miner receives a certain reward.

Mathematical problems appear within the network not by chance, but as a consequence of the next transaction. The history of all financial transactions is recorded in a special register that is publicly available. Equipment connected to the network begins processing the incoming information, and its main goal is to find the desired hash by enumerating random numbers. If the “correct” hash matches the secret key, then the peer-to-peer network provides access to the following operations.

To make it more clear what hashrate is, let’s give a clear example. Let's say we know that the miner's equipment has a power of 15 MH/s (megahash/second). This means that computing power makes it possible to generate 16 million different numerical combinations every second, among which there may be the only correct one that satisfies all the requirements of the peer-to-peer network.

How to find out the hashrate of your equipment

The surest and easiest way to find out the computing power of your existing equipment is to install special mining software, and then open the console, which displays all the data. However, this method is absolutely not suitable for people who are just thinking about purchasing devices for crypto mining. In this case, you should pay attention to the power declared by the manufacturer. But it has an average value and may vary depending on the following factors:

  • Mining algorithm. It should be taken into account that the hashrate can either increase or decrease when working with different algorithms. For example, if a device demonstrates high performance within a peer-to-peer network using the SHA algorithm, then the efficiency decreases significantly when switching to a network working with Scrypt.
  • Equipment manufacturer. If, for example, we take a GTX 1080 video card from Nvidia and a similar one from MSI, then despite the general similarity of indicators, their hashrate will be completely different.

Most novice miners surf the World Wide Web in search of special tables that contain reliable information about the computing power of a particular equipment.

Video cards with the highest hashrate

The modern market for graphics adapters offers the widest range, but not all video cards cope effectively with mining. We suggest you consider the table, which shows the best video adapters for crypto mining at the end of November 2017.

Hashrate

(MH/s)

Price

(rubles)

Payback (days)

Payback without taking into account costs

for electricity (days)

Radeon RX470

11.700

Radeon RX480

15.100

GeForce GTX 1060

12.000

GeForce GTX 1070

23.500

Radeon Fury X

26.500

The hashrate shown in the table is valid when working with the Equihash algorithm. However, the indicators may change significantly as the difficulty of mining continuously increases. At the moment, it is impossible to predict what the computing power of these devices will be even after a month. Therefore, the payback period for equipment can increase significantly.

How to calculate income knowing the hashrate

Every miner who knows the real hashrate of his own equipment can easily calculate his daily, weekly and even monthly income. To do this, just use an online calculator, for example, provided by the coinwarz.com service.

Stay up to date with all the important events of United Traders - subscribe to our

Often, when downloading torrents or the files themselves, the description says something like “ad33e486d0578a892b8vbd8b19e28754” (for example, in ex.ua), often with the prefix “md5”. This is the hash code - the result that the hash function produces after processing the incoming data. Translated from English, hash means confusion, marijuana, weed, or a dish of finely chopped meat and vegetables. very, very difficult, one might say almost impossible. Then the question arises: “Why is all this needed at all? They give out incomprehensible gobbledygook, which is also not decipherable?” This will be discussed in this article.

What is a hash function and how does it work?

This function is designed to convert incoming data of arbitrarily large size into a fixed-length result. The process of such a conversion is called hashing, and the result is a hash or hash code. Sometimes the words “fingerprint” or “message digest” are also used, but in practice they are much less common. There are a lot of different algorithms for how you can turn any data array into a certain sequence of characters of a certain length. The most widely used algorithm is called md5, which was developed back in 1991. Despite the fact that today md5 is somewhat outdated and is not recommended for use, it is still in use and often instead of the word “hash code”, sites simply write md5 and indicate the code itself.

Why is a hash function needed?

Knowing the result, it is almost impossible to determine the input data, but the same input data gives the same result. Therefore, the hash function (also called the convolution function) is often used to store very important information such as password, login, ID number and other personal information. Instead of comparing the information the user enters with what is stored in the database, their hashes are compared. This ensures that in the event of an accidental information leak, no one will be able to use important data for their own purposes. By comparing the hash code it is also convenient to check that files are being downloaded correctly from the Internet, especially if there were connection interruptions during the download.

Hash functions: what are they? T

Depending on its purpose, a hash function can be one of three types:

1. Function for checking the integrity of information

When happening over the network, a hash of the packet is calculated, and this result is also transmitted along with the file. Upon reception, the hash code is again calculated and compared with the value received over the network. If the code does not match, then this indicates errors, and the damaged packet will be transmitted again. This function has fast calculation speed, but a small number of hash values ​​and poor stability. An example of this type: CRC32, which has only 232 different values.

2. Cryptographic function

Used for protection against (ND). They allow you to check whether data corruption has occurred as a result of an accident during file transfer over the network. The true hash in this case is publicly available, and the hash of the resulting file can be calculated using many different programs. Such functions have a long and stable lifespan, and searching for collisions (possible coincidences of results from different source data) is very difficult. These are the functions that are used to store passwords (SH1, SH2, MD5) and other valuable information in the database.

3. A function designed to create an efficient data structure

Its goal is a compact and fairly orderly organization of information in a special structure called a hash table. Such a table allows you to add new information, delete information, and search for the necessary data at very high speed.

String hashing algorithms help solve many problems. But they have a big drawback: that most often they are not 100% accurate, since there are many strings whose hashes are the same. Another thing is that in most problems you can ignore this, since the probability of hashes matching is still very low.

Hash definition and calculation

One of the best ways to determine the hash function of a string S is as follows:

H(S) = S + S * P + S * P^2 + S * P^3 + ... + S[N] * P^N

where P is some number.

It is reasonable to choose a prime number for P, approximately equal to the number of characters in the input alphabet. For example, if the strings are expected to consist of only small letters, then P = 31 would be a good choice. If the letters can be both uppercase and lowercase, then, for example, P = 53.

All code in this article will use P = 31.

It is advisable to store the hash value itself in the largest numeric type - int64, also known as long long. Obviously, when the string length is about 20 characters, value overflow will already occur. The key point is that we do not pay attention to these overflows, as if taking the hash modulo 2^64.

An example of hash calculation if only small Latin letters are allowed:

Const int p = 31; long long hash = 0, p_pow = 1; for (size_t i=0; i

In most problems, it makes sense to first calculate all the necessary powers of P in some array.

Example task. Finding identical strings

We are now able to effectively solve this problem. Given a list of strings S, each no more than M characters long. Let's say you want to find all duplicate strings and divide them into groups so that each group contains only identical strings.

With regular string sorting we would get an algorithm with complexity of O(N M log N), while using hashes we would get O(N M + N log N).

Algorithm. Let's calculate the hash from each line, and sort the lines by this hash.

Vector s(n); // ... reading lines... // count all powers of p, say, up to 10000 - the maximum length of lines const int p = 31; vector p_pow(10000); p_pow = 1; for (size_t i=1; i >hashes(n); for (int i=0; i

Substring hash and its fast calculation

Suppose we are given a string S, and given indices I and J. We need to find the hash of the substring S.

By definition we have:

H = S[I] + S * P + S * P^2 + ... + S[J] * P^(J-I)

H * P[I] = S[I] * P[I] + ... + S[J] * P[J], H * P[I] = H - H

The resulting property is very important.

Indeed, it turns out that Knowing only the hashes of all prefixes of a string S, we can obtain the hash of any substring in O(1).

The only problem that arises is that you need to be able to divide by P[I]. In fact, it's not that simple. Since we are calculating a hash modulo 2^64, to divide by P[I] we must find its inverse element in the field (for example, using the Extended Euclidean Algorithm), and multiply by this inverse element.

However, there is an easier way. In most cases, instead of dividing hashes by powers of P, you can, on the contrary, multiply them by these powers.

Let's say two hashes are given: one multiplied by P[I], and the other by P[J]. If I< J, то умножим перый хэш на P, иначе же умножим второй хэш на P. Теперь мы привели хэши к одной степени, и можем их спокойно сравнивать.

For example, code that calculates hashes of all prefixes and then compares two substrings in O(1):

String s; int i1, i2, len; // input data // count all powers p const int p = 31; vector i2 && h1 == h2 * p_pow) cout<< "equal"; else cout << "different";

Using hashing

Here are some typical uses of hashing:

  • Determining the number of distinct substrings in O(N^2 log N) (see below)
  • Determining the number of palindromes within a string

Determining the number of distinct substrings

Let a string S of length N be given, consisting only of small Latin letters. You need to find the number of different substrings in this string.

To solve, let’s take the length of the substring one by one: L = 1 .. N.

For each L, we will build an array of hashes of substrings of length L, and reduce the hashes to the same degree, and sort this array. We add the number of different elements in this array to the answer.

Implementation:

String s; // input string int n = (int) s.length(); // count all powers of p const int p = 31; vector p_pow(s.length()); p_pow = 1; for (size_t i=1; i H(s.length()); for (size_t i=0; i hs(n-l+1); for (int i=0; i

In the Bitcoin network and most other modern cryptocurrencies, the unit of computing power is the hashrate. By processing operations and forming new blocks of transactions, computer technology performs complex mathematical calculations for solving which the miner receives a certain number of new crypto coins. All information about completed transactions is recorded and stored in a history that is publicly available. The miners' task is to select the desired hash from all possible combinations. This hash is similar to a secret key and provides access to new operations. Having solved the problem, the miner is paid a one-time reward, the size of which is strictly regulated by the algorithm of the cryptocurrency network. After “closing” a block, the miner moves on to computing a new block. As a rule, a large number of devices working in the same pool are simultaneously searching for a hash, and as soon as one of them finds the hash, the reward is paid in proportion to the entire group, after which the process begins again.

If you imagine this mathematically, it looks like this - miners are engaged in selecting a hash, which includes part of the previous block, the total number of hashes over the last few minutes and an arbitrary number. Miners need to find a suitable random number by trying all possible options until a hash is generated that meets the requirements of the system.

This process is reminiscent of the operating principle of torrent trackers. It's no secret that they are the basis of the p2p network, which makes it possible to quickly and in unlimited quantities download films, music and software. Any user, having downloaded a file and remaining on the distribution, provides the opportunity for other network participants to download this information, while his rating increases, allowing him to download a certain number of gigabytes of data again in the future.

Mining is carried out on more and more powerful equipment, which leads to an increase in the difficulty of mining new coins. In the early years of Bitcoin, anyone could mine cryptocurrency on their own home computer, while miners used powerful video cards to mine Bitcoin. However, at a certain point, the complexity increased so much that it became impossible to mine btc on a regular computer, and special devices were developed for this purpose - ASIC miners, which have a high hash rate at low energy costs.

How to find out hash rate

There are no uniform information tables that would indicate the power of this or that equipment, and all because the hashing speed (hashrate) is influenced by various factors. Here are the main ones:

  • Equipment manufacturer. With absolutely identical technical characteristics, devices from different manufacturers will produce different hashrates.
  • The slot through which the miner or video card is connected to the motherboard. There are cases that when connecting a device to different slots, the hashing speed is radically different.
  • Algorithm. The equipment performs differently on each of the algorithms used. For example, if you calculate using the Scrypt algorithm, then the hash rate will be the same, but if the equipment performs calculations using SHA, then the hash rate will be completely different.

Novice miners should remember that certain types of equipment, despite high performance, may not work with certain cryptocurrencies at all.

Equipment manufacturers always indicate the declared power on their products, but you should not completely trust these figures, because even models that come off the same assembly line produce different hash rates. The best option for calculating hashrate is to calculate the average hash rate over a certain period of time on running equipment.

Conclusion

Hash rate is a key indicator that affects the speed of calculations and therefore increases the miner’s profit. However, this indicator in mining depends on many different external factors, so when purchasing equipment you cannot know exactly what power it has and, therefore, what income the equipment will bring. Many miners prefer not to bother with fine-tuning the device, but to turn to specialists from services that provide cloud mining services. By concluding an agreement with a company, a miner rents a certain power from it and in this case nothing will be able to influence the hashrate speed.

Stay up to date with all the important events of United Traders - subscribe to our



Did you like the article? Share it