# Blockchain Based Secure Routing and Trust Management in Wireless Sensor Networks +
## 1 Introduction  
A Wireless Sensor Network (WSN) plays an important part in the growth of various applications such as healthcare, the military, industrial surveillance, etc., [1, 2, 3]. In this self-organized network, Sensor Nodes (SNs) with limited energy, storage and computational capabilities are randomly distributed [4, 5, 6]. The SNs monitor different factors, which are wind, humidity, temperature, etc., and then forward the data to the Base Stations (BSs) [7].  
One of the major issue in WSNs is security threats. The reason is that SNs are resource constrained and can be easily compromised [8, 9]. Generally, there are two types of attacks that are performed in the WSNs. In external attacks, the attackers take control over the SNs to perform malicious activities, whereas, in internal attacks, SNs behave selfishly to preserve their energy and storage. Consequently, identifying and removing the malicious nodes from the network are crucial aspects [10].  
The blockchain technology is an option to resolve the aforementioned issues by introducing smart contracts where all agreements in the system are written. It was introduced in 2008, and it consists of nodes that keep track of the state of the distributed ledger. In general, there are three types of blockchain network, which are public, private and consortium [11; 12]. The public blockchain is fully decentralized where any node can enter and become part of a fully decentralized network. The private blockchain is a permission based network where only the selected nodes can participate. The consortium blockchain is a semi-decentralized network, which is managed by multiple organizations. The miners in the blockchain verify the transactions through consensus [13; 14]. Different consensus algorithms are used in the network, which are Proof of Authority (PoA), Proof of Work (PoW), Proof of Stake (PoS), etc. In PoW, the nodes solve a mathematical puzzle for the selection of miner nodes in the network, The node that finds the puzzle solution first will add a new block in the blockchain. This puzzle solving requires high computational cost. In PoA, the blocks and transactions are validated by preselected nodes, called validators. Therefore, high computational capabilities for the selection of miners are not required. In PoS, the miners with the most coins validate and mine the blocks.  
A blockchain is an effective way to keep a record of transactions between several groups in a distributed manner [15; 16]. As the blockchain is immutable, no one can tamper with the data. In a blockchain, the transaction data are secure, as the blocks are linked by the hashes [17]. The hashes of the Merkle tree and previous blocks reside in the block header, whereas the transactions are present in the block body [18].  
Without authentication, the intruders utilize the network resources to forge the benign nodes' identities and locations [19; 20]. The presence of intruders in the network has a negative impact on the routing mechanism. The intruders alter the data and transmit incorrect information of the route, which degrade the network's performance [21; 22]. To solve the aforementioned problems, we propose a secure routing mechanism using blockchain based encryption and trust evaluation. The contributions of our paper are given below.  
1. The malicious SNs in the network are identified considering three factors: Forwarding Rate (FR), Response Time (RT) and Delayed Transmission (DT).
2. A routing mechanism is proposed that ensures real time and energy efficient data delivery from SNs to BSs. The ANs act as relay nodes in the data delivery.
3. Secure and reliable data delivery is ensured using the RSA technique.  
The rest of the paper is structured as follows. Section 2 presents the related work. The problem statement and system model are presented in Sections 3 and 4, respectively. The simulation results are discussed in Section 5. The paper is concluded in Section 8.