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.
问题当然在于:收款方(payee)无法验证某位所有者是否没有对同一枚币进行双重支付(double-spend)。一个常见的解决方案是引入一个受信任的中央权威(central authority),或称铸币机构(mint),由它检查每笔交易是否发生双重支付。每次交易之后,这枚币必须交回铸币机构以发行一枚新币;并且只有直接由铸币机构发行的币,才被信任不会被双重支付。这个方案的问题在于:整个货币系统的命运取决于运营铸币机构的那家公司,而且每笔交易都必须经过它——就像银行一样。
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 announced1, 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.
我们需要一种方式,让收款方确信:之前的所有者没有签署任何更早的交易。对我们的目的而言,最早的那笔交易才算数,因此我们不关心之后的双重支付尝试。确认“某笔交易不存在”的唯一办法,是对所有交易都“知情”。在铸币机构模型中,铸币机构知道全部交易,并决定哪一笔最先到达。要在没有受信任第三方的情况下做到这一点,交易必须被公开发布(publicly announced)¹,并且我们需要一个系统,使参与者能够就“收到交易的先后顺序”达成一个单一历史(single history)。收款方需要证据证明:在每次交易发生时,多数节点都同意该交易是“最先收到”的那笔。
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 post2 3 4 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)开始。时间戳服务器的工作方式是:对一组需要加时间戳的条目做哈希(hash),然后把这个哈希广泛发布出去,例如刊登在报纸上或发布到 Usenet 帖子中²³⁴⁵。时间戳证明了这些数据在当时必然已经存在——否则不可能被纳入该哈希。每一个时间戳在其哈希中包含前一个时间戳,从而形成一条链;而每新增一个时间戳,都会对之前的时间戳起到“加固”的作用。
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 Hashcash6, 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.
为了以点对点(peer-to-peer)的方式实现一个分布式时间戳服务器,我们需要使用一种类似于 Adam Back 的 Hashcash⁶ 的工作量证明(proof-of-work)系统,而不是依赖报纸或 Usenet 帖子。工作量证明的过程是:扫描(scanning)寻找某个数值,使得对其进行哈希(例如用 SHA-256)后,得到的哈希值以若干个零比特(zero bits)开头。所需的平均工作量随“要求的零比特数量”呈指数增长,但验证却只需要执行一次哈希即可。
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.
对于我们的时间戳网络,我们通过在区块(block)中递增一个随机数(nonce),直到找到某个值使得该区块的哈希满足所要求的零比特条件,从而实现工作量证明。一旦耗费 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.
工作量证明(proof-of-work)也解决了“多数决策中代表权(representation)如何确定”的问题。如果多数是按“一 IP 地址一票(one-IP-address-one-vote)”来计算,那么任何能分配大量 IP 的人都可以颠覆它。工作量证明本质上是“一 CPU 一票(one-CPU-one-vote)”。多数决策由最长链(longest chain)来代表,因为最长链投入了最多的工作量证明努力(greatest proof-of-work effort)。如果多数 CPU 算力由诚实节点控制,诚实链将增长得最快,并超过任何竞争链。要修改过去的一个区块(past block),攻击者必须重做该区块以及其后所有区块的工作量证明,然后再追赶并超过诚实节点所完成的工作量。我们稍后将展示:随着后续区块不断增加,一个较慢攻击者追赶成功的概率会以指数方式下降(diminishes exponentially)。
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.
为了补偿硬件速度提升以及节点运行兴趣随时间变化所带来的影响,工作量证明难度(difficulty)通过一个移动平均(moving average)来决定,其目标是把“每小时平均产生的区块数量”稳定在一个水平上。如果区块生成得太快,难度就会提高。
5. Network
网络
The steps to run the network are as follows:
运行网络的步骤如下:
1)New transactions are broadcast to all nodes.
新的交易会广播(broadcast)给所有节点。
2)Each node collects new transactions into a block.
每个节点把新的交易收集进一个区块(block)。
3)Each node works on finding a difficult proof-of-work for its block.
每个节点开始为自己的区块寻找一个“困难的”工作量证明(difficult proof-of-work)。
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.
节点只有在确认区块内所有交易都有效(valid)且尚未被花费(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.
节点通过继续创建链上的下一个区块来表达自己对该区块的接受:把被接受区块的哈希作为“前一区块哈希(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.
节点始终把最长链视为正确链(correct 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.
新的交易广播不一定必须到达所有节点。只要它们到达足够多的节点,就会在不久后被打包进某个区块。区块广播同样能容忍消息丢失(dropped messages)。如果某个节点没有收到某个区块,它会在收到下一个区块、意识到自己漏掉一个时,发起请求来补齐。
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.
按惯例,一个区块中的第一笔交易是一种特殊交易:它会创建一枚由该区块创建者(creator of the block)拥有的新币。这为节点支持网络提供了激励(incentive),并且在没有中央权威发行货币的情况下,提供了一种把货币最初分发到流通中的方式。持续、稳定地增加一恒定数量的新币,类似于黄金矿工耗费资源把黄金加入流通。只不过在我们的场景里,被耗费的是 CPU 时间与电力。
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.
激励也可以由交易费(transaction fees)来资助。如果一笔交易的输出价值(output value)小于其输入价值(input value),两者之差就是交易费;该费用会被加到“包含这笔交易的区块”的激励价值中。一旦预定数量的货币进入流通,激励就可以完全过渡为交易费,从而实现彻底的“零通胀(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.
激励机制也可能有助于促使节点保持诚实。如果一个贪婪的攻击者(greedy attacker)能够聚集比所有诚实节点更高的 CPU 算力,那么他必须在两种用途之间做选择:要么用这些算力通过“把自己支付出去的钱偷回来”来欺诈他人(stealing back his payments),要么用这些算力来生成新币。他理应发现:遵守规则更有利可图——因为规则会让他获得比其他所有人合计更多的新币——相比之下,破坏系统会削弱体系本身以及他自己财富的有效性(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 Tree257, 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.
一旦一枚币的最新交易(latest transaction)被足够多的区块“埋深”(buried),它之前那些已经花费掉的交易(spent transactions)就可以被丢弃,以节省磁盘空间。为了在不破坏区块哈希(block's hash)的情况下做到这一点,交易会被哈希进一棵 Merkle Tree²⁵⁷,并且只有根(root)被包含在区块哈希中。这样,旧区块就可以通过“截断树枝(stubbing off branches)”来压缩(compacted)。内部哈希(interior hashes)无需被存储。

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.
一个不含交易的区块头(block header)大约是 80 字节。假设区块每 10 分钟生成一次,那么 80 字节 × 6 × 24 × 365 = 4.2MB/年。鉴于截至 2008 年,计算机系统通常配备 2GB 的 RAM,且 Moore's Law 预测当前每年约增长 1.2GB,即使区块头必须常驻内存,存储也不应成为问题。
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.
无需运行完整网络节点也可以验证支付。用户只需要保存“最长工作量证明链(longest proof-of-work chain)”的区块头副本;他可以通过向多个网络节点查询,直到确信自己拿到的是最长链。随后,再获取把该笔交易与其被时间戳记录的区块相连接的 Merkle 分支(Merkle branch)。他无法自行验证交易本身是否有效,但通过把交易定位到链上的某个位置,他就能确认某个网络节点已经接受了它,而在其后不断追加的区块会进一步确认网络对该交易的接受。

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.
因此,只要诚实节点控制着网络,这种验证就是可靠的;但如果网络算力被攻击者压制,它就更脆弱。网络节点可以自行验证交易,而这种简化方法在攻击者能够持续压制网络的期间,可能被攻击者伪造的交易所欺骗。一种防护策略是:当网络节点检测到无效区块(invalid block)时,向用户发出警报,促使用户的软件下载完整区块与被警报标记的交易,以核实不一致之处。那些频繁收款的企业,出于更独立的安全性与更快的验证需求,可能仍然希望运行自己的节点。
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.
虽然可以逐枚处理货币(coins),但如果一次转账中的每一分钱都要单独做一笔交易,那将非常笨重。为了允许价值被拆分与合并,交易(transactions)包含多个输入(inputs)与输出(outputs)。通常要么是来自一笔更大先前交易的单一输入,要么是把多个较小金额合并起来的多个输入;输出最多两项:一项用于支付,另一项(若存在找零)把找零返还给付款方(sender)。

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.
需要指出的是,这里的“扇出(fan-out)”并不是问题:即一笔交易依赖于多笔交易,而这些交易又依赖于更多交易。系统从不需要抽取一份“完整、可独立存在”的交易历史副本(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.
传统银行模型通过限制信息访问范围(只让交易双方与受信任第三方可见)来实现一定程度的隐私。必须公开宣布所有交易这一要求,使得这种方法无法使用;但隐私仍可通过在另一个位置“打断信息流”来维持:保持公钥(public keys)的匿名性。公众能看到“有人给另一个人转了一笔金额”,但缺乏把交易与具体身份关联起来的信息。这类似于证券交易所发布的信息水平:单笔交易的时间与规模(the "tape")是公开的,但不会披露交易双方是谁。

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.
作为额外的防火墙,每笔交易都应使用一个新的密钥对(key pair),以避免被关联到同一所有者。对于多输入交易(multi-input transactions),仍不可避免会出现一定程度的关联,因为它必然揭示这些输入属于同一所有者。风险在于:一旦某个密钥的所有者身份被揭示,关联关系可能进一步暴露该所有者的其他交易。
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.
我们考虑这样一种情形:攻击者试图比诚实链更快地产生一条替代链(alternate chain)。即便攻击者做到了这一点,也并不会让系统对任意篡改敞开大门,例如凭空创造价值(creating value out of thin air)或拿走从未属于攻击者的钱。节点不会接受无效交易(invalid transaction)作为支付,而诚实节点永远不会接受包含无效交易的区块。攻击者唯一能尝试做的,是修改他自己最近的一笔交易,把他刚花出去的钱拿回来。
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.
诚实链与攻击者链之间的竞赛可以刻画为一个二项随机游走(Binomial Random Walk)。所谓“成功事件”是诚实链被扩展一个区块,使其领先优势增加 +1;所谓“失败事件”是攻击者链被扩展一个区块,使差距减少 -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 follows8:
攻击者从某个既定落后程度追赶成功的概率,类似于“赌徒破产(Gambler's Ruin)”问题。设想一个拥有无限信用额度的赌徒从落后状态开始,进行可能无限次的试验以试图回到盈亏平衡点。我们可以计算他最终回到盈亏平衡点的概率——也就是攻击者最终追上诚实链的概率——如下⁸:
p = probability an honest node finds the next block
p = 诚实节点找到下一个区块的概率
q = probability the attacker finds the next block
q = 攻击者找到下一个区块的概率
q z = probability the attacker will ever catch up from z blocks behind
q^z = 攻击者从落后 z 个区块起最终追上的概率

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.
在我们假设 p > q 的前提下,随着攻击者需要追赶的区块数增加,这个概率会以指数方式下降(drops exponentially)。在胜算不利的情况下,如果他不能在早期凭运气实现一次“幸运突进(lucky lunge)”,那么随着落后加深,他的成功机会会变得极其渺小(vanishingly small)。
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.
接下来我们考虑:一笔新交易的收款方需要等待多长时间,才能足够确信付款方无法更改该交易。我们假设付款方是攻击者:他想让收款方在一段时间内相信“钱已经付出去了”,随后在时间过去后把交易切换(switch)为“把钱付回给自己”。这种情况发生时收款方会收到警报,但攻击者希望那时已经“为时已晚”。
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.
收款方在签名前不久生成一个新的密钥对(key pair),并把公钥(public key)给付款方。这阻止付款方提前准备一条领先链:例如,他事先持续挖矿,直到运气好到足够领先,然后在那一刻执行交易。交易一旦发送,不诚实的付款方就会秘密启动一条并行链(parallel chain),其中包含其交易的一个替代版本(alternate version)。
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:
收款方会等待:交易被加入一个区块,并且其后又链接了 z 个区块。收款方不知道攻击者具体取得了多少进展,但在假设诚实链区块生成时间等于“每区块的平均期望时间”的前提下,攻击者的潜在进展可视为服从参数为期望值的泊松分布(Poisson distribution),其期望值为:

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:
为了得到“攻击者此刻仍能追上”的概率,我们把攻击者可能取得的每一种进展幅度对应的泊松密度(Poisson density),乘以他从该进展状态出发仍能追上的概率,然后把这些乘积加总:

Rearranging to avoid summing the infinite tail of the distribution...
通过重新整理(rearranging),以避免对分布的无穷尾部(infinite tail)进行求和……

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'.
跑出一些结果后,我们可以看到:随着 z 增大,概率呈指数级下降(drop off exponentially)。
- 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.1%(0.001)的 z 值……
- 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