Blockchain concept that you must Know the fourth issue (2)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Fourth mining-related algorithms (2)

Less card cool

wechat:13260325501

Read (1), I believe you must have a little understanding of the mechanism of mining. So in this article, let's take a look at the mining algorithm.

In the following article, if you encounter a word that you don't understand in the first half of the article, you may be given an answer in the second half of the article. Finally on the part that do not understand welcome everyone to leave a message under the article, I will give a reply in time.

What is a chunk of blockchain?

    • Mining is to generate a chunk, so what is a chunk? What is the role of chunks? What information does a chunk contain?
    • Simply understood, a block can be understood as a struct. We know that structs can store different types of information, which can be a string, a number, or a date. What information is included in that chunk? Here we give a picture, first to understand the block information there are several major categories.
    • Figure 1

    • A block of information by category, mainly divided into four categories, this point we only do conceptual understanding can. The information that really has a role in generating chunks is mainly in the chunk header:
    • Index (the record is currently the number of blocks)
    • Current hash (currently hashed value)
    • Previous hash (the hashed value of the previous block, which guarantees that the chunk is concatenated by time)
    • Timestamp (timestamp, record the generation time of the chunk)
    • Data (transaction details, detailed record of the transfer of each transaction and revenue side, amount and digital signature)
    • Nounce (random number, which is the whole net miner together PK calculation, can satisfy the hash difficulty request answer)
    • I hope you have an impression of nounce value first. This nounce value is not only related to mining, but also has a very important identity in the subsequent implementation of the Code.
    • Give a simple list:
    • Figure 2

What is a hash and hash value?

    • To understand the code mechanism of mining, we first solve several concepts. The first one is "hash".
    • In the last mining we mentioned the calculation. Also said that the calculation is how many times a mine machine can do a hash collision per second. So what is a hash and what is a hash collision?
    • Simply understood, a hash is a function. The essence of the hash collision is that the CPU is constantly looking for a value that can generate the "difficulty" conditions for the Bitcoin at this stage, in the process of random exhaustive values. Once this value is found, a successful hash collision is generated.
    • Now you must be fine. What is the value of Chhashi? Let's take a look at the ==sha256== hash algorithm.
    • Here is a Web site, interested students can do some tests with me.

Link

    • Hello

    • HelloWorld

    • Hello World

    • Hello,world

    • After testing, we can see that the hash function has some very unique characteristics:
    1. Any content can generate a hash value.
    2. The hash value is in hexadecimal notation and is fixed in length.
    3. Different content generates different hash values. Even very similar content produces values that are completely different and irregular to follow.
    4. The same content will output the same hash value each time.
    • By comparing the output of "Hello", "HelloWorld", "Hello World" and "Hello,world", we can verify our summary of the hashing algorithm. Interested students can then verify other values, and you will find that no matter how small the difference, it will lead to a completely non-traceable change of the hash value.
    • It is also these characteristics of hashes that give them higher security when encrypting information.

About the "difficulty" of mining

    • The last concept is the difficulty of mining. The difficulty here, from shallow and deep, let us first give an example to understand its principle.

    • , for example, we put together a 5-digit number to divide a implementing bit. If the first permutation combination, I specify the million and thousands are 5, the other number of unlimited; the second permutation, I only specify the million-bit is 5, then who is the chance to get a small chance to get who?
    • -The answer is the first probability is small, the second probability is big. The more limited the number, the less likely it is to be optional.
    • In the same vein, mining is to match a hash that has been assigned a number of bits. The "difficulty" of mining is determined by the number of bits specified. This is independent of the number specified in hexadecimal.

    • As shown in the box, when the hash value is difficult to set the first four bits to "0", only when matching the previous four bits is "0", a successful hash collision is generated. If the number of "0" is set, the more difficult the hash succeeds, the greater the difficulty of mining.
    • At the very beginning of bitcoin, the difficulty is very small, only the first is "0" and collision success. It is very simple to dig mine. And now with the increase in the total network, mining difficulty is also large, now the hash difficulty is more than 10 "0".
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.