Bitcoin and basic principles of blockchain

At present, the research, experiment and promotion of blockchain are in full swing. Can blockchain really change our lives? This article will introduce bitcoin blockchain technology in a simple and understandable way. Strive to let readers quickly understand the basic principles of bitcoin and blockchain, but do not involve too detailed technical issues._DJMINER


primary coverage


1. Introduction to bitcoin

2. Working principle of blockchain

3. bitcoin account

4. bitcoin transaction

5. essence and influence of blockchain Technology



I. Introduction to bitcoin




What is bitcoin?

Bitcoin is a digital currency, or a digital asset. He was created and published by an anonymous man who called himself Nakamoto. Bitcoin network consists of many nodes (computers) on the Internet, which maintain the operation of bitcoin network according to the agreed protocol. The ingenious algorithm design makes the nodes in the network comply with the consensus protocol, so bitcoin can be generated at a controllable speed and trade in a reliable way.

Non cash payment is very popular in China. Money is a number in the banking system. Similarly, bitcoin can also be said to be the number recorded in each user account in the bitcoin system. RMB and US dollar are controlled and issued by the government. Bitcoin is not controlled by any government or individual. Although bitcoin is also supported by a network of miners, this organization is very loose and does not have a strong and consistent subjective will. Each miner must run according to the predetermined rules, and cannot modify the rules at will. Miners who violate the rules will automatically face losses and non recognition. We'll explain why in detail later.



Why is bitcoin recognized by users?



The reason why gold has been used as a stable currency for a long time is that it is relatively rare, if there are as many as sand, it can't be used as currency; the mining cost and speed are relatively stable, which can't be created by people arbitrarily; the physical and chemical properties are stable, which can be stored for a long time.

Although bitcoin is a digital currency, it also has the characteristics similar to gold: first, the number and issuing speed of bitcoin are controlled by the agreement of bitcoin protocol; bitcoin is supported by thousands of nodes on the Internet, each node stores all transactions, so the transaction record ratio is more reliable, and the account amount will not be lost easily.

Of course, after the design, there must be a certain number of supporters to promote it in order to get more recognition and use. Because of its convincing and original theory, bitcoin has been promoted to recognition in the early stage. It can be said that it is the most successful virtual currency system so far.

So how does bitcoin work? This is the focus of this paper. Let's start with the working principle of bitcoin system._DJMINER


II. Working principle of blockchain



What is blockchain?

As the name implies, blockchain is a chain of blocks.

A good metaphor is: blockchain is an account book. Each block is a page of the ledger. Each block records multiple related or unrelated transactions. Each page has a summary of the previous page, so that multiple pages must be verified one after the other, so it is called a chain. This ledger is independently checked and recorded by multiple witnesses (miners), so it is called distributed ledger.

The blockchain is maintained by many miners. The miners are not a tight organization, but one that everyone can join. You can also easily download bitcoin software and bitcoin blockchain data from the Internet, and then run to join the ranks of miners.


How do miners maintain the blockchain?

First, every transaction is broadcast on the bitcoin blockchain network. In this way, each miner can receive a lot of transaction records. These transactions are placed on each miner's scratch paper (cache area). At the same time, the miner will verify that each transaction is legal. Every once in a while, these transactions will be put into a block, which will be added to the blockchain.

That's the problem. Every miner receives different trading information. Because each transaction arrives at different miners at different times. So all the miners can't produce a completely consistent block. Moreover, any transaction should not be executed and recorded repeatedly. The solution: only one miner can create a new block at a time.

How do you decide which miner will generate the next block?


The answer is to roll the dice. Who first rolls to N consecutive zeros (proof of work) who creates the next block. The faster you roll the dice, the more likely you are to roll to n zeros in a row. So miners will continue to upgrade their computers so that they can roll to n zeros at a faster rate. At the same time, bitcoin network will adjust the difficulty n according to the time when multiple blocks are generated in front, so as to maintain the creation speed of one block in about 10 minutes. This speed must be controlled. Each block will create a certain number of new bitcoins. The new bitcoin amount will be given to the miners who created the block. This is the income from mining. This is one of the reasons why miners are willing to pay for the computer 24x7 to do this boring job. Another income is that each transaction will pay a certain handling fee to the miners.


According to the algorithm, the mining revenue from mining will be halved every four years, and eventually become zero in about 2140. At that time, the only income of the miner will be the transaction fee. There are also concerns about bitcoin's serious deflation. Others argue that inflation and deflation are not hard related to money issuance, which involves financial theory.

Of course, rolling dice is just a metaphor. The real algorithm is not as simple as rolling dice. SHA-256 hash algorithm is used.

Hash algorithm is a kind of one-way operation algorithm which is irreversible for information. For a simple example, for any four digit number, I can multiply the first two digits by the last two digits to get a new number. So hash (1234) = 12x34 = 408. It is impossible to know the original number from 408, because more than one four digit can get a hash value equal to 408 (such as 3412).


A SHA-256 hash value is a hexadecimal 40 bit string. For example:

Hash: 0xfe88c94d860f01a17f961bf4bdfb6e0c6cd10d3fda5cc861e805ca1240 c58553

This hash number must take the data on the blockchain + randomly filled data as the input, and the first n characters of the calculated hash string are all 0. A small change in the input data will cause the entire hash string to change completely. Therefore, to get a string with n characters all 0, you need to try many different random padding data.

The amount of work involved in the dice roll is very necessary. It can prevent blockchain from being tampered with. Modifying any block in history will cause all subsequent blocks to recalculate proof of work. Because the generation of each block requires a lot of calculation, it is almost impossible to forge a blockchain branch and get approval beyond the length of the main chain.

How to ensure that every miner abides by the agreement?




The blockchain is distributed, and each miner saves the entire blockchain. Therefore, after each block is generated, it will be distributed to other miner nodes. Every miner will verify that the new fast chain meets all the rules. If the rule is not met, this block will be discarded and the next block that meets the rule will be accepted. In order to get mining revenue and transaction fees, every miner will abide by the rules. Otherwise, electricity, Internet and computer money will not be paid back._DJMINER


III. bitcoin account


Bitcoin account and key


Generally, a system allows users to log in to the system and perform operations through user name and password, such as the common e-mail system. But because bitcoin is a decentralized and distributed system, and all transactions and data are open, passwords cannot be stored and managed by this system. Therefore, the bitcoin system must use asymmetric system, that is, digital signature technology.

Digital signature is similar to our real world signature or fingerprint or signature. Fingerprints, signatures, and signatures can all be verified by experts, and counterfeiting is difficult.

Digital signature and asymmetric encryption systems use a pair of public and private keys, as well as special algorithms. The public key can be published publicly. The private key must be securely saved by the owner and cannot be disclosed. Public key and private key have special properties, which can complete asymmetric encryption and digital signature. Here, we mainly use the digital signature algorithm: the private key can calculate the input information and get a certain output result, which is called digital signature; we can use another algorithm, which takes the public key, input information and digital signature as the input to verify whether it conforms to the specific rules. If it conforms to the rules, it means that the digital signature is generated by the corresponding private key.

For example, in the process of digital signature, the private key is like a lock making machine, and the public key is like a key. Zhang San, the owner of the account, has a lock making machine. Everyone else has a key that can open the lock made by the machine. Once the lock is opened, it cannot be locked again. Zhang San put his information in a box and locked it. The person who gets the box can open it with the key (public key), which means that the lock must be the lock of the account owner, so the letter in the box must be written by the owner of the private key. Zhang San can't deny it. No one else can forge the lock. The above digital signature does not involve encryption. Because the public key is public, everyone can open the box, but no one can forge the box and the information inside. It's like Zhang San signing the box seal with a pen. Anyone can open it, but no one can forge the signature. So it's called digital signature.

Asymmetric encryption is another use. At this time, the public key is like a lock. Everyone can get a lock of three, but only three have the key (private key) to open the lock. For example, Li Si should write a letter to Zhang San, put the letter in a box and lock it with this lock. Then just find someone to give it to Zhang San, because no one can open the box. It's probably made of titanium alloy:), only Zhang San has a key to open it.

There are more than one algorithm for digital signature and asymmetric encryption. Bitcoin system chooses an asymmetric encryption algorithm called elliptic curve.


I've said so much, and I'm back to business.


Bitcoin accounts are generated by randomly generating a key and a public key, and hashing the public key to get the account string. Yes, it's a hash again, but this time I changed the hash algorithm - ripemd. Both SHA-256 and SHA-256 are hash algorithms. They are used for security. After all, SHA-256 has been wildly used by miners (another name for miners) 24x7. It's safer to change the account algorithm.

Therefore, the key, public key and account have the following relationships:


The public key can verify whether any information is signed by the corresponding private key; for any public key, it can be verified by the ripemd algorithm, that is, the public key corresponding to an account string.

Bitcoin accounts are used to digitally sign information about an authorized transaction, such as a transfer to another account. And then broadcast it to all the miners through bitcoin point-to-point network.

After the miner obtains the signed transaction information and public key, he can verify that the public key is the public key of the account; he can verify that the digital signature is generated by the corresponding private key. Therefore, it can be concluded that the transaction is authorized by the owner of the account. Therefore, the transaction is legal and will eventually be recorded in the blockchain.

All accounts and transactions are open, so how to protect personal privacy?



The answer is that bitcoin accounts are anonymous. But, wait a minute. Although anonymous, people will remember you after trading with others. You can look at the open blockchain to see your transaction and account balance. To solve this problem, the solution of bitcoin software is: you can have many, such as hundreds of bitcoin accounts. How to manage so many accounts? Don't be afraid, bitcoin software comes with bitcoin wallet function, which helps you manage many accounts automatically._DJMINER

IV. bitcoin transaction


Unlike a bank account, the bitcoin network does not record the account balance. Instead, by recording each transaction, you can finally calculate the account balance. And each transaction must indicate which transactions the money was obtained from, and which new accounts to transfer now.

So all transactions recorded in the bitcoin blockchain are also chains. The starting point of the transaction chain is where the corresponding bitcoin is created. That is to say, the mine mentioned above was dug out.

In addition, there is a difference between the input and output of the transaction, which is the handling fee left to the miners. Miners will prioritize deals with high fees. It may be low priority or give up dealing with transactions with low or no handling fees. There is no free lunch in the world.

What if an ordinary user wants to get bitcoin? There are many exchanges that offer a variety of currency to bitcoin businesses. You can also buy some from your friends. The market exchange rate can be found on the Internet._DJMINER

V. essence and influence of blockchain Technology



Bitcoin is a typical and most influential blockchain application. In addition, there are many other types of blockchain open source projects, which provide various blockchains to provide more functions.

Generally speaking, blockchain technology has the following characteristics:

Distributed, can improve system availability.

Decentralized, providing networks that are controlled by algorithms and not controlled by specific institutions.

Virtual currency transactions can be supported.

The miner node can execute specific script programs to complete more complex transaction types other than transfer.

Provides non changeable and tamperable historical transaction function.

Use a digital signature to protect your account.

Ability to trade anonymously.

It can be an open network, with all transaction records open.

Prevent double flowers. That's why a network is needed, not just a digital signature. This is also necessary for the trading system.

What exactly does this mean? Can it really bring about revolutionary changes? What specific problems can be solved?_DJMINER

评论