Types of nodes in the blockchain network
According to , there are three types of blockchain nodes: (i) mining nodes: they are responsible for producing blocks; each time a mining node produces a block, it is rewarded; (ii) full nodes: they are responsible for maintaining and distributing copies of the entire blockchain; in particular, they are responsible for the validation of blocks produced by the mining nodes. The more full nodes, the more decentralised the blockchain and the harder to hack; and (iii) light nodes: They perform similar functions as full nodes without maintaining the entire blockchain; in general, a light node connects to a full node, downloads only the headers of previous blocks, and connects to a full node. By way of illustrating, Figure 6.5 shows an example of block- chain operation; a transaction is generated by a light node and validated by miners. Then, a miner creates a new block, that includes the transaction, that is validated and appended to the blockchain by miners/full nodes.
Types of blockchain
Blockchain comes in many different types. More specifically, there are three types of blockchain : permissionless, also known as a public blockchain (e.g., Bitcoin and Ethereum), permissioned blockchain, also known as consortium blockchain (e.g., hyperledger fabric), and a private blockchain. In public blockchain, any participant or user can write data to the blockchain and can read data recorded in the blockchain; anybody
Figure 6.5 The transaction life cycle from its genesis to its integration to the main chain (Light node: creation step, mining node, and full node: verification step).
can be a full node, a miner, or a light node. Thus, there is little to no privacy for recorded data, and there are no regulations or rules for participants to join the network. Generally, a public blockchain is considered pseudo-anonymous (e.g., bitcoin and Ethereum); participants do not have to divulge their identity (e.g., name) instead they are linked to an address (i.e., the hash of the public key). Providing anonymity is difficult, but it is feasible (e.g., Zcash). The success of this type of blockchain depends on the number of participants, and it uses incentives to encourage more participation. Consortium blockchain put restrictions on who can participate. In particular, the creation and validation of blocks are controlled by a set of pre-authorised nodes; for example, we have a consortium of 10 banks where each bank operates one node. The right to read data recorded in the blockchain can be public or restricted to the participants. Even participants may be restricted on what they can do in the blockchain; for example, transactions between two participants may be hidden from the rest of the participants. In a private blockchain, write permissions are centralised and restricted to one entity; read permissions may be public or restricted.
Blockchain main ingredients
Consensus mechanisms are one of the key components of a blockchain. They are addressed for preventing and precluding the double spending and
Byzantine General (BG) problems . All the distributed nodes present on the network have to follow and reach a consensus to successfully append new blocks to the blockchain. Consensus mechanisms can be categorised into two categories. Proof-based schemes such as POW and proof-of-stake (POS)  and the voting-based scheme such as Practical Byzantine Fault Tolerance . In that way, the miners, by respecting the consensus protocol, try to reject the creation of illicit blocks undertaken by malicious entities. They operate differently, but they come together to reward miners as a recompose for their contribution which makes that competition takes place. The use of each consensus mechanism depends on the specificity of the blockchain applications, and they are yet under improvement with the aim to minimise the time and energy consumed while validating the created transactions .
One of the fundamental mechanisms of blockchain is cryptography. As we know, the etymology of cryptography has reference to the two Greek words ‘cryptos graphein’ that referred respectively to ‘hidden write’ . In an insecure environment, the cryptography is introduced to entitle only the approved and accredited entities to extract data from the signed and encrypted messages using several techniques. Data integrity, data confidentiality, authentication, anonymity, and privacy preserving are the primary requirements achieved by cryptography. For the purpose of implementing a secure and private platform, the cryptographic algorithms are used in the blockchain platform to respond to the requirements aforementioned. Asymmetric cryptography or as also called ‘public-key cryptography’ has been mainly used to construct digital signature for signing transactions. Rivest-Shamir-Adleman (RSA) and Elliptic Curve Diffie-Hellman (ECDHA) are the most interesting cryptographic schemes used in the blockchain platform.
Cryptographic hashing  is a mechanism used to encrypt data transactions before broadcasting it in the network by its issuer. Secure hash algorithm (SHA256) is the famous hash algorithm implemented in several cryptosystems which relies on hashing an input parameter and converting it to an output with a size of 256 bit. It is a one-way function; that is, each input has one and only hash target as a result, and also there is no way to predict and to divine the input just based on the hash. Additionally, SHA- 256d (SHA256 function is applied two times on data) is used for enhancing the complexity and the mining time (Bitcoin, Peercoin implement the SHA- 256d). Also Scrypt (implemented by Litecoin) and EtHash (implemented by Ethereum) are other algorithms as a hashing function .
184.108.40.206.1 Signing transactions
Establishing the trust and reliability between different entities in the blockchain network is ensured by verifying whether the sender of the transaction is the real and the rightful owner of the data and whether the transaction data has been modified or altered in the network. The asymmetric cryptography bound to each entity in the network by a couple of keys (public key and private key). The public key is shared among all entities in the blockchain network, contrary to the private key which needs to be secretly kept from other entities regardless of the trust established in the network. The blockchain-based system has the autonomy to generate a unique address of 27-34 alphanumeric characters, referred to the global unique identifier (GUID), for each transaction using ECDSA or RSA with the secp256kl . According to , blockchain could allocate a number of addresses estimated to 1.46 x 1048 which enhances the addresses provided by IPv6. Each transaction has a sender and a receiver. The public key is used to generate an address associated with the transaction, using pay-to-pub key hash (P2PKH) method . The private key is a 64-alphanumeric (256-bit hexadecimal format) used to sign the transactions, and it is undeniable which means that the issuers of the transaction cannot deny their ownership of data.
The concept of smart contract was introduced, before any blockchain technology was even in existence by nick Szabo in 1994. It defines the rules and penalties around an agreement in the same way that a traditional contract does, but also automatically enforce those obligations. A smart contract is a piece of code and data that is deployed to a blockchain; the first smart contract, with blockchain technology, was deployed on Ethereum in 2015. A smart contract can perform calculations, store information, and automatically send funds to other accounts. More specifically, it provides a number of functions/primitives (e.g., transfer token, store document, and buy token) that can be called by users. A smart contract is immutable (on blockchain); thus, it can be trusted by users to execute operations ranging from simple cryptocurrency transfers to more complex operations. On Ethereum, a smart contract can be implemented using Solidity language (Turing complete language) and deployed using RemixIDE .