区块链也是一个动态的网络,不断有新节点的加入和原区块链网络中节点的退出。新节点的不断加入为系统引入新的资源,整个网络由此得以构建和发展,资源的丰富性与多样性随之扩充,点对点网络的分散性、健壮性、可用性与整体性能也将随着节点的数量增加而增强。
Block chains are also a dynamic network, with new nodes constantly added and nodes removed from the original node network. The new node is constantly added to introduce new resources into the system, which allow the network to be constructed and developed, and the wealth and diversity of resources expanded. The fragmentation, robustness, availability and overall performance of point-to-point networks will also increase as the number of nodes increases.
区块链是一个分布式账本
The block chain is a distributed account book.
区块链的分布式账本结构
Distributed account structure for block chains
在桃花岛上,由黄老邪一人记账的时期,整座岛上只有一本账本来对所有的信息进行记录。改变记账模式后, 岛上的每一 户人家都拥有一本账本,这就相当于区块链这个分布式的公共账本。
On Peachflower Island, only one account of all the information was recorded in the entire island during the time when it was recorded by one person. With the change in the accounting pattern, every household on the island has an account book, which is equivalent to the distributed public account book of the block chain.
区块链推翻了传统的记账模式。与传统记账模式不同,区块链中的交易信息不再由单个机构来记录,而是由其中的每一个节点共同参与记账。在这个分布式网络上,每个节点都有账本的完整备份。如果有人想篡改账本上的记录,他必须改动各节点存储的账本备份,这就使篡改账本记录的行为难以实现。
The block chain overturns the traditional mode of bookkeeping. Unlike the traditional mode of bookkeeping, the transaction information in the block chain is no longer recorded by a single institution, but by each of the nodes involved. On this distributed network, every node has a complete backup of the ledger. If someone wants to change the record on the ledger, he has to change the backup of the book stored at the node, which makes it difficult to change the record.
区块链用哈希算法实现信息的不可篡改
The block chain uses the Hashi algorithm to make the information immutable.
随着新交易的不断产生,桃花岛每家每户账本里记录的交易信息也快速增长,越来越多的记录信息页会保存到信箱中。类似地,在区块链中,一个又一个新产生的区块会不断链接到现有区块链的尾端。如何能够保证这个记录信息页的每一页,以及区块链账本中的每一个区块都是真实准确、没有被篡改过的呢?
As new transactions continue to occur, transactions recorded in each account book in Peachflower Island grow rapidly, and more and more records information pages are kept in the mailbox. Similarly, in the block chain, one newly created block will continue to be linked to the end of the existing block chain. How can it be ensured that each page of this log information page, and each block in the block chain book, is genuinely accurate and unaltered?
设想一下, 如果我们通过一种算法对账本信息进行加密,给区块链上第一个区块打上一个唯一的标签, 之后的每一个区块也通过加密后打上一个唯一标签,同时又能够包含前一个区块链的标签。这时,只要采用一种方法保证这个标签无法被轻易替换更改,那么就能保证这个区块记录的信息没有被篡改过。
Imagine, if we encrypt the account book information by means of an algorithm, placing a unique label on the first block on the block chain, and then placing a unique label on each block by means of encryption, while at the same time containing the label of the previous block chain. In that case, if we use a method to ensure that the label cannot be easily replaced, then we can ensure that the information recorded in the block has not been altered.
哈希算法就是上面提到的区块链中保证交易信息不可篡改的单向密码体制。该算法的思想是接收一段明文, 以一种不可逆的方式将它转化成一段长度较短、位数固定的输出做列。这个加密过程是不可逆的,这就意味着无法通过输出散列的内容推断出任 何与原文有关的信息。任何输入信息的变化,哪怕仅仅是一~位数字的更改,都将导致散列结果的明显变化。基于输出散列与输人原文一 一对应的特性,哈希算法可以被用于验证信息是否被修改。通过哈希算法可对一个交易区块的所有交易信息进行加密,并把记账内容压缩成一串数字和字母组成的字符串,这个字符串无法反推出原来的内容。区块链的哈希值可以唯一、准确地标识--个区块,并且任何节点通过简单地对区块头进行哈希计算都可以独立地获取该区块哈希值。如果想要确认区块的内容是否被篡改,那么利用哈希算法重新进行计算,记账信息没有变化,计算出的哈希值也将不会产生变化。
The Hashi algorithm is a one-way cryptographic system in the block chain referred to above to ensure that the transaction information cannot be tampered with. The idea of the algorithm is to accept an explicit message that can be used to verify whether the information has been modified in an irreversible manner. The encryption process is irreversible, which means that it is impossible to extrapolate information about the original text by exporting the contents of the hash. Any change in input information, even if it is only a one-digit number, will result in a clear change in the hash result. The Hashi algorithm can be used to encode all transactional information in a trading block in a nonreversible way, and, if the Hashi algorithm is used to confirm whether the content of the block has been altered, the string cannot be reversed.
在区块链中,通常使用SHA-256的哈希算法进行区块的加密,该算法的输出长度为256位,即生成长度为32字节的随机散列。
In the block chain, block encryption is usually done using the HA-256 Hashi algorithm, which produces a random hash with a 32byte length of output of 256.
区块链用公钥、私钥来标识身份
Block chains identify with public and private keys
在区块链中,信息的传播按照公钥加私钥的方式进行。公钥相当于桃花岛上每家每户居民的信箱地址,当别人获知你的公钥时,可以与你通信。相应地,私钥相当于信箱的钥匙,只有拥有私钥的人才能查看信箱中的信件信息。在区块链中,数字签名可以用于验证信息发送者的身份,用户可以公布自己的公钥,然后发送可以被公钥所验证的、已经通过私钥加密过的信息。如果信息的接收者能够使用公钥解密加密过的信息,即可证明这条信息发送者的身份属实。上述过程可以用图3-4 表示:区块链中有两个用户Alic和Bob,Alicc想让Bob知道自己是真实的Alice,而不是他人冒充的。Alice 只需要使用私钥对文件签名并发送给Bob, Bob 使用Alice的公钥对文件进行签名验证,如果验证成功,则该文件一定是使用Alice的私钥加密的。由于Alice的私钥只由Alice一人持有,Bob 就可以确定文件的发送者正是Alice本人。
In the block chain, a digital signature can be used to verify the identity of the sender of the information, and the user can publish its public key, and then send the information that can be encrypted through the private key. If the recipient of the information can use the public key to decrypt the encrypted information, it can prove the identity of the sender. The process can be illustrated in figure 3-4: there are two users in the block chain, Alic and Bob, and Alicc wants Bob to know that he is the real Alice, not someone else. Alice simply needs to use the private key to sign the document and send it to Bob, and Bob uses the public key of Alice to authenticate the document, and if it is successful, it must be Alice’s private key.
此外,公钥与私钥还可以保证分布式网络中点对点信息传递的安全。我们不妨假想这样一个情形: Alice想在分布式网络中发送一封情书给Bob。但由于分布式网络的信息传递特性,这封情书将被发送至每一个用户手中。Alice 不希望情书的内容被其他用户看到,因此Alice使用Bob的公钥对情书进行加密。网络中除Bob外的其他用户接收到这封经过加密的情书,看到的只是一段密文。只有Bob可以使用自己的私钥对密文进行解密,得到一份情书的明文。通过这个加密与解密的过程,Alice与Bob之间实现了点对点的数据传递。
In addition, public and private keys can also secure the transmission of the distributed network mid-point message. We might imagine a situation in which Alice wants to send a love letter to Bob in the distributed network. Because of the information transfer properties of the distributed network, this is sent to every user. Alice does not want the content of the love letter to be seen by other users, so Alice encrypts it using Bob's public key. Other users in the network, except Bob, receive the encrypted love letter, and see only a secret text. Only Bob can use his private key to decrypt the secret and get a letter. Through this encryption and decrypting process, Alice and Bob have achieved a point-to-point data transfer.
在区块链的信息传递过程中,信息传递双方的公私钥加密与解密往往是成对出现的,即信息发送方使用私钥对信息签名、使用信息接收方公钥对信息加密,信息接收方使用对方公钥验证信息发送方的身份、使用私钥对加密信息解密。
The public-private key encryption and decryption of information between the two parties to the block chain often occur in pairs, i.e. the sender signs the information using a private key, the recipient uses a public key to encrypt the information, the recipient uses the other public key to authenticate the identity of the sender, and the recipient uses a private key to declassify the encrypted information.
区块链用Merkle树结构简化验证程序
Simplified authentication program for block chains using Merkle tree structure
Merkle树是区块链的基本组成部分,Merkle树的叶子节点存储的是数据文件的哈希值,非叶子节点存储的是对其下面所有的叶子节点值的组合结果进行哈希计算后得出的哈希值。区块链利用Merkle树这种数据结构存放所有叶子节点的哈希值,并以此为基础生成一个统一的哈希值。区块中的任何一笔交易的发生和交易信息的变动都会使Merkle树发生改变。在交易信息的处理、比对及验证的过程中,尤其是在分布式环境下进行比对或验证时,Merkle 树会大大减少数据的传输量和计算的复杂度。
The Merkle tree is an essential part of the block chain, and the Merkle leaf node stores the Hashi value of the data file, and the non-leaf node stores the Hashi value of the combined results of all the leaf node values below it. The block chain uses the Merkle tree as a data structure to store the Hashi value of all leaves node and to generate a single Hashi value on that basis. Any transaction in the block and any change in the transaction information can change the Merkle tree.
Merkle 树结构图
Merkle Tree Structure
区块链为每一笔交易盖上时间戳
Block chains cover every transaction with a time stamp.
黄老邪在传授记账方法时,要求居民将发生在桃花岛上的每一笔交易都记录下来,并且要求他们将交易发生的时间也一并记录在账本上,这就相当于区块链为每- -笔交易在发生时盖上了时间戳。
In teaching the method of bookkeeping, Huang Xiaohua requires residents to record every transaction that takes place on Peachflower Island, and they are required to record the time when the transaction takes place on the books, which is equivalent to the time stamped by the block chain for every transaction that takes place.
在区块链中,时间戳的应用是对每一次交易记录的认证,它就像交易合同公证一样,能够显示交易记录的真实性。时间戳作为区块元数据的一部分,具有天然的时间特性。从某种意义上讲,区块链的本质可以被理解为构造了一个永不停息、无坚不摧的时间戳系统。
In the block chain, the time stamp is used to authenticate each transaction record, which, like a trade contract notarized, shows the trueness of the transaction record. The time stamp, as part of the block metadata, is a natural temporal feature. In a sense, the essence of the block chain can be understood as the construction of a never-ending, indestructible time-stamp system.
在现实经济交易中,常常会出现信息欺诈等虚假交易现象。为了减少这些不法行为给交易中诚实守信的一方带来的损失,人们通常会寻求有公信力的第三方机构对交易进行核验。区块链通过时间戳来保证分布式账本的唯一一性, 避免双花问题的产生。时间戳从区块生成的一刻起就存在于区块之中,它扮演了区块链中的公证人的角色。与现有的公证机制相比,基于时间截的公证系统更为经济,并且完全可信。
In real economic transactions, false transactions such as information fraud often occur. In order to mitigate the losses that these misdeeds cause to honest and faithful parties to the transaction, a credible third-party body is often sought to verify the transaction. The block chain guarantees the uniqueness of the distributed books through a time stamp that avoids double-collar problems. The time stamp is present in the block from the moment it is created, playing the role of notary in the block chain. A notarized system based on time cutbacks is more economical and fully credible than existing notarized mechanisms.
区块链中的时间截比传统的公证制度更为可信,是因为时间签名是直接写在区块链上的,区块链中已经生成的区块不能以任何方式进行修改。一旦区块被修改,生成的哈希值就无法匹配,操纵行为也将由此而被系统检测到。区块链根据分布式的协议,构建了一个分布式的开放结构体系,交换的信息可以通过分布式记账的方式确定信息数据内容,加盖时间戳后生成区块数据,再通过分布式广播发送给各个节点,最终实现分布式存储。
The time cut in the block chain is more credible than in the traditional notarized system because the time signature is written directly on the block chain, and the blocks already generated in the block chain cannot be modified in any way. Once the block has been modified, the Hashi value generated cannot be matched, and manipulation will be detected by the system. The block chain builds a distributed open structure based on a distributed agreement, and the information exchanged can determine the content of the information by way of a distributed account, adding the time stamp and generating block data by way of a distributed broadcast to all nodes, ultimately leading to a distributed storage.
对数据应用安全散列算法加盖时间戳,并将该随机哈希值在全网中进行广播能够证实一组数据在某一 -时刻是真实存在的,因为数据只有在该时刻的确存在,才能获取相应的随机哈希值。每个时间戳会将前一个时间戳纳入其随机哈希值之中, 每一个后面位置的时间截都会对前面的时间戳进行增强,这过程不断重复、依次推进,最终形成一个完整 的链条。时间戳与哈希算法、Merkle树共同作用,增强了区块链的安全性能。
Applying the security hash algorithm to the data with a time stamp and broadcasting the random Hash value on the whole web can confirm that a set of data is real at a given time, because the data can only be obtained if it does exist at that time. Each time stamp will include the previous time stamp in its random Hash value, and each later position will be timed to enhance the previous time stamp, a process that repeats and moves in sequence and eventually forms a complete chain. The time stamp, in conjunction with the Hash method, the Merkele tree, enhances the security of the block chain.
时间戳证明存在性的功能可能是区块链的另一种用途,它或许会彻底改变人类的未来。由于区块哈希值的不可伪造性,一个区块能提供出哈希值即可证明区块哈希值存在于该区块生成时刻之后,就像你在一张白纸上写下了一串数字,说明的是数字出现的时间晚于白纸 这也称为时间点后向证明。时间点前向证明则需要构造一个包含数字摘要的交易,当该交易进入区块后,便可以证明你在该区块时刻之前拥有该数字摘要。
The function of a time stamp to prove the existence of a block may be another use in the chain of blocks, which may change the future of the human race altogether. Because of the unforgivable nature of a block, a block can provide a Hashi value to prove that the block exists at the moment of its creation, just as you wrote a series of figures on a white paper that indicates that the number appears later than it does at the point of time, which is called proof after the point of time. The proof before the point of time requires the construction of a transaction containing a digital summary, and when the transaction enters the block, you can prove that you have the number summary before the time of the block.
区块链使智能合约成为现实
Block chains make smart contracts a reality.
1994年,密码学家尼克萨博(Nick Szabo)首次提出了智能合约的理念。 然而在过去的中心化体系下,智能合约几乎是没有意义的,因为保存在中心化系统中的合约可以被系统所有者随时修改甚至删除。但是有了区块链以后,智能合约可以被事先写入到区块链的分右式网络体系中。当合约中的某一事项发生时, 智能合约就会被触发并自动执行相应的合约条款。在这个过程中,某一个人或者某一个机构都不能够修改或删除合约,也无法阻碍智能合约的自动执行。
In 1994, the cryptographer Nick Szabo introduced the idea of a smart contract for the first time. In the past, however, in a centralized system, smart contracts were almost meaningless, because contracts that were kept in a centralized system could be modified or even deleted by the owners of the system at any time.
智能合约指的是一段部署在分布式账本中的代码,它可以处理信息,接收、储存和发送价值,是一个能够自动执行合约条款的计算机程序。从本质上讲,智能合约的工作原理类似于计算机程序中的if-then判断语句,智能合约以这样一种方式 与现实世界里的资产进行交互。
Smart contracts refer to a code that is deployed in a distributed book that handles information, receives, stores and sends value, and is a computer program that automatically enforces the terms of the contract. In essence, smart contracts work in a way that interacts with real-world assets, similar to if-then judgements in computer programs.
智能合约见图3-6。
Smart contracts are shown in figures 3-6.
智能合约拥有自治、自足和分布式的特点,它由代码定义并独立执行。智能合约的执行流程从双方达成合约协定时开始,通过将合约中的内容进行数字化编码并写入区块链中实现对合约内容的形式化。合约中约定的条件事项的发生将自动触发合约的执行程序。借助区块链技术,智能合约可能会在未来对人们的生活带来极大的改变。智能合约能够使得人与人之间的价值交易过程自动化和信任化,通过智能合约实现价值交易不仅节省了时间和金钱,还提高了交易的效率。在区块链技术中,智能合约在分布式交易所、金融衍生品、身份认证、医疗健康和科学发现等领域均有着广泛的应用。
Smart contracts are self-governing, self-contained and distributed. They are defined by code and implemented independently. Smart contracts start with the conclusion of contractual agreements, by digitizing their contents and writing them into block chains. The occurrence of contractual terms will automatically trigger contract enforcement. Smart contracts can make a significant difference in people's lives in the future, thanks to block-chain technology. Smart contracts can automate and trust value-trading processes between people, save not only time and money, but also improve the efficiency of transactions through smart contracts. In block-chain technologies, smart contracts have a wide range of applications in distributed exchanges, financial derivatives, identity certification, medical and scientific discovery.
发表评论