《详解比特币白皮书》- Proof-of-Work(PoW工作量证明机制)

工作量证明:要求用户进行一些耗时适当的复杂运算,并且答案能被服务方快速验算,以此耗用的时间、设备、能源作为担保成本,以确保服务与资源是被真正的需求所使用。

To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof- of-work system similar to Adam Back's Hashcash [6], rather than newspaper or Usenet posts.

为了在点对点的基础上建立一个分布式的时间戳服务器,我们将使用一种与AdamBack的Hashcash相类似的工作量证明(POW)系统,而不是像报纸或Usenet发帖子。

重点:作者参考的Hashcash,是由Adam Back1997年提出的工作量明系。起初是了抵御垃圾件和DoS,即要求送端在求的候附加一段以多个0的哈希种哈希只能用通暴力枚的方法尝试不同的随机数来生成,需要消耗一定的CPU计算时间。

工作量证明的技术原理:

工作量明最常用的技原理是散列函数。由于入哈希h()的任意n,会对应到一个h(n)结果,而n只要变动一个比特,就会引起雪崩效,所以几乎无法从h(n)反推回n,因此借由指定h(n)的特征,户进行大量的穷举运算,就可以达成工作量明。

若指定h(n)16进制值的前四值,求n这样统计上平均要运行216h(n)散列运算,才会得到答案,但算只要行一次就可以了。如果想要增加度,那就增加指定的位数即可。以SHA256函数例,假理数据Hello World,并找出h(n)前四值为0000n,如果从Hello World0开始加上一个ASCII进行穷举猜测,到Hello World107105时才会得到匹配条件的h(n)0000BFE6AF4232F78B0C8EBA37A6BA6C17B9B8671473B0B82305880BE077EDD9

验算时只要将Hello World107105代入SHA256函数一次即可。

The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits.

这个工作量证明需要在哈希(Hash)的过程中(以枚举的方式)寻找一个以一定数量0比特开头的哈希值,比如用SHA-256算法。

The average work required is exponential in the number of zero bits required and can be verified by executing a single hash. 

所需的平均工作量随所需的0比特位数量以指数级增长,而验证工作量只需做一次哈希。

For our timestamp network, we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block's hash the required zero bits. 

在我们的时间戳网络中,我们不断递增区块中的nonce随机数来找到那个满足所需0比特数量的区块哈希值,并将这个计算过程作为PoW。

Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it. 

一旦CPU的消耗使之足了工作量明要求,个区就不能改了,除非重做这项工作。随着后来的区在其后接,改的工作量将包括改之后所有的区

工作量证明的步骤如下:

  1. 构建区块,把将要写入区块交易信息组成交易列表,通过Merkle树算法把交易列表信息生成Merkle根哈希。
  2. 把Merkle根哈希、难度值等相关字段组装成区块头,把区块头80字节数据作为工作量证明的数据输入。
  3. 不停地变更区块头的随机数,即nonce的数值,变更后不断采用SHA256运算。与目标值做对比,如果小于目标值,则解题成功,工作量证明完成。

The proof-of-work also solves the problem of determining representation in majority decision making. 

工作量证明还解决了多数决策过程中的表决问题。

If the majority were based on one-IP-address-one-vote, it could be subverted by anyone able to allocate many IPs. Proof-of-work is essentially one-CPU-one-vote. 

如果多数(的统计)是基于一个地址一票的,那么可以分配多个IP的人将破坏规则。工作量证明本质上是一个CPU一票。

The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it.

那么大多数的决定表达为最长的链,因为有最多工作了证明的努力投入其中。

If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. 

如果大部分CPU功率由诚实节点控制,那么诚实的链将以最快的速度增长从而淘汰任何竞争的链。

To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes. 

要修改一个过去的区块,攻击者将不得不重做该区块和之后所有区块的工作量证明,然后追上并赶超诚实结点的工作量。我们随后会介绍,随着后来区块的不断增加,较慢的攻击者追上的概率以指数级降低。

We will show later that the probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added. 

我们随后会介绍,随着后来区块不断增加,较慢的攻击者追上的概率以指数级降低。

To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they're generated too fast, the difficulty increases. 

为了补偿日益增长的硬件速度和日益变化的运营节点的利息,工作量证明的难度由一个每小时平均区块产生数量为目标的变化的均值来决定。如果它们(区块)产生的太快,难度就会增加。

重点:寻找工作量证明的过程就是传说中的。比特币为了控制出的速度,加入了定。随着科技的步,算机硬件性能的提升,以及参与人群的大,中本聪预料到会有越来越多的算力投入到挖的行列。如果速度不加控制,比特将会很快达到预设的上限。

猜你喜欢

转载自blog.csdn.net/q602968956/article/details/85006277
今日推荐