Introduction to Blockchain Concepts

blockchain definition

Blockchain is a data storage tool that integrates some technologies, is suitable for multi-party games, and is endorsed by multiple parties. The core technology of blockchain includes block chain storage, point-to-point communication, cryptography, consensus mechanism, smart contract, etc.

Blockchain is to use block chain data structure to verify and store data, use distributed node consensus algorithm to generate and update data, use cryptography technology to ensure the security of data transmission and access control, and use intelligence composed of automated script codes A new distributed infrastructure and computing paradigm that uses contracts to program and manipulate data.

Core Technology

Block chain data structure

The blockchain is composed of blocks, and the blocks are connected by indexes to form a chain of blocks. Each block contains several transactions, also known as transactions, and the number of transactions in each block can be configured. Every transaction has a transaction hash as a unique identifier. When a block is formed, the block hash of the block will be formed, which is included in the block header of the block, as well as the hash of the parent block, the time stamp of the block, and the Merck Er tree (in the public chain), and a block on this block is called its parent block, and the index will point to the parent block. Such a block chain storage structure ensures that the data in the block cannot be tampered with: when the programmer tampers with the transaction information in the A block, the block hash stored in the A block header and the current block hash Unable to correspond, the programmer needs to tamper with the block hash in the block header of A, and this does not correspond to the hash of the parent block (block A) saved in the sub-block header, and the programmer needs to tamper with the hash stored in the sub-block Hash, and so on, the final programmer needs to tamper with all blocks after block A, and the cost of tampering is relatively high.

peer-to-peer communication

In the past, the centralized server was weak in terms of computing pressure and security, and the use of distributed storage and peer-to-peer communication can greatly solve this problem. The blockchain needs to have at least 3 nodes, and communicate with each other through the P2P protocol. Because it is a distributed storage, the computing power can be distributed to each storage terminal. Because of the decentralized storage, and each node (full node) stores the same set of stored data, if the stored data is to be tampered with, then 2/3 of the nodes must be tampered with, further increasing the cost of tampering.

Cryptography

Cryptography includes symmetric encryption (that is, use the same set of passwords to verify), asymmetric encryption (a pair of public and private keys), and hash algorithms. A large number of blockchains use asymmetric encryption. Each blockchain user will obtain a pair of public and private keys. The public key is similar to the user's account, and the private key is similar to a password and must be kept properly. Taking Bitcoin as an example, when user A transfers money to user B, user A needs to know the public key information of user B, and user B needs to use the private key that matches the public key to decrypt the transfer after receiving the transfer. If user B wants to know whether the transfer is from user A, he can use A's public key to verify the signature, because when user A transfers money, he will use A's private key to encrypt (sign). The application of cryptography guarantees the privacy of data. In the current situation where data is abused and user privacy is infringed, the importance of cryptography to user data will be more and more valued.

sign

That is, digital signature, which is a specific form of electronic signature, refers to the use of asymmetric encryption to attach private key information to electronic information and documents. Signature verification: It is to verify the signature information. Here, the public key is used to verify the private key. If the two match, the verification is successful.

consensus mechanism

On the basis of the above technologies, what needs to be considered is the alliance governance between multiple parties, otherwise the disorderly growth of data will cause the paralysis of the blockchain: how should there be a unified system for different information entered by multiple nodes at the same time? standard rules to govern. The consensus mechanism is a rule, which data should be recorded in the block, how to record, who should record, and the reward mechanism to make unified regulations. Typical consensus mechanisms include public key POW, consortium chain PBFT, RPCA, etc. There is also a consensus mechanism for consortium chains that greatly increases consensus efficiency at the cost of sacrificing accuracy, among which are representatives such as paxos and raft.

Fragmentation Consensus

Both the network and transactions are fragmented, and the network is divided into several areas, each area has a set of nodes that can complete the consensus. When the consensus starts, the transaction is passed to the gateway node, and the gateway node puts the transaction in the transaction pool. Afterwards, the groups are distributed to each area, and the initial block microledger is formed after the consensus of the shard nodes, which is passed to the committee node. The committee node also undertakes the consensus task of its own area, combines the preliminary blocks of all areas to form the final block finalLedger, and transmits it to the gateway, synchronization SYNC node, and fragmentation node, and the final block is synchronized in the entire network. The sharding consensus has some limitations. The general single-chain consensus BFT can tolerate 3F+1 nodes, that is, 4 nodes can tolerate 1 fault, and 7 nodes can tolerate 2 faults.

smart contract

contract definition

A smart contract (SmartContract) is a computer protocol designed to disseminate, verify or execute contracts in an informational manner. Its essence is a set of programs running on the blockchain. Based on the immutable characteristics of the blockchain, it is guaranteed that this program is recognized and cannot be tampered with by a single organization. Smart contracts allow for trusted transactions without third parties, which are traceable and irreversible. In fact, a smart contract is a set of promises (Promises) defined in digital form, including agreements on which contract participants can execute these promises.

contract history

Smart contracts cannot be used before Ethereum, and programs can only be written on the blockchain after Ethereum appears.

Contract Lifecycle

In the blockchain, a typical life cycle of a smart contract includes:

Contract writing, using the contract development language to write smart contracts;

Contract compilation, using the contract compiler to compile the smart contract into bytecode;

Contract deployment, deploying the compiled bytecode to the blockchain;

Contract call, the client sends the transaction calling the contract method to the blockchain node for execution;

Contract upgrade, that is, modify the contract code according to business needs, recompile and then update to the blockchain;

The contract is frozen. The frozen contract no longer allows new calls. This feature is used for emergency intervention under contract defects or contract offline.

A smart contract is an indispensable component of the blockchain. It implements a pre-specified business process. The difference from ordinary programs is that it can be executed by multiple people at the same time, and it is decided whether to continue to submit according to the execution results.

On the platform, users can automatically choose to deploy, start, and stop smart contracts.

The smart contract in Fabric is also called chain code (Chaincode). The chain code encapsulates the business network transaction in the code, and finally runs in a Docker container. Users can develop and test offline.

practical application

The current popular NFT uses smart contracts, among which ERC721 and 1155 protocols are widely used.

Other smart contracts applicable to industries abound.

Cross-chain technology

definition

Cross-chain is the information exchange between multiple chains, and the transfer of information on the chain.

type

Including notary mechanism, relay chain, side chain, hash lock, etc.

difficulty

At present, cross-chain between isomorphic chains (the same underlying blockchain framework) is relatively simple, and there will be technical barriers to cross-chain between heterogeneous chains. There are some disadvantages in cross-chain technology, such as the centralization of the notary mechanism.

Guess you like

Origin blog.csdn.net/xzhu4571/article/details/125309671