Computational theory of Blockchain
Tags: webdev, blockchain, cybersecurity
Published: 2023-01-27 07:59:09

Blockchain is a digital decentralized (no financial institutions involved) and distributed ledger. It is a database that stores records and transactions on multiple computers without one controlling party and according to an agreed policy. The data that is stored is a block, and the blocks are linked together to form a blockchain. Each block contains records and transactions; these blocks are shared across multiple computers and should not be altered absent an agreement (consensus) of the entire network. The network is ruled according to a specific policy. The computers are connected on one network and called peers or nodes.

> It is possible that blockchain mechanisms might be the most efficient and equitable models for administering all transnational public goods, particularly due to their participative, democratic, and distributed nature. This is provided by the blockchain’s immutable public record, transparency, access, and reach.

**Cryptography in Blockchain:**

Cryptography is the process of using the techniques of encryption and decryption. The word cryptography came from the Greek word Krypto’s, which means hidden or secret. Blockchain uses cryptography in various ways, especially security and privacy mechanisms. Enabling digital signatures, wallet creation, secure and transparent transactions are some of the areas where Blockchain uses cryptography.

> Encryption + Decryption = Cryptography

Cryptographic functions provide the following benefits to the blockchain:

- 
Avalanche effect — A slight change in the data can result in a significantly different output.

- 
Uniqueness — Every input has a unique output. • Deterministic — Any input will always have the same output if passed through the hash function.

- 
Quickness — The output can be generated in a very small amount of time.

- 
Reverse engineering is not possible, i.e., we cannot generate the input by having the output and the hash function

**Consensus Mechanism:**
A traditional centralized system such as a bank, there is a master computer that is trusted with the ledger of transactions. The bank can obviously trust its own computer, and therefore it has no problem being the one responsible for the security and integrity of the master computer. When you are dealing with untrusted peers sharing a ledger, there is a need to place rules that will ensure security and provide integrity of the ledger to prevent double spending and other potential hacker attacks. These rules and agreements are called a consensus mechanism.

Few important consensus mechanisms:

- 
Proof of work (PoW)
- 
Proof of stake (PoS)
- 
Delegated proof of stake (DPoS)
- 
Proof of Elapsed Time (PoET)
- 
Proof of Activity (PoA)
- 
Proof of Capacity (PoC)
- 
Proof of Burn (PoB)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgyobxrjmcp5yvscsp79.jpg)
> A distributed consensus means that a pool of peers, geographically apart, agree in a decentralized manner, instead of one master computer (centralized).

These methods can be easily broken by identifying the frequency of letters. Later, Enigma Machine, a system using multiple rotors, is used to generate ciphertext, which cannot be broken quickly based on letter frequency. Hashing helps in ensuring the data integrity by linking each block with the other by the hash code. Thus, a chain of blocks linked via a hash is called Blockchain.

**Conclusion:**
The blockchain structure is cryptographically linked blocks, with each block containing one or more transactions. Hashes are used to link the blocks together. Once a block has been added to the blockchain, it can’t be modified or removed.