Contacts

Cryptocurrencies with the sha 256 algorithm. SHA256 is a hashing algorithm. Hash decryption. Video about cryptographic functions and algorithms

SHA 256 is a cryptographic set of instructions for mining cryptocurrencies. In other words, it reliably protects all transactions on the network, and complicates the extraction of electronic coins. This abbreviation stands for Secure Hashing Algorithm, which means a highly popular and effective hashing method.

The essence of SHA 256 is to convert information into values, numbers. This chain has a fixed length. This means that any information you transmit within the network will be encrypted with special values ​​- identifiers (IDs).

When making transactions, the SHA 256 algorithm compares the ID with the original data, which cannot be retrieved, and then provides access to the transaction. This protocol is now used in the mining of cryptocurrencies such as BTC and BCH.

History of appearance

How did it happen that Bitcoin started using SHA 256? It all started with the algorithm becoming a member of the SHA-2 family, which have a hash chain size of 224-512 bits.

They, in turn, were created on the basis of their great-grandfather - SHA-1, whose hash was 160 bits long. The technology appeared in 1995, and was intended for use for civilian purposes - that is, encryption of ordinary, non-state-important information.

The SHA-2 family, to which SHA 256 belongs, was developed by the National Security Agency 16 years ago - in the spring of 2002. Based on this, we can say that the algorithm is morally outdated. However, it is still one of the strongest algorithms for encrypting transactions on the network.

Technical parameters of SHA 256

The algorithm is designed for data divided into equal parts of 64 bytes. SHA 256 ensures that they are collected and combined into a single 256-bit chain. The main method for this method is the encryption operation, which is performed in a loop 64 times.

Brief characteristics of SHA 256 algorithmic instructions:

  • 64-bit blocks - works most quickly with 32-bit blocks;
  • the peak length of the encrypted chain of information is 33 bytes;
  • message digest size - 32 bytes;
  • the standardized size of one word is 4 bytes;
  • encryption cycle in one round of operation is 64 bytes;
  • the speed at which the algorithm operates is 140 Mbit/s.

It is worth noting that this member of the SHA-2 family is based on the framework described by Merkle-Damgaard. This means that before dividing the information into words, the data is divided into blocks. The process strengthens encryption by shuffling the data.

The collection of information itself is carried out in the range from 64 to 80 repetitions. Each subsequent loop converts the created blocks into words. The final result, namely the hash, is created by summing all the initial values.

Cryptocurrencies with SHA 256 algorithm

As mentioned earlier, not only Bitcoin has such a set of instructions, but also:

  • peercoin, the peculiarity of which is that the code is created based on the cue ball, but PoS is used to protect the entire network, and PoW is responsible for the distribution of coins;
  • namecoin is a digital currency that acts as a means of protection, confidentiality, and decentralization; unobtanium - has extremely low inflation; it will take at least 300 years to mine all the coins;
  • deutsche eMark is a German micronetwork that is used for exchanging assets and money. The process itself takes place without intermediaries; betaCoin - works on the same principle as the world famous BitCoin;
  • jouleCoin - also based on the grandfather Bitcoin, but provides faster confirmation of transactions;
  • steemit is not even a separate crypt, but an entire platform on the blockchain. Its main task is to reward interesting publications.

Litecoin also uses the SHA 256 algorithm, but not in the entire system, but in a subroutine. For Litecoin mining, the Scrypt security protocol is used, which increases the complexity of mining and reduces the payback of ASICs.

Cryptocurrency mining based on the SHA 256 algorithm

To mine electronic coins that are based on the SHA-2 family, it is not necessary to use specialized tools - ASIC. Both CPU and GPU based farms perform well in mining. The latter is clearly superior in speed to the former.

And yet ASIC is the best solution for mining cryptocurrencies. Its advantages are to some extent offset by its significant price - about 100 thousand rubles, more powerful models even exceed 500,000. As complexity increases, the payback decreases. Therefore, the equipment does not always justify itself, although it provides a much higher mining speed than farms on video cards and, especially, a CPU.

GPU mining is considered more or less profitable. In general, the entire farm will cost approximately $1000-2000, plus additional equipment - in particular, cooling systems for video cards. It is also worth taking into account the rental of premises, electricity payments and salaries for service personnel.

Among video cards, the GTX 1080 Ti from Nvidia performs well. It produces a speed of 1400 successful operations per second. AMD is slightly behind with its Vega line cards - 1200 MH/s. There are also cheaper options like the Radeon 7970, but its speed does not exceed 800 MH/s.

The SHA 256 algorithm, although old, is still used in Bitcoin, the No. 1 cryptocurrency in the world. The protocol is also used in a number of other promising altcoins. SHA256 is gradually being replaced by Scrypt, but Bitcoin has no plans to switch to it. Regarding mining, everything is simple - if you have money, take ASICs with a high hash rate. Want a more economical solution? Then build a farm from AMD or Nvidia video cards.

  • Translation

At one point I wanted to figure out how quickly it was possible to mine Bitcoins manually. It turned out that SHA-256 hashing is used for mining, and it is quite simple and can be calculated even without a computer. Of course, the process is very slow and completely impractical. But after going through all the steps on paper, you can have a good understanding of the details of how the algorithm works.

One crypto round

Mining

A key part of the entire Bitcoin security system is mining. The basic idea is that miners group Bitcoin transactions into one block, which they then hash an incalculable number of to find a very rare hash value that falls under special conditions. When such a value is found, the block is considered mined and enters the block chain. Hashing itself serves no useful purpose other than increasing the difficulty of finding the correct block. Thus, this is one of the guarantees that no one alone with any existing set of resources will be able to take control of the entire system. You can read more about mining in my last article.

The cryptographic hashing function receives a block of data as input and produces a small but unpredictable output. It is designed so that there is no quick way to get the output you want, and you have to keep searching until you find the right value. Bitcoin uses SHA-256 as such a function. Moreover, to enhance the resistance, SHA-256 is applied to the block twice and is called double SHA-256.

In Bitcoin, the criterion for a hash to be valid is to have a sufficient number of leading zeros. Finding such a hash is as difficult as, for example, finding a car or phone number ending in several zeros. But of course for a hash it's exponentially more difficult. Currently, a valid hash must contain approximately 17 leading zeros, which only 1 in 1.4x10 20 satisfies. If we draw an analogy, then finding such a value is more difficult than finding a specific particle among all the sand on Earth.

Blue blocks non-linearly shuffle bits to make cryptographic analysis more difficult. Moreover, for even greater reliability, different mixing functions are used (if you can find a mathematical loophole to quickly generate valid hashes, you will take control of the entire Bitcoin mining process).

The majority function (Ma block) operates bitwise on the words A, B, and C. For each bit position, it returns 0 if the majority of the input bits at that position are zeros, otherwise it returns 1.

Block Σ0 rotates A by 2 bits, then the original word A is rotated by 13 bits, and similarly by 22 bits. The resulting three shifted versions of A are bitwise added modulo 2 ( normal xor, (A ror 2) xor (A ror 13) xor (A ror 22)).

Ch implements the selection function. At each bit position, a bit from E is checked, if it is equal to one, then the bit from F from this position is output, otherwise a bit from G. Thus, the bits from F and G are mixed based on the value of E.

Σ1 is similar in structure to Σ0, but works with the word E, and the corresponding shift constants are 6, 11 and 25.

The red blocks perform a 32-bit addition, generating new values ​​for the output words A and E. The value W t is generated based on the input data (this happens in the part of the algorithm that receives and processes the hashed data. It is beyond our scope). K t is its own constant for each round.

In the diagram above, it is noticeable that only A and E change in one cryptographic round. The remaining words do not change, but are shifted at the output - old A turns into output B, old B into new C, and so on. Although a single round of the algorithm does not change the data much, after 64 rounds, the input information will be completely encrypted.

We mine manually

In the video I show how you can go through all the steps described with a pen and paper. I performed the first round of hashing to mine the block. It took me 16 minutes, 45 seconds.


Let me explain a little what is happening: I wrote down the words from A to H in hexadecimal form, and under each I made a translation into binary form. The result of block Ma is below the word C, and the values ​​of A after the shifts and the output Σ0 itself appear above the line with A. The select function appears below G, and finally the corresponding shifted versions of E and the value after the block Σ1 go above the line with E. In in the lower right corner performed an addition, the result of which is involved in the calculation of both the new A and the new E (the first three red summation blocks). On the top right I calculated the new value of A, and in the middle is the calculation of the new value of E. All these steps were discussed above and can be easily tracked in the diagram.

In addition to the round shown in the video, I conducted one more - the last 64th hashing round for a specific Bitcoin block. In the photo, the hash value is highlighted in yellow. The number of zeros confirms that it is a valid Bitcoin hash. Note that the zeros are located at the end of the hash, and not at the beginning, as I wrote earlier. The reason is that Bitcoin simply flips the bytes received by SHA-256.


The last round of SHA-256, as a result of which a successfully mined Bitcoin block is visible

What does all this mean for the design of hardware miners?

Each step in SHA-256 looks very simple in digital logic - simple bit operations and 32-bit sums (if you've ever studied circuit design, you've probably already imagined what this might look like in hardware). Therefore, ASICs implement SHA-256 very efficiently, placing hundreds of SHA-256 round execution units in parallel. The photo below shows a mining chip that can calculate 2-3 billion hashes per second. You can see more photos on Zeptobars.


A silicon shot of the Bitfury ASIC chip, which can mine Bitcoin at 2-3 gigahashes per second. Picture from Zeptobars. (CC BY 3.0)

In contrast to Bitcoin, Litecoin, Dogecoin and other similar alternative -coin systems use the scrypt hashing algorithm, which is inherently difficult to implement in hardware. This algorithm stores 1024 different hash values ​​in memory during execution, and combines them at the output to obtain the final result. Therefore, much more memory and circuitry is required to calculate scrypt hashes compared to SHA-256 hashes. The impact of changing the hashing algorithm is clearly visible when comparing the corresponding mining hardware - versions for scrypt (Litecoin and others) are thousands of times slower than versions for SHA-256 (Bitcoin).

Conclusion

SHA-256 was suddenly so simple that it could even be calculated by hand (the elliptic curve algorithm used to sign a Bitcoin transaction would be much more painful, since it involves a bunch of multiplications of 32-byte numbers). Calculating one round of SHA-256 took me 16 minutes, 45 seconds. With this performance, hashing an entire Bitcoin block (128 rounds) will take 1.49 days, that is, we get a hashing rate of 0.67 hashes per day (in fact, of course, the process would speed up with practice). By comparison, the current generation of Bitcoin miners produce several terahashes per second, which is about a quintillion times faster than me. I think it's clear that manual Bitcoin mining is not very practical.

A reader from reddit asked about my energy expenditure. Since I do not exert any serious physical effort, we can assume that the metabolic rate will be 1500 kilocalories per day, then we find that manual hashing requires almost 10 megajoules per hash. Typical consumption energy for an iron miner is 1000 magehash per joule. Thus, I am less energy efficient than a specialized piece of iron by 10^16 times (10 quadrillion). Another question is the cost of energy. Donuts cost 23 cents per 200 kilocalories. costs 15 cents per kilowatt-hour, which is 6.7 times cheaper than donuts. As a result, the cost of energy in terms of hash for me, as a human miner, is 67 quadrillion times higher. Good luck with manual Bitcoin mining, and that's not even taking into account the cost of paper and pens!

Why was SHA - 256 created?

SHA 256 - short for Secure Hashing Algorithm - is a popular cryptographic hashing algorithm developed by the National Security Agency - the US National Security Agency. The task of SHA - 256 is to make certain values ​​with a fixed length from a random set of data that will serve identifier this data.

The resulting value is compared with duplicates of the original data, which cannot be retrieved. The main scope of application of the algorithm is use in various applications or services related to information security, where the function has become widespread spreading. It is also used as a technology for mining cryptocurrencies.

This algorithm belongs to the group of encryption algorithms SHA - 2, which in turn are developed on the basis of the SHA - 1 algorithm, first created in 1995 for use for civilian purposes. SHA-2 itself was developed by the US National Security Agency in the spring of 2002. Within three years, the US NSA issued a patent for the use of SHA technology in civilian projects.

In 2012, the National Institute of Standards and Technology created an updated version of the algorithm: SHA - 3. Over time, the new algorithm will displace both the current main algorithm SHA - 2 and the already outdated, but still used SHA - 1.

Hash-sum is not a data encryption technology in the classical sense; this makes it impossible to decrypt data in the opposite direction. This is one-way encryption for any amount of data. All SHA algorithms are based on the Merkle-Damgaard method: the data is divided into uniform groups, each of which passes through a one-way compression function. As a result, the data length is reduced.

This method has two significant advantages:

  • fast encryption speed and almost impossible decryption without keys;
  • minimal risk of collisions (identical images).

Where else is it used?

Every day, every Internet user, knowing it or not, uses SHA-256: the SSL security certificate that protects every website includes the SHA-256 algorithm. This is necessary to establish and authenticate a secure connection to the site.

Pros of SHA - 256

SHA - 256 - the most common mining algorithm among all others. It has proven itself to be hack-resistant (with rare exceptions) and an efficient algorithm for both mining and other purposes.

Cons of SHA - 256

The main disadvantage of SHA-256 is its controllability miners: those with the largest computing power receive the majority of the cryptocurrency, which eliminates one of the fundamental principles of cryptocurrencies - decentralization.

After large investors began investing in computing power for industrial Bitcoin mining, the difficulty of mining increased exponentially and began to require exceptional computing power. This drawback has been corrected in other protocols, more modern and “tailored” for use in cryptocurrency mining, such as Scrypt. Despite the fact that today SHA-256 occupies a large part of the cryptocurrency market, it will weaken its influence in favor of more secure and advanced protocols.

After a while SHA-1 algorithms no longer provide the required level of reliability due to the likely occurrence of collisions. SHA-256, like SHA-512, are more protected from this flaw, but the likelihood of occurrence is still present.

Use in cryptocurrencies

Mining on SHA - 256

Mining with SHA-256, as with any other algorithm, is the process of solving some complex cryptographic a task that is generated by a mining program based on data from previous blocks.

There are three ways to mine using the SHA-256 function:

  • CPU (central processing unit);
  • GPU (graphics processing unit);
  • specialized processor: ASIC.

In mining, the hash amount is used as an identifier of existing blocks and the creation of new ones based on previous ones. The mining process is displayed in the interface as “accepted f33ae3bc9...”. Where f33ae3bc9 is a hash - sum, part of data, intended for decryption. The main block consists of a huge number of similar hash sums.

That is, mining with the SHA-256 algorithm is non-stop selection of the correct hash value, enumeration of numbers to create a new block. The greater your computing power, the greater the chance of getting the correct block: the speed of searching through different hash sums depends on the power.

Due to the fact that Bitcoin is built on the SHA-256 algorithm, for competitive Mining on it requires extremely large computing power. This is due to the fact that for Bitcoin mining, the production of “ASICs” - application specific integrated circuit, i.e., has been established for a long time. e. special purpose integrated circuit. ASICs allow you to mine Bitcoins and other cryptocurrencies using the SHA-256 algorithm much faster, more efficiently and cheaper.

Which cryptocurrencies use the SHA-256 algorithm

SHA - 256 is a classic algorithm for cryptocurrencies: the main cryptocurrency - Bitcoin - is built on it. Accordingly, this algorithm is used in Bitcoin forks: Bitcoin Cash, Gold, Diamond.

In addition to them, SHA - 256 is also used in:

  • Steemit;
  • DigiByte;
  • PeerCoin;
  • NameCoin;
  • TeckCoin;
  • Ocoin;
  • Zetacoin;
  • EmerCoin.

Also, the SHA-256 algorithm is used as a subroutine in the Litecoin cryptocurrency, and the main algorithm for mining there is Scrypt.

The SHA 256 hashing function formed the basis of the very first cryptocurrency in the world - Bitcoin and many altcoins. Did you know that it was created long before the advent of cryptocurrencies and was intended for completely different purposes? Today we will look at the history of the algorithm, the principle of its operation, current problems and which cryptocurrencies use SHA256.

Story

The name of the algorithm SHA 256 is an acronym for Secure Hashing Algorithm. That's what the developer called it - the US National Security Agency. The algorithm is a hashing function. This means that its input is a volume of data of arbitrary length, and the output is a set of characters of a fixed length, called a hash.

One of the key features of hash hashing functions is irreversibility. We can get the hash by passing the original data through the function, but knowing the hash, we will not be able to get the original data. Thanks to this property, the function has become widespread in various services and applications where data protection is required. Every day we use the SHA 256 algorithm when visiting sites on the Internet. It includes an SSL security certificate, which is required to establish a secure connection to the site.


The algorithm is part of the SHA-2 family, developed on the basis of SHA-1, which appeared in 1995. Since its introduction, sha256 has been extensively tested for its strength using cryptanalysis. Cryptanalysis tests the resistance of hash functions to two main types of attacks:
  • Finding collisions - detecting identical hashes with different input parameters. The success rate of this attack compromises the security of the digital signature using the current algorithm.
  • Finding a preimage is the ability to decrypt the original message using its hash. This attack compromises the security of storing authentication password hashes.

The analysis was first tested in 2003, but no vulnerabilities were found then. As time passed, computing power developed. In 2008, collisions were found for the SHA-512 and SHA-256 iterations. In September of the same year, a method for creating collisions was developed for 31 iterations of SHA256 and 27 iterations of SHA-512.

Obviously, the time has come to develop a new crypto-resistant function. In 2012, the NSA invented SHA-3. Gradually, the updated algorithm will displace its less crypto-resistant predecessors.

Mining on SHA 256

US law permits the use of SHA and similar hash functions as part of other protocols and algorithms in certain non-Secret federal information security applications. SHA-2 can be used by private and commercial organizations.

It's no surprise that it was used in cryptocurrencies. Miners collect all transactions into a block and then begin hashing it. When a hash value that matches the system rules is found, the block is considered ready to be attached to the end of the blockchain. The new block will be found by someone who can calculate hash values ​​very quickly. The speed of calculations depends on the power of the equipment. Three types of equipment can be used to mine Bitcoin:

  • CPU (central processing unit);
  • GPU (video cards);
  • ASIC (Application Specific Device).

The Bitcoin network is designed in such a way that each new block must be found once every 10 minutes. The number of network participants is constantly changing, but time must remain constant. To ensure equal residence times, the system adjusts the computational difficulty depending on the number of miners. Cryptocurrencies have gained popularity recently, and the number of miners has increased greatly. To prevent blocks from being found too quickly, the complexity of the calculations also increased.


Bitcoin began to be mined on processors. Then, when their power became insufficient, they switched to video cards. Soon the video cards could no longer cope. Then ASICs were invented - special devices designed for calculations using the sha 256 algorithm. One ASIC is much more powerful and energy efficient than several video cards.

Enterprising miners are creating huge farms from ASICs. In addition to the high cost of the equipment itself, such a farm receives electricity bills of several tens of thousands of dollars every month. Now Bitcoin mining makes sense only on such industrial farms; a home computer or even a farm with several video cards will not be able to compete with them, and even recoup the electricity.

However, this is easy to calculate. There are calculators to calculate the profitability of mining on sha256. For example, https://www.coinwarz.com/miningprofitability/sha-256. Enter the hashrate of your equipment (computing power), energy consumption and its cost into the form, the service will calculate your profit.

Altcoins SHA-256

Let's look at the list and list of cryptocurrencies that work on sha 256.

Bitcoin Cash (BCH)

Separated from it on August 1, 2017. The block size in classic Bitcoin is 1 MB. The network has grown so large that all transactions can no longer fit into a block. This led to the formation of queues of transactions and an increase in fees for making payments. The community decided to introduce a new protocol, according to which the block increased to 2 MB, some information began to be stored outside the blockchain, and the time frame for recalculating the complexity was reduced from two weeks to a day.

Namecoin (NMC)

It is a system for storing and transmitting name-value combinations based on Bitcoin technology. Its most famous application was the domain name distribution system, which is independent of ICANN, and therefore makes domain repossession impossible. Namecoin was launched in 2011, it runs on Bitcoin mining software forwarded to the server where Namecoin runs.

DigiByte (DGB)

A cryptocurrency launched in 2013 with the goal of improving the performance of Bitcoin and Litecoin. DigiByte differences:

  • Low volatility is achieved due to the huge number of issued coins (up to 21 billion), which ensures their low cost and ease of use in calculations;
  • Fast transactions by doubling the block size every two years;
  • Low commissions or no commissions;
  • The mining process is divided into five algorithms that allow you to mine coins independently of each other. You can use ASICs for SHA-256 and Scrypt, video cards for Groestl and Skein, and a processor for Qubit.

The SHA 256 algorithm is the most common among cryptocurrencies. This was caused by the popularity and success of Bitcoin, and the desire of altcoin developers to create similar coins. The increase in computational complexity prompted miners to look for ways to mine more efficiently, which resulted in the emergence of ASICs.


Bitcoin encryption is based on SHA-256, a special algorithm that is part of the program code. Its task is to convert the input data into a specific set of characters (in alphabetic and numeric representation) and protect the information. Such actions are called hashing. What are the subtleties of this algorithm? Why is it needed and how does it work? What are the advantages and disadvantages? We will consider these and a number of other points in detail.

What encryption algorithm does Bitcoin have, and where is it used?

When discussing cryptocurrency, the features of its operation and mining, participants in the crypto network inevitably come across such a widespread definition as the Bitcoin encryption algorithm. From the day BTC was developed until today (August 13, 2018), SHA-256 has been used, which is necessary to solve the following problems in the Bitcoin network:

  1. Formation of BTC addresses (used for transactions).
  2. Mining (proof of work).
  3. Achieving the required degree of security and anonymity.
  4. For digital signature and its recognition.
The SHA-256 algorithm is relevant not only for Bitcoin, but also for other coins, namely Bitcoin Cash, Mazacoin, Peercoin, Namecoin and other cryptocurrencies. In addition, SHA-2 (the basis of SHA-256) is used to create many protocols designed to protect data on the Internet, namely SSL, TSL and others.

The Bitcoin hashing algorithm is necessary to control information through its analysis and timely identification of inaccuracies. Once the data has been processed and converted into a hash, it is impossible to get the information back. If you take an already encrypted BTC file, do the calculations again and make sure that the hash parameters are identical, you can be sure that there are no changes to the original information. If the data differs, this indicates a system hack.

Bitcoin encryption algorithm - how it works in simple words


SHA-2 is based on the framework created by Merkle and Damgaard. The peculiarity of the hash function used in cryptography is the non-standard approach to its formation. The incoming data is divided into blocks of identical size, after which the created elements are converted to hexadecimal numbers. It is with them that calculations are subsequently made. A hash function is applied to the resulting value, and the result of the processing is the hash sum that appears in the output. It is a set of characters presented in alphabetic and numeric display. Essentially, this is a hash.

The next block is built according to the principle described above. In this case, a new process is launched after the creation of the previous element. If changes are made to the original data, the hash changes. In the case when identical hash function parameters suddenly appear in different blocks, a conflict situation occurs in the operation of the algorithm. When such a discrepancy occurs, the entire blockchain chain is called into question.

Thus, a hash function is used to create a digital signature. If the situation discussed above occurs, there is a high probability of signature forgery. To calculate such failures (collisions), a special technique is used that involves enumerating the data, which increases the strength of the hash function.

The correctness of Bitcoin encryption is controlled by four requirements:

  1. When you make changes to the incoming data, the hash amount remains the same.
  2. During hashing, an individual hash sum is obtained (the character set must be unique).
  3. Creating a key using hashing is extremely complicated.
  4. Hashes are irreversible. This means that work with input data is allowed without the possibility of performing reverse action.

How does this apply in Bitcoin?

The task of the nodes of the cryptocurrency network is to find one in numerous transactions that suits it in all respects. When evaluating options, the initial attention is paid to the size of the commission (by the way, for this reason, transactions with a larger commission are completed faster). Next, the operation is checked, the input and output data are studied, and the originality of the digital signature is clarified.

As soon as the considered work is completed, the next element of the Bitcoin chain (block) is created with a certain size (for the cryptocurrency in question - 1 megabyte). The resulting nodes consist of the version, formation time, two hashes (past block and incoming transactions), as well as additional parameters that ensure uniqueness (bits and nonce). In the complex, the created block is hashed many times, resulting in the formation of a head hash, which acts as an output for the “old” element of the chain, and as an input for the new one.

Let's say that the hash set contains a specific number “0” (for example, the nonce is 17). It is extremely difficult to select such a value using only enumeration of values. It is this aspect that ensures the reliability of information in the blockchain network and its protection from hacking. To create a hash, enormous power is required, without which it is impossible to find the required set of characters. Once this work is completed and the parameter is found, it is sent to the elements of the crypto network with the newly created block and the found hash with 17 “0s”. Next, all participants in the Bitcoin network check the hash, combining the set of characters with information from the block. If there is no collision, a new element appears in the blockchain chain.

When did the Bitcoin encryption algorithm appear - a brief history


The term "SHA" is an abbreviation of three words: "Secure Hashing Algorithm". Bitcoin uses SHA-256, and the “base” of the mentioned hash function is SHA-2, which includes many crypto algorithms (including 256).

The creators of SHA-2 are the United States NSA, a special agency dealing with the country's national security issues. After developing and testing the algorithm, it was released to the public in 2002. The new SHA-2 also included the first hash function SHA-1 (created 7 years earlier - in 1995). Since the introduction of SHA-2, many variants of the algorithm have been released, one of which was used by Satoshi Nakamoto when creating Bitcoin in 2009.

The goal of the developers was to release an algorithm that would ensure the formation of a specific value of a certain length from a random set of characters. They did it. In the future, the resulting parameter will be used to identify (check) information. The original purpose of SHA-2 is to protect data on various services, and today (in 2018) SHA-256 is known primarily as an algorithm used in coin mining.

In 2012, the system was improved and an updated version of the hash function appeared - SHA-3. It is believed that over time, the new development will displace the previous algorithms, which will improve the already high degree of security.

Characteristics of the Bitcoin encryption algorithm


The essence of SHA-256 is simple. The initial message after making the addition is divided into blocks, and each of them is 16 words. The resulting elements go through special cycles involving 64 or 80 stages. At each of them, two words are converted, and the transformation option is formed by the remaining words. The resulting parameters are summed up to form a hash.

During the operation of the algorithm, 6 commands are used:

  • "xor" - removes "OR".
  • “shr” - shifts the indicator by the required number of bits to the right with a specific frequency.
  • “rots” - shifts the indicator by the required number of bits to the right (without using a specific cycle).
  • “II” - a connection of elements that are linear in nature.
  • “and” - “And”.
  • “+” - tracking.
Protocol characteristics:
  1. The upper limit for message duration is 33 B.
  2. The maximum speed parameter is 139 MiB/s.
  3. Word size - 4 B.
  4. The number of repetitions in a cycle is 64.
  5. The size of the block element is 64 B.
  6. The total hash code is 32 B.

Bitcoin encryption algorithm in mining


When performing calculations within mining, the correctness of the resulting hash code is determined by the number of zeros at the beginning of the line. For example, if this parameter is 17, the probability of finding such a number is extremely low and is somewhere around 1:1.4*10 to the 20th power. It is not surprising that Bitcoin mining requires the use of powerful equipment and high energy costs. At the same time, optimizing the search for the required hash is impossible, because after receiving a block of information, a random number appears at the output.

The difficulty of mining a virtual coin is to find the necessary hash and form the next block. To achieve this goal, standard enumeration of values ​​is used, which requires high-performance equipment. As mentioned, the search is not for a simple hash, but for a value with a large number of “0s” in front of it.

Cryptocurrency mining using SHA-256 is a set of measures aimed at solving a specific crypto problem. In the case of Bitcoin, the following equipment is used for mining:

  1. Since the advent of BTC in 2009, as well as until mid-2010, the use of a central processing unit (CPU) was relevant.
  2. Until mid-2011, miners used computers with video cards (GPUs).
  3. Until early 2013, FGPAs were popular, as were GPU farms.
  4. In 2014, ASICs appeared. They eclipsed existing equipment in performance. Despite this, until the beginning of 2017, miners used GPU farms and worked in pools, but by the end of 2017 and to this day, only -miners are relevant. The use of other equipment is unprofitable.
The mentioned devices are used to select the hash function of interest and generate a new one. The higher the hashrate (computing power) of the device, the faster the data is sorted and the less time it takes to find a solution.

With increasing competition and the release of more productive miners, and increases, the parameter of which changes every 2 weeks.

Weaknesses and strengths of the Bitcoin hashing algorithm


Above we looked at what Bitcoin hashing algorithm is and what its features are. This is SHA-256, which is considered the most common algorithm with a high level of reliability and a relatively simple operating principle. It is highly resistant to hacking and allows you to mine coins on any equipment (depending on the difficulty parameters).

Despite a number of positive qualities, the Bitcoin hashing algorithm has a number of weaknesses:

  1. Control by BTC mining participants. The same principle works here as in joint-stock companies (JSC), when company participants have a certain number of shares. The more power is concentrated in the hands of crypto network miners, the stronger their impact on the overall system. In addition, due to the growing complexity of mining in 2018, there is a noticeable tendency for mining to move from the hands of private miners to the control of large organizations involved in creating equipment for mining virtual coins. To receive Bitcoins, a private miner must spend large sums on purchasing ASICs, connect to one of the pools and pay for electricity. If you skimp on equipment, production loses profitability.
  2. A consequence of the situation discussed above is the fact that the “lion’s” share of Bitcoins is concentrated in the hands of the owners of large mining companies. If we take into account that not all Bitcoin received goes on sale, such organizations turn into investors and custodians of coins. As a result, the number of coins in circulation decreases. In addition, the accumulation of cryptocurrency allows you to influence decentralization, as well as the exchange rate of BTC during the trading process.
  3. Due to existing shortcomings, the SHA-256 algorithm is gradually becoming a thing of the past, and more advanced projects are taking its place. For example, Scrypt, Ethash, Blake-256, Equihash and others are gaining popularity. New algorithms have better protection and security levels, which forced the creators of many cryptocurrencies to abandon the outdated SHA-256 in favor of more advanced technologies.
  4. Despite correcting the main errors that were identified by the developers, some vulnerabilities could not be removed (in 2008, collisions were found for 22 iterations). That is why the development of SHA continued, and the second version was replaced by SHA-3.
In 2009, I was forced to use SHA-256, because at the time of the creation of the cryptocurrency, state governments adopted this protocol. At that time, it was actively used for data protection in some government programs, and was also used in the commercial sector. It turned out that the protocol was created to solve certain problems, but in reality it is in demand in a completely different way.

For clarity, let’s tabulate the positive and negative features of the Bitcoin encryption algorithm.

AdvantagesFlaws
Widespread (including in the cryptocurrency sector). The SHA protocol is actively used in everyday life to protect information.Loss of decentralization. Power is concentrated in the hands of mining companies.
Reliable burglary protection.The SHA iteration has a simple structure, which has led to an increase in mining complexity over time. As of August 2018, only ASICs with high performance can be used for mining Bitcoins.
Convenience in terms of coin mining, versatility in choosing mining equipment.New algorithms appear that have a more advanced structure.
In the second version (SHA-2), the creators managed to eliminate a number of shortcomings that negatively affected the reliability of the system.Despite active work on bugs, many shortcomings were not removed. Not surprisingly, the developers created a new version of SHA-3.
The protocol has been adopted at the legislative level in the United States.

Today it is almost not used in the development of new cryptocurrencies. The most striking example of a coin that still uses SHA-256 is Bitcoin Cash, a fork of Bitcoin that appeared in August 2017. But in the situation with this coin, the use of SHA is more a necessity than a choice of the creators. As for Bitcoin itself, the use of this series protocol is due to the lack of alternatives from Satoshi Nakamoto.

Today, in 2018, there is a lot of talk about improving this algorithm and making changes to the cryptocurrency network, but so far such intentions have not found physical implementation and remain only in the form of proposals.

Video about cryptographic functions and algorithms:



Did you like the article? Share it