Cryptography In Security: What Are Three Types Of It?
Cryptography is essential for the security of our digital world. Blockchain technology uses a wide range of cryptographic techniques. To be able to understand it, you need to understand the basics of it and this article will try to help with that.
What is cryptography?
Cryptography is about protecting data with the use of code in order to prevent third parties or the public from reading private messages. It has numerous aspects in information security such as data confidentiality, data integrity or authentication.
What are the types of cryptography?
This encryption type converts any data into a unique identifier called a checksum. The identifier is much shorter than the original text, so imagine that a book can be hashed to a string of just 128 characters. The most important property of hashing is that it cannot be reversed, which means that you cannot find a message that yields a given checksum, and changing the message even slightly produces a completely different checksum.
Hashing use cases
There are many use cases of hashing. One of them is storing passwords in web applications. Imagine that someone broke into a database with users login and password. An attacker can then log in as any user and take control of the user's account. An easy way to solve this problem is to store checksums of the password and not the password itself. When a user logs in we hash their password and compare it to the hash in the database; if it’s the same, we let them in. An attacker is left with a database with checksum values that themselves won’t allow him to login to the system.
In the blockchain, blocks are hashed and each block contains a checksum of a previous block down to the genesis block. If anyone would like to tamper with one block, they would need to be able to generate the same hash or change hashes of all blocks following it.
This encryption method is more classic and easier to understand. You have a secret key that is just a string of random bytes. You use the same key for data encryption and decryption. It is fast and super secure, so secure that most symmetric encryption algorithms are impossible to break even by quantum computers. This method plays a crucial role in technologies like TLS/HTTPS or SSH but not that much in the blockchain. There is one inconvenient drawback of this type of encryption - it is challenging to securely convey a secret key between parties.
With help comes the asymmetric cryptography, where we have a pair of keys (called the public key and private key). The public key is used for encrypting the data, and the private key is used to decrypt the data. The first one does not need to be kept private because it cannot be used to decrypt the data. So it is common to distribute it to anyone that you wish to establish an encrypted channel with.
That person can send you a message encrypted with your public key, and only you can decrypt it using your private key. This helps a lot with the security issues of symmetric encryption. If someone gets your public key, it gives them nothing – even if they somehow get an encrypted message, they won’t be able to decrypt it.
The biggest disadvantage of this cryptographic technique is that it is less secure and much slower. Often we combine both encryptions. For example in HTTPS, the browser generates a one-time symmetric secret key,encrypts it using its public key and then sends it to the server. Then all following data is encrypted using that symmetric secret key.
Digital signature with asymmetric cryptography
Signing messages similar to physical signing, is a method to prove that we are the author of the message and that nobody has tampered with it. When signing, you use a private key to generate a signature of the message and a public key can then be used to verify it. This means that only you (the owner of private key) can sign and anybody else can verify the signature.
To be more precise, in this scenario private key acts as public key and public key acts as private key. The signature is a hash of the message that is then encrypted with your private key. This way a public key can be used to decrypt and verify that only you could encrypt the hash of the message.
In blockchain, signing is the most important operation, this is the way one proves that they are the owner of coins that he wishes to spend.
Cryptography is an interesting topic and in this article, we just scratched the surface. Blockchain is full of cryptographic algorithms and applications. If you feel that you would like to learn more, check things like Shamir's Secret Sharing - how to split private key into parts so that you can reconstruct it having only some of the parts, or zkSNARK (Non-interactive zero-knowledge proof) - how to verify that you know something without revealing that knowledge or Verifiable Random Function - how to randomly choose a committee so that only the member that has been chosen knows that and can prove it.
Do you want to work with the best blockchain developers? Go to our career section and apply!