Architecture of blockchain
Cryptocurrencies can be defined as an asset that is purely digital and is made to work as a trade medium by utilizing the field of cryptography to not only form some units which are extra but also to provide a secure path for the exchanges and verify the authenticity of the transactions. These are decentralized and mostly work through a decentralized system known as blockchain, which is a database that is open and is available to be everyone. The blockchain functions like a distributed ledger.
Blockchain is the backbone behind legitimizing cryptocurrency transactions and also making them secure. It is continuously making new records which are called squares; these squares are connected and secured with the help of cryptography. Blockchain behaves like a linked list where each piece contains a pointer which is a hash and points to a previous block, and it can also include a timestamp and the data that is exchanged. By definition, blockchain is immutable and impervious if someone wants to change the data existing on the blockchain. Similarly, an example has been displayed in Figure 1. A blockchain is overseen by a system that is shared and relies on the convention of everyone approving the addition of new blocks. Once these blocks are added, and the data are made part of the system, they cannot be modified because the corresponding hash of the block will change and all the subsequent hashed needs to be changed accordingly.
In general, blockchains are very secure. They are usually the case of a framework that is appropriate in the concerned discussion with great Byzantine adaptation to failures concerned with internal functioning. The accord of decentralization has been achieved with the invention and implementation of blockchain, and it tackles many issues, such as a 2-fold spending issue without involving an expert or a dedicated focal server. Square time is defined by the time taken for a system to produce and adding a block in the blockchain. Few blockchains formulate a block every 7 second. By the time the block is created and added, the included information ends up evident, and at that time, an exchange of cash took place. Thus, a short square time will result in faster exchanges.
Figure 1. Flow of Bitcoin transaction.
- Proof-of-work
The concept of the PoW system is used for preventing abuse of the cryptocurrency system, such as the denial of service attacks, spam, double-spending, and many other attacks. This concept is used to create a distributed trustless consensus, in which the system requires some work, i.e. computational work, from the computer requesting the service. This «work» is usually in the form of processing time by the computer of the requester. Cynthia and Moni invented this concept of doing «work» for your request to be granted.
The main characteristic and probably the reason why PoW is a concept that most cryptocurrency systems have been able to rely on ever since their establishment is the asymmetry between when it comes to the actual computational work, and when it comes to validating it. This idea goes by many other names—computational puzzle, CPU cost function, cryptographic puzzle. Even with its base concept being very similar to that of a CAPTCHA, it is different from it and is intended for humans to solve rapidly than computers. Along the lines of PoW, various other concepts are proposed, such as proof-of-space, proof-of-bandwidth, and proof-of-ownership.
- Proof-of-stake and combined schemes
Unlike PoW which forms a distributed consensus purely based on the amount of computational work done by the service requester, in the proof-of-stake system, the owner of the succeeding block is selected based on the combination of random selection and wealth or age.
Figure 2. Creation and addition of blocks in blockchain.
Although the PoS is more energy-efficient than PoW, PoW is still a highly favored scheme because it provides a better consensus about which computer shall be made the creator of the next block. Most popular cryptocurrencies either use a PoW system or a combined PoW/PoS scheme.
- Mining of blocks
Merkle tree which is different for each block. The methodology has been visualized in Figure 2, which is used for maintaining and creating blocks in the cryptocurrencies’ corresponding blockchain. The miners solve a problematic cryptographic puzzle using their resources and in the process, verify the block that needs to be added to the blockchain. The blocks are stored in a linked list manner where one can traverse the list or chain to find out the owner of each transaction. The data in the blocks are immutable because if one tries to change the block by modifying the data, the corresponding hash will change and thus change the subsequent blocks. Each block consists of the hash of the previous block, make changing the whole subsequent block.
The length of the blockchain keeps on increasing because of the addition of blocks through mining which is a continuous process. This process includes two steps A miner needs to validate the hash value, i.e. it should be less than or equal to the target value for a particular block. Once the validation is done, the block is added to the local blockchain of the miner, and this is broadcast to the whole network. Once the miners receive the broadcasted solution, they validate the block, and if it is valid, then they append the block to their local blockchain, or else they discard the block for an invalid solution. Figure 2 shows the architecture of mining blocks in the network.
- Digital signature
The user who signs the transactions digitally should own two keys: a public key and a private key. The procedure is that the private key is used to sign the transactions and is kept a secret. After signing the transactions, the transactions are announced on the full network; the verification takes place with the public key that the user sent. The general digital signature scheme involves two phases as specified: the signing phase and the verification phase. For instance, a user Bob willing to send another user Alice a message, and also wants that no one else should read the message on the network.
- In the signing phase, Bob encrypts his data with his private key which is maintained secretly, and sends Alice the encrypted result and original data.
- In the verification phase, Alice validates the value with Bob’s public key, and thus Alice can verify if the data has been tampered with or not with ease. Elliptic curve digital signature algorithm is the digital signature scheme that is widely used in blockchains.
- Smart contract
A smart contract is a computer program, or a digital document, with the purpose of digital facilitation, verification, and enforcement of the negotiation and execution of a contract. The term and the concept of smart contracts were coined and proposed by Nick Szabo.
Smart contracts act as a ledger and allow the performance of credible transactions. The workflow is such that each block in the blockchain consists of a ledger of its own, thus avoiding the need for any third party. This way, the smart contracts achieve their aim of providing security and trust in a manner superior to conventional contract law and minimizing other overheads which arise with contracting. Byzantine fault-tolerant algorithms have enabled security in decentralization, which eased the construction of smart contracts. Besides that, the programming languages used to create blockchains have several degrees of Turing-completeness as their built-in feature, which in turn allows the creation of sophisticated custom logic.
Different hash algorithms are used to secure these cryptocurrencies. New cryptocurrencies are made with even better secure algorithms. A hash algorithm transforms an arbitrarily large amount of data into a fixed-length hash code. Hash code would be changed according to the data, i.e. the same hash code will be a result of the same data, but altering the data by just a bit will completely change the hash code. A hash function is a computing process that takes input data of any size, applies an operation on it, and then gives output data of a fixed size.