Unblocking the Blockchain: Private-Key Cryptography
What Is Cryptography?
Cryptography is the encrypting and decrypting of information using complex mathematical algorithms ensuring that information is originated from the sender and can only be viewed by the intended recipient.
To help us understand Cryptography better, let's look at an example of how Cryptography was implemented in the past before Internet.
Caesar Cypher, also known as "Shift Cipher" or "Substitution Cipher," is one of the simplest and earliest known encryption techniques. Each alphabet in the Plaintext is replaced by an alphabet by shifting a fixed number of positions down the order, pre-determined and known to both the sender and the receiver. This "number" is the private key and will be subsequently used by the intended recipient to unlock the message.
Assume "1" is the chosen private key.
You will see from the diagram above that every alphabet has been shifted 1 position to the right. A is replaced by B, B is replaced by C and so on.
The word BLOCKCHAIN will be replaced by CMPDLDIBJO when sent, as shown below.
Mathematical Implementation of Caesar Cryptography
We shall now examine how Caesar Cryptography is implemented mathematically.
Assuming that the private key is now "5". As shown below, "A" is replaced by "F", "B" by "G" and so on.
Encryption and Decryption of a letter x by a shift n can be represented mathematically using
En (x) = (x+n) mod (26), and
Dn (x) = (x-n) mod (26)
What Is Mod?
Mod, also known as modulus, has the mathematical symbol "%".
For example, y mod x is equal to the remainder after dividing y by x.
Hence, 53 % 26 should return 1, since 53/26 = 2, with a remainder of 1
First convert letters to numbers; "A" -> 1; "B" -> 2 and so on.
Using the same example above, since the private key is 5, the letter "B" will be replaced by "G" as shown below.
Convert “B” to 2
En (2) = (2+5) mod (26) = 7 mod (26) = 7 (7 is "G")
Thus, letter "B" is replaced by "G"
Dn (7) = (7-5) mod (26) = 2 mod (26) = 2 (2 is "B")
letter "G" becomes "B" after decrypting using the same private key 5
What Do You Observe?
Caesar Cipher is a rather weak cryptography technique for encryption of plaintexts. Both the encryption and decryption private keys are the same. The plaintext can be easily figured out by reversing the Caesar Cipher. Furthermore, the sender has to remember different private keys when sending to multiple recipients.
Cryptography uses mathematics to encrypt data so that only the intended recipient can read this encrypted data.
A private key is used to securely encrypt the plaintext to convert it into a ciphertext before sending to the recipient. The ciphertext is in an unreadable encrypted format. The intended recipient would need the same private key to decrypt the ciphertext (encrypted data) into something readable (plaintext).
This encryption technique is also known as symmetric key cryptography.
Symmetric Key Cryptography
To further elaborate on Symmetric Key Cryptography, let's look at the following example:
Whenever A wishes to send a secret message to someone, he will use one of his private keys to lock the message. This is a very simple way to encrypt important information. However, there are also issues with this type of symmetric key cryptography.
- The two parties need some way to agree on the private key
- Sender A needs a different key for each receiver
- Anyone with the key can decrypt the message
Symmetric key cryptography uses the same private key to encrypt and decrypt data. Therefore, the two communicating parties have to securely share this same private key in order for this method to work. The reason why you are encrypting a message is because you do not trust the communication channel. Hence, this may be not be so easily achieved without the risk of being intercepted.
While symmetric key cryptography works well for some applications, it is not secure enough for communication purposes. For example, anyone on the network with access to your private key will be able to decrypt the message.
In addition, symmetric key cryptography is non-repudiation. This is because in symmetric key cryptography the receiver also has the same private key. Therefore there is no way to prove if the message was actually sent by the sender.
We need something more secure for Blockchain. We will look at Asymmetric key cryptography or Public-Private Key Encryption in the next article.
- Unblocking the Blockchain: Digital Signatures
How does Blockchain ensure that validated transactions cannot be altered and tampered with?
- Unblocking the Blockchain: Public-Key Cryptography
Blockchain use Public-key Cryptography (asymmetric key algorithms) to protect transaction messages across the network.
This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.
Questions & Answers
© 2018 Heng Kiong Yap