LongCut logo

Blockchain 101 - Part 2 - Public / Private Keys and Signing

By Anders Brownworth

Summary

Topics Covered

  • Private keys are any random number
  • Public keys reveal no private secrets
  • Signatures prove private key ownership
  • Tampered transactions fail signature checks
  • No central authority needed for addresses

Full Transcript

Welcome back Last time we looked at a blockchain, and how it works particularly in the financial context and we have these transactions that we were creating that move money from one person to another but there's a big problem with this and that is what's to stop somebody from just adding a Transaction that spends all of someone else's money to them There's seems to be no

Protection here for that so what we're gonna do is we're gonna look at ways to add transactions to a blockchain that Keep it. So not just anyone can create these transactions in order to do this. We need to look at

Keep it. So not just anyone can create these transactions in order to do this. We need to look at another cryptographic primitive and that is Public private key pairs, and then we'll use that for signatures, so let's take a look at that right now so here's a public/private key pair The private key here It's just you know

It's a really really long number and any number is a private key right you could Make this be one one is a private key It's not a very good one lots of people have thought of the number one before but you could you know you could pick some really really long number and it's sort of a random number and

We can use that as a private key. Now. You can see every time. I'm adding digits here its Recomputing the public key that relates to that private key, and that's why the stuff down Here starts changing so as the name would imply this Private key is to be kept private only you have this private key, and you never tell it to anyone else

Okay, and just as the name implies Public key the public key here, you just tell everyone this is something that you want everybody to know This is something that there's no harm in letting everyone know There is not a way to derive from this public key What the private key is okay? So it's just a kind of a public

Version of this private key that does not reveal what the private key is Okay, so I'm gonna hit my little ray number generator, so I get a nice really long private key And it's not something you know where the numbers are close together where I typed On the keyboard it's something a little bit more random looking and then the system has derived a public key

From this so this is going to be my private key, and I'm gonna use this to do signatures So let's do that right now, so Here's a message signature So here is a message. I'm gonna type. You know hello on ders. That's me

and I have My private key here six five six whatever it is is my private key only I have that and here's the message that only I have And I can hit sign and come up with a message signature here now this message Signature I can pass to someone else

I'm gonna hit my little verify button I'm gonna pass this message signature to someone else to anybody else okay now of course they don't have my private key because I keep that private nobody else can see that but I Publicize my public key, and they know that everybody knows that this is my public key So given this message and everybody knows my public key and given the signature that I just made

You should be able to verify this now of course if I hit verify sure enough the screen goes green This is a valid message And I have verified that whoever signed this message and came up with a signal Signature had access to the private key behind this public key

Okay, and if I have kept that private key secret that must be me okay So that's a message signature And how you can sign something and verify it now instead of just using this freeform text box Let's put some structure around this. I'm gonna make a transaction here instead all right. This is similar to what we saw before

the message I'm gonna say is I'm gonna send twenty dollars from this happens to be my public key to Somebody else's public key whoever whoever this is that I'm sending money to okay? I

Of course because I'm Simon smashes. I have my private key I never tell anybody the private key, but I can use this private key to sign this message Which consists of these three things up here?

And if I hit sign I get a message signature great all right now I send this whole thing out I send out my message and my signature to to somebody else and They know that I'm trying to send twenty dollars from my public key to this somebody else's public key

You'll notice this little blue box around the from public key that suggests that You can check this signature against this public key to see whether or not the private key behind, this public key actually sign this message so let's hit verify sure enough it verifies so I know that the person in possession with the

Private key behind this public key must only beyonders is sending twenty dollars To some other public key, okay, now, let's use this in the blockchain Let's go back to the blockchain case where we were that we're looking at before now You'll notice a couple of different things here all right first of all

There's not names here anymore right there There are just public keys in the from and the two and you'll also notice that that I added a signature section here, okay, so In this case this is this Public key sending two dollars to this public key And here's a message signature that says that it is well

What happens if I change this to you know 25 dollars okay?

Of course it broke the block But it also broke the signature the signature is not verified and that's why the signature is turning red so Wow?

we couldn't press the little mine button you know a miner could take this altered block and Remind this block They're gonna end up with something where the block is signed which should eventually happen and there we go and the signature though is still invalid because the the minor has no they don't have my

Private key, they only have my public key, so they can't come up with the right signature. Okay, so that's the way We can make sure that The message this transaction here was posed By the person that had the money and only that person not just anyone else on on the Internet So that's how public private key pair Message signing is used to protect

transactions and make sure that they are from the people that they proposed that they're from Now if you think about it it actually works really well because in order to create a new address a new public key the only thing you have to do is go back and

Come up with a new private key a new random number. You didn't have to go to a centralized Authority to come up with a Public/private key pair, you know you just make up a private key And you use it you derive the public key from it and you put that out there And and that's how people can pay you so

That's a blockchain and again. It's it's a financial context all successful production block chains that are Distributed use a token of some sort so they did they're all they'll have a financial context so that's You know how a blockchain?

Will will work I mean I have glossed over a couple of the details But for the most part the the overall idea here that you're looking at is is very similar to the way that Bitcoin works And many other cryptocurrencies as well, so that's a blockchain. I hope it's helpful to you please leave me some notes down below and let me know what you think of this and

I hope to see you next time in the next video

Loading...

Loading video analysis...