Home » A to Z Knowledge of Blockchain

A to Z Knowledge of Blockchain

by Scienceooze

What is a Blockchain?

Blockchain is Pack the information of multiple transactions and the information indicating the block together, and the verified package is the block.

In each block, the hash value of the previous block is stored, so that there is a relationship between the blocks, that is to say, a chain. Together it is called a blockchain.

What is Bitcoin

The Bitcoin concept was proposed by Satoshi Nakamoto in 2009. The Bitcoin chain generates a block approximately every 10 minutes, and this block is dug out by miners for 10 minutes. As a reward for miners, a certain amount of Bitcoin will be issued to miners, but this certain amount is halved every four years. Now it is 6.25. In this way, all bitcoins will come out in 2140.

What is Ethereum

The biggest difference between Ethereum and Bitcoin is that there are smart contracts. Allows developers to develop and run various applications on the top.

Characteristics of blockchain


Distributed ledger

It is a database that is shared, replicated, and synchronized among network members. To put it bluntly, all users on the blockchain have accounting functions and the content is consistent, which ensures that the data cannot be tampered with.

What is quasi-anonymity

I believe everyone has a wallet, and the wallet address (a string of strings) used to send transactions is quasi-anonymous.

What are openness and traceability

The blockchain stores all data from history to the present, anyone can view it, and any data in history can also be viewed.

What is non-tamperable

Historical data and current transaction data cannot be tampered with. The data is stored in the block on the chain, and there is a hash value. If the block information is modified, its hash value will also change, and the hash value of all blocks behind it must also be modified to make it a new chain. At the same time, the main chain is still performing transactions to generate blocks. After the modification, the chain must always be synchronized with the main chain to generate blocks to ensure that the length of the chain is the same. The cost is too great, just to modify a piece of data.

What is the anti-DDoS attack

DDoS: Hackers control many people’s computers or mobile phones to allow them to access a website at the same time. Since the broadband of the server is limited, the influx of a large amount of traffic may make the website unable to work normally and suffer losses.

But the blockchain is distributed, there is no central server, one node fails, and other nodes are not affected. Theoretically, more than 51% of nodes are attacked and problems will arise.

Blockchain classification

Definition of the main chain

Take Bitcoin as an example. At a certain point in time, two miners can dig out a block at the same time, and then the chain that generates 6 blocks first is the main chain.


A single chain refers to a data structure that processes everything on one chain.

Multi-chain structure, its core essence is the public chain + N sub-chains. There is only one, theoretically, there can be countless sub-chains, and each sub-chain can run one or more DAPP systems

Public chain/alliance chain / private chain

Public chain: Everyone can participate in the bookkeeping of the blockchain and download complete transaction information.

Consortium chain: only allow alliance members to participate in accounting and query

Private chain: The permission to write and view is only in the hands of one organization.

The hierarchical structure of the blockchain

Consensus layer, data layer,

The overall structure of the blockchain has six layer

  • Data layer
  • Network layer
  • Consensus layer
  • Incentive layer
  • Contract layer
  • Application layer

Data layer: the layer that records data and belongs to the underlying technology.

Network layer: an architecture for building a blockchain network, which determines the way users are organized.

Consensus layer: Provides a set of rules to allow everyone to agree on the information received and stored.

Incentive layer: design incentive policies to encourage users to participate in the blockchain ecology.

contract layer: generally refers to “smart contracts”, which is a set of contract systems that can be automatically executed and written according to their own needs.

Application layer: The application on the blockchain is similar to the mobile phone app.

The basic technology of blockchain


The timestamp refers to the total number of seconds from 0:00:00:00 on January 1, 1970, to the current time, or the total number of nanoseconds, and so on.

Each block has a timestamp when it is generated, indicating the time when the block was generated.

Block/block header/block body

The block is the basic unit of the blockchain, and the block header and block body are the components of the blockchain. The information contained in the block header includes the hash of the previous block, the hash of this block, the timestamp, and so on. The block body is the detailed data in the block.

Merkle tree

Merkle tree, also called a binary tree, is a data structure for storing data. The bottom layer is the original data contained in all blocks, and the upper layer is the hash value of each block. The hash values ​​of this layer are combined in pairs to generate new ones. The hash value forms a new layer and then goes up layer by layer until a hash value is generated. This structure can be used to quickly compare large amounts of data, and you can quickly find the lowest historical data you want without downloading all the data.

What is an expansion

The block size of Bitcoin is about 1M, and it can store 4000 transaction records. Expansion is to increase the size of the block to save more data.

Data structure

What is a chain

Each block saves the hash of the previous block, so that there is a relationship between the blocks, and this relationship is the chain. Through this chain, data such as block transaction records and state changes are stored.

Block height

This is not the height in terms of distance, it refers to the total number of blocks between the block and the first block on the chain. This height indicates the first few blocks, which are just for identification.


Two blocks are generated at the same time (the transaction information in the block is the same, but the hash value of the block is different), and then two chains are forked on these two blocks, and the two chains are linked Whoever generates 6 blocks first is the main chain, and the other chain is discarded.

Ghost Agreement

Mining pools with high computing power can easily generate blocks faster than mining machines with low computing power, resulting in most blocks on the blockchain being generated by these high computing power mining pools. The blocks generated by the mining machines with low computing power are not stored on the chain because they are slow, and these blocks will be invalidated.

The ghost protocol allows blocks that should be invalidated to remain on the chain for a short period of time, and can also be used as part of the proof of work. In this way, miners with small computing power will contribute more to the main chain, and large mining pools will not be able to monopolize the confirmation of new blocks.

Orphan block

As mentioned before forking, orphan blocks are blocks generated at the same time. One of them forms a chain, and the other behind does not form a chain. Then the block that does not form a chain is called an orphan block.

Uncle block

The orphan block mentioned above, through the ghost protocol, makes it part of the proof of work, then it will not be discarded and will be stored on the main chain. This block is the uncle of the next block.

Replay attack

It means that the hacker re-sends the message that has been sent to the server. Sometimes this can trick the server into multiple responses.

Directed Acyclic Graph

Also called data set DAG (directed acyclic graph)

DAG is an ideal multi-chain data structure. Most of the blockchains we are talking about are single chains, that is, one block is connected to one block, and DAG is connected to multiple blocks. The advantage is that several blocks can be generated at the same time, so the network can process a large number of transactions at the same time, and the throughput will definitely increase. But there are many shortcomings and it is currently in the research stage.

Decryption algorithm

What is encryption/asymmetric encryption

Symmetric encryption

Symmetric encryption means that both the encryption algorithm and the decryption algorithm are in the same mode. The secret key is used to encrypt and decrypt information. Generally, the longer the key, the more difficult it is to crack the ciphertext. Symmetric encryption has one of the biggest weaknesses: there is only one key that guarantees the encryption and decryption of data, so Party A must tell Party B the key, otherwise, Party B cannot decrypt it. But saving and transferring keys has become the most troublesome problem.

Asymmetric encryption

Asymmetric encryption requires two (a pair) of keys: a public key (public key) and a private key (private key). After the data is encrypted with the public key, only the corresponding private key can be decrypted; otherwise, if the private key is used Encrypted, only the corresponding public key can be decrypted. In this way, it can be ensured that the communicating parties are private and the identities of both parties can be confirmed.

The sent information is transmitted in the form of ciphertext. What the receiver can decrypt is symmetric encryption, and what cannot be decrypted is asymmetric.

Digital signature/digital identity/digital certificate

A private key signature, public key verification. The private key corresponds to two large numbers r, s, and the published message, and r, s are packaged into a message and sent together with the public key. The receiver decodes the information through the public key to generate r, s, and compare the r in the public key Whether s is the same, the same means the verification is successful.

Digital identity is your identity on the Internet, which often corresponds to a unique identification number. All operations you perform on the Internet are carried out through digital identity.

Digital certificate: issued by some certification bodies to prove the true identity in reality behind a certain digital signature.

RSA/ellipse encryption algorithm

These two encryption methods are currently the safest. The key length of RSA is generally 1024 bits, while the key length of elliptic encryption is 256 bits. This is the main difference.

Ring signature

When I transact with someone else, I will mix my private key with someone else’s public key and process it into a signature in some way. Since this is a multi-person signature and there is no order between people, this is called a ring signature. In this way, others only know that this group of people participated in the transaction, but they do not know who is trading.

Currency mixing service

Generally speaking, each transaction information on the blockchain will display an input address and an output address, so that the addresses of both parties to the transaction are exposed. The Chaos service can record several transactions of the same amount together, where multiple input addresses are mixed, and multiple output addresses are mixed. This eliminates the correspondence between the parties to the transaction.

Zero-knowledge proof

We have talked about this knowledge point in our group. When this method is applied to the blockchain, the transaction information of both parties will not be disclosed at all, but the transaction can be concluded.

Distributed technology

Node and Full Node

Node: A node of the network in a distributed system, generally refers to servers, computers, etc. connected through the network. Your computer can also be a node on the network.

Full node: refers to the node that owns all the data on the network. A full node needs to synchronize all blockchain data. It can independently verify all transactions on the blockchain and update data in real-time. It is mainly responsible for sending transaction information to other nodes so that other nodes can quickly verify transactions without downloading all the data.

Point-to-point communication

The two nodes communicate directly without going through a third party to ensure user privacy.

Distributed storage

Traditional distributed storage is a centralized organization that backs up data in many places. In the blockchain, the distributed database in the entire blockchain is established through the open storage space of each node in the chain. Distributed storage in the blockchain can improve the operating efficiency of the network and solve the bottleneck of server processing speed in traditional distributed storage.

Consensus mechanism

What is a consensus mechanism

A rule that everyone agrees on in the blockchain. All transactions or other information transfers need to be confirmed by the consensus mechanism, and this information can be saved on the chain after confirmation is legal. This ensures the consistency and accuracy of everyone’s accounting.


English is proof of work, which is proof of work. Bitcoin mining is the pow mechanism. The principle is that the computer continuously calculates a series of numbers through variable (nonce) changes, and does not stop the calculation until a certain series of numbers meet the specified difficulty requirements. This string of numbers is the hash value of the newly generated block.


The English are proof of stake, which is the proof of stake mechanism. The pos mechanism is directly linked to the number of tokens held and the holding time. This model will allocate corresponding interest to you based on the amount and time you hold the digital currency.

Simply put, it is a system that gives you interest based on the amount and time of currency you hold. In the proof-of-stake POS model, there is a noun called currency age. Each currency generates 1 currency age per day. For example, if you hold There are 100 coins held for a total of 30 days, then your coin age is 3000 at this time. At this time, if you find a POS block, your coinage will be cleared to 0. Every time you are cleared of 365 coins, you will get 0.05 coins of interest from the block (assuming that the interest can be understood as an annual interest rate of 5%), then, in this case, the interest=3000*5%/365=0.41 Currency, this is very interesting, holding currency has an interest.


The English have delegated proof of stake and the certificate of entrusted equity.

DPoS gives a way of thinking. Thousands of PoS nodes will be elected by a certain mechanism (such as the number of tokens) to elect a number (odd number) of nodes, and voting among these nodes (in some In the implementation, polling between these nodes is even carried out in a token ring manner to further reduce the voting overhead) each checkpoint (block generation) node is selected, instead of choosing between all nodes in the network.

This mechanism can greatly improve election efficiency. Consistency voting between dozens of nodes at most hundreds of nodes can generally be completed and reached consensus in seconds, so the DPoS mechanism can increase the checkpoint (transaction confirmation time) to the second level by reducing the number of voting nodes or The token ring mechanism can even be reduced to the millisecond level.

51% attack

One person controls more than 50% of the computing power of the entire network, then he will have an advantage when competing for the accounting rights of the next block, and will complete the proof of work faster than others. Because this person has such a large amount of computing power, it is easy to do 1. Modify his own transaction records, which can enable him to make double payments. 2. Block confirmation of some or all transactions. 3. Prevent some or all miners from mining anything. Valid block

Byzantine Generals Question

Describe the story of 10 small countries attacking a big country. This can be found online, so I won’t go into details.

Improved practical Byzantine fault-tolerant PBFT

We focus on the three historical stages of pre-prepare, prepare, and commit. The two stages of pre-preparation and preparation are used to ensure the timing of sending requests in the same view (even if the master node that sorts the requests fails), and the two stages of preparation and confirmation are used to ensure the confirmation of requests between different views It is strictly ordered.

Preparation stage

In the pre-preparation phase, the master node assigns a sequence number n to the received request, and then sends a pre-preparation message to all backup nodes. The format of the pre-preparation message is <

Blockchain expansion technology


Sharding technology can solve the problems of slow transaction speed and low throughput. It divides transactions on the network into many small pieces, and different nodes are responsible for verifying the content of different small pieces. In this way, the more nodes, the more transactions that can be verified at the same time, and the overall speed of verification are accelerated. With sharding technology, different transactions are verified by different nodes. Blockchain is like only one toll station on a high-speed highway, so it is prone to congestion; fragmentation technology is like providing several toll stations so that vehicles can pass through quickly. But the shortcomings are fatal, and transactions with conflicting content may cause double payments because of verification by different nodes. Currently under study.

Lightning Network/Raiden Network

The Lightning Network is to place small transactions on a single chain, and key transactions on the main chain to increase transaction throughput. It uses time lock technology. If one party wants to tamper with the transaction, and the other party discovers such cheating within a period of time, it can punish the other party while protecting its own property from loss. At the applicable stage.

Based on the idea of ​​the Lightning Network, the Ethereum community also proposed its own off-chain micropayment channel solution, which is implemented through smart contracts, which is the Raiden Network.

​​Cross-chain and interconnected chains

Kua lian is similar to the bank’s inter-bank transfer. Typical cross-chain technology: notary mechanism, side chain, hash lock mode.

Interconnection chain refers to the connection of various blockchains through a certain technology.


A side chain is a mechanism for connecting two different blockchains. Through the side chain, we can transfer tokens to other blockchain projects and return them safely.

Implementation method: Through the side chain technology, we can lock a bitcoin; and another blockchain project will allow the user to use a token equal to the value of bitcoin after receiving the lock information.

During this period, after various transactions/operations are completed, the remaining tokens will be re-locked, and a processing message will be sent back to the Bitcoin main chain to unlock the remaining Bitcoins. The side chain is an independent and isolated system. Problems in the side chain will only affect the side chain itself, which greatly reduces the risk and cost of innovation.

Turing Complete

If a system can write a program to find the answer, the system is Turing complete. The specific implementation is based on smart contracts. Users can write codes according to their own needs to implement the required functions and call them.

Decentralized application DApp

Dapps are generally open-source and autonomous. The data in the app is encrypted and stored on the blockchain to ensure safety, protect privacy, and change the production relationship. For example, in a damp, the revenue generated by the user’s access to the traffic can be directly output to the content producer, without the need to go through the platform.

Blockchain technology application

Digital currency

It is the numbers generated based on network algorithms, and the recognized groups of these numbers are given the function of issuing coins and conducting transactions.

Smart contract

I have talked about it. It is to leave a piece of smart contract code in the source code. The methods in the contract can be called externally.


Short for Ethereum Virtual Machine. It is a code operating environment built on the Ethereum blockchain to execute Ethereum smart contracts. Ethereum is a peer-to-peer network, and each node will run the Ethereum virtual machine. When a smart contract takes effect, the virtual machine on the node compiles the code, executes the contract, stores data, and ensures that the execution result is recorded on the blockchain.


Generally considered to be tokens. Strictly speaking, it should be called digital proof of rights.

Digital currency transactions

Public/Private Key

This belongs to the category of encryption.

Secure Hash Algorithm (Secure HashAlgorithm, abbreviated as SHA), using the modified algorithm to calculate a fixed-length string (also known as a message digest) for data of any length, and the string is unique.

The Bitcoin private key is actually a 32-byte (256-bit) random number generated using SHA-256, and the range of the valid private key depends on the secp256k1 elliptic curve digital signature standard used by Bitcoin. The numbers between 0x1 and 0xFFFF FFFF FFFFFFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 are almost all legal private keys.

Add the version number in front of the private key, and add the compression mark and additional check code at the back. (The so-called additional check code is to perform two SHA-256 operations on the private key, and take the first four bytes of the two hash results ), and then Base58 encoding it, we can get our common private key in WIF (Wallet Import Format) format.

The private key is multiplied by the elliptic curve to obtain the public key. The public key is a point on an elliptic curve and has x and y coordinates. There are two forms of public keys: compressed and uncompressed. In the early days, Bitcoin used uncompressed public keys. Now most clients use compressed public keys by default.

Due to mathematical principles, it is feasible to deduce the public key from the private key, but it is impossible to deduct the private key from the public key.

People who are new to Bitcoin often have a misunderstanding that the Bitcoin public key is an address, which is incorrect. From the public key to the address, some calculations are required.


The public key information generated by the elliptic curve algorithm is relatively long, with 33 bytes in the compressed format and 65 bytes in the uncompressed format. The address is to reduce the number of bytes that the receiver needs to identify. The steps to generate a Bitcoin address are as follows:

Generate private key and public key

2 Process the public key through the SHA256 hash algorithm to obtain a 32-byte hash value

The 3 pairs of obtained hash values ​​use the RIPEMD-160 algorithm to obtain a 20-byte hash value-Hash160

4 Perform a double SHA256 hash operation on the 21-byte array composed of version number + Hash160, and the first 4 bytes of the obtained hash value are used as the checksum and placed at the end of the 21-byte array.

5 Perform Base58 encoding on the 25-bit array to get the address.

We don’t need to figure out the specific process one by one, it involves a lot of mathematical formulas and principles. But we need to understand the following points:

Due to the characteristics of elliptic curve multiplication and hash function, we can derive the public key from the private key or the address from the public key, and this process is irreversible. For this reason, in the entire Bitcoin (Ethereum, etc.) system, the public key can be disclosed, which means that the wallet address is safe. The private key is the most critical part.

Mining/miner/block rewards

The mining process is to perform a series of conversions, connections, and hash operations on the above six fields, and as the random numbers are continuously tried to find one by one, finally a random number is successfully found to meet the conditions: the hash operation The value is smaller than the hash value of the preset difficulty value, then the mining is successful, the node can broadcast the block to the neighboring node, and the neighboring node receives the block and performs the same operation on the above six fields.

Verify compliance, and then broadcast to other nodes. Other nodes use the same algorithm to verify. If 51% of the nodes in the entire network are verified successfully, even if the block is truly “mined” successfully, each The nodes all adds this block to the back of the previous block, delete the same list of records in the block as their own, and regenerate the above process again.

Another thing to say is that, regardless of whether the mining is successful or not, each node will pre-register the 50 rewarded bitcoins and the handling fee (total input-total output) of all transactions in the first item of the transaction list (this is The most fundamental purpose of “mining” is also the fundamental reason to ensure the long-term stable operation of the blockchain), the output address is the address of this node, but if the mining is unsuccessful, the transaction will be invalidated without any reward. And this transaction called “production transaction” does not participate in “mining” calculations.

Mining Machine

Mining machines are computers with various configurations, and computing power is their biggest gap.

The place where the mining machines are concentrated in one place is the mine

Mining Pool

Miners unite to form a team, and the computer group under this team is the mining pool. Mining rewards are distributed according to their own computing power contribution.

Mining difficulty and computing power

The difficulty of mining is to ensure that the interval between generating blocks is stable within a short period of time, for example, Bitcoin generates 1 block in 10 minutes.

Computing power is the configuration of the mining machine



When the verification in the blockchain is a confirmation of the legitimacy of the transaction, when the transaction message is propagated between nodes, each node will verify whether the transaction is legal. For example, verify whether the transaction syntax is correct, whether the transaction amount is greater than 0, whether the entered transaction amount is reasonable, and so on. After the verification is passed, it will be packaged and handed over to miners for mining.

Transaction Broadcast

It is the node that sends information to other nodes through the network.

Miner fees

The blockchain needs to work continuously like a perpetual motion machine and requires miners to maintain this system all the time. Therefore, it is necessary to give the miners a favorable fee to last.

Transaction Confirmation

When a transaction occurs, the block that records the transaction will be confirmed for the first time, and will be confirmed again in every block on the chain after the block; when the number of confirmations reaches 6 or more, it is usually considered this The transaction is relatively safe and difficult to tamper with.

Double transaction

That is, I have 10 yuan, I bought a pack of cigarettes with the 10 yuan, and then instantly bought another cup of coffee with the 10 yuan that had not yet been paid.

So when verifying the transaction, you must confirm whether the 10 yuan has been spent.

UTXO unspent transaction output

It is a data structure containing transaction data and execution code, which can be understood as a digital currency that exists but has not been consumed.

The number of transactions per second TPS

That is throughput, tps refers to the number of transactions that the system can process per second.



Similar to Alipay, blockchain technology is more secure for storing digital currency.

Cold wallet/hot wallet

A cold wallet is an offline wallet. The principle is to store it locally and use the QR code to communicate so that the private key never touches the Internet.

A hot wallet is an online wallet. The principle is to encrypt the private key and store it on the server, download it from the server when needed, and decrypt it on the browser side.

Software wallet/hardware wallet

A software wallet is a computer program. Generally speaking, a software wallet is a program that interacts with the blockchain, allowing users to receive, store and send digital currency, and can store multiple keys.

Hardware wallets are smart devices that specialize in processing digital currency.



The project party sends the digital currency to each user’s wallet address. For nothing


Mapping is related to the issuance of blockchain currency and is the mapping between chains. For example, some blockchain companies have not completed the development of the chain in the early stage. They rely on Ethereum to issue their own currency. The issuance and transactions of the early currency are all operated on Ethereum. With the development of the company, the company’s own chain development is completed. The company wants to map all the information previously on Ethereum to its own chain. This process is mapping.


The GHOST protocol allows us to choose a path on which the most calculations are completed. One way to determine the path is to use the block number of the most recent block (leaf block). The block number represents the total number of blocks on the current path (not including the genesis block). The larger the block number, the longer the path, which means that more mining power is consumed on this path to reach the leaf block. Using this reasoning allows us to agree with the authoritative version of the current state.

You may also like