How blockchains use symmetric and asymmetric cryptography.
The word cryptography comes from the Greek words that mean to study and to write secrets. Today, the word mostly applies to the science and art of preventing third parties from accessing data or assets.
Blockchain networks use cryptography very extensively. For example, on the Bitcoin network, a user generates a cryptographic public key and a cryptographic private key when creating a new Bitcoin wallet. The Bitcoin network itself seals every block of the Bitcoin blockchain with a cryptography hash that needs to meet the requirement of difficulty. This article will give an overview of symmetric and asymmetric cryptography and give an introduction to cryptography hashes.
Imagine a person, let’s call him Bob, with a box that has a lock on it. Bob has a key to the lock and using the key he can lock and unlock the box, leaving the box either locked or unlocked, respectively.
Whenever Bob wants to safeguard an asset, be it a document, a ring, or some money, he puts the asset in the box and locks the box with the key.
This is how symmetric cryptography works: there is one key and one key can both lock and unlock the box. Symmetric cryptography works in the same way in the digital world: you would have just one password and with that password you can log into an account. After you log into an account, you can leave it unlocked (meaning that you stay signed in) or you can lock it by signing out of the account.
Symmetrical cryptography is only one type of cryptography. In asymmetrical cryptography, a box would have not just one lock with a key, but it will have two separate keys. Typically, you can only turn the first key clockwise and the second key only counterclockwise.
The first key is what is typically known as a “private” key. The private key unlocks the door. The second key, the “public” key, can only lock the door.
This allows for a lot of interesting and useful scenarios and combinations that simply do not exist with symmetrical cryptography and just one key. For example, Bob can give the public key to a number of people who may need or want to give sensitive information or assets to Bob in a secure way. These people will be able to use the public key to place the assets inside of the box, but none of them will be able to open the box because only Bob has the private key.
There is another interesting scenario, which is locking the box with a private key in such a way that there is a position for a public key to unlock the box. Basically, it works in the opposite way from the scenario above. What both scenarios have in common is that the person that has the private key has the control as to what happens to the box.
In the second scenario, being able to unlock the box with the public key can only mean one thing: that the box was originally locked by the owner of the private key.
Asymmetrical cryptography is exactly how the Bitcoin network and most other cryptocurrency networks protect wallets and encrypt transactions. Because everything happens digitally, things are much easier than in the examples above.
Cryptography keys on blockchain networks are simply long strings of data. After creating a wallet, a person can keep the private key in a separate file, on a hardware wallet, a USB key, an external hard drive, or even print the long combination of symbols on a piece of paper.
When it comes to a public key, it is possible to put it almost anywhere, including email and message signatures, websites, and forum boards.
If anyone chooses to encrypt something with a public key, only the private key can decrypt the message. If the private key owner encrypts a message, anybody with the public key would be able to decrypt it, but they will know for sure that the message came from the owner of the private key.
Obviously, on the financial blockchain networks messages signed with keys are the messages about transactions and this is how the network knows that a transaction is legitimate. This also means that if someone gains access to the private key from your cryptocurrency wallet, they get access to all the funds in the wallet.