preface

It’s been a while since I started blogging, for a variety of reasons. From graduation to moving house, I’ve taken another step in my life. Today we are going to talk about blockchain. This is my topic related to my graduation project. Everyone for the block chain controversy, seems to have been there. Those old things in the coin circle affect the development of blockchain. At present, few of the many blockchain teams are really studying blockchain application scenarios. It also takes time for blockchain applications to be implemented. However, the emergence of blockchain technology can be said to be a milestone in the field of finance and the Internet. Let’s talk about blockchain technology. If you like my article, feel free to comment on it, and welcome to the Star~ Github blog

The body of the

In fact, LONG before the bitcoin fire, I heard about blockchain (read a public account about the correlation between blockchain and talent chain). At the beginning, I did not have a deep understanding of blockchain, and I did not care about it. In economic society, capital has been able to drive the development of technology. There was little interest in blockchain technology until the bitcoin boom.

After reading the white paper of Bitcoin, I found that blockchain technology is a foundation of bitcoin. At the same time, the theme of my graduation project is also related to blockchain, so LET’s talk about blockchain here.

In simple terms, a blockchain is a distributed ledger, or database. This database can be synchronized to every node in the node network. Use a picture in Teacher Ruan Yifeng’s blog to describe it, as shown below:

In this figure, we can see that the reason why it is called decentralization is that in the whole node network, every node is a participant and can carry out data processing operations. There is no unified centralized server for business processing. The results of each node’s processing are then propagated across the network to synchronize the entire network.

Blockchain is an interesting English word called blockchain. Blockchain can be divided into blocks +chain. So, we can look at the contents of the block first.

block

What is a block? A block is something like a database where data is recorded. So, every time the system writes data, a block is created.

Let’s take a look at an example block diagram as follows:

The Previous Hash is used to record the Hash value of the Previous block. This allows the previous block to be connected to the next block.

It also records the time of the block and the Data inside the block. A Hash value is an encrypted string. Hash is a one-way encryption, and Hash collisions rarely occur in reality. Generally speaking, Hash cracking can only be done by means such as rainbow tables. Its own security is relatively general encryption method to high. The Hash encryptions we will be exposed to are MD5, SHA128, and SHA256. For now, SHA256 is hard to crack.

With all that Hash stuff, let’s go back to blocks. We can take a look at some of the actual Block table contents, as shown below:

This is a list of blocks for the test network, and we can see that its block ID is a hash value. It also has special fields such as height to record the content size of the entire block.

With that in mind, let’s take a look at the formation of blockchain.

The formation of the chain

In bitcoins, for example, the process of trading bitcoin is the process of block formation. The establishment of the block, just like the data of the ledger, there is a block with the data. Again, the process of generating blocks generates a certain amount of reward. The following blocks will be attached to a block hash to ensure that the entire blockchain is immutable. As shown in the figure:

If a hacker modifies the contents of block 51, he must change the Hash value of 51 out of 52 blocks. At the same time, the Hash value of 52 is changed. So, it’s a chain reaction. At the same time, the blockchain broadcasts the whole process to the entire network. In this way, each node in the network node receives a change that changes its own block content.

Such a design can ensure that the content of the entire network can not be changed by external forces. It also shows that the entire network is secure. So what is a 51% attack?

Let’s take an example:

If I had 51 percent of the computing power of the Internet, I could secretly calculate a blockchain containing all of my Bitcoin transactions to my private account. The length of the blockchain is 10, but I don’t broadcast it to the whole web. At the same time, I put all my bitcoins on the market to sell. The transaction is recorded on a normal blockchain.

The normal length of the blockchain should be 9 when I withdraw my transaction dollars. The length of my hidden block chain is 10. At the same time, I broadcast this block chain to the network, and then by observing the network will think that the block I sent later is correct, so as to achieve the purpose of modifying the transaction record.

After that, the double flower problem was solved.

Double flowers problem

What is the two-flower problem? Figuratively speaking, a person makes two transactions at the same time. This problem has always been the difficulty of payment system. Whether it is a centralized payment system, or a decentralized transaction system, it has to face this problem. Here’s an example:

So-and-so had 20 bucks in his hand. He made a $20 transaction with two people at the same time. In real life, you can definitely spot a problem. However, in contrast to payment systems, concurrency often occurs. Once an imperfect payment system, double spending problem is easy to happen. Of course, back-end processing can solve problems in the form of queues. However, for decentralized trading systems, this issue also needs to be addressed.

Each transaction will generate a block, so it is often found that such a situation, as shown in the figure:

As we can see, Block A and Block B are connected to the same Block. So, for that matter, the bitcoin system uses the rule of choosing the longest chain. Typically, Bitcoin uses a six-check rule. Within an hour, a block of 6 lengths is usually generated according to the principle of producing a block in 10 minutes. So, just confirm this block, you can avoid connecting to other blocks.

The theory is that the longer the blockchain, the higher the accuracy.

# summary

Blockchain technology could be a productivity-liberating alternative to a centralized, high-cost approach. Of course, there aren’t many scenarios where blockchain actually hits the ground. Bitcoin is one of the few applications that actually hits the ground. As a developer, I believe in the future of blockchain. In this article, we talked about:

  1. Block generation
  2. The formation of the chain
  3. Double flower problem

Finally, I hope you can be interested in blockchain.

If you have any questions about what I wrote, you can comment on it. If I wrote something wrong, you are welcome to correct it. You like my blog, please follow me to Star~ yo github blog

Welcome to subscribe to wechat official account