Skip to content

比特币:一种点对点的电子现金系统(白皮书) ​

原始发布页

打开来源页面
查看 1 个交叉存档

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

中本聪

satoshin@gmx.com

www.bitcoin.org

摘要。 一种纯粹的点对点电子现金系统,可以让在线支付直接从一方发送给另一方,而无需经过金融机构。数字签名提供了部分解决方案,但如果仍然需要可信第三方来防止双重支付,主要优势便会丧失。我们提出一种利用点对点网络解决双重支付问题的方案。该网络通过把交易哈希进一条持续延伸的、基于哈希的工作量证明链,为交易加上时间戳,形成一份若不重做工作量证明便无法更改的记录。最长链不仅能证明已见证事件的先后顺序,还能证明它来自最大的 CPU 算力池。只要多数 CPU 算力由未合谋攻击网络的节点控制,它们就会生成最长链,并超过攻击者。网络本身只需极少的结构。消息以尽力而为的方式广播,节点可以随时离开并重新加入网络,把最长的工作量证明链作为它们离开期间所发生事件的证明。

1. 引言 ​

互联网商业几乎已经完全依赖由金融机构充当可信第三方来处理电子支付。尽管这一系统对大多数交易而言运作得足够好,但它仍然受到基于信任模型固有弱点的困扰。完全不可逆的交易实际上并不可能,因为金融机构无法避免调解争议。调解成本会增加交易成本,限制实际可行的最小交易规模,并断绝小额临时交易的可能;而且,由于失去了为不可逆服务进行不可逆支付的能力,还会产生更广泛的成本。有了撤销的可能,对信任的需求便会蔓延。商家必须提防客户,麻烦客户提供比原本所需更多的信息。一定比例的欺诈被认为不可避免。当面使用实体货币可以避免这些成本和支付的不确定性,但目前没有任何机制能在没有可信方的情况下通过通信渠道进行支付。

我们需要的是一种以密码学证明而非信任为基础的电子支付系统,让任意两个自愿的参与方无需可信第三方即可彼此直接交易。计算上难以逆转的交易能够保护卖家免受欺诈,而常规的托管机制也可以轻松实现,以保护买家。本文提出一种方案:使用点对点的分布式时间戳服务器,生成交易时间先后顺序的计算证明,从而解决双重支付问题。只要诚实节点共同掌握的 CPU 算力超过任何相互协作的攻击节点群体,该系统就是安全的。

2. 交易 ​

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

交易

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

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

3. 时间戳服务器 ​

我们提出的解决方案始于时间戳服务器。时间戳服务器的工作方式是:对一组需要加时间戳的项目组成的区块取哈希,并广泛发布该哈希,例如刊登在报纸或 Usenet 帖子中 [2-5]。显然,数据必须在当时已经存在,才能被纳入该哈希,因此时间戳证明了数据在当时的确存在。每个时间戳的哈希中都包含前一个时间戳,从而形成一条链;每增加一个时间戳,都会进一步巩固此前的时间戳。

时间戳服务器

4. 工作量证明 ​

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

对于我们的时间戳网络,我们通过不断递增区块中的 nonce 来实现工作量证明,直到找到一个能使区块哈希具有所需零比特的值。一旦已经耗费 CPU 算力使其满足工作量证明,若不重做这些工作便无法更改该区块。随着后续区块链接在它之后,更改该区块所需的工作还将包括重做它之后的所有区块。

工作量证明

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

为了补偿硬件速度的增长,以及人们运行节点的兴趣随时间发生的变化,工作量证明难度由移动平均值决定,目标是维持每小时平均生成一定数量的区块。如果区块生成得太快,难度就会提高。

5. 网络 ​

运行网络的步骤如下:

  1. 新交易向所有节点广播。
  2. 每个节点把新交易收集到一个区块中。
  3. 每个节点都为自己的区块寻找一个困难的工作量证明。
  4. 当一个节点找到工作量证明时,它向所有节点广播该区块。
  5. 节点只有在区块中的所有交易均有效且尚未被花费时,才接受该区块。
  6. 节点通过着手创建链中的下一个区块来表示接受该区块,并将已接受区块的哈希用作前一个哈希。

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

新交易的广播不一定需要到达所有节点。只要它们到达许多节点,很快就会被纳入一个区块。区块广播也能容忍消息丢失。如果一个节点没有收到某个区块,那么当它收到下一个区块并意识到自己漏掉一个区块时,就会请求该区块。

6. 激励 ​

按照约定,区块中的第一笔交易是一笔特殊交易,它生成一枚归该区块创建者所有的新币。这会激励节点支持网络,也提供了一种最初将货币分发进入流通的方式,因为没有中央权威机构来发行它们。稳定地加入恒定数量的新币,类似于黄金矿工耗费资源把黄金加入流通。在我们的情形中,耗费的是 CPU 时间和电力。

激励也可以由交易费来提供。如果一笔交易的输出价值小于其输入价值,差额就是一笔交易费,它会加入包含该交易的区块的激励价值中。一旦预定数量的货币进入流通,激励就可以完全转为交易费,并且完全没有通货膨胀。

激励可能有助于鼓励节点保持诚实。如果一个贪婪的攻击者能够聚集比所有诚实节点更多的 CPU 算力,他就必须作出选择:要么用它通过盗回自己的付款来欺骗人们,要么用它生成新币。他应当发现,遵守规则比破坏系统以及他自身财富的有效性更有利可图,因为这些规则使他获得的新币比其他所有人加起来还多。

7. 回收磁盘空间 ​

一枚货币的最新交易一旦被足够多的区块掩埋,就可以丢弃它之前已经花费的交易,以节省磁盘空间。为了在不破坏区块哈希的情况下做到这一点,交易被哈希进一棵 Merkle 树 [7][2][5],只有根被纳入区块哈希。随后可以通过剪除树的分支来压缩旧区块。内部哈希无需存储。

回收磁盘空间

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

8. 简化支付验证 ​

无需运行完整网络节点也可以验证支付。用户只需要保存最长工作量证明链的区块头副本;他可以通过查询网络节点来获得它,直到确信自己拥有最长链,同时还要获得将该交易链接到为其加时间戳的区块的 Merkle 分支。他无法亲自检查这笔交易,但通过把交易链接到链中的某个位置,他可以看到某个网络节点已经接受了它,而在它之后添加的区块会进一步确认网络已经接受了它。

简化支付验证

因此,只要诚实节点控制着网络,这种验证就是可靠的;但如果网络被攻击者压倒,它就更容易受到攻击。网络节点可以自行验证交易,而只要攻击者能够持续压倒网络,简化方法就可能被攻击者伪造的交易欺骗。一种防范策略是:当网络节点检测到无效区块时,接受它们发出的警报,促使用户的软件去下载完整区块和触发警报的交易,以确认不一致之处。经常收款的企业可能仍会希望运行自己的节点,以获得更独立的安全性和更快的验证。

9. 价值的合并与拆分 ​

尽管可以逐枚处理货币,但为一笔转账中的每一分钱分别创建一笔交易会很笨重。为了让价值能够拆分和合并,交易包含多个输入和输出。通常,要么只有一个来自较大笔先前交易的输入,要么有多个合并较小金额的输入;输出最多有两个:一个用于付款,另一个把找零(如果有)退回给发送者。

价值的合并与拆分

应当指出,扇出在这里并不是问题:一笔交易依赖若干笔交易,而这些交易又依赖更多交易。我们从来不需要提取一笔交易历史的完整独立副本。

10. 隐私 ​

传统银行模型通过把信息访问限制在相关参与方和可信第三方之内,达到一定程度的隐私。必须公开宣布所有交易使这种方法无法采用,但仍然可以通过在另一个地方切断信息流来维护隐私:让公钥保持匿名。公众可以看到某人正在向另一个人发送一笔金额,却没有任何信息能把这笔交易与任何人联系起来。这类似于证券交易所披露的信息水平:每笔交易的时间和规模,也就是“行情纸带”,会被公开,但不会说明参与方是谁。

隐私

作为额外的一道防火墙,每笔交易都应使用一对新密钥,以免它们被关联到同一个所有者。多输入交易仍不可避免地会产生一些关联,因为这种交易必然会暴露其输入由同一所有者拥有。风险在于,如果一把密钥的所有者身份被揭示,这种关联可能会揭示属于同一所有者的其他交易。

11. 计算 ​

我们考虑攻击者试图以比诚实链更快的速度生成一条替代链的情形。即使做到了这一点,也不会使系统任由他随意更改,例如凭空创造价值,或拿走从未属于攻击者的钱。节点不会接受无效交易作为支付,诚实节点也绝不会接受包含这种交易的区块。攻击者只能试图更改自己的某笔交易,以取回他最近花掉的钱。

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

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

  • p = 诚实节点找到下一个区块的概率
  • q = 攻击者找到下一个区块的概率
  • qz = 攻击者从落后 z 个区块的状态最终追上的概率
qz={1如果 p≤q(q/p)z如果 p>q

根据我们的假设 p > q,随着攻击者必须追赶的区块数增加,该概率会呈指数下降。在形势对他不利时,如果他没能在早期幸运地猛冲向前,那么随着落后越来越多,他的机会将变得微乎其微。

现在,我们考虑一笔新交易的接收者需要等待多久,才能充分确信发送者无法更改这笔交易。我们假定发送者是攻击者,他想先让接收者在一段时间内相信自己已经付款,然后在经过一段时间后把交易切换为付回给自己。发生这种情况时接收者会收到警报,但发送者希望届时已经太迟。

接收者生成一对新密钥,并在签名之前不久把公钥交给发送者。这可以防止发送者预先准备一条区块链:持续在这条链上工作,直到幸运地取得足够的领先,然后在那一刻执行交易。交易一经发送,不诚实的发送者便开始秘密处理一条包含其交易替代版本的并行链。

接收者等待交易被加入一个区块,并且其后又链接了 z 个区块。他不知道攻击者取得的确切进展,但假设诚实区块每个都花费了平均预期时间,那么攻击者可能取得的进展将服从期望值如下的泊松分布:

λ=zqp

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

∑k=0∞λke−λk!⋅{(q/p)(z−k)如果 k≤z1如果 k>z

重新排列,以避免对分布的无限长尾求和……

1−∑k=0zλke−λk!(1−(q/p)(z−k))

转换为 C 代码:

c
#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 呈指数下降。

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% 的情形……

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. 结论 ​

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

参考文献 ​

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

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

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

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

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

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

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

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

英文原文 ​

展开英文原文

Bitcoin: A Peer-to-Peer Electronic Cash System

Satoshi Nakamoto

satoshin@gmx.com

www.bitcoin.org

Abstract. A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third 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 a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast 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. 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.

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

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.

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

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

4. Proof-of-Work

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.

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

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.

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.

5. Network

The steps to run the network are as follows:

  1. New transactions are broadcast 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. Incentive

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.

The incentive can also be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a transaction fee that is added to the incentive value of the block containing the transaction. Once a predetermined number of coins have entered circulation, the incentive can transition entirely to transaction fees and be completely inflation free.

The incentive may 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.

7. Reclaiming Disk Space

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

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. Simplified Payment Verification

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

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

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

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

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.

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 = 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 p≤q(q/p)zif 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.

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

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)(z−k)if k≤z1if k>z

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

1−∑k=0zλke−λk!(1−(q/p)(z−k))

Converting to C code:

c
#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;
}

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

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

12. Conclusion

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.

[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, "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, "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, "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 - a denial of service counter-measure," http://www.hashcash.org/papers/hashcash.pdf, 2002.

[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, "An introduction to probability theory and its applications," 1957.

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。