Bitcoin For Dummies. Peter Kent

Bitcoin For Dummies - Peter  Kent


Скачать книгу
mathematically associated), and no other.

      Encryption is a handy tool. It means Peter can give you a public key, and you can write him a message and encrypt it using the public key; once it is encrypted, nobody in the world can read it unless they have the private key. So, if Peter carefully protects his keys, he’s the only person in the world who can read it.

      The names of these keys aren’t arbitrary. The private key should be truly private — only you, and nobody else in the world, should have access to it. The public key can be truly public. You can give it away. For example, if you want to have people email encrypted messages to you, you could publish your public key — on your website, in the footer of your emails, on your business card, or whatever — so that anybody who wants to send a message to you can encrypt it with your public key knowing that you are the only person in the world who can read it (because you keep the private key secret).

      This process is essentially what your web browser uses when you send your credit card information online; the web browser uses the web server’s public key to scramble the data so that only the web browser, with the associated private key, can decrypt and read the credit card information. (Okay, that’s a simplification. Browser-to-server communication is more complicated than this description, involving temporary session keys and so on; but the basic principle still applies.)

      HOW DO YOU ENCRYPT EMAILS?

      Email encryption has been around for decades, but it simply never caught on with the public at large. Still, you can encrypt email from most email systems, such as Outlook, Gmail, and Yahoo! Mail, and systems, such as ProtonMail, can encrypt it by default. If you’re interested, you can dig deep into the Help pages.

      Messages to the blockchain

      That’s public key encryption, then. But if the blockchain is not encrypted, what does it have to do with Bitcoin? Well, you use public-key encryption when you send transactions to the blockchain. When you want to send Bitcoin to someone else, you send an encrypted message to the blockchain saying, “Send x.xx of my Bitcoin to this address.”

      But wait. We just told you the blockchain isn’t encrypted, and now we’re telling you a message to the blockchain is encrypted! So why do you care if the message going to the blockchain is encrypted if you’re just going to decrypt it anyway?

      Well, remember that we told you this lock-and-unlock mechanism works both ways. You can lock with the public key and unlock with the private key or lock with the private key and unlock with the public key. Either way, the data is scrambled. The difference is in who has the ability to unscramble it. If you scramble something with the public key, the only person in the world who can unscramble it is the person with the private key. But if you scramble it with the private key, the only person in the world who can open it is…everybody! Anybody and everybody can get to the public key. It’s public, remember!

      So, what’s the purpose of encrypting a message with the private key? Not to secure it, obviously, because anybody can decrypt it. No, the purpose is to sign the message (transaction) and prove ownership of the associated public key.

      Signing messages with the private key

      Let’s go back to the concept of encrypted email for a moment, to help you understand. Let’s say that Peter publishes his public key on his website, in his emails, and on his business cards. Now, one day you get a message that seems to come from Peter. But how can you be sure it’s from him? Well, he encrypted the message using his private key. So, you take his public key (which is publicly available) and use it to decrypt the message. If the message really is from Peter, his public key will decrypt it, and you’ll be able to read it. If it isn’t, the decryption won’t work, because it came from someone else.

      So, by encrypting the message with the private key, Peter has in effect signed the message, proving that it came from him. The recipient knows that the message was created by the person holding the private key that is associated with the public key that opened the message up and made it readable.

      Okay, back to Bitcoin. Remember that these three things are mathemagically associated with each other. Your address in the blockchain was created by your wallet software, which has a private key that was used to create a public key, and which then used the public key to create an address. All done with the magic of mathematics.

      Thus, the private key is associated, through the public key, with the address. Remember also that these elements are all unique and operate with each other. The address is associated with just one private key and one public key, each of which are uniquely associated with each other.

      Sending a transaction message to the Bitcoin ledger

      

You can see this address for yourself in a blockchain explorer. (Use this link to get to it: https://blockstream.info/address/1L7hHWfJL1dd7ZhQFgRv8ke1PTKAHoc9Tq.) By the time you see it, of course, the balance associated with the address may be different.

      Now, let’s say this is your Bitcoin, and you want to send, perhaps, 0.05 Bitcoin to a friend, an exchange, or a merchant from whom you are buying goods or services.

      You send a message to the blockchain saying, essentially, “I own address 1L7hHWfJL1dd7ZhQFgRv8ke1PTKAHoc9Tq, and I want to send 0.05 Bitcoin to address 1NdaT7URGyG67L9nkP2TuBZjYV6yL7XepS.”

      If you just sent a plain text (unencrypted) message to the blockchain, there would be a huge problem of verification and validity. How would the Bitcoin node receiving this message know that you do indeed own this address and the money associated with it? You could just be spoofing this information and making it up, right?

      What we do is use the wallet to sign the message using the private key associated with the address. In other words, we use the private key to encrypt the message. Then we take the public key, add it to the encrypted message, and send it all out across the Bitcoin network.

      MESSAGE TO THE BLOCKCHAIN

      How do you send a message to the blockchain? That’s what your wallet software does. In fact, wallet software is less like a wallet — your wallet contains no Bitcoin — and more like an email program. Your email program sends messages across the email network. Your wallet sends messages (about transactions) across the Bitcoin network. More on wallets soon.

      Unraveling the message

      So, the node — a computer containing a copy of the Bitcoin blockchain — receives the message. It takes the public key that has been attached to the encrypted message, and decrypts the message. The node “learns” something: “This message must have been encrypted — signed — by the private key associated with the public key.” Of course, that’s not really saying much. It’s virtually a tautology! By definition, if the public key can decrypt a message, the message must have been encrypted with the matching private key. Whoop-de-doo.

      But remember, the public key must be mathematically associated with the address 1L7hHWfJL1dd7ZhQFgRv8ke1PTKAHoc9Tq. So now the node can examine the address specified in the message, along with the public key sent with the message, asking, in effect, “Is the public key associated with the address?” If the answer is yes,


Скачать книгу