What is Cryptography and Its Role in Blockchain

What is Cryptography and Its Role in Blockchain

Blockchain For Newbies
January 5, 2019 by Leo Webb
6718
cryptography

Cryptography is intended to create generated or written codes that allow people to keep certain information in secret. Simply put, cryptography turns any kind of data into a new format that can be read only by authorized users. Thus, this data cannot be transmitted by unauthorized users. To make this data readable, it should be converted back into a regular format.

Cryptography is widely used to protect information of any kind. To read the encrypted information, one must have a key that will allow them to decrypt it. When stored and transmitted, the information remains integral. Cryptography also allows for verifying the sender and controlling delivery.

Using key pairs, receivers and senders can authenticate each other. There are many different algorithms for encryption, and here are the most common ones:

    • Public Key Cryptography. This algorithm implies using two keys. The first key is a public key which can be accessed by anyone. Another key is private and can be accessed only by its owner. When the sender sends a message, they use the public key, while the receiver uses the private key to receive and decrypt it. To ensure non-repudiation, the sender uses a private key to encrypt plain text. In turn, the receiver can decrypt it using the sender’s public key. This allows the receiver to understand who sent the message.

 

  • Secret Key Cryptography. This algorithm is also called symmetric encryption. In this case, the same key is used both to encrypt and to decrypt the information.
  • Hash Functions. This method is different from the secret key and public key algorithms, and it’s also known as a one-way encryption. This method isn’t based on keys. The main purpose of hash functions is to make sure that certain information has not been changed. Hashes look like long serial numbers generated automatically. They are very sensitive to any changes and represent the data exactly. Any change in the input data leads to a completely different hash output.

 

The Importance of Cryptography for Blockchain

Blockchain uses cryptography to protect identities of the users of a network, to ensure secure transactions, and to protect all sorts of valuable information. Thanks to cryptography, everyone who uses blockchain can be sure that the information recorded in a blockchain is valid and secure.

Although based on a similar framework, public-key cryptography is a better option for the blockchain technology than symmetric-key cryptography. Public-key cryptography has a number of improvements compared to symmetric-key cryptography. It allows users to transfer data using a public key that can be accessed by anyone.

A combination of public and private keys enables encryption of the information, while the sender’s and recipient’s public keys decrypt it. It’s impossible to get the private key having only the public one so everyone can send their public keys without being afraid of somebody accessing their private keys. When the sender encrypts the information, they can also be sure that it will be decrypted only by the intended recipient.

In addition, blockchain relies on digital signatures. Just like regular signatures, digital signatures are intended for authentication and validation. Digital signatures are an integral part of various blockchain protocols, being one of the main tools used to ensure the integrity and security of the information stored in a blockchain. The range of applications includes securing blocks of transactions, software distribution, transfers of important information, contract management, and other tasks where preventing external access is important.

Theoretically, when a user sends some encrypted data, it can be altered by a hacker, which will be unnoticed by both the sender and the recipient. However, digital signatures prevent hackers from altering the data because if they change it, the digital signature will also change and become invalid. Thus, digital signatures not only protect data but also indicate if it has been altered.

Additionally, digital signatures secure the identity of the sender. Every user has his or her own digital signature so that all users can be sure that they’re communicating with the right person. It’s virtually impossible for a hacker to fake somebody else’s digital signature because such a task is almost impossible from the mathematical point of view. Digital signatures are linked to private keys, ensuring non-repudiation. Thus, if a user signs something digitally, it becomes associated with this user and can be legally binding. It becomes possible due to the reliability of private keys and digital signatures.

Here’s how digital signatures are created:

  • They can be created using a key generation algorithm, based on a public and private key.
  • Signing algorithms can combine a private key and data to make a signature.
  • Signatures are verified using an algorithm that analyses the public key, the signature itself, and the message, determining whether or not the message is authentic.

Cryptography in Different Blockchain Consensus Protocols

The main purpose of consensus protocols is to create a general agreement of the current state of a blockchain. In other words, if Bill sends $50 worth of Bitcoin to Nancy, he will lose $50 worth of Bitcoin from his wallet, and Nancy will get these $50 in her wallet. Every cryptocurrency transaction is recorded in the public ledger of Bitcoin, and a consensus protocol makes sure that the blockchain itself hasn’t been changed.

Now let’s take a closer look at the most common consensus protocols.

    • Proof-of-Work (PoW)
      Perhaps, it’s the most well-known protocol, as it has been used in the first blockchain — the Bitcoin blockchain. PoW works thanks to the effort of miners — people who provide computing resources. The miners verify transactions by solving a hash puzzle, which is a complex cryptographic problem. A puzzle has its rules, and miners should use random values to make the result of a hash operation match these rules. Puzzles may be more or less difficult, depending on the number of matching symbols required. The more letters, the more complex the puzzle. Even three matching letters are quite a difficult task. Miners perform the hash operation with random input values until the output matches the rules of the puzzle.
      In the case of the Bitcoin blockchain, the input consists of random values combined with the already existing data, which is the hash value of the previous block. Solving a hash puzzle may take more than a hundred billion billion attempts, which is a virtually impossible task for an individual. However, thousands of miners compete to solve a puzzle, making more than a trillion operations per second.
      Once some miner has found the solution, he or she receives a reward in a cryptocurrency, and the new block is added to the blockchain. The hash of this block is then used in the puzzle for the next operation.

 

  • Proof-of-Stake (PoS)
    While PoW requires miners to compete in order to find the solution for a hash puzzle, PoS allows people to stake a certain amount of their cryptocurrency in order to get a chance to be chosen for validation of a block. The probability of being chosen depends on the amount of cryptocurrency staked by a particular user.
    In addition, most PoS systems don’t have a rewarding mechanism. While Bitcoin miners receive a reward for every solution, PoS protocols allow users who validate blocks to keep transaction fees.
    The idea of staking tokens is aimed to select legitimate validators and to prevent fraudsters from making false validations. If somebody tries to make a false validation, he or she will lose the stake, which motivates participants to play fair.
  • Delegated Proof-of-Stake (DPoS)
    This protocol is somewhat similar to PoS, however, these two protocols are also different from each other. Just as in the case of PoS, token holders also stake their tokens, however, DPoS doesn’t rely on simple probabilistic algorithms when choosing validators. There is a panel of witnesses who ensure the security of the network, and potential validators (delegates) who must receive a certain number of votes based on their stakes. Delegates don’t need to have a lot of money to make a stake, however, they need to compete in order to get the most votes.
    DPoS ensures better scalability compared to PoS and PoW. There are nodes chosen specifically for producing blocks. Users can vote any time if they want to get rid of some block producer so reputation becomes especially important. On the other hand, DPoS has certain disadvantages. The thing is that DPoS creates semi-centralized networks. However, many people consider scalability to be more important, which is a reason why DPoS gains popularity, being used by BitShares, Steem, and EOS.
  • Proof-of-Authority (PoA)
    This protocol is also similar to PoS and DPoS, as only a certain group of pre-selected users can produce new blocks. Validators create new blocks on a blockchain only when they reach a super majority.
    Identities of all the validators are public and can be validated by any third party. In this case, the identity and reputation of a validator play the same role as a stake in PoS protocols. Users don’t want their identity to be compromised so they need to work for the best interest of their network.
    Just as in the case of DPoS, PoA raises concerns regarding the possible centralization of networks, however, most experts agree that this protocol is a good solution for private blockchains and blockchains of the consortium type. In addition, it also addresses the scalability issues.

 

Quantum-Resistant Blockchains

All the existing blockchains are based on standard cryptographic functions that make them virtually impossible to break because such a task would require a hacker to have huge computing resources. A hacker would need to not only alter a certain block on a blockchain but also all the other blocks connected to it. Otherwise, hashes won’t match. However, it also means that if we had more powerful computers, hackers would have more opportunity to break blockchains.

For example, a number of companies are working on the development of quantum computers. Traditional computers encode data into bits — binary digits that can take a value equal to either 1 or 0. In quantum computers, bits are replaced with qubits. Qubits illustrate one of the main challenges of quantum mechanics, being able to be in a superposition of states. Quantum computers have the potential to break any existing cryptographic code in no time, however, this problem can be addressed by creating quantum cryptographic codes and, therefore, quantum-resistant blockchains.

Developers behind IOTA, which is based on its own Tangle mechanism, claim that their BlockDAG protocol is quantum-resistant. Tangle is different from blockchain. Its structure has nothing to do with a chain but resembles a tree. This model demonstrates faster transactions and removes proof of stake. Instead of PoS protocol, Tangle uses so-called “proof-of-movement.” Transactions are validated based on the history of a block and its movement within the network. Thus, BlockDAG references the previous blocks, as blockchain does, and it also publishes a new block immediately.

Another solution to the problem of quantum computing was offered by the project called The Quantum Resistant Ledger (QRL). The developers of QRL claim that they are going to change the blockchain technology as we know it, protecting it from the threats of the upcoming quantum era of computing. While the existing blockchains are based on the elliptic-curve method of public-key cryptography, QRL relies on a hashtag-based tree of signatures called Extended Merkle Signature Scheme (XMSS). Combining XMSS and PoS, such networks can provide unique signatures that are used only once, in order to make sure private keys are not changed by the quantum software.

Conclusion

Cryptography is an integral part of any blockchain. It is used to protect information and to authenticate users. Most blockchains rely on such cryptographic mechanisms as public and personal keys, hash functions, and digital signatures.

PoW, the first consensus protocol used in the Bitcoin blockchain, requires miners to compete, trying to come up with the solution to a complex cryptographic task. Any block implies solving a puzzle based on a hash of the previous block, which makes it impossible to alter the data in the block. However, PoW protocol is associated with a slow speed of transactions and certain scalability issues. As a result, PoS, DPoS, and PoA protocols were created.

Although blockchain protects data using cryptography, the reliability of this technology is determined by the computational power available for hackers. As quantum computers become a discussed topic, blockchain experts realize that traditional cryptography will not be able to protect the data in a blockchain from quantum threats. This issue pushed developers to come up with new, quantum-resistant solutions that may change the blockchain technology as we know it forever.