ADM-201 dump PMP dumps pdf SSCP exam materials CBAP exam sample questions

关于比特币和其他加密货币底层技术的最清晰解释 – 译学馆
未登录,请登录后再发表信息
最新评论 (0)
播放视频

关于比特币和其他加密货币底层技术的最清晰解释

Ever wonder how Bitcoin (and other cryptocurrencies) actually work?

“拥有”一枚比特币究竟意味着什么?
What does it mean to *have* a Bitcoin?
很多人都听说过比特币
Many people have heard
它是一种数字货币 并不需要特定政府发行
of Bitcoin that it’s a fully digital currency with no government to issue it;
也不依赖银行来管理账户及验证交易
and that no banks need to manage accounts and verify transactions;
甚至都没有人真正知晓其发明者
and also that no one really knows who invented it.
很多人都不知道片头提及的那个问题的答案
And yet, many people don’t know the answer to this question,
至少不全了解
at least not in full.
要想搞明白
To get there,
同时也为了让
and to make sure
比特币背后的技术细节显得直观
that the technical details underlying the answer actually feel motivated,
我们将从你会如何建立比特
what we’re going to do is walk through step by step
币的过程中一步一步地说明
how you might have invented your own version of Bitcoin.
首先我们从你用于记录你与好友
We’ll start with you keeping track of payments
们交易的公共账本开始
with your friends using a communal ledger.
然而你与好友及世界
And then, as you start to trust
上的其他人的互信开始逐渐降低
your friends and the world around you less and less,
但聪明的你引入了
and if you’re clever enough to bring
密码学中的某些
in a few ideas from cryptography
概念来解决信任危机
to help circumvent the need for trust,
你就创造了一种新事物 叫做“加密货币”
what you end up with is what’s called a”cryptocurrency”.
比特币只是第一个被广泛应用的加密货币的例子
You see, Bitcoin is just the first implemented example of a cryptocurrency.
而如今有了更多其他的加密货币并与传统货币发生交易
And now, there are thousands more on exchanges with traditional currencies.
从你发明你自己
Walking the path
的加密货币入手 能帮助我们理解
of inventing your own can help to set the foundations
如今几大主流加密货币的理论基础
for understanding some of the more recent players in the game
了解其背后在不同方面存在着不同的设计空间
and recognizing when and why there’s room for different design choices.
事实上我选
In fact, one
这个选题是因为在过去一年
of the reasons I chose this topic is that
中针对加密货币
in the last year,
有大量的关注、
there’s been a huge amount of attention and investment and,
资本投入甚至老实讲还有媒体过分渲染
well, honestly hype directed at these currencies.
我并不会对当前及未来的
And I’m not going to comment or speculate
汇率发表评论及预测
on the current or future exchange rates,
但我想任何想要
but I think we’d all agree that
购买加密货币的人都应 搞明白加密货币究竟是怎么一回事
anyone looking to buy a cryptocurrency should really know what it is.
我不会含糊地
And I don’t just mean in terms
将其与挖矿作类比
of analogies with vague connections to gold mining,
我会直接描述当我们发送
I mean an actual direct description
、接受、
of what the computers are doing
创造加密货币时计算机内部所发生的事情
when we send, receive and create cryptocurrencies.
我还要强调一点:
One thing worth stressing, by the way, is that
虽然我们将花
even though you and I are
一些时间稍深入
going to dig into the details here,
地了解背后的原理
and that takes meaningful time,
仅仅日常使用的话 我们并不需要
you don’t actually need to know those details
了解其详细技术原理
if you just want to use the cryptocurrency,
就像你不需要了解你刷信用卡
just like you don’t need to know the details
背后所发生的一切一样
of what happens under the hood when you swipe a credit card.
与电子支付一样 加密货币也有很多方便易用的应用
Like any digital payment, there’re lots of user-friendly applications that
用于发送和接受货币而
let you just send and receive the currencies
不需要知道是怎么实现的
without thinking about what’s going on.
区别在于加密货币的背后并不是
The difference is that the backbone underlying this
某家银行来验证交易
is not a bank that verifies transactions. Instead,
而是一套基于密码学中某些数学方法的
it’s a clever system of decentralized trust-less verification
去中心化的、互不信任的交易验证体系
based on some of the math born in cryptography.
在开始讲之前
But to start,
你暂时把
I want you to actually set aside the thought
加密货币放在一边
of cryptocurrencies and all that just for a few minutes.
我们先从更基本的概念入手:账本和电子签名
We’re going to begin the story with something more down-to-earth: ledgers and digital signatures.
如果你和你的朋友们有很频繁的金钱来往
If you and your friends exchange money pretty frequently,
比如AA支付晚餐的账单等等
you know, paying your share of the dinner bill and such,
用现金总是不方便的
it can be inconvenient to exchange cash all the time.
所以可能会用到一个公共账本
So you might keep a communal ledger
它记录了某些
that records all of the payments
未来将会发生的交易信息
that you intend to make some point in the future.
如Alice支付Bob
You know, Alice pays Bob $ 20,
20元Bob支付Charlie
Bob pays Charlie $ 40, things like that.
40元等等这个账本必须是公开的
This ledger is going to be
每个人都能查阅
something public and accessible to everyone,
就像一个网站一样 每个人都能查阅并添加新的记录
like a website, where anyone can go and just add newlines.
而到了每个月底大家
And let’s say that at the end of every month,
对交易记录都无异议就会一起合计
you all go together, look at the list of transactions and settle up.
如果你入不敷出
If you spent more than you received,
就要向公家交钱
you put that money in the pot;
如果仍有结余 就可以从中取钱
and if you received more than you spent, you take that money out.
所以这个简单体系的
So the protocol for being part
设计大概会是如下所述
of this very simple system might look like this:
每个人都能向账本添加
anyone can add lines to the ledger;
交易信息 到月底再统一结算
and at the end of every month you all get together and settle up. Now,
但公共账本存在一个问题
one problem with a public ledger
正因为每个人都能添加记录
like this is that anyone can add a line,
应该怎样避免Bob在没有Alice核准的情况下偷偷记下:Alice给Bob
so what’s to prevent Bob from going in writing”Alice pays Bob $100″ without Alice approving?
100元我们又凭什么相信账本中的记录
How are we supposed to trust that all of these transactions
都准确无误呢
are what the sender meant them to be? Well,
这里就需要密码学中的电子签名技术
this is where the first bit of cryptography comes in: digital signatures.
就像手写签名一样
Like handwritten signatures,
Alice
the idea here is
需能在交易信息边上留下记录
that Alice should be able to add something next to that transaction
以证明她了解并且允许这笔交易发生
that proves that she has seen it and that she’s approved of it.
而且这个签名不能被他人获取并伪造
And it should be infeasible for anyone else to forge that signature.
乍一思索电子签名
At first, it might seem
似乎不太可能实现
like a digital signature shouldn’t even be possible.
无论电子签名是如何存储的
I mean, whatever data makes up
计算机读取并复制即可
that signature can just be read and copied by a computer,
那究竟该如何防止伪造呢
so how do you prevent forgeries? Well,
要实现电子签名 每个人都需要生成一对公共密钥及私人密钥
the way this works is that everyone generates what’s called a”public key – private key pair”,
每一个密钥都是一串比特
each of which looks like some string of bits.
私人密钥有时也被叫做“秘密”钥匙
The”private key” is sometimes also called a”secret key”,
以便能够缩写成sk 公共密钥则缩写成pk
so that we can abbreviate it as”sk”, while abbreviating the public key is”pk”.
正如其名
Now as the name suggests,
私人密钥是由你自己保存的
this secret key is something you want to keep to yourself.
现实生活中
In the real world,
你所签署的所有文件中的签名都是一致的
your handwritten signature looks the same no matter what document you’re signing.
电子签名则更进一步
But a digital signature is actually much stronger,
它会随着签署的内容变化而变化
because it changes for different messages.
它看上去就是一串10代码
It looks like some string of ones and zeros,
通常长度是256位
commonly something like 256 bits;
而内容的轻微变动都会
and altering the message even slightly
让这串代码看上去几乎完全不同
completely changes what the signature on that message should look like.
正式一点地讲
Speaking a little more formally,
产生这样的签名需要一个函数
producing a signature involves a function that depends both
它同时要求所签署的内容以及你的私人密钥
on the message itself and on your private key.
私人密钥确保了只有你本人能产生这个电子签名
The private key ensures that only you can produce that signature,
这个签名还取决于签署的内容
and the fact that it depends on the message
就意味着其他人不能简单地
means that no one can just copy one
复制这个签名并在其他内容上伪造另一个签名
of your signatures and then forge it on another message.
与此同时还有一个验证函数用于验证
Hand-in-hand with this is a second function used to verify
签名是否真实
that a signature is valid.
而这个函数还需要公共密钥
And this is where the public key comes into play.
它的作用是告诉我们这个
All it does is output”true” or”false”
签名是否是由一个私钥加密
to indicate if this was a signature produced

by the private key
有一个与之配对的公钥用于验证
associated with the public key that you’re using for verification.
这里并不会具体讨论
I won’t go into the details
这些函数具体如何实现
of how exactly both these functions work,
它保证了如果
but the idea is
你不知道私钥 你几乎不可能找到
that it should be completely infeasible to find a valid signature
一个正确的签名
if you don’t know the secret key. Specifically,
准确地讲 并不会有比穷举
there’s no strategy better
并反复验证更好的办法了
than just guessing and checking random signatures,
然后用大家都知道的公钥进行验证
which you can check using the public key that everyone knows.
现在想想256位比特到底有
Now think about how many signatures there are
多少可能的签名
with a length of 256 bits,
总共有2的256次方个可能的签名
that’s 2^256.
这是一个天文数字
This is a stupidly large number.
称其为天文数字实际上又远远高估了天文学的范畴
To call it astronomically large would be giving way too much credit to astronomy.
我还做了另一个补充视频
In fact, I made a supplemental video
来演示这个数字究竟有多大
devoted just to illustrating what a huge number this is.
现在如果一旦
Right here, let’s just say that
你验证了一个
when you verified that a signature
签名是真的
against a given message is valid,
你就能相当有把握地认为
you can feel extremely confident
这个签名只能由他本人持有
that the only way someone could have produced it
的私钥加密产生
is if they knew the secret key associated
以及与这个私钥配对的公钥验证
with the public key you used for verification.
现在确保了每个人都会在交易
Now making sure that people sign transactions
信息后面签名
on the ledger is pretty good,
仍然会存在另一个问题
but there’s one slight loophole:
比如Alice签署了一条Alice支付Bob 100元的交易记录
if Alice signs a transaction, like”Alice pays Bob $100″,
即便Bob不能在Alice的新交易记录上伪造签名
even though Bob can’t forge Alice’s signature on a new message,
他还可以把这条记录随心所欲地复制好几遍
he could just copy that same line as many times as he wants.
这些记录以及它对应的签名都是正确的
I mean, that message-signature combination remains valid.
要解决这个问题
To get around this,
你在签署新的交易信息时
what we do is make it so that when you sign a transaction,
交易信息还必须包含一个
the message has to also include some sort
唯一的编号与之对应
of unique ID associated with that transaction.
那样如果Alice多次支付Bob 100元的话
That way, if Alice pays Bob $100 multiple times,
账本上的每条记录都会要求一个新的签名
each one of those lines on the ledger requires a completely new signature.
有了电子签名
All right, great!
就完美地解决了原本体系
Digital signatures remove a huge aspect
中的信任危机
of trust in this initial protocol,
但要真正实现 仍然需要依赖
but even still, if you were to really do this,
一个类似的信用机构
you would be relying on an honor system of sorts. Namely,
也就是说你信任每个人到了月底
you’re trusting that everyone will actually follow through
都会出现并用现金结算
and settle up in cash at the end of each month.
万一Charlie
What if, for example,
欠了很多钱但就是不出来
Charlie racks up thousands of dollars in debt
还钱该怎么办
and just refuses to show up.
而再次使用现金
The only real reason to revert
的唯一
back to cash to settle up
原因是其中有人欠了钱
is if some people (I’m looking at you, Charlie) owe a lot of money.
聪明的你想到了一个方法
So maybe, you have the clever idea
就不需要真正再用现金结算
that you never actually have to settle up in cash,
只要能够避免其中有些人的
as long as you have some way to prevent people
所得不足以支付其支出
from spending too much more than they take in.
所有人开始就往
Maybe what you do is start
账上支付100元
by having everyone pay $ 100 into the pot,
账本上最先记录几条:
and then have the first few lines of the ledger read
Alice获得100元 Bob获得100元 Charlie等等
“Alice gets $100″,”Bob gets $100″,”Charlie gets $100”, etc. Now,
现在只需要拒绝在账本上记录
just don’t accept any transactions
某些人入不敷出的交易
where someone is spending more than they already have on that ledger.
举个例子 如果前两条交易记录是
For example, if the first two transactions are
Charlie支付Alice 50元 Charlie支付Bob
“Charlie pays Alice $50″ and”Charlie pays Bob $50”,
50元 如果他想记录Charlie支付你20元 那将是不合法的
if he were to try to add”Charlie pays you $20″, that would be invalid,
和他没有签名一样不合法
as invalid as if he had never signed it. Notice,
因此这就意味着验证一条交易
this means that verifying a transaction
就需要了解截至当前所有的历史交易信息
requires knowing the full history of transactions up to that point.
这在加密货币
And this is more or less
中同样如此
also going to be true in cryptocurrencies,
并且仍有待优化
though there is a little room for optimization.
有趣的是
What’s interesting here is that
这个设计真正去掉了账本和真实货币的联系
this step removes the connection between the ledger and actual physical US Dollars.
理论上如果世界上所有人都是用这个账本
In theory, if everyone in the world was using this ledger,
你整个一生都可以在这个
you could live your whole life
账本上支付并获得钱财中度过
just sending and receiving money on this ledger
根本不需要真实的货币
without ever having to convert to real US Dollars.
为了强调这一点
In fact, to emphasize this point,
我们把账本上的货币单位称之为账元 并简称为LD
let’s start referring to the quantities on the ledger as”ledger dollars”, or”LD” for short.
你也可以将
You are, of course,
账元自由地兑换成真的美元
free to exchange ledger dollars for real US Dollars.
举个例子 Alice在现实
For example, maybe Alice gives
中给了Bob 100元
Bob a $ 10 bill in the real world
同时Bob在公共账本上记上Bob
in exchange for him adding and signing the transaction
支付Alice
“Bob pays Alice 10 LD” to this communal ledger.
100元但这样的兑换并
But exchanges like that,
不在这套系统的设计初衷之内
they’re not going to be guaranteed by the protocol.
这样的兑换与美元
It’s now more analogous to
和欧元或市场上其他
how you might exchange dollars for Euros,
的货币兑换类似
or any other currency on the open market,
那是另外一个事情了
it’s just its own independent thing.
这是理解比特币和其他加密货币
This is the first important thing to understand
的最重要的信息了
about Bitcoin or any other cryptocurrency:
它实际上就是一个账本 所有的历史交易总和就是当下(current)的货币(currency)
what it is is a ledger, the history of transactions is the currency.
当然就比特币而言
Of course, with Bitcoin,
人们只有用现金购买和使用比特币才会在账本上记录
money doesn’t enter the ledger with people buying in using cash.
但新的比特币如何产生我一会儿
I’ll get to how new money enters the ledger
再细说
in just a few minutes,
但此之前 我们的LD体系
but before that, there’s actually an even more significant difference
和当前加密货币还有一大不同
between our current system of ledger dollars and how cryptocurrencies work.
我刚提到这个公共
So far, I’ve said
账本存在于某个公共地点
that this ledger is in some public place,
比如一个网站 所有人都能登陆并添加记录
like a website, where anyone can add newlines.
那样的话我们就必须信任这一中心机构
But that would require trusting a central location,
那究竟谁来管理这个网站
namely”who hosts the website?”,
谁来控制添加记录的规则呢
“who controls the rules of adding new lines?”.
让所有人都能获取这份
To remove that bit of trust,
账本也就不需要信任中心机构了
we’ll have everybody keep their own copy of the ledger.
当你需要发生交易 如Alice支付Bob
Then when you want to make a transaction,
100元
like Alice pays Bob 100 LD,
你需要将这个信息广播给网络中所有
what you do is broadcast that out into the world
的其他人 他人收到了这个信息都在自己那份账本上记下这条交易
for people to hear and to record on their own private ledgers. But,
想法虽然简单 但这样的设计相当糟糕
unless you do something more, this system is absurdly bad.
如何确保所有人手里都是正确的那份账本呢
How could you get everyone to agree on what the right ledger is?
当Bob收到了如Alice支付Bob10账元的交易
When Bob receives a transaction, like Alice pays Bob 10 LD,
他如何确保并
how can he be sure
相信其他所有人也同样收到了这一信息
that everyone else received and believes that same transaction
能让他在今后可以用
that he’ll be able to later
这10账元支付给Charlie做交易?
on go to Charlie and use those same 10 LD to make a transaction? Really,
试着想想是你自己收听着来自外界的交易信息广播
imagine yourself just listening to transactions being broadcast,
该如何确保其他人
how can you be sure
和你一样以相同的顺序接受交易信息
that everyone else is recording the same transactions and in the same order?
这才是关键所在
This is really the heart of the issue.
也是一个有趣的难题
This is an interesting puzzle.
你能想出一个方法来决定
Can you come up with a protocol
接受或拒绝收到的交易信息
for how to accept or reject transactions
而且你确信其他所有人在这个方法下
and in what order so that you can feel confident that
能以同样的顺序接受交易信息
anyone else in the world who’s following that same protocol
最终形成同样的一份账单
has a personal ledger that looks the same as yours?
这也是比特币原始论文中详述的部分
This is the problem addressed in the original Bitcoin paper.
简单地讲 比特币的解决办法是
At a high level, the solution that Bitcoin offers is
选择信任消耗最多计算资源的那份账本
to trust whichever ledger has the most computational work put into it.
我会花一些时间详细讲是什么意思
I’ll take a moment to explain exactly what that means,
它涉及到“加密散列函数”这个概念
it involves this thing called a”cryptographic hash function”.
基本的思路如下:
The general idea that we’ll build to
如果你将计算资源的消耗作为
is that if you use computational work
你的信任之基
as a basis for what to trust,
那么伪造交易记录
you can make it so that fraudulent transactions and conflicting ledgers
将会需要不可能达到的计算能力才有可能
would require an infeasible amount of computation to bring about. Again,
在提醒大家一次
I’ll remind you
这里我们将会继续深入讨论
that this is getting well into the weeds
对大多数仅仅只是使用
beyond what anyone would need to
比特币的用户并不需了解
know just to use a currency like this,
但这个想法实在是太酷了!
but it’s a really cool idea!
如果你懂了
And if you understand it,
你就会理解比特币和其他加密货币的核心
you understand the heart of Bitcoin and all other cryptocurrencies.
那么首先 什么是散列函数?
So first things first, what’s a hash function?
这些函数的输入可以是
The inputs for one of these functions can be any kind
任何信息
of message or file,
或文件
it really doesn’t matter.
它们会输出一个固定长度
And the output is a string of bits
的比特字符串
with some kind of fixed length, like 256 bits.
如256位这个输出值叫做这个信息的散列值 或者称其为“指纹”
This output is called the”hash” or the”digest” of the message.
它故意设计成会输出看似相当随机的内容
And the intent is that it looks random.
但并不是随机的
It’s not random –
对给定的信息总是输出相同的内容
it always gives the same output for a given input.
但如果你
But the idea is that
将输入稍作修改
if you slightly change the input,
也许仅仅只是修改了其中一个字母
maybe editing just one of the characters,
最终的散列值会变得面目全非事实上
the resulting hash changes completely.
我这里做演示的散列函数叫做“SHA256”
In fact, for the hash function that I’m showing here,
输入
called SHA256,
的轻微修改 输出就会完全不同 毫无规律可言
the way the output changes as you slightly change that input is entirely unpredictable.
明白了吧 这不是普通的散列函数
You see, this is not just any hash function,
这是加密散列函数
it’s a cryptographic hash function.
这就意味着逆向计算是不可能的
That means it’s infeasible to compute in the reverse direction.
如果告诉你一串1
If I show you some string of ones and zeros,
0的字符串然后问你 哪一个输入经过
and ask you to find an input
SHA256
so that the SHA256 hash
函数计算后会得到同样的结果
of that input gives this exact string of bits,
没有比一个一个尝试更好的办法了
you will have no better method than to just guess and check.
如果你想感受一下2
And again, if you want to feel
的256次方个尝试究竟需要计算多久
for how much computation would be needed to go through 2^256 guesses,
可以看看这个补充
just take a look at the supplement video.
视频
I actually had way too much fun writing that thing.
你会想如果知道了这个
You might think that if you just really dig
函数的运作细节
into the details of how exactly this function works,
是不是就可以不用瞎猜而是可以倒过来推断这个输入呢
you could reverse engineer the appropriate input without having to guess and check.
但目前没有人可以做到
But no one has ever figured out a way to do that. Interestingly,
有趣的是 目前还没有严格的
there’s no cold hard rigorous proof
证明逆向计算是困难的
that it’s hard to compute in the reverse direction.
目前大量的安全行业和加密需求都取决于
And yet, a huge amount of modern security
加密散列函数以及它的这个性质
depends on cryptographic hash functions and the idea that they have this property.
如果你细看浏览器和
If you were to look
youtube建立的加密连接
at what algorithms underlie the secure connection
背后的加密算法
that your browser is making with YouTube right now,
或浏览器连接银行网站时
or that it makes with your bank,
你很可能会看到SHA256算法但现在
you will likely see the name SHA256 show up in there.
我们的关注点会是
For right now, our focus will just be on
这样的函数如何
how such a function can prove
证明一个账单
that a particular list of transactions
它所需要的计算力
is associated with a large amount of computational effort.
想想如果有人给你一份交易记录并说
Imagine someone shows you a list of transactions, and they say “Hey!
“嘿!我发现了一个特殊的数字
I found a special number
你把这个数字放在
so that when you put that number
这份交易记录后面
at the end of this list of transactions
整体信息进行SHA256函数计算后
and apply SHA256 to the entire thing,
前面30个数字都会是0!”
the first 30 bits of that output are all zeros!”
你想想找到这样的一个数字有多难?
How hard do you think it was for them to find that number? Well,
对于一个随机的信息
for a random message,
其散列值前30位都是0的概率
the probability that a hash happens to start
是2的30次方分之一
with 30 successive zeros is 1 in 2^30,
差不多是十亿分之一
which is about one in a billion.
而且因为SHA256是一个加密散列函数
And because SHA256 is a cryptographic hash function,
找到这个特殊数字的唯一
the only way to find a special number
方法只能是穷举验证
like that is just guessing and checking.
所以刚才那个人基本上
So this person almost certainly had to go
已经尝试了十亿次
through about a billion different numbers
才找到了这个特别数字
before finding this special one.
而你知道了这个数字
And once you know that number,
很快计算一下散列值
it’s really quick to verify –
发现开头确实是30个0换言之
you just run the hash and see that there are 30 zeros.
你能很快
So in other words,
地验证他们确实经过了大量的计算
you can verify that they went through a large amount of work,
而你不需要亲自付出这么多重复劳动
but without having to go through that same effort yourself.
这叫做“工作量证明”
This is called a”proof of work”.
重要的是
And importantly, all
这个工作量证明和这份交易记录紧密相关
of this work is intrinsically tied to the list of transactions.
如果你更改了其中一条交易信息 即便是轻微的改动
If you change one of those transactions, even slightly,
也会完全改变最终的散列值
it would completely change the hash,
所以就又需要经过
so you’d have to go
十亿次尝试才能找到新的工作量证明
through another billion guesses to find a new proof of work,
即找到那个特别数字
a new number that makes it
和它对应的交易记录的散列值
so that the hash of the altered list together
会以30个0开头
with this new number starts with 30 zeros.
现在回过头来考虑我们的分布式账本的情形:
So now think back to our distributed ledger situation:
每个人都在广播交易信息
everyone is there broadcasting transactions,
我们想找到一个方法能让所有人
and we want a way for them to agree
都确认一份正确的账单
on what the correct ledger is.
我前面说过比特币原始论文的核心点就是
As I said, the core idea behind the original Bitcoin paper
每个人都信任需要最多计算能力的那份账单
is to have everyone trust whichever ledger has the most work put into it.
要实现这个想法首先
The way this works is to
需要将账单整理成区块
first organize a given ledger into blocks,
这些区块包含了一系列交易信息以及其工作量
where each block consists of a list of transactions together
证明
with a proof of work,
也即有一个特别数字满足
that is a special number so that the hash
其散列值以一系列0开头
of the whole block starts with a bunch of zeros.
我们暂时先定60个0开头吧
For the moment, let’s say that it has to start with…
一会儿
60 zeros,
我们会回头来看
but later we’ll return back to a
如何系统地确定这些0的个数
more systematic way you might want to choose that number.
类比于交易
In the same way
信息要经过发送方签名才被认定为有效
that a transaction is only considered valid when it’s signed by the sender,
一个区块只有当它有工作量证明时才被认定为有效
a block is only considered valid if it has a proof of work.
而且为了确保这些
And also, to make sure
区块有一定的顺序
that there’s a standard order to these blocks,
我们规定前一区块的散列值必须加入到当前
we’ll make it so that a block has to contain the hash
区块的头部信息中
of the previous block at its header.
这样的话 如果你回头想
That way, if you were to go
改变其中某个区块的内容
back and change any one of the blocks
或交换两个区块的顺序
or to swap the order of two blocks,
你就会改变它后一个区块的内容
it would change the block that comes after it,
也就改变了那个区块的散列值
which changes that block’s hash,
然后又影响到再下一个区块
which changes the one that comes after it, and so on.
那将会需要重新计算所有这些区块的散列值
That would require redoing all of the work,
重新寻找每个特别
finding a new special number
数字使得区块的散列值以60个0开头
for each of these blocks that makes their hashes start with 60 zeros.
因为区块以这种方式相互链接
Because blocks are chained together like this,
与其称其为账本 不如称其为“区块链”
instead of calling it a ledger, it’s common to call it a”blockchain”
在这个新的体系之下
As part of our updated protocol,
我们现在允许世界上的每个人都能成为区块的建立者
we’ll now allow anyone in the world to be a block creator.
意思是说他们
What that means is
都将收听网络中的交易信息
that they’re going to listen for transactions being broadcast,
整理这些信息生成区块 然后花大量的计算能力
collect them into some block, and then do a whole bunch of work
寻找特别数字使得区块
to find a special number that makes the hash
的散列值以60个0开头
of that block start with 60 zeros.
一旦找到了这个数字 他们就将这个区块广播出去
And once they find it, they broadcast out the block they found.
为了奖励这个区块建立者的工作付出
To reward a block creator for all this work,
当她建立了一个区块
when she puts together a block,
我们规定她可以把一笔特别的交易信息放在
we’ll allow her to include a very special transaction
账单开头即:
at the top of it,
她获得10账元
in which she gets, say 10 LD, out of thin air.
这叫做“区块奖励”
This is called the”block reward”,
这是我们接受或拒绝交易信息
and it’s an exception to our usual rules
规则的一个例外情况
about whether or not to accept transactions.
它并不来自于其他人
It doesn’t come from anyone,
所以也并不需要签名
so it doesn’t have to be signed.
也意味着整个网络中
And it also means that the total number
的账元会随着新区块的产生而增加
of ledger dollars in our economy increases with each new block.
建立区块通常叫做“挖矿”
Creating blocks is often called”mining”,
因为它会需要大量的计算力
since it requires doing a lot of work
挖矿会为整个经济中引入新的货币量
and it introduces new bits of currency into the economy.
所以当你听到或看到矿工时
But when you hear or read about miners,
你现在明白他们所做的其实就是
keep in mind that what they’re really doing is
收听交易信息
listening for transactions, creating blocks,
建立区块 广播区块并获得新货币的奖励
broadcasting those blocks, and getting rewarded with new money for doing so.
而在矿工眼中
From the miner’s perspective,
每个区块就像是一个小型的彩票
each block is kind of like a miniature lottery,
每个人都想尽可能快得猜数字
where everyone is guessing numbers as fast as they can
直到其中有一个幸运儿找到了那个特别数字
until one lucky individual finds a special number
能让区块的散列值以很多0开头
that makes the hash of the block start with many zeros,
然后他们就得到奖励
and they get the reward.
而对于其他只是想利用这个
For anyone else who just wants
系统做交易的人而言
to use the system to make payments,
并不需要收听交易记录
instead of listening for transactions,
他们只需要收听被矿工广播的区块即可
they all start listening just for blocks being broadcast by miners,
然后更新自己的那一份区块链
and updating their own personal copies of the blockchain.
现在我们新体系的关键点来了
Now the key addition to our protocol is that
如果我们收到了两份完全不同的区块链
if you hear two distinct blockchains with conflicting transaction histories,
我们倾向于选择最长的那一个
you defer to the longest one,
也就是需要最多的工作量的那一份
the one with the most work put into it.
如果暂时难分上下
If there’s a tie,
等待下一个区块的广播 总有一个会形成更长的区块链
just wait until you hear an additional block that makes one of them longer.
所以即便没有中心机构
So even though there’s no central authority
所有人也都自己维护自己的那份区块链
and everyone is maintaining their own copy of the blockchain,
但如果每个人都信任最多工作量
if everyone agrees to give preference to whichever
的那个区块链
blockchain has the most work put into it,
我们就达到了一个去中心化的共识
we have a way to arrive at decentralized consensus.
为什么这样能够建立一个可信的系统
To see why this makes for a trustworthy system,
并理解这个
and to understand
系统里的交易到底有多可信
at what point you should trust that a payment is legit,
我们尝试在这个系统
it’s actually really helpful to walk
中伪造信息欺骗他人到底有多难
through exactly what it would take to fool someone using this system.
也许Alice想要用一个伪造的区块欺骗Bob
Maybe Alice is trying to fool Bob with a fraudulent block,
也即她给Bob一个区块里包含
namely she tries to send him
里她支付Bob 100账元的信息
one that includes her paying him 100 LD
但她没有把这个区块广播给网络中的其他人
but without broadcasting that block to the rest of the network.
那样的话 其他人还会人会她仍然持有那100账元
That way, everyone else still thinks that she has those 100 LD.
她要比其他所有矿工先找到工作量
To do this, she would have to find a valid proof
证明才能欺骗所有人
of work before all of the other miners,
他们都在独立计算区块
each working on their own block.
而这确实是有可能发生的!
And that could definitely happen!
有可能Alice刚好比其他所有人都先找到了这个证明
Maybe Alice just happens to win this miniature lottery before everyone else.
但Bob也还会收到
But Bob is still going to
来自其他矿工的区块广播
be hearing the broadcasts made by other miners,
所以为了让他相信她那份伪造的区块
so to keep him believing this fraudulent block,
Alice后面都要重新计算
Alice would have to do all of the work herself
她那份伪造给Bob的区块后面的所有区块
to keep adding blocks on this special fork in Bob’s blockchain.
这些区块和Bob收到了来自其他矿工的区块都不同
It’s different from what he’s hearing from the rest of the miners. Remember,
但系统规定Bob总是
as per the protocol,
信任他所指的最长的那一个区块链
Bob always trusts the longest chain that he knows about.
Alice在前几个区块还有可能
Alice might be able to keep this up
保持领先
for a few blocks if,
如果刚好碰巧她比其他所有
just by chance, she happens to find blocks more quickly
矿工都先找到那个区块
than the rest of the miners on the network all combined.
但除非她拥有接近所有
But unless she has close to 50 %
矿工的计算资源的50%
of the computing resources among all of the miners,
所以更可能发生的是
the probability becomes overwhelming
所以其他矿工
that the blockchain
计算的区块
that all of the other miners are working on
会比Alice伪造给Bob的区块形成的区块链更长更快
grows faster than the single fraudulent blockchain that Alice is feeding to Bob. So,
所以经过足够长的时间
after enough time,
Bob会放弃他收到的来自Alice的区块链
Bob’s just going to reject what he’s hearing from Alice
而选择其他所有人都在计算的那一份区块链
in favor of the longer chain that everyone else is working on. Notice,
所以你一开始
that means
并不会立即信任收听到的新的区块
that you shouldn’t necessarily trust a new block that you hear immediately; instead,
而要等到后面
you should wait
有新的区块添加后
for several new blocks to be added on top of it.
如果你还没收听到更长的区块链
If you still haven’t heard of any longer block chains,
你就能信任这个区块和
you can trust that this block is part
其他人的区块链中是一致的
of the same chain that everyone else is using.
到此 我们讲解了所有主要内容
And with that, we’ve hit all the main ideas.
这个基于工作量证明的分布式账本系统
This distributed ledger system based on a proof of work
多多少少和比特币还有
is more or less how the Bitcoin protocol
其他加密货币一样
works and how many other cryptocurrencies work.
再讲讲更多的细节
There’s just a few details to clear up. Earlier,
刚我讲到工作量
I said
证明是寻找那一个特别数字
that the proof of work might be to find a special number
满足其区块的散列值以60个0开头
so that the hash of the block starts with 60 zeros. Well,
而现实的比特币体系中
the way the actual Bitcoin protocol
这些0的数字规律的变化
works is to periodically change that number of zeros
以保证平均每10分钟产生一个新的区块
so that it should take on average 10 minutes to find a new block.
当有越来越多的
So as there are more and
矿工加入其中
more miners added to the network,
为了赢得每10分钟
the challenge actually gets harder and harder,
开奖的彩票
in such a way that this miniature lottery only has
计算也变得越来越难
about one winner every 10 minutes.
很多新的加密货币有更短的区块时间
Many newer cryptocurrencies actually have much shorter block times than that.
比特币体系中所有的比特币都来自于生成新区块的奖励
And all of the money in Bitcoin ultimately comes from some block reward.
在一开始 是每区块50个比特币
In the beginning, these rewards were 50 Bitcoin per block.
还有一个叫做“Block Explorer”的网站你可以去看看
There’s actually a great website you can go to called”Block Explorer”
上面能轻松地看到比特币区块链中的信息
that makes it easy to look through the Bitcoin blockchain.
如果你看区块
And if you look
链最初识的那几个区块
at the very first few blocks on the chain,
它们除了奖励给矿工的50个比特币之外并没有其他交易
they contain no transactions other than that 50 Bitcoin reward to the miner.
但每过210000个区块 差不多每4年
But every 210000 blocks, which is about every 4 years,
区块奖励就会减半
that reward gets cut in half.
现在 每个区块的奖励是12.5个比特币
So right now, the reward is 12.5 Bitcoin per block.
也因为这个奖励随着时间等比减少
And because this reward decreases geometrically over time,
也就意味着最终可获取的比特币不会超过21000000
it means there will never be more than 21000000 Bitcoin in existence. However,
但这并不是说矿工最终赚不到钱
this doesn’t mean that miners will stop earning money.
除了区块奖励外 矿工还可以获得交易费
In addition to the block reward, miners can also pick up transaction fees.
每当你支付时
The way this works is that whenever you make a payment,
你可选择一小笔交易费一起支付
you can purely optionally include a little transaction fee with it
这笔交易费最终会给包含这笔记录的区块建立者
that’s going to go to the miner of whichever block includes that payment.
你这么做能够激励矿工们
The reason you might do that is to incentivize miners
将包含你这笔交易信息的区块广播给网络中的其他人
to actually include the transaction that you broadcast into the next block.
在比特币中
You see, in Bitcoin,
每个区块包含约2400笔交易记录
each block is limited to about 2400 transactions,
很多批判家认为这个限制过于严格
which many critics argue is unnecessarily restrictive.
与VISA比较 VISA每秒平均
For comparison, VISA processes an average
处理约1700笔交易
of about 1700 transactions per second,
而它每秒能够处理多达24000笔交易
and they’re capable of handling more than 24000 per second.
相比而言比特币较慢的交易速度使得它的交易费用更高
This comparatively slow processing on Bitcoin makes for higher transaction fees,
正是交易费用让矿工更倾向将其交易收入到新
since that’s what determines which transactions miners choose to include
的区块中
in a new block.
除了以上这些加密货币的基础知识
All of this is far from a comprehensive coverage of cryptocurrencies;
还有其他许多不同的加密货币的系统
there are still many nuances and alternate design choices
设计尚未涉及
that I haven’t even touched.
我希望这个视频能够让大家在今后遇到新概念时
But my hope is that this can provide a stable”wait but why” style tree-trunk of understanding
能有一个理性的思考
for anyone looking to add a few more branches with further reading.
正如我开头所说
Like I said at the start,
我做此视频的初衷是目前有
one of the motives behind this is that a lot
大量的资金涌入加密货币中
of money has started flowing towards cryptocurrencies.
是好是坏我并
And even though I don’t want to make any claims
不过多评价
about whether that’s a good or bad investment,
但我认为想要进入
I really do think that it’s healthy
这一领域的人
for people getting into the game
如果懂一些基本内容是有所裨益的最后
to at least know the fundamentals of the technology.
我衷心感谢在Patreon
As always, my sincerest thanks to those
支持这个频道的你们
of you making this channel possible on Patreon.
我理解并不是每个人都能支持到这个地步
I understand that not everyone is in a position to contribute,
但你如果仍想支持我
but if you’re still interested in helping out,
最好的方式之一就是
one of the best ways to do that
将这个
is simply to share videos
视频分享给你认为对其有益的人们
that you think might be interesting or helpful to others.
这对我是莫大的支持
I know you know that, but it really does help.
我还想感谢Protocol Labs对此视频的支持
I also want to thank Protocol Labs for their support of this video.
这是一家运营着众多不同研究和开发项目的机构
This is an organization that runs a number of different research and development projects.
如果你点击我留在
And if you follow some
视频描述中的链接
of the links I’ve left in the description
进一步了解这些项目的细节
to read into the details of those projects,
你会发现有些项目有与这个视频中相似的理念
you’ll notice some strong parallels with the concepts covered in this video.
去中心化的挑战和好处
The challenges and benefits of decentralization
并不仅限于货币和交易历史
are by no means limited to currency and to transaction histories.
密码学中的工具如散列
And the usefulness of tools from cryptography,
函数和数字签名
like hash functions and digital signatures,
有更广泛的应用
are likewise much more general.
比如Protocol Labs上的有些项目
For example, a couple of Protocol Labs projects,
如IPFS和Filecoin
such as IPFS and Filecoin,
将文件的分布式存储作为其研究中心
center on the idea of distributed file storage,
由此将会展开一个全新的充满机遇和挑战的领域
which opens up a whole field of interesting challenges and possibilities.
对开发者而言 Protocol
For any developers among you,
Labs非常注重开源
Protocol Labs places a very high value on open source.
所以如果你感兴趣
So if you’re interested,
就可以加入其中
you can join what’s already a very strong community of contributors.
而他们也招募全职的开发者
But they’re also looking to hire full-time developers.
如果你有信心胜任 大胆申请吧
So if you think you might be a good fit there, definitely apply.

发表评论

译制信息
视频概述
听录译者

收集自网络

翻译译者

收集自网络

审核员

自动通过审核

视频来源

https://www.youtube.com/watch?v=bBC-nXj3Ng4

相关推荐