Blockchain Public / Private Key Cryptography In A Nutshell

Demiro Massessi
Oct 15, 2018 · 4 min read

Blockchain makes use of several different types of cryptography.
Among these is:

Public Key Cryptography
Public key cryptography uses a pair of a public key and a private key to perform different tasks. Public keys are widely distributed, while private keys are kept secret.

Using a person’s public key, it is possible to encrypt a message so that only the person with the private key can decrypt and read it. Using a private key, a digital signature can be created so that anyone with the corresponding public key can verify that the message was created by the owner of the private key and was not modified since.

Blockchain makes extensive use of public key cryptography.

So, let’s talk a little bit about cryptography and some cryptography principles.
The first is easy and hard problems, and this is basically what public — private key cryptography is based off of.

There are some problems that are very easy one way, but difficult another way. You can have a great example of this with multiplication.

If I give you a pen and paper and a lot of time, I can ask you to multiply any two numbers, and you can probably come up with an answer easily enough.

What’s a lot more difficult is if I give you the product of two numbers and ask you to factor that and find out all the numbers you can multiply together to get that result, that’s a much harder problem.

“This is how public — private key cryptography works”

We use an easy mathematical problem to generate a message, but we make it very hard for that message to be decrypted by someone who shouldn’t decrypt it, and public and private keys play a big role in blockchain.

Let’s see an example:

Imagine we have two different wallets. I’ve got a wallet that everyone is probably used to, the one you keep money in, and then I’ve got a hardware wallet, a digital wallet that you’d use to trade something like bitcoin or ether.

Now, what you’re used to, in your regular wallet, is putting money in there and you keep your money in there, and if you lose it, whoever finds it gets your money and they get to spend it.

In blockchain, with cryptocurrencies, it’s a little bit different.

The only thing that ever gets kept in your hardware / cryptocurrency wallet, is your private key.

And private key — public key work together so that I can use a private key to sign, digitally sign, any message or, in the case of cryptocurrencies, transactions. You can then take the public key, which anyone can know, and use that to verify that my specific private key was the one that actually signed that message / transaction.

Now, you can know without a doubt that I’m the one who created that message and that no one was pretending to be me sending it.

This is how it works trading digital currencies back and forth.

If I decide I’m going to pay you three bitcoins and I’m going to do it out of my hardware wallet or any software wallet like Metamask, any kind of digital currency like Bitcoin, the only thing that’s kept on your wallet device is your private key and it never leaves.

That means if I want to send you some money, all I’m doing is accessing the private key on this device to sign a message that gets transmitted to the blockchain, that says I’m paying you some Bitcoin or some Ether or some Litecoin, and my public key is used to verify that that message actually did come from the wallet that says it did.

“This is how we trade cryptocurrencies back and forth, and that’s what makes the concept of a digital wallet a little bit different”

If I happen to lose it, I haven’t lost the money that’s in it, because there’s no money ever in it.

All that money is just a record on the blockchain, and, as long as I can recover that private key somehow, I can just get a new device, start using my private key again and keep right on trading.

So, that’s how public and private keys fit into blockchain. They are used to sign and verify any transactions that you make.
And you share just the public key, you NEVER share your private key, because if you do so everyone can access and use your money.

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

 by the author.

Demiro Massessi

Written by

CTO / Co-Founder / Manager / Full-Stack Software Engineer / Blockchain Solution Architect / Technology lover / Wannabe writer

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade