<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>How Asymetric Encryption Works | tait.tech</title><linkrel="stylesheet"href="/assets/css/style.css"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="author"content="Tait Hoyem"><metaname="keywords"content=""><metaname="description"content=""></head><body><divid="wrapper"><header><nav><inputtype="checkbox"id="menu"><labelfor="menu">☰</label><divclass="menu-content"><ahref="/"class="nav-link">Home</a><ahref="/blog/"class="nav-link">Blog</a><ahref="https://github.com/TTWNO/"class="nav-link"target="_blank"rel="noopener noreferrer">Github</a></div></nav></header><main><article><header><h1class="post-title">How Asymetric Encryption Works</h1><timedatetime="20-04-02"class="post-date">Thursday, April 02 2020</time></header><hr><p>In a few previous articles I have explained <ahref="/2020/01/26/rsa1/">why encryption may be important to you</a> and <ahref="/2020/02/19/rsa2/">how the theory behind encryption works</a>. I did not yet explain the system of asymetric cryptography, however. That is what this article is for.</p><p>Previously, we talked about how <em>symetric</em> encryption works. This is by having a shared key that both parties use to simultaniously encrypt, and decrypt the data. (See Ceasar Cipher for example).</p><h2id="public-key-or-asymetric-encryption">Public-key, or Asymetric Encryption</h2><p>Asymetric encryption is based on the idea of having multiple keys instead of only one shared key. For example: instead of encrypting with one key, and decrypting with that same key (like our ROT ciphers we talked about previously), we can use one key to <em>encrypt</em> the information, and a different key to <em>decrypt</em> the information.</p><figure><imgsrc="/assets/img/alice-to-bob.png"alt="Alice sending her message to Bob using Bob's public key. Bob decrypts the message with his private key."/><figcaption> Alice sending her message to Bob using Bob's public key. Bob decrypts the message with his private key. </figcaption></figure><p>In the picture above, see how Alice uses Bob’s public key to encrypt some data, then sends it to Bob for him to decrypt with his private key? That is the essense of public-key encryption.</p><p>The great thing about public-key encryption is that your public key is <em>public</em>! There is no need to be afraid of sending this everywhere! You can attach it at the end of all your emails, the end of your forum posts, <ahref="/public-key.asc">a link to it on your low-power webserver</a> (wink). There are even things called <ahref="http://keys.gnupg.net/">keyservers</a> that will save your public key on them for retrival in case somebody wants to verify your public key.</p><p>Anything encrypted with your public key can only be decrypted with your private key. Provided you never, <em>NEVER</em> share your private key with anyone ever, we can assume that all messages sent to you encrypted with your public key will never be read by anyone else.</p><p>Asymetric encryption, however, often contains four keys instead of two. Why is this?</p><h4id="verification-of-author">Verification of Author</h4><p>One interesting thing about keys pairs is that not only can the private key decrypt anything the public key encrypts, but the public key can decrypt anything the private key encrypts.</p><p>Now why would one want to encrypt a message that can be decrypted by anyone?</p><figure><imgsrc="/assets/img/alice-sign-to-bob.png"alt="Alice sending a message to bob which is 'signed' with her private key. This allows Bob to know only Alice could have sent it!"/><figcaption> Alice sending a message to bob which is 'signed' with her private key. This allows Bob to know only Alice could have sent it! <br/><br/> Note: Although the picture shows otherwise, the text is not sent in the plain. It is encrypted with Alice's private key. </figcaption></figure><p>This is how you can verify that the person who says they wrote the message real