【区块链】区块链背后的4大核心技术

资讯 2024-07-10 阅读:41 评论:0
  区块链的技术定义˂a class="innerlink" href="http://www.chinaaaet.com/tags/block chain" target="_blank"...

  区块链的技术定义

  简单来说,区块链是一个提供了拜占庭容错、并保证了最终一致性的分布式数据库;从数据结构上看,它是基于时间序列的链式数据块结构;从节点拓扑上看,它所有的节点互为冗余备份;从操作上看,它提供了基于密码学的公私钥管理体系来管理账户。

In simple terms, the block chain is a distributed database that provides Byzantine tolerance and ensures ultimate consistency; it is a chain data block structure based on time series in terms of data structure; all of its nodes are redundant backups in terms of nodes; and, operationally, it provides a cryptographic-based public-private key management system to manage accounts.

  或许以上概念过于抽象,我来举个例子,你就好理解了。

Perhaps these concepts are too abstract. Let me give you an example. You can understand them.

  你可以想象有 100 台计算机分布在世界各地,这 100 台机器之间的网络是广域网,并且,这 100 台机器的拥有者互相不信任。

You can imagine 100 computers spread around the world, the network between these 100 machines is a wide area network, and the owners of these 100 machines don't trust each other.

  那么,我们采用什么样的算法(共识机制)才能够为它提供一个可信任的环境,并且使得:

So what algorithm do we use (consensus mechanism) to provide it with a trusted environment and to make:

  节点之间的数据交换过程不可篡改,并且已生成的历史记录不可被篡改;

The process of data exchange between nodes cannot be tampered with and the historical records generated cannot be tampered with;

  每个节点的数据会同步到最新数据,并且会验证最新数据的有效性;

Data for each node will be synchronized to the latest data and the validity of the latest data will be validated;

  基于少数服从多数的原则,整体节点维护的数据可以客观反映交换历史。

Based on the principle of majority subordination, the data maintained by the overall node can objectively reflect the history of the exchange.

  区块链就是为了解决上述问题而产生的技术方案。

The block chain is a technical solution to the above-mentioned problems.

  我们结合以往讲过的内容,和即将要讲的内容,先提炼一下区块链在技术上的 7 个特征,你先记住,我们后续会慢慢道来:

In the light of what we've said and what we're about to say, let's refine the seven technical features of the block chain.

  区块链的存储基于分布式数据库;

Storage of block chains is based on distributed databases;

  数据库是区块链的数据载体,区块链是交易的业务逻辑载体;

The database is the data carrier for the block chain, which is the operational logical carrier for transactions;

  区块链按时间序列化区块数据,整个网络有一个最终确定状态;

The block chain sequences block data over time, with a final determination status for the entire network;

  区块链只对添加有效,对其他操作无效;

Block chains are effective only for additions and not for other operations;

  交易基于非对称加密的公私钥验证;

Public-private key authentication for transactions based on asymmetric encryption;

  区块链网络要求拜占庭将军容错;

The block chain network requires General Byzantine to be mistaken;

  共识算法能够“解决”双花问题。

Consensus algorithms can “solve” the double flower problem.

  区块链的核心技术组成

Core technical composition of block chains

  无论是公链还是联盟链,至少需要四个模块组成:P2P 网络协议、分布式一致性算法(共识机制)、加密签名算法、账户与存储模型。

At least four modules are required for public and union chains: P2P network protocols, distributed consistency algorithms (consensus mechanisms), cryptographic signature algorithms, accounts and storage models.

  1. P2P 网络协议

1. P2P Network protocol

  P2P 网络协议是所有区块链的最底层模块,负责交易数据的网络传输和广播、节点发现和维护。

The P2P network protocol is the bottom of all block chains and is responsible for network transmission and broadcasting of transaction data, node discovery and maintenance.

  通常我们所用的都是比特币 P2P 网络协议模块,它遵循一定的交互原则。比如:初次连接到其他节点会被要求按照握手协议来确认状态,在握手之后开始请求 Peer 节点的地址数据以及区块数据。

Usually, we use the Bitcoin P2P network protocol module, which follows a certain principle of interaction. For example, initial connections to other nodes are required to confirm the status according to the handshake agreement, and after handshake, we start to ask for Peer node address data and block data.

  这套 P2P 交互协议也具有自己的指令集合,指令体现在在消息头(Message Header) 的 命令(command)域中,这些命令为上层提供了节点发现、节点获取、区块头获取、区块获取等功能,这些功能都是非常底层、非常基础的功能。如果你想要深入了解,可以参考比特币开发者指南中的 Peer Discovery 的章节。

The P2P interactive protocols also have their own command collection, which is reflected in the message header command (command) domain, which provides nodes, nodes acquisition, block acquisition, block acquisition, etc. for the upper layers, which are very bottom and very basic functions. If you want to know more, you can refer to the Peer Discovery section of the Bitcoin Developer's Guide.

  2. 分布式一致性算法

2. Distributive consistency algorithms

  在经典分布式计算领域,我们有 Raft 和 Paxos 算法家族代表的非拜占庭容错算法,以及具有拜占庭容错特性的 PBFT 共识算法。

In the classic distributed area of computing, we have non-Bazant arithmetic algorithms represented by the Raft and Paxos algorithms, as well as PBFT consensus algorithms with Byzantine tolerance.

  如果从技术演化的角度来看,我们可以得出一个图,其中,区块链技术把原来的分布式算法进行了经济学上的拓展。

From the point of view of technological evolution, we can draw a graph in which block chain technology expands the economics of the original distributed algorithms.

640.webp (11).jpg

  (图来自网络)

(Figures from the Web)

  在图中我们可以看到,计算机应用在最开始多为单点应用,高可用方便采用的是冷灾备,后来发展到异地多活,这些异地多活可能采用的是负载均衡和路由技术,随着分布式系统技术的发展,我们过渡到了 Paxos 和 Raft 为主的分布式系统。

As we can see in the graph, computer applications are applied more often in single-point applications, more easily accessible to cold hazards, and later more lively in remote areas where load balances and routers can be used, and as distributed system technology evolves, we transition to distributed systems dominated by Paxos and Raft.

  而在区块链领域,多采用 PoW 工作量证明算法、PoS 权益证明算法,以及 DPoS 代理权益证明算法,以上三种是业界主流的共识算法,这些算法与经典分布式一致性算法不同的是,它们融入了经济学博弈的概念,下面我分别简单介绍这三种共识算法。

In the area of block chains, the PoW workload certificate algorithms, the PoS equity certificate algorithms, and the DPOS proxy equity certificate algorithms, the three types of consensus algorithms that differ from the classic distributed consistency algorithms, which are integrated into the concept of economics games, are briefly described below.

  PoW: 通常是指在给定的约束下,求解一个特定难度的数学问题,谁解的速度快,谁就能获得记账权(出块)权利。这个求解过程往往会转换成计算问题,所以在比拼速度的情况下,也就变成了谁的计算方法更优,以及谁的设备性能更好。

PoW: Usually, under a given constraint, solves a particular difficult mathematical problem, and whoever solves it quickly gets the right to account. This process often turns into a question of calculation, so it becomes a better method of calculation than the speed of the puzzle, as well as a better device.

  PoS: 这是一种股权证明机制,它的基本概念是你产生区块的难度应该与你在网络里所占的股权(所有权占比)成比例,它实现的核心思路是:使用你所锁定代币的币龄(CoinAge)以及一个小的工作量证明,去计算一个目标值,当满足目标值时,你将可能获取记账权。

PoS: This is an equity certification mechanism, the basic concept of which is that the difficulty of creating blocks should be proportional to the equity (ownership ratio) that you occupy in the network, and the central idea it achieves is to use the currency age (CoinAge) that you have locked in your currency, as well as a small workload certificate, to calculate a target value, and when the target value is met, you will be able to obtain the right to account.

  DPoS: 简单来理解就是将 PoS 共识算法中的记账者转换为指定节点数组成的小圈子,而不是所有人都可以参与记账。这个圈子可能是 21 个节点,也有可能是 101 个节点,这一点取决于设计,只有这个圈子中的节点才能获得记账权。这将会极大地提高系统的吞吐量,因为更少的节点也就意味着网络和节点的可控。

DPOS: Simplely understood is to convert the book keeper in the Pos Consensus algorithm into a small circle of specified nodes, not all of whom can be involved. This circle could be 21 nodes, or 101 nodes, depending on design, and only nodes in this circle would be given the right to account. This would greatly increase the system's throughput, because fewer nodes would also mean that networks and nodes could be controlled.

  3. 加密签名算法

3. Encryption signature algorithms

  由于我不是密码学专业出身,所以这个部分我会以介绍为主。

Since I'm not a cryptography professional, I'm going to focus this part on introductions.

  在区块链领域,应用得最多的是哈希算法。哈希算法具有抗碰撞性、原像不可逆、难题友好性等特征。

In the area of block chains, the Hashi algorithm is the most applied.

  其中,难题友好性正是众多 PoW 币种赖以存在的基础,在比特币中,SHA256 算法被用作工作量证明的计算方法,也就是我们所说的挖矿算法。

Among them, the comfort of the problem is the basis on which many PoW currencies exist. In bitcoin, the SHA256 algorithm is used as a means of calculating the workload proof, which is what we call the mining algorithm.

  而在莱特币身上,我们也会看到 Scrypt 算法,该算法与 SHA256 不同的是,需要大内存支持。而在其他一些币种身上,我们也能看到基于 SHA3 算法的挖矿算法。以太坊使用了 Dagger-Hashimoto 算法的改良版本,并命名为 Ethash,这是一个 IO 难解性的算法。

In Leiter, we can also see the Scrypt algorithm, which, unlike SHA256, requires large memory support. In some other currencies, we can also see mining algorithms based on SHA3. The improved version of Dagger-Hashimoto algorithms is used in Tails and named Ethash, which is an IO solvency algorithm.

  当然,除了挖矿算法,我们还会使用到 RIPEMD160 算法,主要用于生成地址,众多的比特币衍生代码中,绝大部分都采用了比特币的地址设计。

Of course, in addition to mining algorithms, we use the RIPEMD160 algorithm, which is used mainly to generate addresses, and most of the many bitcoin derivatives use bitcoin address designs.

  除了地址,我们还会使用到最核心的,也是区块链 Token 系统的基石:公私钥密码算法。

In addition to the address, we'll be using the core and the cornerstone of the Token system: a public-private key password algorithm.

  在比特币大类的代码中,基本上使用的都是 ECDSA。ECDSA 是 ECC 与 DSA 的结合,整个签名过程与 DSA 类似,所不一样的是签名中采取的算法为 ECC(椭圆曲线函数)。

In the bitcoin class, ECDSA is basically used. ECDSA is a combination of ECC and DSA, and the whole signature process is similar to DSA, except that the algorithm used in the signature is ECC (an elliptical function).

  从技术上看,我们先从生成私钥开始,其次从私钥生成公钥,最后从公钥生成地址,以上每一步都是不可逆过程,也就是说无法从地址推导出公钥,从公钥推导到私钥。

Technically, we begin with the generation of private keys, followed by the generation of public keys from private keys and, finally, the generation of addresses from public keys, each of which is an irreversible process, meaning that public keys cannot be derived from an address, from a public key to a private key.

640.webp (10).jpg

  图来自《精通比特币》一书

It's from the book Bitcoin.

  4. 账户与交易模型

4. Account and transaction models

  从一开始的定义我们知道,仅从技术角度可以认为区块链是一种分布式数据库,那么,多数区块链到底使用了什么类型的数据库呢?

From the very beginning of the definition, we know that the block chain can only be considered as a distributed database from a technical point of view, so what kind of database is most of the block chain used?

  我在设计元界区块链时,参考了多种数据库,有 NoSQL 的 BerkelyDB、LevelDB,也有一些币种采用基于 SQL 的 SQLite。这些作为底层的存储设施,多以轻量级嵌入式数据库为主,由于并不涉及区块链的账本特性,这些存储技术与其他场合下的使用并没有什么不同。

In designing the meta-block chain, I consulted multiple databases, BerkelyDB, LevelDB of NoSQL, and SQL based SQL-based SQL-Lite in some currencies. These are bottom-level storage facilities, mostly based on light-weight embedded databases, which are no different from those used on other occasions, as they do not address the physical characteristics of the block chain.

  区块链的账本特性,通常分为 UTXO 结构以及基于 Accout-Balance 结构的账本结构,我们也称为账本模型。UTXO 是“unspent transaction input/output”的缩写,翻译过来就是指“未花费的交易输入输出”。

The physical character of the block chain, usually divided into a UTXO structure and an account based on the Accout-Balance structure, is also referred to as an account book model. UTXO is the acronym "unspent transaction input/output" which is translated to mean "unspent transaction input output".

  这个区块链中 Token 转移的一种记账模式,每次转移均以输入输出的形式出现;而在 Balance 结构中,是没有这个模式的。

An account mode for the Token transfer in this block chain, each transfer takes the form of an input output; this is not available in the Balance structure.

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
热门文章
  • 以太坊区块链浏览器的搭建

    以太坊区块链浏览器的搭建
    环境;Ubuntu 首先需要下载git 参考链接:?http://www.360bchain.com/article/156.html??Environment; Ubuntu first needs to download git reference link: ˂a rel="noformlow" href="http://www.360bchai.com/article/156.html"? http://www.360bchai.com/article/156.htm...
  • 百度元宇宙希壤app官方下载

    百度元宇宙希壤app官方下载
    希壤元宇宙是一款非常好玩的休闲手游,这款游戏采用了元宇宙的游戏概念,超级自由的游戏玩法,在这里没有什么标准限定,你可以自由的在这里进行着一切你想做的事情,游戏比较的休闲和放松,没有什么操作难度,感兴趣的小伙伴们可以来007游戏网下载这款非常有趣的希壤元宇宙吧!˂a href=http://m.yx007.com/key/xxsy" target="_blank" , a game that uses the concept of meta-cosm, super-free p...
  • 【CoinCentral 合作內容】加密貨幣 Decred 正式推出 2018 發展路段線圖

    【CoinCentral 合作內容】加密貨幣 Decred 正式推出 2018 發展路段線圖
    早些時候,加密貨幣Decred發表了一篇博客文章,概述了他們2018年的正式發展路線圖。Earlier, encrypt currency Decred published a blog article outlining their official road map for development in 2018.在這個路線圖中,團隊在為他們制定營銷宣傳之前,明確地表明他們於建立和發布可交付物品的成果,同時將他們的營銷集中在項目的核心組成部分。Decred團隊正在研究一些...
  • 跨接在两个网络间的语音记录仪设计

    跨接在两个网络间的语音记录仪设计
      摘  要: 设计了语音记录仪。该语音记录仪桥接在通信设备之间,同时提供3种桥接接口:以太网接口,支持在IP通信方式下的各通话组的直通及录音功能;二线接口,支持模拟二线方式下的直通及录音功能;音频接口,支持模拟音频方式下的直通及录音功能。同时话音记录仪提供FTP服务器,可以通过局域网对语音记录仪保存的语音文件进行下载和管理。此外,该设备支持语音回放功能。 extracts & nbsp; to : The voice record...
  • 元宇宙概念股有哪些 元宇宙概念股一览表

    元宇宙概念股有哪些 元宇宙概念股一览表
    元宇宙概念股排行精选 元宇宙概念股一览表(2022/11/08),下文就随小蔡来简单的了解一下吧。The contours of the meta-cosmology unit are in the list of the meta-cosmological concept units (2022/11/08), so let's get to the bottom of this with Little Choi. 元宇宙概念股龙头有:The contou...
标签列表