Mathematics of PoS Blockchains for the Impatient

ETHCC 4 · July 2021 · 19:47

Konstantin Kladko introduces the mathematics behind proof-of-stake blockchains. He explains proposal, commitment and finalization alongside distributed key generation, BLS signatures and asynchronous binary consensus.

Speakers

Topics

From ETHCC 4, hosted by Ethereum France.

Transcript

okay guys let's try all to wake up it might be hard for some people to wake up but let's try uh okay so i'm i'll tell a little bit about myself my name is constantin kletko i'm the cto of scale actually i'm a scientist so i did lots of physics in my former life so i was at los alamos national lab in new mexico then i worked at stanford university department of physics and then actually what happened i joined crypto the way i joined crypto there was a startup which professor bonair at stanford started may some of you know him so i joined the startup and then that's actually how i actually moved to crypto

so this this time i've been to one startup another startup it was really interesting and then we started scale and scale is a network of ethereum compatible blockchains it can run websites it can stream music show images videos it's really interesting but today i'm actually not really going to talk about scale i'm going to talk about professor consensus and mathematics which is related to this consensus so my best desire is when you guys guys live you will know more about consensus than what you know now okay so let's start let's start with waking you up

a little bit so please raise your hair what do you know about blockchain if if you know about how it works right so if you just have a vague feeling how blockchain works please raise your hand okay then if you know well please raise your hand okay and if you can build it yourself please raise your hand raise your hand guys anyone can build anything it depends i mean depends on time just raise your hands anyway so so hopefully after this conversation today more of you will know more about blockchain okay so that's a very simple definition

blockchain is a network of computers computers that accepts transactions from users users usually send money or they try to make money so these are transactions they send something to blockchain and uh and then what blockchain does it orders them in blocks so blocks are like deck of cards you know if some of you played poker or any simpler card game there's a deck of cards and the order of cards and in the in the in the deck in the same way on a blockchain there are blocks and locks ordered and so what you need to reach consensus on

is what's the order of transactions in the block so you have this deck of cards but you order them how they are placed in the deck that's that's what is called consensus okay so uh have this video some of you just can meditate it's a video of consensus that i made it's actually our consensus and i'll just see for a while how it works so in this video what happens is that you have 16 computers and they're kind of starting so it's kind of starting strapping phase but once they bootstrap this consensus and you see that

on every computer there are blocks which are these decks of cards right and these blocks these chains are growing and what's important is that the blocks look the same on all nodes on all computers so this is yellow this is yellow this is why this is white it's actually very simple problem turns out mathematically it's really hard to solve this problem so that's consensus just keep on watching for a while and so you just get the feeling of it you see that when this is happening every point here is the network message so they exchange messaging on the network some of the messages are tiny some of the messages are really really large and in the process this is the mathematical algorithm

this is the algorithm that runs consensus and the blocks are being extended and created so that's consensus actually that was a live one so before this conference i made a small tweak in our blockchain and every time a computer would send a message it would actually like create this point so actually what you've seen is actual real consensus okay so let's come back and talk more so another question to you guys to wake you up again why do you think blockchain consensus is hard to build please raise your hand answer number one because

internet is unreliable raise your hand okay answer number two because many computers need to work together raise your hand okay and answer number three because some of the computers can be malicious please raise your hand okay the truth is actually all of these answers are kind of true but there's a progression of complexity definitely network is unreliable sometimes packets and internets get lost so you need to deal with this right that's number one number two computers need to work together you have to you have this distributed system and distributed systems are hard to build so it's harder

and then the most hardest thing is that some of these guys can be malicious we assume that some of them can do bad things and the third thing actually turns out to be really really hard mathematically to deal with the second one is also hard the first one is kind of easy but these are the problems that we face when we build consensus [Music] okay now there are two types of consensus proof of work proof of stake and that do good things and bad things about proof of error propose take proof of work lots of number crunching you probably know right graphic cards uh waste lots of energy also no you know heats up things some people do things like water warmers

based on on mining right uh probably secure it can easily easily security it's secure and it's easy to understand it just requires high high school level of math you can read satoshi nakamoto paper if you're good at math at the high school you can read it right and understand it and last it's slow it takes minutes you know guys takes minutes to finalize transactions proof of stake no number crunching no energy waste good things probably secure you can prove security for some of them right it's drastically much more mess so you replace the number crunching with huge huge amount of mess if you want to do it securely it takes 10 times more lines of code

more bugs harder to actually make it right crashes more all kinds of things it's probably secure as i said it requires probably a graduate level of knowledge of mathematics if you don't have a graduate level known knowledge of mathematics you can build it but it won't be secure and it's fast the as you've seen just here the finalization time of seconds [Music] now what does proving something mean that's a messy magical definition proving is really really really a really strong thing if you prove something mathematically like two by two is four you can destroy the universe kill all of the people two by two you'll be still before

you know there was a greek philosopher plato he said that there are three types of universes there's a universe of mathematics universal physics and universe of feelings and these three things are separate so mathematical world exists independently of physical world it's it's a really really interesting thing now there are several assumptions we are making about blockchain to be able to have it secure number one network has to be reasonably reliable it has to be able to send a pocket from point a to point b in a reasonably reliable way so it doesn't have to be hundred percent reliable because you can resend things but has to be reasonably reliable and so

let me ask you a question are the following networks reasonably reliable first united states postal service who thinks that united states postal service is reasonably reliable please raise your hand yeah actually it is uh i actually sometimes send tax reports to irs and i know it will get lost so the way the way actually i find this i just send it many times just send every day 10 copies and one cup you'll get actually delivered next question is if you just if you are on a desert deserted island bootle you put a message in a bottle and you wait for people to actually read this message is it a reliable network yeah probably not right

so so there's a measure of reliability it doesn't have to be fully reliable but has to be reasonably reliable agreed and so then another question to you guys if you think that the computer is malicious what can this computer do what actions are malicious answer number one send false information to other computers is this malicious yes right answer number two attempt to steal cryptography keys from other guys is this malicious yes right and the last question is if it just stops doing anything is this malicious or not please raise your hand if you think it's malicious it gave me a feeling it is malicious

because it actually make can make blockchain stuck so the bad guys win if bad things happen or if the thing simply stucks okay now let's watch again a different video sooner than expected so that life could go on for all of us this video is a little different because we actually stopped five of 16 computers and you think it works slowly but at some point it actually starts working again and consensus still works so probably

secure consensus works even if you stop some of the machines and the maximum you can stop is one server there are symmetrical proofs that show that you cannot have more than one sword of bad guys but in this case five of the guys i just stopped them and so they see the consensus still works blocks are being mined so the algorithms are able to actually take take this problem and solve it if i would stop six computers this thing would stop they would get stuck and then what if like the next day i would actually power on the the another computer it will start working again so that's really important about consensus once you're this kind of a magic number okay now

really really something that you need to know the only if you need to remember one thing after this presentation that's this slide a blockchain a probably secure blockchain is hard to build but the phases and if you make every face secure the entire thing is secure right if you make a meal and you want it to be fat free if every ingredient is fat free the entire meal is fat free same as here if every phase is secured the entire thing is secure and these phases are incredibly important for every consensus so what are the phases first phase is super simple uh okay so we have a mathematical framework that actually splits things and our blockchain is one implementation of this framework where as i said again if every phrase is

secure the entire thing is secure you can take our source code and change things on every phase changing mathematical algorithms and as long as the phases stay secure the entire thing is going to stay secure [Music] okay so let's talk about phases first phase super simple many of you know it when you did it right you set the transaction to the blockchain and it just goes somewhere usually it goes to something which is called the pending queue on every node it's really simple the browser sends it you know your mobile app may send it at this moment there are these printing cues but pending cues are chaotic they are not ordered and you need to order them in blocks

second phase super important is proposal phase one node many nodes need to form proposals and a proposal is a block that wants to be but many of them there could be many proposals proposers so because of this this the second the next phase is that you decide which proposal wins and you need to have an algorithm that decides this actual algorithm is called consensus i'm going to talk about this later and then there's a kind of you always kind of a signature phrase the blocks needs to be signed so for historical reasons if you if you like next year you want to validate the blockchain you want to have the signature so you need to sign the block and then

ultimately there is an interesting phase which is called finalization phase by this phase by the previous phase not all computers may have the block the winning block so they need to download this winning block and to download it the winning proposal is to be widely distributed so at this point they download this attach it to the end of the blockchain you've seen and then the interesting starts again these are the phrases now really let's watch relic fast and try to identify phases so if you look at how it runs you see that there are some like tiny messages big messages like these are like tiny and now i'm

gonna have like bigger ones like these ones like and the bigger ones are proposals and the tiny ones are consensus messages networking messages so this is phases which which keep on happening if you just watch this for a while you'll kind of see this pattern of phrases the periodicity of it okay so then blockchain as you guys now see is a game the bad guys good guys bad guys win if everything is fine blockchains are mined and and the system is not stuck bad guys win if the blockchain start stuck or diverges meaning that

it looks differently on different notes you've seen just on video that in our anarchists it was looking exactly the same on all notes if it diverges back the guys win and actually mathematical proof means you prove that if there are less than one sword of bad guys good guys always win okay the proposal phase let's talk about this a little more this is where uh [Music] question is during the proposal phase what makes it a a bad guy a malicious guy if we understand it we can we can then later fix this problem we can address the problem so what makes it a bad guy a bad proposal when proposer can

do a corrupt proposal right something doesn't make sense then it can propose different proposals to different parties to different computers and then the blockchain will diverge that's really really bad another thing that can be done is never propose you don't propose you hope that you will get things stuck and also you never distribute a proposal widely so we've seen this finalization phase if the proposal is distributed widely then guys at the finalization phase won't be able to download this all of these are good things and what we need to do mathematically is to fix and address all of them and then it becomes probably secure so so a magic object

is called signature in particular there's a way to do it using social signature that's ways but i'm going to talk about trash concealer way which is really efficient so there's a super super great mathematical object with signatures and they turned out they eliminate all the bad behavior so how they work please raise your hand guys if you know what the digital signature is ever use digital signature okay let me ask you a very simple question if you don't have your private key can you create digital signature yes or no if you think yes please raise your hand if you think no please raise your hand right so you do need to have your private key because private key actually tells that it's you and when you create the

signature because only you can create it using a private key it proves that you actually did this so then later the government or whatever does the particular come after you that's the purpose of the signature now threshold signature is a similar thing but it's for a group it's where let's say we have all of you guys and we want to sign a statement that you agree on something like two-thirds of you the majority agrees on something so all of you use your private keys and then it's like a jigsaw puzzle your signatures can actually get glued together and create this interesting mathematical object which is a threshold signature which proves that a group not just one person but a group created

this thing so a question to you very simple which signature you would trust more threshold or regular you think that stressful signatures better please raise your hand right it's better because group it's a group of people so there's more security so stress code signatures can be done to eliminate the proposal but things i i just discussed in the following way when you propose instead of just proposing you go to every other computer every other node and ask this computer to create this threshold signature so they all sign the statement that your proposal is good so instead of just proposing you create a

proposal go to all other computers they verify it and they sign that is good and you have this threshold signature and this question signature verifies that the proposal is unique non-corrupt you don't send two to different guys all of those things are actually eliminated by this whole signature so you have a safe proposal okay the last thing i want to say about signatures it's a really cool mathematical process which is called dkg we do it in our network it actually runs on ethereum mainnet and it allows you to create keys for this for this threshold signatures it turned out it turns out this key is like super magic and you need to have a specific procedure that does it and it's called dkg the

open source