区块链区块是什么意思 区块链中的区块到底是什么

区块链是什么?区块里装的是什么?为什么又要用链接起来?它到底长什么样子?本文是区块链入门文章,为想跟上金融科技时事、但又不是很熟的区块链新手诉说一个简单易懂又生动的故事。

区块链,简单来说是一种新式资料库(Database),过去我们常使用硬碟与云端资料库来储存资料,这两者是实体与虚拟的差别,但都属于将资料存在一个中心化、集中式的资料库中,因此若中心伺服器当机或遭遇骇客攻击,都会让用户遇到服务停摆或个资外泄的危机,而这些中心化的资料库也有被窜改的风险,例如骇客骇进银行资料库,只要删掉一个0,客户就损失重大了!台湾也时有行员伪造文书、盗领顾客存款的新闻,显示若管理这个资料库的人不具诚信,也会对于文件储存的安全性造成风险。


透过层层加密,区块链的安全性相当高

因此,区块链与传统资料库的差别,在于去中心化和中心化的差别,如下面的概念图​​,去中心化的差别在于没有一个主要的头,但与最右边的分散式仍有些许差异。区块链的资料储存分布多处于去中心化和分散式之间,如下图(B)所示。


资料储存模型分为中心化、去中心化、分散式(图片来源:Paul Baran— On Distributed Communications)

从上图可看到许多点,这些点称为节点,节点可以是一台电脑或伺服器,因此储存在区块链的资料是指存在这些分散的节点里,而非一个集中式的中心伺服器,类似鸡蛋不要放在同一个篮子里分散风险的概念。而每一个节点存的资料都必须一样,也就是资料正本只有一个,但每个参与区块链的节点会有一个副本,如果有人想要修改已经存在区块链中的资料,必须要经过这些节点的同意,换句话说,一个人好说话,但若要一百个人都同意,那可是非常困难的,因此区块链具有不可窜改的特性便是从这而来。

区块链里的秘密

区块链的区块究竟装的是什么?前面提过,区块链是种分散式的资料库,资料库里存的就是交易纪录,也可以视为一本帐本,记录着流水帐。你可能会想流水帐为何这么重要?还要大费周章的找一堆节点分散储存?其实流水帐如同你的银行明细,纪录的是钱的支出与收入,最后算出个人帐户里有多少结余,若今天一个骇客偷偷在你的银行帐本里加一笔汇出的纪录,银行就会根据这笔纪录认定你有这笔支出,扣掉你户头里的钱,这也是为什么帐本的正确性与安全性非常重要,而区块链技术会造成这么大的轰动原因之一。

我们已经知道区块里装的是交易纪录,但区块本身是什么东西?其实是为了帐本的安全性,我们需要为这些帐本加装保全,也就是使用密码学来加密,包一层加密规则来保护记录,最后产生的密码值就是区块。区块也可视为一个保险箱,把珍贵的帐本放入保险箱锁上,最后看到的就是一个保险箱的区块。


把记有交易纪录的帐本锁进加密的保险箱

实际在电脑里又是怎么跑的呢?如:A 转帐1000 元给B,但在电脑的世界里这笔交易纪录会被转为二元的资料,呈现出由0 和1 组成的数字序列,如:10011001101111。接着经过一道加密手续(通常是使用密码学SHA-256 的规则来加密),整个加密过程称为Hash Function,产生出来就是Hash 值(区块)。

区块(锁着帐本的保险箱)= Hash 值= 交易纪录(帐本) + Hash Function(密码锁)

那链又是指什么呢?其实区块链的链非彼链,而是指区块之间彼此交叠扣住的区域,将每个区块以这个方式串接起来。


链是指区块之间彼此交叠扣住的区域,将每个区块以这个方式串接起来.因此除了第一块创世块外,每块的「区块头」都会包含前一块的Hash值,再加上本身新的交易资料与后续的加密步骤

刚刚提到,区块链的安全性是相当高的,在于其加密的过程非常复杂,环环相扣到牵一发动全身的程度。Hash Function 的过程又可细分为Nonce 和Difficulty。简单来说,Nonce 是一个加密的规则,例如:规定在这笔交易的二元数字序列中,每五个数字就分别按照顺序插入101011:

交易序列:1001100110101101100101010…
Nonce:每五个、101011
Hash值:10011100110010110111001001010…


Hash Function的过程又可细分为Nonce和Difficulty

组合而成,便成了区块链的第一块区块-创世块:


创世块的组成有6个栏位:交易资料、Nonce、Difficulty、时间戳记、Merkleroot和Version,为了避免让读者头晕,后三个栏位在此略过不提

Nonce 的设定也不是随便乱设的,需要符合Difficulty 这条游戏规则。我用Nonce 算出的Hash 值需要小于或等于Difficulty,最后才算符合游戏规则,赢得游戏、成功「上链」。后面的区块同样需要遵守相同的游戏规则,才可上链成为区块链的一份子,也就是前一块的Hash 值加上新的Nonce,并符合Difficulty 的规则,产生新的Hash 值,以此类推,区块链则会越接越长。

也因为如此,每一块区块都用了前一块的Hash 值做加密的动作,所以如果我想要更改第1001 块的区块的交易资料,我连前面的1000 块都要跟着一起改,否则很容易被其他节点识破我在偷偷干的好事,所以一般而言,区块链是越长越安全。

新Hash 值(新区块)

= 前Hash 值(上一个区块) + 新交易资料+ Nonce(加密) ≤ Difficulty(游戏规则)


1(前一块Hash值)+ 2(新交易)+ 3(Nonce)+ 4(≤Difficulty)= 5(新Hash值)


越来越长的区块链

小结

区块:又称Hash值,共有6个档位:包括前一块区块的Hash值、Nonce、Difficulty、时间戳记、Merkleroot和Version
链:不是真的链,而是每块使用前一块的Hash值一起加密,像是积木重叠扣在一起的样子。
加密:比特币区块链使用SHA-256密码学,将原始交易资料加密并上链,其中Nonce和Difficulty就是旷工挖矿的重点。



What is blockchain? What's in the block? Why use links again? What does it look like? This article is an introductory article on blockchain. It tells a simple, easy-to-understand and vivid story for newcomers to blockchain who want to keep up with current affairs in financial technology but are not very familiar with it.

Blockchain is simply a new type of database. In the past, we often used hard drives and cloud databases to store data. The two are physical and virtual, but they are both Data is stored in a centralized database. Therefore, if the central server crashes or is attacked by a hacker, users will encounter the risk of service shutdown or personal information leakage. These centralized databases There is also the risk of tampering. For example, if a hacker breaks into a bank database and deletes a 0, the customer will suffer heavy losses! There are also news in Taiwan about bank employees forging documents and stealing customer deposits, which shows that if the person managing this database is not honest, it will also pose a risk to the security of document storage.


Through layers of encryption, the security of blockchain is quite high

Therefore, the difference between blockchain and traditional databases lies in decentralization and centralization The difference between decentralization, as shown in the concept diagram below, is that there is no main head, but it is still slightly different from the decentralized version on the far right. The data storage distribution of blockchain is mostly between decentralization and decentralization, as shown in the figure (B) below.


Data storage models are divided into centralized, decentralized and decentralized (picture source: Paul Baran—On Distributed Communications)

You can see many from the picture above Points, these points are called nodes. A node can be a computer or a server. Therefore, the data stored in the blockchain is stored in these scattered nodes, rather than a centralized central server. Similar to eggs, do not put them in The concept of spreading risks within the same basket. The data stored in each node must be the same, that is, there is only one original copy of the data, but each node participating in the blockchain will have a copy. If someone wants to modify the data that already exists in the blockchain, they must go through these The agreement of the nodes, in other words, is easy for one person to speak, but it is very difficult for a hundred people to agree. Therefore, the non-tamperable nature of the blockchain comes from this.

Secrets in the blockchain

What exactly do the blocks of the blockchain contain? As mentioned before, the blockchain is a decentralized database. The database stores transaction records. It can also be regarded as a ledger, recording running accounts. You may be wondering why the journal is so important? Do you still need to go to a lot of trouble to find a bunch of nodes for distributed storage? In fact, the journal is like your bank details. It records the expenditure and income of money, and finally calculates the balance in your personal account. If a hacker secretly adds a remittance record to your bank account today, the bank will Based on this record, it is determined that you have this expenditure, and the money in your account is deducted. This is why the correctness of the account book isAccuracy and security are very important, and this is one of the reasons why blockchain technology has caused such a stir.

We already know that blocks contain transaction records, but what is the block itself? In fact, for the security of the ledgers, we need to add security to these ledgers, that is, use cryptography to encrypt, and include a layer of encryption rules to protect the records. The final password value is the block. A block can also be regarded as a safe. Put the precious ledger into the safe and lock it, and the last thing you see is the block of the safe.


Lock the ledger with transaction records into an encrypted safe

How does it actually run on the computer? For example: A transfers 1,000 yuan to B, but in the computer world, this transaction record will be converted into binary data, showing a numerical sequence composed of 0 and 1, such as: 10011001101111. Then after an encryption procedure (usually encrypted using the cryptography SHA-256 rules), the entire encryption process is called Hash Function, and the Hash value (block) is generated.

Block (a safe that locks the ledger) = Hash value = transaction record (ledger) + Hash Function (password lock)

What does the chain mean? In fact, the chain of the blockchain is not the other chain, but refers to the overlapping and interlocking areas between the blocks, and each block is connected in this way.


Chain refers to the area where blocks overlap and interlock with each other, and each block is connected in this way. Therefore, in addition to the first genesis block, the "block header" of each block will contain the Hash value of the previous block, plus its own new transaction data and subsequent encryption steps

Just mentioned, the area The security of the blockchain is quite high because its encryption process is very complex and interlocking to the extent that it affects the whole body. The process of Hash Function can be subdivided into Nonce and Difficulty. To put it simply, Nonce is an encrypted rule. For example, it is stipulated that in the binary number sequence of this transaction, every five numbers should be inserted into 101011 in order:

Transaction sequence: 1001100110101101100101010…
Nonce: every five, 101011
Hash value: 10011100110010110111001001010…


The process of Hash Function can be subdivided into a combination of Nonce and Difficulty

Once completed, it becomes the first block of the blockchain - the genesis block:


The genesis block consists of 6 fields: transaction data, Nonce, Difficulty, and timestamp. , Merkleroot and Ver.sion, in order to avoid making readers dizzy, the last three fields are omitted here

The settings of Nonce are not random, and need to comply with the Difficulty rule of the game. The Hash value I calculated using Nonce needs to be less than or equal to Difficulty. In the end, it is considered to be in compliance with the rules of the game and the game is won and successfully "on-chain". The subsequent blocks also need to abide by the same game rules before they can be uploaded to the chain and become part of the blockchain. That is, the Hash value of the previous block is added to the new Nonce, and it complies with the rules of Difficulty to generate a new Hash value. By analogy, the blockchain will become longer and longer.

Because of this, each block uses the Hash value of the previous block for encryption, so if I want to change the transaction data of the 1001st block, I even have to change the previous 1000 blocks. I have to change it together, otherwise it will be easy for other nodes to see through the good things I am doing secretly, so generally speaking, the longer the blockchain, the safer it is.

New Hash value (new block)

= Previous Hash value (previous block) + new transaction data + Nonce (encryption) ≤ Difficulty (game rules)


1 (Hash value of previous block) + 2 (new transaction) + 3 (Nonce) + 4 (≤Difficulty) = 5 (new Hash value)


More Coming to a longer and longer blockchain

Summary

Block: also known as Hash value, there are 6 levels: including the Hash value of the previous block, Nonce, Difficulty, Timestamp, Merkleroot and Version
Chain: Not a real chain, but each block is encrypted using the hash value of the previous block, like building blocks overlapping and buckled together.
Encryption: The Bitcoin blockchain uses SHA-256 cryptography to encrypt the original transaction data and upload it to the chain. Nonce and Difficulty are the focus of mining.


本文来源: 网络 文章作者: 网络投稿
    下一篇