Bitcoin.org

比特币白皮书早期草稿

中本聪 · 2008 年 10 月 3 日

SN-10004 附来源、原文与上下文。

阅读语言

比特币:一种点对点电子现金系统

Bitcoin: A Peer-to-Peer Electronic Cash System

摘要。 一种完全点对点的电子现金,可以让在线支付直接从一方发送给另一方,免去经由金融机构的负担。数字签名提供了部分解决方案,但如果仍然需要可信任的一方来防止双重支付,主要的好处就会丧失。我们提出一种利用点对点网络解决双重支付问题的方案。网络把交易进行哈希运算,纳入一条持续延伸、基于哈希的工作量证明链,为交易加上时间戳,形成一份不重新完成工作量证明就无法更改的记录。最长链不仅证明了所见事件的先后顺序,也证明它来自规模最大的 CPU 算力集合。只要诚实节点掌握网络中最多的 CPU 算力,它们就能生成最长链,超过任何攻击者。网络本身只需要极少的结构。消息以尽力而为的方式广播,节点可以自由离开和重新加入网络,并将最长的工作量证明链作为它们离开期间所发生事情的证明。

Abstract. A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without the burdens of going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as honest nodes control the most CPU power on the network, they can generate the longest chain and outpace any attackers. The network itself requires minimal structure. Messages are broadcasted on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone.

1. 引言

1. Introduction

互联网商业几乎完全依赖金融机构作为可信任的第三方来处理电子支付。虽然这个系统对于大多数交易都运作得足够好,但它仍然存在基于信任的模式所固有的弱点。完全不可撤销的交易实际上无法实现,因为金融机构无法避免调解争议。调解成本增加了交易成本,限制了实际可行的最低交易金额,也排除了小额随意交易的可能性;对于无法撤回的服务,不能进行不可撤销的支付,还带来了更广泛的成本。由于支付可能被撤销,对信任的需要也随之扩散。商家必须提防顾客,不断向他们索要原本并不需要的更多信息。人们接受了一定比例的欺诈无法避免。当面使用实物货币可以避免这些成本和支付的不确定性,但目前还没有一种机制,可以在无需可信任一方的情况下通过通信渠道进行支付。

Commerce on the Internet has come to rely almost exclusively on financial institutions serving as trusted third parties to process electronic payments. While the system works well enough for most transactions, it still suffers from the inherent weaknesses of the trust based model. Completely non-reversible transactions are not really possible, since financial institutions cannot avoid mediating disputes. The cost of mediation increases transaction costs, limiting the minimum practical transaction size and cutting off the possibility for small casual transactions, and there is a broader cost in the loss of ability to make non-reversible payments for non-reversible services. With the possibility of reversal, the need for trust spreads. Merchants must be wary of their customers, hassling them for more information than they would otherwise need. A certain percentage of fraud is accepted as unavoidable. These costs and payment uncertainties can be avoided in person by using physical currency, but no mechanism exists to make payments over a communications channel without a trusted party.

我们需要一种基于密码学证明而非信任的电子支付系统,让任何有意愿的双方都能直接交易,无需可信任的第三方。在计算上无法切实撤销的交易可以保护卖家免受欺诈,而常规的托管机制也可以很容易地实现,以保护买家。本文提出一种解决双重支付问题的方案:使用点对点的分布式时间戳服务器,为交易的时间顺序生成计算证明。只要诚实节点合计掌握的 CPU 算力超过任何一组相互协作的攻击节点,这个系统就是安全的。

What is needed is an electronic payment system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need for a trusted third party. Transactions that are computationally impractical to reverse would protect sellers from fraud, and routine escrow mechanisms could easily be implemented to protect buyers. In this paper, we propose a solution to the double-spending problem using a peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions. The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes.

2. 交易

2. Transactions

我们把一枚电子货币定义为一条数字签名链。每位所有者对上一笔交易和下一位所有者的公钥计算哈希,再对该哈希进行数字签名,并将这些内容添加到这枚币的末尾,从而把币转给下一位所有者。收款人可以验证这些签名,以验证所有权链。

We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.

Transactions

Transactions

问题当然在于,收款人无法验证某位所有者是否对这枚币进行了双重支付。一种常见的解决方案是引入一个可信任的中央机构,也就是铸币机构,由它检查每笔交易是否存在双重支付。每次交易之后,币都必须交回铸币机构,以发行一枚新币;只有铸币机构直接发行的币,才被认为没有被双重支付。这种方案的问题在于,整个货币系统的命运都取决于经营铸币机构的公司,每笔交易都必须经过它,就像银行一样。

The problem of course is the payee can't verify that one of the owners did not double-spend the coin. A common solution is to introduce a trusted central authority, or mint, that checks every transaction for double spending. After each transaction, the coin must be returned to the mint to issue a new coin, and only coins issued directly from the mint are trusted not to be double-spent. The problem with this solution is that the fate of the entire money system depends on the company running the mint, with every transaction having to go through them, just like a bank.

我们需要一种方法,让收款人知道之前的所有者没有签署过任何更早的交易。对于我们的目的而言,只有最早的交易算数,因此我们不关心之后的双重支付尝试。确认一笔交易不存在的唯一方法,就是知晓所有交易。在基于铸币机构的模式中,铸币机构知道所有交易,并决定哪笔先到。要在没有可信任一方的情况下做到这一点,就必须公开宣布交易 [1],而且需要一个系统,让参与者就交易接收顺序的一份唯一历史达成一致。收款人需要证据,证明在每笔交易发生时,多数节点都同意它是最先收到的那笔。

We need a way for the payee to know that the previous owners did not sign any earlier transactions. For our purposes, the earliest transaction is the one that counts, so we don't care about later attempts to double-spend. The only way to confirm the absence of a transaction is to be aware of all transactions. In the mint based model, the mint was aware of all transactions and decided which arrived first. To accomplish this without a trusted party, transactions must be publicly announced [1], and we need a system for participants to agree on a single history of the order in which they were received. The payee needs proof that at the time of each transaction, the majority of nodes agreed it was the first received.

3. 时间戳服务器

3. Timestamp Server

我们提出的方案从时间戳服务器开始。时间戳服务器的工作方式是:对一组需要加上时间戳的项目组成的区块计算哈希,然后广泛发布该哈希,例如刊登在报纸上或发布到 Usenet 帖子中 [2-5]。时间戳证明这些数据在当时必然已经存在,因为显然,只有先存在,才能被纳入哈希。每个时间戳的哈希都包含前一个时间戳,从而形成一条链,每个新增的时间戳都会加强它之前的时间戳。

The solution we propose begins with a timestamp server. 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 [2-5]. The timestamp proves that the data must have existed at the time, obviously, in order to get into the hash. Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it.

Timestamp Server

Timestamp Server

4. 工作量证明

4. Proof-of-Work

要以点对点的方式实现分布式时间戳服务器,我们需要使用类似 Adam Back 的 Hashcash [6] 的工作量证明系统,而不是报纸或 Usenet 帖子。工作量证明需要不断寻找一个值,使它经过 SHA-256 等哈希运算后,所得哈希以若干个 零比特开头。所需的平均工作量随要求的 零比特数量呈指数增长,而验证只需要执行一次哈希运算。

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. 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. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.

对于我们的时间戳网络,实现工作量证明的方法是递增区块中的 nonce,直到找到一个值,使区块哈希具有所要求数量的零比特。CPU 一旦付出计算工作,使区块满足工作量证明要求,不重新完成这些工作就无法修改该区块。随着后续区块连接在它后面,修改这个区块所需的工作还包括重新计算它之后的所有区块。

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. 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.

Proof-of-Work

Proof-of-Work

工作量证明也解决了多数决策中如何确定代表权的问题。如果多数建立在一个 IP 地址一票的基础上,任何能够分配大量 IP 地址的人都可以破坏它。工作量证明本质上是一个 CPU 一票。最长链代表多数决定,因为它投入了最多的工作量证明工作。如果诚实节点掌握多数 CPU 算力,诚实链就会增长得最快,超过所有竞争链。要修改过去的一个区块,攻击者必须重新完成该区块及其之后所有区块的工作量证明,然后追上并超过诚实节点的工作量。后面我们将说明,随着后续区块的增加,速度较慢的攻击者追上的概率会呈指数下降。

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. 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. 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.

5. 网络

5. Network

运行网络的步骤如下:

The steps to run the network are as follows:

  1. 新交易广播给所有节点。
  2. 每个节点把新交易收集到一个区块中。
  3. 每个节点为自己的区块寻找一个难以求得的工作量证明。
  4. 当节点找到工作量证明时,就把该区块广播给所有节点。
  5. 节点只有在区块中的所有交易都有效,而且没有被花费过时,才接受该区块。
  6. 节点使用已接受区块的哈希作为前一区块的哈希,着手创建链中的下一个区块,以此表示接受该区块。
  1. New transactions are broadcasted to all nodes.
  2. Each node collects new transactions into a block.
  3. Each node works on finding a difficult proof-of-work for its block.
  4. When a node finds a proof-of-work, it broadcasts the block to all nodes.
  5. Nodes accept the block only if all transactions in it are valid and not already spent.
  6. Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

节点始终把最长链视为正确的链,并持续努力延长它。如果两个节点同时广播不同版本的下一个区块,一些节点可能先收到其中一个,另一些节点则先收到另一个。此时,它们会在最先收到的区块上继续工作,但也保留另一个分支,以防它变得更长。当下一个工作量证明被找到、某个分支变得更长时,平局就会被打破;此前在另一个分支上工作的节点便会切换到较长的分支。

Nodes always consider the longest chain to be the correct one and will keep working on extending it. 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.

新交易的广播不一定需要到达所有节点。只要到达足够多的节点,它们不久就会进入一个区块。区块广播也能容忍消息丢失。如果一个节点没有收到某个区块,它会在收到下一个区块、发现自己漏了一个时,请求补收。

New transaction broadcasts do not necessarily need to reach all nodes. As long as they reach many nodes, they will get into a block before long. Block broadcasts are also tolerant of dropped messages. If a node does not receive a block, it will request it when it receives the next block and realizes it missed one.

6. 激励

6. Incentive

按照惯例,区块中的第一笔交易是一笔特殊交易,它创建一枚归该区块创建者所有的新币。这为节点支持网络增添了激励,也提供了一种最初将币分配到流通中的方式,因为这里没有发行货币的中央机构。以稳定的速度增加固定数量的新币,类似于金矿工人消耗资源,让黄金进入流通。在我们的系统中,消耗的是 CPU 时间和电力。

By convention, the first transaction in a block is a special transaction that starts a new coin owned by the creator of the block. This adds an incentive for nodes to support the network, and provides a way to initially distribute coins into circulation, since there is no central authority to issue them. The steady addition of a constant of amount of new coins is analogous to gold miners expending resources to add gold to circulation. In our case, it is CPU time and electricity that is expended.

这种激励也有助于鼓励节点保持诚实。如果一个贪婪的攻击者能集结超过所有诚实节点的 CPU 算力,他就必须作出选择:是用这些算力把已付出去的钱偷回来、欺骗人们,还是用它来生成新币。他应该会发现,遵守规则比破坏系统和自己财富的有效性更有利可图,因为这些规则使他能获得比其他所有人加起来还多的新币。

The incentive may also help encourage nodes to stay honest. If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins. He ought to find it more profitable to play by the rules, such rules that favour him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth.

为了适应硬件速度不断提高,以及人们运行节点的意愿随时间变化,工作量证明的难度由移动平均值决定,目标是使每小时平均生成一定数量的区块。如果区块生成得太快,难度就会上升。

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.

7. 回收磁盘空间

7. Reclaiming Disk Space

当一枚币的最新交易被足够多的区块覆盖后,它之前已花费的交易就可以丢弃,以节省磁盘空间。为了在不破坏区块哈希的情况下做到这一点,交易被组织成一棵 Merkle 树并进行哈希运算 [7][2][5],区块的哈希只包含树根。这样就可以通过剪去树的分支来压缩旧区块。内部哈希无需存储。

Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space. To facilitate this without breaking the block's hash, transactions are hashed in a Merkle Tree [7][2][5], with only the root included in the block's hash. Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do not need to be stored.

Reclaiming Disk Space

Reclaiming Disk Space

不含交易的区块头大约为 80 字节。假设每 10 分钟生成一个区块,则每年需要 80 字节 * 6 * 24 * 365 = 4.2MB。2008 年出售的计算机系统通常配有 2GB 内存,而摩尔定律预测目前每年增长 1.2GB,因此即使必须把区块头保存在内存中,存储也不成问题。

A block header with no transactions would be about 80 bytes. If we suppose blocks are generated every 10 minutes, 80 bytes * 6 * 24 * 365 = 4.2MB per year. With computer systems typically selling with 2GB of RAM as of 2008, and Moore's Law predicting current growth of 1.2GB per year, storage should not be a problem even if the block headers must be kept in memory.

8. 简化支付验证

8. Simplified Payment Verification

无需运行完整的网络节点,也可以验证支付。用户只需保存最长工作量证明链的区块头副本;他可以查询网络节点,直到确信自己拿到的是最长链,然后取得将交易连接到为它加上时间戳的区块的 Merkle 分支。他无法自行检查这笔交易,但把它连接到链上的一个位置后,就能看到已有网络节点接受了它;此后添加的区块进一步确认网络已经接受它。

It is possible to verify payments without running a full network node. A user only needs to keep a copy of the block headers of the longest proof-of-work chain, which he can get by querying network nodes until he's convinced he has the longest chain, and obtain the Merkle branch linking the transaction to the block it's timestamped in. He can't check the transaction for himself, but by linking it to a place in the chain, he can see that a network node has accepted it, and blocks added after it further confirm the network has accepted it.

Simplified Payment Verification

Simplified Payment Verification

因此,只要诚实节点控制网络,这种验证就是可靠的;但如果攻击者压倒了网络,它就更容易受到攻击。网络节点可以自行验证交易,只会面临交易被撤销的风险;而对于简化方法,只要攻击者能够持续压倒网络,就能用伪造的交易欺骗它。一种防范策略是接受网络节点在检测到无效区块时发出的警报,促使用户软件下载完整区块及所报告的交易,以确认不一致之处。经常接收付款的商家,可能仍会希望运行自己的节点,以获得更独立的安全保障和更快的验证。

As such, the verification is reliable as long as honest nodes control the network, but is more vulnerable if the network is overpowered by an attacker. While network nodes can verify transactions for themselves and are only vulnerable to reversal, the simplified method can be fooled by an attacker's fabricated transactions for as long as the attacker can continue to overpower the network. One strategy to protect against this would be to accept alerts from network nodes when they detect an invalid block, prompting the user's software to download the full block and reported transactions to confirm the inconsistency. Businesses that receive frequent payments will probably still want to run their own nodes for more independent security and quicker verification.

9. 价值的合并与拆分

9. Combining and Splitting Value

虽然可以逐枚处理币,但若转账中的每一分钱都需要一笔单独的交易,就会很不方便。为了让价值可以拆分和合并,交易包含多个输入和输出。通常,要么只有一个来自先前较大金额交易的输入,要么有多个输入,把较小的金额合并起来;输出最多有两个:一个用于付款,另一个在需要找零时,把零钱退还给付款人。

Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender.

Combining and Splitting Value

Combining and Splitting Value

需要指出,一笔交易依赖几笔交易,而这些交易又依赖更多交易,这种扇出关系在这里并不构成问题。任何时候都不需要提取一笔交易历史的完整独立副本。

It should be noted that fan-out, where a transaction depends on several transactions, and those transactions depend on many more, is not a problem here. There is never the need to extract a complete standalone copy of a transaction's history.

10. 隐私

10. Privacy

传统银行模式通过把信息访问权限限制在交易相关方及可信任的第三方之间,获得一定程度的隐私。所有交易都必须公开宣布,因此无法采用这种方法,但仍可以在其他地方切断信息流来保护隐私:让公钥保持匿名。公众可以看到有人向另一个人发送了一笔钱,却没有信息能把这笔交易与任何人联系起来。这与证券交易所公开的信息程度相似:单笔交易的时间和金额,也就是逐笔行情记录,是公开的,但不透露交易双方是谁。

The traditional banking model achieves a level of privacy by limiting access to information to the parties involved and the trusted third party. The necessity to announce all transactions publicly precludes this method, but privacy can still be maintained by breaking the flow of information in another place: by keeping public keys anonymous. The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone. This is similar to the level of information released by stock exchanges, where the time and size of individual trades, the "tape", is made public, but without telling who the parties were.

Privacy

Privacy

作为一道额外的防线,每笔交易都应使用一对新的密钥,以免它们被关联到同一位所有者。不过,多输入交易仍然无法避免某些关联,因为它们必然会暴露这些输入属于同一位所有者。风险在于,如果某个密钥的所有者身份被揭露,关联分析就可能揭露同一位所有者的其他交易。

As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner. Some linking is still unavoidable with multi-input transactions, which necessarily reveal that their inputs were owned by the same owner. The risk is that if the owner of a key is revealed, linking could reveal other transactions that belonged to the same owner.

11. 计算

11. Calculations

我们考虑这样一种情况:攻击者试图以比诚实链更快的速度生成另一条链。即使他做到了,也不能任意更改系统,例如凭空创造价值,或取走从未属于攻击者的钱。节点不会把无效交易当作付款接受,诚实节点也绝不会接受包含此类交易的区块。攻击者只能尝试更改自己的一笔交易,以拿回他最近花出去的钱。

We consider the scenario of an attacker trying to generate an alternate chain faster than the honest chain. Even if this is accomplished, it does not throw the system open to arbitrary changes, such as creating value out of thin air or taking money that never belonged to the attacker. Nodes are not going to accept an invalid transaction as payment, and honest nodes will never accept a block containing them. An attacker can only try to change one of his own transactions to take back money he recently spent.

诚实链与攻击者链之间的竞争,可以描述为二项随机游走。成功事件是诚实链延长一个区块,使其领先幅度增加 +1;失败事件是攻击者链延长一个区块,使差距的变化量为 -1。

The race between the honest chain and an attacker chain can be characterized as a Binomial Random Walk. The success event is the honest chain being extended by one block, increasing its lead by +1, and the failure event is the attacker's chain being extended by one block, reducing the gap by -1.

攻击者从给定的落后幅度追上的概率,类似于赌徒破产问题。假设一个拥有无限信贷的赌徒从亏损状态开始,可以进行无限次尝试,试图回到收支平衡。我们可以如下计算他最终回到收支平衡的概率,也就是攻击者最终追上诚实链的概率 [8]:

The probability of an attacker catching up from a given deficit is analogous to a Gambler's Ruin problem. Suppose a gambler with unlimited credit starts at a deficit and plays potentially an infinite number of trials to try to reach breakeven. We can calculate the probability he ever reaches breakeven, or that an attacker ever catches up with the honest chain, as follows [8]:

  • p = 诚实节点找到下一个区块的概率
  • q = 攻击者找到下一个区块的概率
  • qz = 攻击者从落后 z 个区块最终追上的概率
  • p = probability an honest node finds the next block
  • q = probability the attacker finds the next block
  • qz = probability the attacker will ever catch up from z blocks behind
qz={1if pq(q/p)zif p>qq_z = \begin{cases} 1 & \text{if } p \leq q \\ (q/p)^z & \text{if } p > q \end{cases}

根据我们关于 p > q 的假设,随着攻击者需要追赶的区块数量增加,这个概率呈指数下降。形势对他不利;如果他没有在一开始幸运地大幅前进,那么随着他越落越远,机会就会变得微乎其微。

Given our assumption that p > q, the probability drops exponentially as the number of blocks the attacker has to catch up with increases. With the odds against him, if he doesn't make a lucky lunge forward early on, his chances become vanishingly small as he falls further behind.

现在考虑一笔新交易的收款人需要等待多久,才能有足够把握认为付款人无法更改交易。我们假设付款人就是攻击者,他想让收款人暂时相信自己已收到付款,过一段时间后再把这笔钱改为付回给自己。发生这种情况时,收款人会得到警告,但付款人希望到那时已经太晚了。

We now consider how long the recipient of a new transaction needs to wait before being sufficiently certain the sender can't change the transaction. We assume the sender is an attacker who wants to make the recipient believe he paid him for a while, then switch it to pay back to himself after some time has passed. The receiver will be alerted when that happens, but the sender hopes it will be too late.

收款人生成一对新密钥,并在签名前不久把公钥交给付款人。这样可以防止付款人提前准备一条区块链,一直计算,等到足够幸运、领先足够多时再执行交易。交易发出后,不诚实的付款人开始秘密构建一条并行链,其中包含这笔交易的另一个版本。

The receiver generates a new key pair and gives the public key to the sender shortly before signing. This prevents the sender from preparing a chain of blocks ahead of time by working on it continuously until he is lucky enough to get far enough ahead, then executing the transaction at that moment. Once the transaction is sent, the dishonest sender starts working in secret on a parallel chain containing an alternate version of his transaction.

收款人等待交易被加入某个区块,并且该区块后又连接了 z 个区块。他不知道攻击者已经推进了多少,但假设诚实节点出块所用的时间等于平均预期时间,攻击者可能取得的进展就服从泊松分布,其期望值为:

The recipient waits until the transaction has been added to a block and z blocks have been linked after it. He doesn't know the exact amount of progress the attacker has made, but assuming the honest blocks took the average expected time per block, the attacker's potential progress will be a Poisson distribution with expected value:

λ=zqp\lambda=z\frac{q}{p}

为了得到攻击者此时仍能追上的概率,我们把攻击者可能取得的每种进展对应的泊松概率密度,乘以他从那个位置追上的概率:

To get the probability the attacker could still catch up now, we multiply the Poisson density for each amount of progress he could have made by the probability he could catch up from that point:

k=0λkeλk!{(q/p)zkkz1k>z\sum_{k=0}^{\infty}\frac{\lambda^k e^{-\lambda}}{k!}\begin{cases}(q/p)^{z-k}&k\leq z\\1&k>z\end{cases}

重新整理,避免对分布的无穷尾部求和……

Rearranging to avoid summing the infinite tail of the distribution...

1k=0zλkeλk!(1(q/p)zk)1-\sum_{k=0}^{z}\frac{\lambda^k e^{-\lambda}}{k!}\left(1-(q/p)^{z-k}\right)

转换成 C 代码:

Converting to C code:

#include <math.h>
double AttackerSuccessProbability(double q, int z)
{
    double p = 1.0 - q;
    double lambda = z * (q / p);
    double sum = 1.0;
    int i, k;
    for (k = 0; k <= z; k++)
    {
        double poisson = exp(-lambda);
        for (i = 1; i <= k; i++)
            poisson *= lambda / i;
        sum -= poisson * (1 - pow(q / p, z - k));
    }
    return sum;
}
#include <math.h>
double AttackerSuccessProbability(double q, int z)
{
    double p = 1.0 - q;
    double lambda = z * (q / p);
    double sum = 1.0;
    int i, k;
    for (k = 0; k <= z; k++)
    {
        double poisson = exp(-lambda);
        for (i = 1; i <= k; i++)
            poisson *= lambda / i;
        sum -= poisson * (1 - pow(q / p, z - k));
    }
    return sum;
}

运行一些结果,可以看到概率随 z 呈指数下降。

Running some results, we can see the probability drop off exponentially with z.

q=0.1
z=0    P=1.0000000
z=1    P=0.2045873
z=2    P=0.0509779
z=3    P=0.0131722
z=4    P=0.0034552
z=5    P=0.0009137
z=6    P=0.0002428
z=7    P=0.0000647
z=8    P=0.0000173
z=9    P=0.0000046
z=10   P=0.0000012

q=0.3
z=0    P=1.0000000
z=5    P=0.1773523
z=10   P=0.0416605
z=15   P=0.0101008
z=20   P=0.0024804
z=25   P=0.0006132
z=30   P=0.0001522
z=35   P=0.0000379
z=40   P=0.0000095
z=45   P=0.0000024
z=50   P=0.0000006
q=0.1
z=0    P=1.0000000
z=1    P=0.2045873
z=2    P=0.0509779
z=3    P=0.0131722
z=4    P=0.0034552
z=5    P=0.0009137
z=6    P=0.0002428
z=7    P=0.0000647
z=8    P=0.0000173
z=9    P=0.0000046
z=10   P=0.0000012

q=0.3
z=0    P=1.0000000
z=5    P=0.1773523
z=10   P=0.0416605
z=15   P=0.0101008
z=20   P=0.0024804
z=25   P=0.0006132
z=30   P=0.0001522
z=35   P=0.0000379
z=40   P=0.0000095
z=45   P=0.0000024
z=50   P=0.0000006

求解 P 小于 0.1% 的情况……

Solving for P less than 0.1%...

P < 0.001
q=0.10   z=5
q=0.15   z=8
q=0.20   z=11
q=0.25   z=15
q=0.30   z=24
q=0.35   z=41
q=0.40   z=89
q=0.45   z=340
P < 0.001
q=0.10   z=5
q=0.15   z=8
q=0.20   z=11
q=0.25   z=15
q=0.30   z=24
q=0.35   z=41
q=0.40   z=89
q=0.45   z=340

12. 结论

12. Conclusion

我们提出了一种无需依赖信任的电子交易系统。我们从由数字签名构成的币这一常见框架出发,它能有力地控制所有权,但缺少防止双重支付的方法,就仍不完整。为了解决这一点,我们提出一种点对点网络,使用工作量证明记录公开的交易历史;只要诚实节点掌握多数 CPU 算力,这份交易历史很快就会在计算上变得难以被攻击者更改。网络以其无结构的简洁性获得稳健性。节点同时工作,几乎无需协调。它们不需要身份识别,因为消息无需路由到任何特定位置,只要尽力传送即可。节点可以自由离开和重新加入网络,并将工作量证明链作为它们离开期间所发生事情的证明。它们用 CPU 算力投票,通过继续延长有效区块来表示接受,通过拒绝在无效区块上继续工作来表示拒绝。这种共识机制可以执行任何所需的规则和激励。

We have proposed a system for electronic transactions without relying on trust. We started with the usual framework of coins made from digital signatures, which provides strong control of ownership, but is incomplete without a way to prevent double-spending. To solve this, we proposed a peer-to-peer network using proof-of-work to record a public history of transactions that quickly becomes computationally impractical for an attacker to change if honest nodes control a majority of CPU power. The network is robust in its unstructured simplicity. Nodes work all at once with little coordination. They do not need to be identified, since messages are not routed to any particular place and only need to be delivered on a best effort basis. Nodes can leave and rejoin the network at will, accepting the proof-of-work chain as proof of what happened while they were gone. They vote with their CPU power, expressing their acceptance of valid blocks by working on extending them and rejecting invalid blocks by refusing to work on them. Any needed rules and incentives can be enforced with this consensus mechanism.

参考文献

References

[1] W. Dai, "b-money," http://www.weidai.com/bmoney.txt, 1998.

[1] W. Dai, "b-money," http://www.weidai.com/bmoney.txt, 1998.

[2] H. Massias、X.S. Avila 和 J.-J. Quisquater,《设计一种信任要求最低的安全时间戳服务》,第 20 届比荷卢信息论研讨会,1999 年 5 月。

[2] H. Massias, X.S. Avila, and J.-J. Quisquater, "Design of a secure timestamping service with minimal trust requirements," In 20th Symposium on Information Theory in the Benelux, May 1999.

[3] S. Haber、W.S. Stornetta,《如何为数字文档加上时间戳》,《密码学杂志》,第 3 卷第 2 期,第 99-111 页,1991 年。

[3] S. Haber, W.S. Stornetta, "How to time-stamp a digital document," In Journal of Cryptology, vol 3, no 2, pages 99-111, 1991.

[4] D. Bayer、S. Haber、W.S. Stornetta,《提高数字时间戳的效率和可靠性》,《序列 II:通信、安全与计算机科学中的方法》,第 329-334 页,1993 年。

[4] D. Bayer, S. Haber, W.S. Stornetta, "Improving the efficiency and reliability of digital time-stamping," In Sequences II: Methods in Communication, Security and Computer Science, pages 329-334, 1993.

[5] S. Haber、W.S. Stornetta,《位串的安全名称》,第 4 届 ACM 计算机与通信安全会议论文集,第 28-35 页,1997 年 4 月。

[5] S. Haber, W.S. Stornetta, "Secure names for bit-strings," In Proceedings of the 4th ACM Conference on Computer and Communications Security, pages 28-35, April 1997.

[6] A. Back,《Hashcash——一种拒绝服务攻击对策》,http://www.hashcash.org/papers/hashcash.pdf, 2002 年。

[6] A. Back, "Hashcash - a denial of service counter-measure," http://www.hashcash.org/papers/hashcash.pdf, 2002.

[7] R.C. Merkle,《公钥密码系统的协议》,1980 年安全与隐私研讨会论文集,IEEE 计算机学会,第 122-133 页,1980 年 4 月。

[7] R.C. Merkle, "Protocols for public key cryptosystems," In Proc. 1980 Symposium on Security and Privacy, IEEE Computer Society, pages 122-133, April 1980.

[8] W. Feller,《概率论及其应用导论》,1957 年。

[8] W. Feller, "An introduction to probability theory and its applications," 1957.

来源

阅读字号

选择适合你的字号,之后阅读会继续使用。