解决比特币双重支付问题

以比特币为代表的数字货币,关键的创新是通过时间戳(Timestamp)和工作量证明(Proof of Work)机制解决双重支付(Double Spending)和拜占庭将军问题(Byzantine Generals’ Problem),即保证同一笔比特币不会同时出现在两个地址,并且在信道可靠的基础上,所有节点都可以让其它节点接收到自己的真实意图,并最终一致行动。

这一技术方案最早见于化名为中本聪(Satoshi Nakamoto)的个人或团体在2008年发表的论文Bitcoin: A Peer-to-Peer Electronic Cash System 。

在Bob接收来自Alice的比特币的场景中,一方面,这笔付款被广播给系统中所有节点,任何人都可以使用Bob的公钥来验证这个交易的合法性,如果Alice试图双重支付,就必须先删除这个交易记录,否则新交易无法通过验证。中本聪在论文中写道:

“时间戳服务器为一个区块的数据的哈希计算结果加上时间戳,并大范围发布这一哈希计算结果,好比在报纸或新闻网上发表。显然,时间戳证实这些数据一定在这一特定时间存在,只有这样才能得到哈希计算结果(A timestamp server works by taking a hash of a block of items to be timestamped and widely publishing the hash, such as in a newspaper or Usenet post. The timestamp proves that the data must have existed at the time, obviously, in order to get into the hash)”。

另一方面,工作量证明机制使得生成下一个区块的节点和矿工几乎无法被预测到,所以删除交易记录几乎不可能。系统中的节点将过去约10分钟内的比特币交易进行打包,而只有获得有效哈希值的矿工才能生成新区块,并得到挖矿奖励;矿工除了打包比特币交易,还要结合随机数来完成有效哈希值的创建工作,获得以要求的数量的0作为开始的哈希值。

中本聪在论文中写道:
             e7ba44378123cd21beac835f8b00779bfcc68f27
图5,出自中本聪论文Bitcoin: A Peer-to-Peer Electronic Cash System 

  • “工作量证明本质上是一CPU一票(Proof-of-work is essentially one-CPU-one-vote)”;
  • “如果两个节点同时广播不同版本的新区块,那么一些节点会先收到其中一个的广播。在这种情况下,节点在先收到的区块基础上工作,并保留另外一个分支,以防后者变成较长的链。这个僵局要等到发现下一个工作量证明才能被打破,其中一条链将成为较长的链,在另一个分支上工作的节点将切换到较长的链上继续工作(If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proof-of-work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one)”;
  • “节点永远认为最长的链是正确的链,并将持续在它上面延长(Nodes always consider the longest chain to be the correct one and will keep working on extending it)”。

所以除非永久控制整个系统中超过一半的节点,才能阻止矿工把这个交易添加到新区块中。

最后,考虑到硬件运算速度的增长和节点参与程度的变化,中本聪用移动平均目标来确定工作量证明的难度,使得两个区块生成的时间间隔约为10分钟。

发布了436 篇原创文章 · 获赞 269 · 访问量 56万+

猜你喜欢

转载自blog.csdn.net/qq_32146369/article/details/105263233
今日推荐