Blockchain combines three existing technologies — cryptography, P2P networks and game theory — to make sure that a disparate network of actors who do not know or trust each other reach consensus over which transaction is correct, without a centralized party.

Source: BlockchainHub

The role of cryptography is to contribute to the security of the network — by making it hard to manipulate data — and provide individual security for its users — enabling transparent transactions while maintaining the privacy of the individual.

The Bitcoin blockchain uses public key cryptography and cryptographic hash functions to reach that goal. But what is cryptography, and how does it work?

History of Cryptography

Cyphers

One of the first known encryption techniques are called ciphers and have been used to encrypt plain text with the help of a separate so-called cipher alphabets. A cipher alphabet could look like a mixed up latin alphabet. Most ciphers used a keyword or a phrase for shuffling of words and letters. Cyphers pass plain text through these alphabets using keywords which are referred as encoding. One important property of ciphers is that it’s very easy to encrypt a message, but very hard to reverse it if you don’t know the code. With the invention of computers, classical ciphers became redundant because they were very easy to guess with simple brute force attacks, where a computer algorithm runs all possible combinations until it guesses the right code.

Symmetric Cryptography

Two parties agree on a secret key (private key) and use the same key for encryption, and can at a later point use this secret key to decrypt a message. The problem with this approach was that this method does not scale. If you wanted to communicate privately with somebody, you would need to physically meet and agree on the secret key. In the world of modern communications, where we need to coordinate with many actors, such methods would not be feasible.

Asymmetric Cryptography (Public Key Cryptography)

Asymmetric cryptography uses key pairs for encryption where each party generates their own public-private key pair. Private keys should be kept secret and a public key could be freely distributed among parties. In an asymmetric encryption scenario, two parties would distribute their public keys and allow anyone to encrypt messages using their public keys. Because of how a key pair mathematically works it is impossible to decrypt a message which got encrypted with a public key. This message can travel securely to the owner of the private key and only he/she would be able to decrypt the message using the private key which is associated with the public key (padlock). This method works the other way around. Any message encrypted with a private key can only be decrypted with the corresponding public key. This method is also referred as a Digital Signature. Public key cryptography has been around since the 1970s and used in computer and communication security since then. The first publicly available asymmetric key scheme was produced by the cryptographers Ron Rivest, Adi Shamir and Leonard Adleman. The algorithm was called RSA and it is still one of the most widely used algorithms as of today.

Symmetric vs Asymmetric cryptography

Symmetric and asymmetric cryptography algorithms have their pros and cons. Encrypting files and messages with asymmetric algorithms might not always be practical. The main reason is performance. Symmetric key cryptography is much faster and handles better the encryption of big files and databases, therefore, is still widely used.

The Padlock Analogy

To explain public-key cryptography, imagine the following scenario: Let’s assume that Alice and Bob want to communicate privately and therefore both buy padlocks. One would need the key which comes with the padlock, to open the padlock. However, anyone could lock the padlock with a simple push. We will refer to the padlock key as the private key and the padlock itself as the public key.

Now, if Bob wants to send a message to Alice, but is worried that somebody might intercept and read it, he will ask Alice to send her padlock (unlocked) over to him. Bob can now put his letter in a small box and lock it with the padlock that Alice sent him. The letter is sent around the world without being intercepted by an unauthorized person. Only Alice, who has the key to her padlock, can open the letter.

Of course, someone could try and break the box with brute force. It is possible, but the difficulty depends on the resilience of the box, and the strength of the lock. The same applies to modern cryptography. Every cryptographic algorithm is vulnerable to brute force attack if someone tries to guess your private key. The crucial question is: how long would it take to guess the number, how much resources would you have to spend?

To make sure that it is really hard to guess the number, a resilient private key has minimum requirements:

  • It has to be a randomly generated number
  • It has to be a very large number
  • It has to use a secure algorithm for the generation

Every number could be guessed with enough computing power. The question is how long it would take a computer system to guess a number? If it takes a couple of decades the random number is considered secure. This kind of attack is called brute force attack. With time computers get more powerful and can guess numbers faster.

Definition of Terms

  • Privacy -  Keeping information secret from third parties. Only authorized entities are allowed to see it.
  • Signature - A way to associate information with an entity.
  • Time-stamping - A record of the time when information got created
  • Validation - Acknowledgment that information is authorized or true?
  • Verification - to test the correctness of a fact or value
  • Data origin - Where information comes from.
  • Data integrity - Ensuring that information has not been tampered with.
  • Plain text - A message that will be converted into a secret. Usually a simple written language or a number.
  • Brute force attack - When an attacker is trying to break the password by guessing all possible combinations.
  • Private key - A secret random number generated by the user. It should be kept secret.
  • Public key - A public key is mathematically derived from the private key. It is made available to everyone.

References

Originally published at BlockchainHub.