## 3 Blockchain
### Overview and Definitions
A P2P network stores and transfers data between the clients (or nodes) of the network without the need for a central point of storage (central server), so the data are less vulnerable to being hacked or lost. In a blockchain P2P network, the blocks of the chain can actually be copied across all the existing computers of the network (thousands or millions of computers) through the usage of the appropriate cryptographic key across all the peers. As time passes, the blockchain grows and the system becomes more and more complex. If someone attempts any malicious alteration on one or more blocks of the chain, they have to control, attack or manipulate 50% of the network's peers or more in order to break the blockchain, otherwise the other peers of the network will immediately realize the difference and will alert the whole network by sending a signal to replace the broken one. In this way, distributed P2P networks add an extra level of security on the existing cryptographic hash, which is a one-level security schema. In a consensus protocol, the more layers of security used, the stronger and safer the blockchain is made [18]. Every block that composes the blockchain contains at least four fields, namely:  
1. The number of the block;
2. The stored data (or stored transactions);
3. The hash of the previous block;
4. The hash of the current block. Another field in the block is called nonce (number used only once) and relates to the meaning of \"mining\". The hash of every block is dictated by four components, i.e., block number, the previous hash, the stored data, and nonce, and is generated by providing these as input to the SHA256 hashing algorithm. The block number, the previous hash, which is linked directly to contents of the previous block, as well as the stored data, cannot be changed because this would essentially mean that data tampering is attempted. Nonce provides additional control and flexibility that makes defining the correct hash value (one that meets certain requirements) possible, without the need to change any of the other components. In proof of work systems like blockchains, miners must find (by using brute force and significant computational power) a nonce value that, when plugged into the hashing algorithm, generates an output that meets specific requirements (e.g., a certain number of leading zeros). Hence, mining can be perceived as the process of creating a new block for the blockchain and enriching it with a number of transactions. The mining difficulty indicator is the number that suggests the work intensity that a node's computer has to perform in order to create a new block. In the bitcoin blockchain, this is not a constant number but is automatically adjusted every 2016 blocks. Normally, the creation of this number of blocks should take exactly two weeks. In this period, if more blocks need to be created, the mining difficulty is increased, otherwise it is reduced. For the blockchain, this means that if more miners try to solve the cryptographic puzzle in a shorter timeframe, the system should increase the difficulty in order to maintain it. In an opposite situation (a lot of users may stop mining), the difficulty has to be reduced. In other words, the difficulty adjustment ensures that the mining process is performed for a specific amount of time, no matter how many users are mining or how fast the hardware is. One important disadvantage of this is that it tends to lead to centralization. Decentralized applications (Dapps) on the blockchain are interfaces enabling people to connect and interact with many components of it. They are applications that can exist as decentralized programs that can run and can be stored on the peers' computers in the blockchain network rather than in a centralized server. The core visionary idea is to build a global super-computer in a distributed manner, which will be facilitated through a blockchain where everything (programs, transactions) will be recorded, tracked and stored in an immutable manner.