为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链怎么实现的数据结构,区块链是怎么实现的

发布时间:2023-12-19-19:15:00 来源:网络 区块链知识 区块

区块链怎么实现的数据结构,区块链是怎么实现的

区块链是一种分布式数据库,它使用密码学和分布式记账技术来实现安全的数据存储和管理。本文将介绍区块链实现的三个关键技术:共识机制、数据结构和加密算法。

共识机制

区块链的共识机制是一种分布式技术,它能够让多个节点之间形成一致。这种技术可以让多个节点在不同的网络上进行数据交换,而不需要依赖中央服务器。共识机制的原理是,所有节点都必须遵守一定的规则,以此来确保数据的一致性。常见的共识机制包括工作量证明(Proof of Work)、权益证明(Proof of Stake)、Paxos等。

数据结构

区块链的数据结构是一种分布式数据结构,它使用链表的形式来存储数据。每个节点都有一个本地的链表,该链表包含所有发生过的交易。当有新的交易发生时,所有节点都会收到这个交易的信息,并将其添加到本地链表中。这种数据结构具有安全性、可靠性和可追溯性,可以有效地防止数据被篡改。

加密算法

区块链的加密算法是一种密码学技术,它使用数字签名和哈希函数来保护数据的安全性和完整性。数字签名是一种私钥加密技术,可以用来确保数据的完整性和可靠性。哈希函数是一种散列算法,可以将任意长度的数据转换成固定长度的哈希值,可以有效地防止数据被篡改。

总之,区块链的数据结构、共识机制和加密算法是实现安全数据存储和管理的关键技术。它们的正确使用可以有效地防止数据被篡改,保证数据的安全性和可追溯性。


请查看相关英文文档

A. You have to know the operating principles and development of blockchain!


1. Why is there innovation in blockchain?
The starting point of the first generation of the Internet is the TCP/IP protocol, which implements a unified format for peer-to-peer transmission of information by all nodes on the network. Open code. However, the impact of such an uncomplicated innovation on mankind is epoch-making. It has programmed, agreed, and enforced the basic values ​​required by a unified global market: "freedom, equality, and fraternity." Then the STMP email protocol, HTTP domain name protocol, etc. were derived, achieving low-cost and high-efficiency global information transmission in a decentralized manner. As Alibaba Vice President Gao Hongbing said:
"The Internet is to eliminate the (information) supply chain that has very low value and high cost - it is open, interconnected, peer-to-peer, globalized, and decentralized."
We know: The essence of the market is also decentralized. It automatically executes the decentralized agreement of "equivalent exchange". Just as Nobel Prize winner Ronald Coase summed up: "The market economy is based on two On the basis of deep cognition: admitting ignorance and tolerating uncertainty." Adam Smith also described the market as: "the invisible hand"! Therefore, the market must require the low-cost flow of information decentralization, and the Internet has adapted to the global Under the general climate formed by the unified market, it turned out to be.
However, the first generation of Internet decentralized solved the problem of low-cost and efficient transmission of information, but it did not solve the problem of credit of information. Therefore, what the second-generation Internet must break through is: how to establish global credit in a decentralized manner so that value transfer can be carried out at low cost and with high efficiency.
So what are the problems with the original centralized credit system? As we all know: centralized credit, such as the legal currencies of various countries, has different credit values, and the clearing systems are also incompatible, which adds a lot of cost to global trade. The current global credit system centered on the US dollar has a "Triffin Paradox" in its mechanism (the essence is that a country's legal currency cannot simultaneously resolve the conflict between its own economic interests and global economic needs). Therefore, in 2009, the Governor of the Central Bank of China, Zhou Ogawa called for the creation of a super-sovereign storage currency. In the same year, Satoshi Nakamoto disclosed the first-generation blockchain source code-"Bitcoin" online.
2. How does the blockchain system operate?
First of all, Satoshi Nakamoto knew very well that establishing a credit system for payment must solve the problem of preventing "duplicate payments", that is, no counterfeit currency can be created. The centralized credit system relies on state machinery to prevent counterfeit currency. What about "Bitcoin"? Satoshi Nakamoto's great innovation is to "timestamp" every transaction. There is a block (block: equivalent to a network account book) every ten minutes, and all network transactions for these ten minutes are correctly timestamped. The question is who will cover it? Satoshi Nakamoto did not assume that everyone on the Internet is Lei Feng. He agreed with Adam Smith: people in the market are greedy. He asked the so-called "miners" to compete for the accounting rights of each block for ten minutes. The rules of competition are correct.While ensuring accounting, you need to solve the SHA256 problem. Whoever can prove that his computer has the fastest computing power (the so-called PROOF OF WORK mechanism) can compete for the legal accounting rights of these ten-minute blocks and get 25 Bitcoin reward. This is the so-called "mining" process. It is actually a decentralized credit process that establishes a network-wide ledger - the blockchain. Therefore, the more essential function of miners is "bookkeepers"!
Satoshi Nakamoto is here In its Bitcoin white paper, the process of establishing this credit system is described in detail:
Step 1: In order for the entire network to recognize it as valid, each transaction must be broadcast to each node (node: that is, the miner);
The second step: Each miner node must correctly timestamp each transaction in these ten minutes and record it in that block;
The third step: Each miner node must Compete for the legal accounting rights of this ten-minute block by solving the SHA256 puzzle, and strive to get a reward of twenty-five bitcoins (fifty bitcoins every ten minutes for the first four years, decreasing by half every four years);< br>Step 4: If a miner node solves the SHA256 puzzle of these ten minutes, it will publish all the timestamped transactions recorded in its ten-minute blocks to the entire network, and they will be checked by other miner nodes in the entire network;< br>Step 5: Other miner nodes in the entire network check the correctness of the block accounting (because they are also stamping the accounting at the same time, but they have not competed for the legal block accounting rights, so there is no reward), there is no error Finally, they will compete for the next block after the legal block, thus forming a single chain of legal accounting blocks, which is the general ledger of the Bitcoin payment system - the blockchain.
Generally speaking, each transaction must undergo six block confirmations, that is, six ten-minute accounting, before it can finally be recognized as a legal transaction on the blockchain. The following is the accounting format of Bitcoin:
So the so-called "Bitcoin" is such a billing system: it includes the owner electronically signing with the private key and paying to the next owner, and then the entire network's "miners" "Time stamp the account and form a blockchain.
3. What are the innovations in Bitcoin’s blockchain finance?
Similar to gold, trying to establish decentralized credit on the global Internet may allow value to flow across the entire network at high speed and at low rates (currently each transfer The transfer rate is one ten thousandth);
The total amount of currency is agreed upon by the cryptographic protocol;
Compared to gold, digital currency is infinitely divisible;
The value of currency can be based on a large number of P2P transactions ;
Full transparency in financial management (every transaction can be traced on the blockchain).
Bitcoin’s blockchain-wide accounting system has established a market value of US$10 billion, the highest on the global Internet. Therefore, Wu Xiaoling, dean of Tsinghua PBC School of Finance, pointed out: The blockchain experiment established distributed credit, which is an upgraded version of Internet TCP/IP, upgrading from information transmission to value transmission;
4. Bitcoin’s blocks What are the inherent flaws of chain systems?
Bitcoin’s blockchain system has been successful since it was open sourced on the Internet in 2009, but it also shows some inherent flaws that are difficult to overcome:
The total amount cannot change with the market situation and will inevitably rise and fall. ;
Mining is highly carbon-intensive. Only less than 1% of miners can compete for the accounting rights of blocks of less than ten minutes, and more than 99% of other miners participating in the competition waste computing power;
About 10% every year The inflation has greatly increased the cost of the Bitcoin financial ecology, and even threatened her survival;
As a decentralized self-organizing DAC system, the operating costs of the accounting and issuance functions are too high.
As a global payment system, its efficiency is far from meeting the actual requirements of global trade. The Bitcoin network currently confirms a maximum of 7 transactions per second. In comparison, Visa's network system can process 10,000 transactions per second at the fastest, and Alipay's record is 80,000 transactions per second on Singles' Day in 2014!
5. Block The development of chain technology 2.0:
As the 2.0 upgrade and development of blockchain, it first focuses on solving the high-carbon mining of Bitcoin accounting:
When we discuss how to overcome the high carbon of Bitcoin mining and accounting Professor Liu Taoxiong from the Tsinghua Institute of Economics pointed out that mining competition relies on computing power. In the end, only one company competes for the legal accounting rights, and the other 99% of the miner nodes are mined for nothing, which is a waste of resources. It is obviously unreasonable. If The whole network transparently knows the legal accounting rights of the next block, and it is randomly generated in the entire network, which eliminates the high carbon cost of competitive accounting! After hearing this, we all praised Professor Liu for his brilliant idea, because the second generation is now more successful. Coin NXT has this mechanism. Their white paper is called "Transparent Forging". However, the probability of the accounting rights going to someone is directly proportional to the NXT token holdings in each miner node wallet. This is called the proof of equity mechanism ( PROOF OF STOCK). Of course, this also triggered a debate about the unfairness of NXT’s distribution of tokens to early investment developers!
RIPPLE is a semi-decentralized blockchain solution that uses “trusted gateways” to conduct block operations. The credibility of chain accounting is based on the consensus ledger protocol that these gateways will not do evil at the same time.
The most ambitious attempt is Ethereum, which combines blockchain technology with Turing completeness, hoping to develop a basic platform that can support the construction of various blockchain systems in the future. The development of various credit currencies, digital assets, smart protocols and even financial derivatives. The system design is to unify blockchain accounting on the ETHERUM platform and be used by all developers. Maybe their official version will be released in the near future.
6. Possible applications of blockchain innovation in other fields:
Now, blockchain’s attempts to establish decentralized credit are no longer limited to the financial world, but have attracted attention from all fields of society, especially in At present, some of China’s central credits, such as the “Red Cross”, are in a state of “collapse”, blockchain can provide a new way of thinking and technical options for social management. Here are some new developments and related discussions we have learned about:
The combination of blockchain and the Internet of Things unifies digital assets and atomic assets , eliminate the difference between consumer assets and cash assets, expand public credit, and accelerate value circulation; (IBM-Samsung)
Establish an intellectual property protection system on the blockchain, keep accounts of the use of intellectual property across the entire network, and establish a global Advertising market;
Whether blockchain can provide technical support for the issuance of protocol-based cryptographic currencies in emerging economies along the Belt and Road Initiative;
Blockchain + cloud computing can develop into a decentralized self-media and community system;
Blockchain can build a decentralized equity crowdfunding system, allowing innovative projects to enter the circulation field in advance;
Blockchain can develop a fully transparent financial management system;
Blockchain supports the establishment of a global Decentralized corporate organization.
In short, in this era when credit has become a scarce resource, the technological innovation of blockchain, as a distributed credit model, provides new opportunities for finance, social management, talent evaluation and decentralized organization construction in the global market. All provide a broad development prospect.

B. How does blockchain achieve distributed consensus?

The entire human society can only constantly find a balance between distribution and consensus. The two have alternated in the past. situation. The distribution is constantly iterating, and each new cycle will inherit the results left by the previous cycle. As a result, human beings can continue to reach a larger scope and higher level of civilization.

The distribution period is mainly characterized by the development of individual interests, but this does not mean that there is no centralized decision-making; the consensus period adopts centralized management that prioritizes efficiency, and distribution will be appropriately considered for overall stability and other demands.

The emergence of distribution often occurs at the end of consensus. At this time, due to uneven distribution and lack of incentives, the public has been unable to obtain further benefits, and the development of the entire society has also slowed down significantly. At this time, we prefer to use distribution Overturn the original small-scale consensus.

Significance

The reason why the Internet can play a huge role in social development lies in the establishment of a decentralized and distributed network and the The use of the TCPIP protocol, which promotes equality and realizes resource sharing, eliminates the problem of over-concentration of information and decision-making caused by centralization in the industrial era.

The emergence of blockchain is based on the prosperity created by the Internet. Through the technological innovation brought by the new distributed ledger, there is an opportunity to further promote the transfer of value. This can solve the obstacles encountered by today's Internet in the process of interconnection and interoperability entering deeper areas, and once again enhance the level of human prosperity.

C. What does blockchain mean and how to make money

The meaning of blockchain and how to make money are as follows:
1. The meaning of blockchain: Blockchain is After a piece of information is confirmed by multiple parties, it is finally stored in multiple places, which is a way to resolve transactions.tool when it comes to credit issues.
2. How to make money with blockchain:
(1) Provide blockchain technology services. Form a corporate team to specialize in the development and application of blockchain technology, and provide your technical results to companies in need for use, or develop corresponding blockchain technology based on the needs of service recipients. A simple understanding is to be a middleman.
(2) Use blockchain technology to issue coins. This method is that the company acts as an issuer and releases a certain number of virtual coins for others to invest, such as Bitcoin, Litecoin, and Dogecoin. At that time, if you wanted to become an issuer, in addition to having blockchain technology, you also had to apply for a series of filing documents and materials such as business qualification certificates and currency issuance qualification licenses from relevant regulatory authorities. Otherwise, if you don’t have these documents, it would be fraud. . However, successfully preparing these documents will still test the strength and capital of the company. If the funds are not strong enough, it will be difficult to sustain.
(3) Payment for blockchain knowledge. In the early days of the blockchain market, many people did not understand what blockchain was and wanted to participate, which inevitably gave rise to a blockchain knowledge payment market. Since this year, many public accounts with the theme of blockchain have appeared, and many paid blockchain courses and small investment circles have been born.
(4) Register to receive free candies. Candy is a token that the blockchain project team rewards early users in order to attract more users to join the early use and spread. Similar to the early "Didi", in order to cultivate a large number of early users, a large number of free taxi tickets were issued to users.

D. How to implement query and search on blockchain data

Blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. . The so-called consensus mechanism is a mathematical algorithm in the blockchain system that enables different nodes to establish trust and obtain rights and interests.

In a narrow sense, blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-tamperable. Unforgeable distributed ledger.

Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, and uses cryptography to ensure data mastery. Security of transmission and access, a new distributed infrastructure and computing paradigm that utilizes smart contracts composed of automated script code to program and manipulate data.

Generally speaking, the blockchain system consists of the data layer, network layer, consensus allocation layer, incentive layer, contract layer and application layer working together to complete the query and search of data.

E. How to do blockchain

It is necessary to establish the data layer, network layer, consensus layer, incentive layer, contract layer and application layer.

1. The data layer encapsulates the underlying data blocks and related basic data and algorithms such as data encryption and timestamps;

2.The network layer includes distributed networking mechanisms, data dissemination mechanisms and data verification mechanisms;

3. The consensus layer mainly encapsulates various consensus algorithms of network nodes;

4. Incentives The layer integrates economic factors into the blockchain technology system, mainly including the issuance mechanism and distribution mechanism of economic incentives;

5. The contract layer mainly encapsulates various scripts, algorithms and smart contracts, and is the area The basis of the programmable features of the blockchain;

6. The application layer encapsulates various application scenarios and cases of the blockchain.

(5) Extended reading on how blockchain is implemented

General Secretary Xi Jinping emphasized during the 18th collective study session of the Political Bureau of the CPC Central Committee that “use blockchain as a core technology to independently "An important breakthrough for innovation" and "accelerate the development of blockchain technology and industrial innovation."

The forward-looking judgment of the Party Central Committee has brought "blockchain" into the public eye and has become a common concern for financial capital, the real economy and social public opinion.

From network power to big data, from media integration to blockchain, the Political Bureau of the CPC Central Committee collectively studied and aimed at the forefront of technological change, demonstrating the direction, forward-looking judgment and future foresight of the Party Central Committee, leading It follows the pace of China's industrial reform and economic transformation. This collective study by the Political Bureau of the Central Committee specifically emphasized "blockchain", which opened up imagination space for the development and application of blockchain.

From a technological perspective, blockchain involves many scientific and technical issues such as mathematics, cryptography, Internet and computer programming. From an application perspective, simply put, blockchain is a distributed shared ledger and database, which has the characteristics of decentralization, non-tampering, full traceability, traceability, collective maintenance, openness and transparency.

These characteristics ensure the "honesty" and "transparency" of the blockchain and lay the foundation for the blockchain to create trust. The rich application scenarios of blockchain are basically based on the ability of blockchain to solve the problem of information asymmetry and achieve collaborative trust and consistent action among multiple subjects.

F. How to apply blockchain How to apply blockchain

1. Financial field:

Blockchain is used in international exchange, letters of credit, Financial fields such as equity registration and stock exchanges have potentially huge application value. The application of blockchain technology in the financial industry can eliminate the need for third-party intermediaries and achieve direct point-to-point connection, thereby quickly completing transaction payments while greatly reducing costs.

2. Internet of Things and logistics fields:

Blockchain can also be naturally combined in the fields of Internet of Things and logistics. Through blockchain, logistics costs can be reduced, the production and delivery process of items can be traced, and the efficiency of supply chain management can be improved. This field is considered a promising application direction of blockchain.

3. Public service field:

Blockchain is widely used in public management, energy, transportation and other fields.It is closely related to people's production and life, but the centralized nature of these fields also brings some problems, which can be transformed with blockchain. The decentralized, fully distributed DNS service provided by the blockchain can realize domain name query and resolution through point-to-point data transmission services between various nodes in the network, and can be used to ensure that the operating system and firmware of an important infrastructure are not Tampered, you can monitor the status and integrity of the software, detect bad tampering, and ensure that the data transmitted by systems using IoT technology has not been tampered with.

4. Digital copyright field:

Through blockchain technology, works can be authenticated, prove the existence of text, video, audio and other works, and ensure the ownership of works. Authenticity and uniqueness. After the rights of the work are confirmed on the blockchain, subsequent transactions will be recorded in real time, realizing full life cycle management of digital copyright, and can also be used as a technical guarantee in judicial evidence collection. For example, MineLabs, a startup company in New York, USA, has developed a blockchain-based metadata protocol. This system called Mediachain uses the IPFS file system to realize copyright protection of digital works, mainly for copyright protection applications of digital pictures.

5. Insurance field:

In terms of insurance claims, insurance institutions are responsible for fund collection, investment, and claims settlement, and often have high management and operating costs. Through the application of smart contracts, there is no need for the policy holder to apply or the insurance company to approve it. As long as the claim settlement conditions are triggered, the insurance policy can automatically settle claims. A typical application case is LenderBot, which was launched in 2016 by blockchain companies Stratumn, Deloitte and payment service provider Lemonway. It allows people to register customized micro-insurance products through the chat function of Facebook Messenger, providing services between individuals. The high-value items exchanged are insured, and the blockchain replaces the third-party role in the loan contract.

6. Public welfare field:

The data stored on the blockchain is highly reliable and cannot be tampered with, so it is naturally suitable for use in social welfare scenarios. Relevant information in the public welfare process, such as donation projects, fundraising details, fund flows, recipient feedback, etc., can be stored on the blockchain and transparently and publicly disclosed conditionally to facilitate social supervision.

G. How to develop a block into a blockchain

1. The development of a block into a blockchain requires the software Go. Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
2. Blockchain is a term in the field of information technology. In essence, it is a shared database, and the data or information stored in it has the characteristics of "unforgeable", "full traces left", "traceable", "open and transparent" and "collectively maintained". Based on these characteristics, blockchain technology has established a solid “trust”foundation, creating a reliable "cooperation" mechanism with broad application prospects.
3. From a technological perspective, blockchain involves many scientific and technical issues such as mathematics, cryptography, Internet and computer programming. From an application perspective, simply put, blockchain is a distributed shared ledger and database, which has the characteristics of decentralization, non-tampering, full traceability, traceability, collective maintenance, openness and transparency. These characteristics ensure the "honesty" and "transparency" of the blockchain and lay the foundation for creating trust in the blockchain. The rich application scenarios of blockchain are basically based on the ability of blockchain to solve the problem of information asymmetry and achieve collaborative trust and consistent action among multiple subjects.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 39437 文章总数
  • 3637499访问次数
  • 3091建站天数