区块链数学建模_试图通过高中数学课程来解释区块链

区块链数学建模

by Kevin Kononenko

凯文·科诺年科(Kevin Kononenko)

试图通过高中数学课程来解释区块链 (Blockchain explained by trying to pass a high school math class)

If you have ever struggled through a high school math class, then you will be able to understand the principles of blockchain technology, which makes Bitcoin possible.

如果您曾经在高中数学课上苦苦挣扎,那么您将能够理解区块链技术的原理,这使比特币成为可能。

Have you ever tried to learn the basics of Blockchain by reading random blog posts and wikis, or watching YouTube videos?

您是否曾经尝试通过阅读随机博客文章和Wiki或观看YouTube视频来学习区块链的基础知识?

It gets technical very quickly. You are quickly presented with concepts like:

它得到的技术非常Swift。 您很快就会看到以下概念:

Distributed ledger

分布式分类帐

Cryptographic hash

加密哈希

Digital signatures

数字签名

Although you can certainly persevere through the initial confusion, you need to understand a series of new technical concepts before you understand the whole system.

尽管您当然可以忍受最初的困惑,但是在了解整个系统之前,您需要了解一系列新的技术概念。

这就是为什么这么难的原因 (Here’s why this is so hard)

Bitcoin (and blockchain) are based on a distributed and decentralized paradigm. We are used to centralized, trustworthy authorities, like banks, healthcare providers, and corporations (yes, we even trust most of them).

比特币(和区块链)基于分布式和去中心化的范例。 我们习惯于集中的,值得信赖的机构,例如银行,医疗保健提供者和公司(是的,我们甚至信任其中大多数人)。

Each one of those institutions has complicated systems in place to maintain high quality. In order to maintain these same standards for vital products without the centralized authority…we need new, complicated rules to keep decentralized systems running, too.

这些机构中的每一个都拥有复杂的系统来维持高质量。 为了在没有中央授权的情况下为重要产品维持相同的标准……我们还需要新的复杂规则来保持分散系统的运行。

So, in this article, I am going to create a new high school called “Distributed High School” that operates using the principles of blockchain. We are going to create a new way to grade assignments from math class using a distributed system. Students will be able to maintain the grading system on their own, without teach involvement.

因此,在本文中,我将创建一所名为“分布式高中”的新高中,该高中采用区块链原理进行运营。 我们将创建一种使用分布式系统对数学课的作业进行评分的新方法。 学生将能够自行维护评分系统,而无需老师参与。

One last note: Although Bitcoin is probably the most popular application for blockchain technology in 2018, many other industries will likely begin to adopt blockchain over the next five years.

最后一点:尽管比特币可能是2018年最流行的区块链技术应用程序,但其他许多行业可能会在未来五年内开始采用区块链。

This explanation will translate most directly to Bitcoin, but it will also apply to other types of blockchains. For example, healthcare providers could use a blockchain to securely store individual medical histories.

这种解释将最直接地转换为比特币,但也将适用于其他类型的区块链。 例如,医疗保健提供者可以使用区块链安全地存储个人病史。

If you are looking for a more technical explanation, this 20 minute animated YouTube video on Bitcoin is probably my favorite.

如果您正在寻找更多技术性的解释,那么这段关于比特币的20分钟动画YouTube视频可能是我的最爱。

集中管理高中的方式 (The centralized way to manage a high school)

Imagine that you are a freshman in high school, and you are taking the algebra class for all 9th graders. In order to pass the class, you need to get a sufficient score on homework assignments, quizzes, and tests. There are 30 total students in your class.

想象一下,您是一名高中新生,并且正在为所有9年级学生参加代数课程。 为了通过课程,您需要在家庭作业,测验和测试方面获得足够的分数。 您的课程共有30名学生。

All of this is managed by one centralized authority: the teacher. This one person will grade all your assignments, deliver your report cards each quarter, and make sure that nobody is cheating on tests (which would ruin the integrity of the class).

所有这一切都由一个集中的机构(教师)管理。 此人将为您的所有作业评分,每季度交付您的成绩单,并确保没有人在考试中作弊(这会破坏班级的完整性)。

Although this is the system that we are all accustomed to, it actually has some inherent flaws.

尽管这是我们大家都习惯的系统,但实际上它存在一些固有的缺陷。

  1. It can be inefficient: when you give 30 tests to a teacher all at once, they can sometimes take a week to get them back to you — because it takes forever to grade 30 tests!

    它可能是低效的:当您一次给一位老师进行30项测试时,有时他们可能需要一周的时间才能将它们退还给您-因为30项测试永远需要等级!

  2. Sometimes it’s risky: sometimes a teacher might loses a student’s test. Or paper tests can get ruined by floods or other natural disasters. These things happen. And teachers handle so many assignments that there will probably be some errors along the way.

    有时很冒险:有时候老师可能会输掉学生的考试。 否则,纸质测试可能会因洪水或其他自然灾害而毁于一旦。 这些事情发生了。 而且老师处理的作业太多,一路上可能会出现一些错误。

  3. Corruptible: Have you ever been the troublemaker in the class? When the teacher sits down to grade your test, they may take one look at the name on the top of the test, and become instantly biased while grading the test. Sometimes this is hard to avoid (human nature and all that jazz).

    腐败:你曾经在课堂上成为麻烦制造者吗? 当老师坐下来为您的测验评分时,他们可能会看一眼测验顶部的名字,并在测验评分时立即变得有偏见。 有时这很难避免(人性和所有爵士乐)。

  4. Costly: All that time spent grading tests is time that could be spent doing other, more productive things. This is also probably the teacher’s least favorite part of the job. They probably became a teacher so they could help students learn, not spend all their “free” time grading tests. Instead, your parents’ taxpayer dollars are going towards an activity that could be much improved.

    成本高:用于评分测试的所有时间都是可以花费在其他更有成效的事情上的时间。 这也可能是老师最不喜欢的工作。 他们可能成为了老师,因此可以帮助学生学习,而不用花费所有的“免费”时间评分测试。 相反,您父母的纳税人钱将用于一项可以大大改善的活动。

You can see similar issues with other centralized systems. For example, although we trust banks with our hard-earned money, the banking industry helped cause the 2008 financial crisis through risky practices that required a massive taxpayer-funded bailout.

您可以在其他集中式系统中看到类似的问题。 例如,尽管我们用来之不易的钱来信任银行,但银行业却通过需要大量纳税人资助的高风险行为,帮助引发了2008年金融危机

Although we trust doctors, medical error is the third-leading cause of death in the United States, behind heart disease and cancer. Many of those errors might be caused by important medical data being inaccessible to doctors.

尽管我们相信医生,但医疗错误是美国第三大死亡原因 ,仅次于心脏病和癌症。 其中许多错误可能是由医生无法访问的重要医学数据引起的。

So, back to high school math class. You might be wondering… how the heck are we going to solve all these problems by removing the influence of the teacher, the one person with the most expertise in this system? How would we prevent it from becoming anarchy?

于是,回到高中数学课。 您可能想知道……我们如何通过消除老师的影响来解决所有这些问题,老师是该系统中最专业的人? 我们如何防止它变成无政府状态?

That is where the blockchain concept comes in. Before I get into the specific way we will use blockchain to create a new way to run Distributed High School, you should know that each blockchain has specific rules that are instituted by its creator.

那就是区块链概念出现的地方。在我进入特定方式之前,我们将使用区块链创建一种新的方式来运行分布式高中,您应该知道每个区块链都有其创建者制定的特定规则。

In Bitcoin’s example, that would be “Satoshi Nakamoto” who wrote the original white paper and created the rules (algorithms) that allow it to operate without human intervention.

在比特币的例子中,将是“中本聪 ”( Satoshi Nakamoto ),他撰写了原始白皮书并创建了规则(算法),使该规则无需人工干预即可运行。

In our school example, we are going to have an exceptionally forward-thinking principal that has changed the rules.

在我们学校的例子中,我们将拥有一位具有超前思维的校长,它改变了规则。

为分布式高中创建区块链 (Creating a blockchain for distributed high school)

While a teacher grades tests and manages grades in private, a blockchain makes all transactions public. So, blockchain doesn’t rely on any central authority aside from the person who created it.

在教师对测试成绩进行私下评分和管理成绩的同时,区块链将所有交易公开。 因此,除了创建者之外,区块链不依赖任何中央权威。

If you haven’t already guessed it, that means that in Distributed High School, we are going to start by having the 9th-grade students grade each other’s tests!

如果您还没有猜到,那就意味着在分布式高中,我们将首先让9年级的学生对彼此的测试进行评分!

Let’s say it is test day, and the class period is an hour long. Students neatly stack their tests on top of the teacher’s desk when they finish.

假设这是考试日,上课时间为一个小时。 完成后,学生将他们的测验整齐地堆放在老师的桌子上。

But, instead of taking all of the tests home for grading, the teacher jumbles all of them into a big pile, and asks each student to take a random test and grade it with an answer key.

但是,老师没有把所有的测试带回家进行评分,而是将所有的测试弄成一堆,并要求每个学生进行随机测试,并用答案进行评分。

This is known as a transaction. This is the fundamental unit that makes up a blockchain. Let’s say that one student, Andy, gave another student, Alice, a grade of 84. In this case, Andy is the sender and Alice is the recipient.

这称为交易 。 这是组成区块链的基本单位。 假设一个学生安迪给另一个学生爱丽丝84分。在这种情况下,安迪是发送者 ,爱丽丝是接收者

In Bitcoin terms, this would not be random: you know where you are sending money!

用比特币的术语来说,这不是随机的:您知道您要汇款的地方!

So far, we have solved the speed and cost problems. Teachers no longer need to spend time on grading, and each student can grade one other test pretty quickly. But, there is a huge potential for fraud. This is pretty close to anarchy. There needs to be a network of responsible people that will keep all participants honest.

到目前为止,我们已经解决了速度和成本问题。 老师不再需要花时间在评分上,并且每个学生都可以很快地对另一个考试评分。 但是,存在巨大的欺诈潜力。 这非常接近无政府状态。 需要有一个负责任的人际网络,以使所有参与者保持诚实。

Here’s where the principal’s policies come in. The principal controls the one thing that everyone cares about: the grading system. At Distributed High School, the principal decides to allow seniors (12th graders) to run this blockchain system in exchange for a reward.

这是校长政策的体现。校长控制着每个人都关心的一件事:分级系统。 在分布式高中,校长决定允许高年级(12年级)运行此区块链系统,以换取奖励。

If a senior reviews 20 of these graded tests in 1 day, they can enter into a competition to get 10 points added to one of their own tests.

如果某位大四学生在1天内复习了其中20项评分测验,他们便可以参加比赛,将10分加到自己的一项测验中

That set of 20 transactions is known as a block, and we will eventually show how all blocks work together to form a blockchain.

那组20笔交易被称为一个区块 ,我们最终将展示所有区块如何一起形成一个区块

So why can only seniors do this? And why must it be a competition?

那么为什么只有老年人才能做到这一点? 为什么要参加比赛?

It must be seniors, because the principal needs participants who are going to be able to handle the workload of grading tests every day (if they want to). If the system slows down, then nobody would have their tests validated and logged, which would be a complete failure.

它必须是高年级学生,因为校长需要参与者,他们将能够每天(如果愿意)处理评分测试的工作量。 如果系统速度变慢,那么将没有人验证和记录他们的测试,这将是完全失败。

And it must be a competition so that the point system is not completely devalued. Imagine if every senior reviewed their 20 tests and received 10 points on their own test? Grade inflation would be rampant, similar to the way that currency inflation increases when the government prints more money. There must be a competition for a scarce number of points. I’ll share the terms of the competition later.

而且这必须是一场竞争,以使积分系统不会完全贬值。 试想一下,如果每位大四学生都复习了20项考试并通过自己的考试获得了10分? 等级通货膨胀将十分猖,,类似于政府印制更多货币时货币通货膨胀增加的方式。 必须要争夺很少的积分。 稍后我将分享比赛条件。

The principal is not forcing any senior to participate, but there is a strong incentive for them to do so.

校长并没有强迫任何高层参加,但是强烈鼓励他们参加。

In Bitcoin, each block has a limit of 1 megabyte (MB) of data. As of late 2017, the average transaction included about 500 bytes of data, so a block typically contained about 2000 transactions (source).

在比特币中,每个块的数据限制为1兆字节(MB)。 截至2017年底,平均交易量包含约500字节的数据,因此一个区块通常包含约2000笔交易( )。

分布式分类帐简介 (An introduction to the distributed ledger)

Now we know how one test gets graded (a transaction) and the incentives in place for the seniors to maintain the system with integrity: they get more points by reviewing and validating more tests. But we are still missing the entire distributed infrastructure for how this work actually gets done.

现在,我们知道如何对一项考试进行评分(一项交易),以及为老年人提供保持完整系统的激励措施:他们通过审查和验证更多考试来获得更多分数。 但是,我们仍然缺少整个分布式基础结构以了解如何实际完成工作。

Let’s say that 10 seniors took the principal up on his offer. They want to be part of this competition to earn more points on their own tests. Another set of 10 seniors decides to volunteer to help maintain the system, but not participate in the competition. This is simply out of support for the distributed system, and part of the spirit of the movement towards open-source grading.

假设有10位老人接受了校长的提议。 他们希望成为本竞赛的一部分,以通过自己的测试获得更多积分。 另有10位长者决定自愿参与维护系统,但不参加比赛。 这完全是出于对分布式系统的支持,而这是向开放源代码分级发展的精神的一部分。

Each one of those seniors is a full node in the network. They communicate in real-time about new transactions and blocks.

这些老年人中的每一个都是网络中的一个完整节点 。 他们实时交流有关新交易和新块的信息。

The 10 seniors that decided to participate in the competition are called miners. They build blocks with transactions available in the mempool, the reservoir of unconfirmed transactions.

决定参加比赛的10名老年人被称为矿工 。 他们使用内存池中的可用交易建立块, mempool是未确认交易的存储库。

When a student, like Andy, finishes grading a test, the student broadcasts an unvalidated transaction to the network of seniors. Each full node shares it around with everyone else, like a rumor. It becomes part of the mempool.

当像安迪(Andy)这样的学生完成测验评分时,该学生会将未经验证的交易广播到老年人网络。 每个完整节点都与谣言共享。 它成为内存池的一部分。

Every node must validate the transaction first. In other words, they determine whether it was possible or not. In this example, validation could mean confirming that the grader actually graded the test correctly by punching in all the final answers into your calculator. We will get into the other part of validation in a little bit.

每个节点必须首先验证交易。 换句话说,他们确定是否可能。 在此示例中,验证可能意味着通过将所有最终答案打入您的计算器来确认评分者确实对考试进行了正确评分。 我们将稍作讨论。

After validation, each miner has the opportunity to build their own block out of 20 tests, or transactions.

验证后,每个矿工都有机会在20个测试或交易中构建自己的区块。

But wait! On test days, 30 new transactions should be added to the network, since there are 30 students in the class. How do the miners choose the transactions to add to their block?

可是等等! 在考试当天,由于班上有30名学生,应该将30笔新交易添加到网络中。 矿工如何选择要添加到其区块中的交易?

The answer is a transaction fee. Each sender must attach a transaction fee to their transaction to compensate the miners for their work. So, the miners usually just choose to put all the transactions with the highest fees into their blocks immediately. Since this operates on supply and demand, they can include the transactions with lower fees on days when there are fewer tests to validate.

答案是交易费 。 每个发送者必须在其交易中附加交易费,以补偿矿工的工作。 因此,矿工通常只是选择立即将所有费用最高的交易放入其区块中。 由于这取决于供需关系,因此可以在需要验证的测试较少的日子里以较低的费用包含交易。

In our school example, this transaction fee could be a point off the sender’s test to donate to the miner. It would not come off of Alice’s (the recipient’s) test. In Bitcoin, it would be a small fraction of a Bitcoin, like 0.000003 BTC. The sender pays the fee since that is the easiest way to handle the logistics.

在我们学校的例子中,这笔交易费可能是发件人测试捐献给矿工的点数。 它不会脱离爱丽丝(收件人)的测试。 在比特币中,它只是比特币的一小部分,例如0.000003 BTC。 发件人支付费用,因为这是处理物流的最简单方法。

At this point, each miner has their block of 20 validated transactions that they would like to add to the blockchain. Now, it is time for the competition to see which of the 10 miners will get their blocks accepted and be awarded the points from the principal.

此时,每个矿工都有自己想添加到区块链中的20个已验证交易的区块。 现在,是时候比赛开始查看10个矿工中的哪个将接受他们的块并从负责人获得积分。

One last thing. You are starting to see the amount of redundancy, or repeated work. Each proposed block will have many transactions (tests) in common. That is a security measure necessary for running a distributed system. If all the nodes are validating transactions separately, that makes it much harder to cheat the system.

最后一件事。 您开始看到冗余的数量或重复的工作。 每个提议的区块将有许多共同的事务(测试)。 这是运行分布式系统所必需的安全措施。 如果所有节点都在分别验证事务,则欺骗系统变得更加困难。

争取工作证明的竞赛 (The race for proof of work)

Imagine that after all this work to create a block of 20 transactions, the principal then shared a 12th-grade level math problem to every miner. The person that solved the problem first was awarded all the points and had their block confirmed.

想象一下,在完成了创建一个包含20个事务的块的所有工作之后,校长然后向每个矿工共享了12年级的数学问题。 首先解决问题的人被授予所有分数,并确认其封锁。

This would mean that the “rich get richer,” and it would skew the incentives for the whole system.

这将意味着“富人变得更富裕”,并且会扭曲整个系统的激励机制。

Every day, the top math students would have an excellent chance at winning the competition, and the rest of the seniors would have little to no chance. Soon, most miners/seniors would stop participating since they would never receive any points.

每天,顶尖的数学学生都有赢得比赛的绝好机会,而其他高年级学生则几乎没有机会。 很快,大多数矿工/前辈将停止参与,因为他们永远不会获得任何积分。

So, instead, our principal is going to set up a scavenger hunt in the school every night. Importantly, the scavenger hunt has nothing to do with a miner’s math ability. This encourages everyone to continue to mine.

因此,相反,我们的校长将每晚在学校进行寻宝活动。 重要的是,寻宝游戏与矿工的数学能力无关 。 这鼓励每个人继续采矿。

The principal will hide a trophy somewhere in the school. The students must race around until they find it, and then yell so that the rest of the students throughout the school can confirm that they found it and go home. Since this principal has some magical foresight abilities, he hides the trophy in a perfect place so that it will take roughly an hour to find each night.

校长将奖杯藏在学校的某个地方。 学生们必须四处奔跑直到找到它,然后大喊大叫,以便整个学校的其余学生可以确认他们找到了它并回家。 由于这位校长具有一些神奇的预见能力,因此他将奖杯藏在一个完美的地方,这样每晚大约需要一个小时才能找到。

Does this sound arbitrary? In other words, does it feel like it came out of nowhere?

听起来随意吗? 换句话说,感觉像是从哪里冒出来的吗?

Well, it must be unrelated to the test-validation so that it can level the playing field. This is known as “proof of work” in Bitcoin. It is an algorithm that is difficult to solve, but easy for the other nodes to confirm once it is solved. Each Bitcoin miner must guess numbers until they choose the right one that solves the puzzle. In Bitcoin, a new block is confirmed every 10 minutes, on average.

好吧,它必须与测试验证无关,以便它可以公平竞争。 这在比特币中被称为“ 工作证明 ”。 这是一种很难解决的算法,但其他节点一旦解决就易于确认。 每个比特币矿工必须猜测数字,直到他们选择解决难题的正确数字。 在比特币中,平均每10分钟确认一次新区块。

Keep in mind, Bitcoin miners are really massive computers that look like this:

请记住,比特币矿工实际上是看起来像这样的大型计算机:

The algorithm also gets gradually more difficult over time as more miners join the network. If there are more miners, that means there will be more guesses, so the challenge must get more difficult if Bitcoin wants to continue to confirm a block every 10 minutes.

随着越来越多的矿工加入网络,该算法也将随着时间的推移逐渐变得越来越困难。 如果有更多的矿工,那就意味着会有更多的猜测,因此,如果比特币想要每隔10分钟继续确认一个区块,那么挑战就将变得更加困难。

This example demonstrates how Bitcoin (and our school example) force every miner to compete against the rest of the network. Once a miner solves the puzzle, they share their answer with the rest of the network, which can be quickly confirmed. After the nodes reach a consensus, or over 50% agree that the block is confirmed, it can be added to the blockchain.

该示例演示了比特币(以及我们的学校示例)如何迫使每个矿工与网络的其余部分竞争。 一旦矿工解决了难题,他们就会与网络的其余部分共享答案,这一点可以很快得到确认。 在节点达成共识后 ,或者超过50%的人同意该区块已被确认 ,就可以将其添加到区块链中。

This has motivated some miners to form guilds. In our school example, this means that a few of the students would agree to split the points once one of them finds the trophy. It simply increases the probability that the first one to find the trophy will be a member of their team.

这促使一些矿工组成行会 。 在我们学校的例子中,这意味着一旦其中一名学生发现奖杯,一些学生就会同意平分。 这只会增加第一个发现奖杯的人成为其团队成员的可能性。

In Bitcoin, the total computing power that is working on solving this “proof of work puzzle” is called the hash rate. The largest Bitcoin guilds control about 10% of the hash rate, which still gives the rest of the miners a good chance to solve the puzzle. If a guild contained 50% of the hash rate, there would be less incentive for others to continue to mine.

在比特币中,用于解决此“工作难题证明”的总计算能力称为哈希率 。 最大的比特币行会控制着大约10%的哈希率,这仍然为其他矿工提供了解决难题的好机会。 如果行会包含哈希率的50%,那么其他人继续开采的动机就会减少。

Once a block is confirmed, the miner receives the prize (10 points on a test) and all the transaction fees from the confirmed transactions. Transactions that were not part of the block then return to the mempool to be included in a future block.

确认区块后,矿工将从已确认的交易中获得奖金(每项测试10分)和所有交易费用。 然后,不属于该块的事务将返回到内存池 ,以包含在以后的块中。

建立区块链 (Building a blockchain)

So far, we have covered most of the steps that go into adding one more block to the blockchain. But, we have not covered the whole point of building a blockchain itself.

到目前为止,我们已经介绍了将更多区块添加到区块链的大部分步骤。 但是,我们还没有涵盖构建区块链本身的全部内容。

A blockchain has a simple three-level structure. A series of transactions make up a block. And a series of blocks make up a blockchain.

区块链具有简单的三级结构。 一系列交易构成了一个障碍。 一系列的块组成了一个区块链。

Although you can certainly divide a blockchain into pieces based on timing, usually, each individual node (senior) will maintain the full history of the blockchain, or the ledger.

尽管您当然可以根据时间将区块链分为几部分,但通常每个节点(高级节点)都将维护区块链或分类帐的完整历史记录。

In our high school example, we are looking at a 9th-grade class. So, the full history of the class could be all of the grades from all of the students in the entire class, from kindergarten until today. Since we are adding blocks at a 1-day interval, and there are approximately 180 days in the school year, that would mean that the blockchain contains about 1700 blocks.

在我们的高中示例中,我们正在研究9年级的课程。 因此,该班级的全部历史可能是整个班级(从幼儿园到今天)所有学生的所有年级。 由于我们以1天为间隔添加区块,并且在学年中大约有180天,这意味着区块链包含大约1700个区块。

Each block has a unique ID, which, due to a “hash function”, depends on the block ID of the previous block. That is what secures the blockchain: there is no such thing as block substitution, or rewriting history, because it will change the block ID of every subsequent block.

每个块都有一个唯一的ID,由于“ 哈希函数 ”,该ID取决于前一个块的ID。 这就是确保区块链安全的要素:没有块替换或重写历史记录之类的东西,因为它将更改每个后续块的块ID。

Since our education example uses one-day intervals, you might think, “Oh, it should be easy to create a unique ID for each block, since each date only occurs once!”

由于我们的教学示例使用一天的时间间隔,因此您可能会认为: “哦,为每个块创建唯一的ID应该很容易,因为每个日期只会出现一次!”

But, that would introduce a security vulnerability. If a miner was able to introduce a new block somewhere in the middle of the chain, it would not break the pattern! The deviant miner would easily be able to replicate the block ID, and none of the following blocks would change their value, since dates follow a dependable pattern that can be easily replicated.

但是,这将引入一个安全漏洞。 如果一个矿工能够在链条中间的某个地方引入一个新区块,那将不会破坏模式! 异常的矿工很容易能够复制区块ID,并且以下日期都不会更改其值,因为日期遵循的是可轻松复制的可靠模式。

Here is a hash generator that you can play around with. I wish there was some wonderful analogy I could give you for the block order, but unfortunately, that is the point of the hash function. It makes it very, very hard to imitate and replace blocks (impossible, as far as we know). So, I will add some random strings to show what is going on.

这是一个哈希生成器,您可以使用它 。 我希望能为您提供一些奇妙的类比,但很遗憾,这就是哈希函数的关键所在。 这就使得模仿和替换方块变得非常非常困难(就我们所知,这是不可能的)。 因此,我将添加一些随机字符串以显示正在发生的情况。

We are going to cover privacy in the next section, because right now, it looks like every 12th grader can see the entire grade history of each 9th grader. That is not what we want!

我们将在下一节中讨论隐私问题,因为现在看来,每个12年级学生都可以看到每个9年级学生的整个历史记录。 那不是我们想要的!

But, on the plus side, the distributed ledger allows each individual senior to ensure the validity of the graded tests as they circulate around the network.

但是,从积极的一面来看,分布式分类帐允许每位年长者确保分级测试在网络上流通时的有效性。

This ordering system is relative, rather than absolute. The order of the blocks matters much more than the times that they were added to the chain. Timestamps, as we discussed above, are too easy to copy and imitate.

此排序系统是相对的 ,而不是绝对的。 块的顺序比将它们添加到链中的时间重要得多。 正如我们上面所讨论的,时间戳太容易复制和模仿。

Let’s give an example of what is known as a double spend attack. Let’s say that one of your classmates takes a math test on a Monday, and knows that she did poorly. One of your classmates grades that version of the test and then broadcasts it to the nodes, per usual.

让我们举一个所谓的“ 双重消费攻击”的例子。 假设您的一位同学在星期一参加一次数学测试,并且知道她的成绩很差。 您的一位同学通常会对该测试版本进行评分,然后将其广播到节点。

Your classmate who did poorly studies like crazy that night, and then shows up the next day to take the same test with another class. Maybe the teacher didn’t notice her there the day before — so she is able to convince the teacher that she was not present on the previous day. Remember, the teacher has no role in grading tests, so the teacher cannot quickly reference the previous day’s exams. The student is allowed to take the test again, and submits it with the rest of the class.

你那学得不好的同学那天晚上疯狂地学习,然后第二天出现,参加另一堂课的相同考试。 也许老师在前一天没有注意到她-因此她能够说服老师在前一天没有在场。 请记住,老师在评分考试中没有作用,因此老师无法快速参考前一天的考试。 允许学生再次参加考试,并与班级其余部分一起提交。

Here are the latest options for blocks from the blockchain, with Alice’s attempt to override her previous grade.

这是区块链中区块的最新选择,爱丽丝(Alice)试图超越她以前的成绩。

Oh, by the way, Alice will now need to become a miner on the network and participate in the scavenger hunt. She is now the 11th miner on this network.

哦,顺便说一句,爱丽丝现在将需要成为网络上的矿工并参与寻宝游戏。 她现在是该网络上的第11名矿工。

The rule is that the “longest chain wins.” That means that on Day 11, the rest of the network may be working on adding a new block with the latest set of transactions. But Alice will be working on “forking” the chain, and adding a new set of transactions for day 10 with 19 transactions in common, and her new test score as a replacement for the old test score.

规则是“最长的链条获胜”。 这意味着在第11天,网络的其余部分可能正在努力添加具有最新交易集的新区块。 但是Alice将致力于“ 分叉 ”该链,并在第10天添加新的一组交易(共有19笔交易),并用新的测试成绩代替旧的测试成绩。

Forking means that she is attempting to build a new longest chain, as opposed to the chain that the rest of the network assumes is the longest.

分叉意味着她正在尝试建立新的最长链,而不是网络其余部分认为最长的链。

If she can win the scavenger hunt that day, and then come back the next day and win it again, she would have the longest chain.

如果她能在当天赢得寻宝游戏,然后在第二天回来并再次赢得胜利,那么她的链条最长。

This is part of the value of the “proof of work” system. Since Alice is one of 11 miners on the network, she has an approximately 1% chance of solving two blocks in a row. There is a 99% chance that she will put in all that work just to get nothing. Not a great incentive.

这是“工作量证明”系统价值的一部分。 由于爱丽丝是网络上11名矿工之一,因此她有大约1%的机会连续求解两个区块。 她将有99%的机会投入所有工作,却一无所获。 这不是一个很大的激励。

This is also why the block IDs and previous block IDs are a better labeling scheme than a specific date. If Alice wins the race on the day that she secretly takes the test a second time, all the new tests from that day will still be eventually stored in the blockchain. They will just need to wait one more day.

这也是为什么区块ID和以前的区块ID比特定日期更好的标记方案的原因。 如果爱丽丝(Alice)在第二次秘密参加考试的那一天赢得了比赛,那么从那天起所有新的测试仍将最终存储在区块链中。 他们只需要再等一天。

介绍公钥和私钥 (Introducing public and private keys)

So far, we have covered all the mechanics that will allow the students of Distributed High School to manage their own grades. We are missing just one major thing: privacy!

到目前为止,我们已经涵盖了允许分布式高中的学生管理自己的成绩的所有机制。 我们只缺少一件事:隐私!

Right now, the grades of each individual student are exposed forever on the blockchain. If this were a currency, it would be easy to figure out how much money each person had. That is not what we want.

现在,每个学生的成绩都会在区块链上永远暴露。 如果这是一种货币,那么很容易弄清楚每个人有多少钱。 那不是我们想要的。

At the same time, the transparency is a great way to keep individual people accountable for unfair grading and other fraudulent practices.

同时,透明度是使个人对不公正的评分和其他欺诈行为负责的好方法。

This is why Bitcoin uses a cryptographic system with public and private keys. In high school, you are probably used to the lockers that line pretty much every hallway.

这就是为什么比特币使用带有公钥和私钥的加密系统的原因。 在高中时,您可能已经习惯了几乎在每个走廊排队的储物柜。

Well, in Bitcoin, there are an (essentially) unlimited number of private-public key combinations. So instead, imagine that this high school’s walls are lined with the little mailboxes that you see in an apartment building.

好吧,在比特币中,(基本上)无限数量的私钥-公钥组合。 因此,可以想象一下,这所高中的墙壁上衬着您在公寓楼看到的小邮箱。

And they cover every wall in this whole dang school. And, since there are an unlimited total number of lockers, each student in the school can own an unlimited number of lockers. In math terms:

他们覆盖了整个荡荡学校的每一堵墙。 并且,由于储物柜的总数不受限制,因此学校中的每个学生都可以拥有无​​限数量的储物柜。 用数学术语来说:

Unlimited/30 students = Unlimited

无限/ 30名学生=无限

Have you seen Harry Potter and the Order of the Phoenix?

你见过《 哈利·波特与凤凰社》吗?

It’s like the scenes from the “Hall of Prophecy” — seemingly limitless.

就像“ 预言厅 ”中的场景一样,看似无限。

But anyway…

但不管怎么说…

For the sake of simplicity, let’s assume that each student gets 1 mailbox for each grade in school (9th-12th) during which they took tests. If a student is in 9th grade, that means they are using their 9th grade locker.

为了简单起见,我们假设每个学生在学校考试(第9-12年级)的每个年级都获得1个邮箱。 如果学生是9年级的学生,则表示他们正在使用9年级的储物柜。

Let’s return to our transaction, where Andy grades Alice’s test.

让我们回到我们的交易中,Andy在这里对Alice的测试进行评分。

Our full nodes, the wonderful seniors, must first evaluate whether Andy is qualified to be grading 9th grade math tests. Andy needs to prove himself.

我们的全部节点 ,出色的前辈,必须首先评估Andy是否有资格进行9年级数学测试。 安迪需要证明自己。

Here’s an issue: if Andy happily announces to the network that he has graded Alice’s assignment, he risks exposing Alice. What if she got a failing grade? She doesn’t want the whole world to know that, forever!

这是一个问题:如果安迪愉快地向网络宣布他已经对爱丽丝的作业进行了评分,那么他就有可能暴露爱丽丝。 如果她的成绩不及怎么办? 她不希望全世界永远知道这一点!

So, he must broadcast while keeping both of them anonymous. He can randomly slip a note to one of the nodes…just like most rumors in 1980's high school movies start!

因此,他必须在广播的同时保持匿名。 他可以随意将音符滑到其中一个节点上……就像1980年代高中电影中的大多数谣言开始一样!

Then the full node would share this rumor with the rest of the network.

然后,整个节点将与网络的其余部分共享该谣言。

This is where our public keys come into play. When Andy slips a note about his graded test to the network, he is really saying:

这是我们的公共密钥起作用的地方。 当安迪(Andy)将有关他的分级考试的笔记放到网络上时,他实际上是在说:

  • My current mailbox address is 126900trl.

    我当前的邮箱地址是126900trl。
  • In order to prove that I was there on test day, here is the answer key that the teacher gave me to grade this specific test (digital signature).

    为了证明我在考试当天到了,这是老师给我评分该特定考试( 数字签名 )的答案。

  • Also, in order to prove that I am indeed a 9th grader in algebra class, here are the final exam scores from math class each year from grades 1–8, and the answer key for each of those tests (transaction chain).

    另外,为了证明我确实是代数班的9年级学生,以下是每年1-8年级数学班的期末考试成绩,以及每个测试( 交易链 )的答案键。

  • I am going to be delivering the test to mailbox 856734pok

    我将把测试传递到邮箱856734pok

This is answering two key questions:

这是在回答两个关键问题:

  1. Is the sender the actual person that he/she claims to be?

    寄件人是他/她声称的真实人士吗?
  2. Is the sender qualified to be the sender (grade the test)?

    发件人是否有资格成为发件人(对考试进行评分)?

In order to answer the first question, Bitcoin uses a digital signature. The digital signature is unique to every transaction and is formed with a hash of the transaction ID and private key. In this case, that is kind of like the test key: you can only own it if you were there on the specific test day and the teacher gave it to you.

为了回答第一个问题,比特币使用数字签名 。 数字签名对于每个交易都是唯一的,并由交易ID和私钥的哈希组成。 在这种情况下,这有点像测试密钥:只有在特定的测试日期您在那儿并且老师将其交给您时,您才能拥有它。

For the second question, remember that in Bitcoin there is no concept of an “account” or “account balance.” If there was, Andy could just share an ID number that proved he was qualified.

对于第二个问题,请记住,在比特币中没有“账户”或“账户余额”的概念。 如果有的话,Andy可以分享一个证明自己合格的ID号。

In order to prove that this particular public key (Andy’s public key) has the sufficient approval, he must share a test history that every full node can validate. That way, everyone can validate that he completed 1st-8th grade. Andy must also provide the answer key for each of those tests to prove that he was in the room at that time. This is called the transaction chain. I will not cover it here, but it is an important part of validation.

为了证明此特定的公共密钥(Andy的公共密钥)具有足够的认可,他必须共享一个测试历史记录,每个完整节点都可以验证该历史记录。 这样,每个人都可以验证他已完成1-8年级。 安迪还必须为每个测试提供答案键,以证明他当时在房间里。 这称为交易链。 我不会在这里介绍它,但这是验证的重要部分。

After Andy’s transaction is validated and then included in a block that has been confirmed, he can go drop the test off in Alice’s mailbox without public knowledge.

确认 Andy的交易,然后将其包含在已确认的区块中之后,他可以在公众不知情的情况下将测试放到Alice的邮箱中。

As you noticed in the transaction above, Andy had to access tests from the last 8 years! This locker system only allows Andy to access his tests.

正如您在上述交易中注意到的那样,Andy必须访问过去8年的测试! 这个更衣室系统仅允许Andy访问他的测试。

Andy has a set of 8 private keys. Every time he started a new year, he opened another locker and put his grades from that year in the locker.

安迪有一组8个私钥 。 每次开始新的一年,他都会打开另一个储物柜,并将当年的成绩放入储物柜中。

Others can slide his latest test results into his locker, but only he can then retrieve the results.

其他人可以将他的最新测试结果放到储物柜中,但是只有他才能取回结果。

Bitcoin software like Coinbase allows you to create many public/private key combinations within your wallet. This improves security. You never want to give away your private keys, which are the only way to access the Bitcoins that have been transferred to you. Unlike a traditional bank, there is nobody to turn to if you forget or lose a private key. The Bitcoin will be locked up.

Coinbase这样的比特币软件使您可以在钱包中创建许多公钥/私钥组合。 这样可以提高安全性。 您永远都不想放弃私钥,这是访问已转移给您的比特币的唯一方法。 与传统银行不同,如果您忘记或丢失了私钥,没有人可以找。 比特币将被锁定。

最后的想法 (Final Thoughts)

To recap, we have:

回顾一下,我们有:

  • Tests (Transactions)

    测试(交易)
  • Answer keys (Digital signatures)

    答案键(数字签名)
  • 9th graders (senders and recipients)

    九年级学生(发送者和接收者)
  • 12th graders (full nodes)

    12年级生(完整节点)
  • Principal (blockchain creator)

    校长(区块链创建者)
  • Unlimited mailboxes (public/private keys)

    无限邮箱(公用/专用密钥)
  • No teachers grading tests (centralized authority)

    没有老师评分考试(中央权威)
  • No report cards (Accounts/account balances)

    没有报告卡(帐户/帐户余额)

Much of this system revolves around the concept of being “trustless,” as you have probably seen by the careful checks and balances and incentive structures. In the traditional playbook for administrating banking or public education, trust in a central authority plays a huge role. In order to give that control back to individual people, there must be a huge amount of redundancy from the nodes to prevent fraud, as well careful security protocols to prevent hackers from infiltrating the system.

正如您可能通过仔细的制衡与奖励结构所看到的那样,该系统的大部分内容围绕“不信任”的概念。 在用于管理银行或公共教育的传统剧本中,对中央机构的信任起着巨大的作用。 为了将这种控制权交还给个人,节点上必须有大量的冗余以防止欺诈,以及谨慎的安全协议以防止黑客渗透到系统中。

But, this distributed system could revolutionize the way that many industries handle their data, and could help prevent industrial accidents, medical malpractice, and financial ruin.

但是,这种分布式系统可能会改变许多行业处理数据的方式,并有助于防止工业事故,医疗事故和财务损失。

If you haven’t already noticed, there is a huge amount of duplicated work across all the full nodes. Between validating and confirming transactions, as well as guessing answers to the “proof of work” as quickly as possible, the system consumes plenty of energy. According to one estimate, the Bitcoin network consumes as much energy as the country of Denmark! But, this is also necessary to form a consensus and maintain the integrity of mining.

如果您还没有注意到,那么在所有完整节点上都有大量重复的工作。 在验证和确认交易之间以及尽快猜测“工作证明”的答案之间,系统消耗了大量能量。 根据一项估计 ,比特币网络消耗的能源与丹麦的国家一样多! 但是,这对于形成共识并维护采矿的完整性也是必要的。

获取更多视觉解释 (Get More Visual Explanations)

Did you enjoy this tutorial? Give it a clap, leave a comment, or sign up here to get my latest technical explanations:

您喜欢本教程吗? 给它鼓掌,发表评论或在此处注册以获取我的最新技术说明:

翻译自: https://www.freecodecamp.org/news/blockchain-explained-by-trying-to-pass-a-high-school-math-class-2322c01ece48/

区块链数学建模

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值