Spider Web-based Dynamic Key for Secured Transmission and Data-Aware Blockchain Encryption for the Internet of Things

In the developed field of information and communication systems, the utilization of the Internet of Things (IoT) devices is greatly increasing. In their applications, data gathering with limited energy consumption and good security is essentially needed nowadays. The network is energy limited as the sensor nodes are operated using battery power. The nodes in the network are vulnerable to several attacks and the proposed data transmission scheme should provide network security. Security is a main concern in data aggregation. In this work, a secured data aggregation scheme with compression technique and blockchain-based encryption added routing is presented. The data transmitted by the device are added with a hash key generated using a spider web-based dynamic key (SWDK) generation process. The SWDK-added compressed data are transferred in the process of blockchain encryption routing. Then compression-based data aggregation is utilized to reduce the data size and sequentially the transmission cost. The devices in the network transmit data to the base station/server in the network through gateways. The simulation results prove that the proposed work gives reduced transmission cost and energy consumption compared with the existing works. The network throughput increases due to the sharing of security keys, as well as network latency and packet dropping, which are reduced in the proposed work.


INTRODUCTION
The utilization of the Internet of Things (IoT) devices rapidly increased in recent days.Recent applications such as smart homes, health care monitoring, smart grid, and industrial applications are realized using IoT devices distributed across several types of servers and users.IoT employs Wireless sensor networks (WSN) as the major part since they serve effective data transmission with lowcost equipment.The sensors measure different types of data such as medical data, environmental data, vehiclerelated data, location tracking data, home appliancesrelated data, etc.The measured data are transmitted to the respective users by the nodes through a base station (BS) [1].The users then perform the monitoring and controlling processes.Those sensor nodes have to transmit data with high reliability, and excellent performance with less energy consumption as the nodes are limited in computation, storage, and battery power [2].In addition, the WSN faces another challenge which is security in data transmission.The sensor nodes of WSN have limited transmission range and hence they need several intermediate sensor nodes to transmit data to the base station (BS).The WSN is vulnerable to many attacks produced by attackers.In IoT-based WSN, the IoT devices can be attacked easily by malicious users as they are generally installed in an open environment (for example, vehicles, and street lights).As the IoT-based WSNs are complex and the sensors are heterogeneous, the IoT is more prone to threats and attacks.Hence, the functioning of the network is severely affected.
In WSN, the sensed data are transmitted to the BS by forming routes through the nodes.The routing mechanism is performed using some protocols to find the optimal path-based on the shortest distance, less energy consumption, reliable data delivery, etc.In data transmission the routing attacks happened in two ways: attacks in the routes and attacks in the data [3].Touting attacks happen when the wrong routes are selected for data transmission.The wrong routes may consume more energy and have the longest distance.This attack affects the nodes/IoT devices and makes them deplete more energy.Hence, the network lifetime is affected.In data-related attacks, the malicious node corrupts the transmitted data to modify the data or to identify the data.Hence, in WSN data security and routing security are very important to obtain good transmission performance.Many algorithms are presented in the literature for implementing data security and routing security in WSN.In IoT-based WSN, the vulnerabilities present in different areas such as device operating systems, transmission schemes, service application areas, and IoT system designs.With such vulnerabilities malicious users create different types of attacks such as denial of service (DoS) attacks, routing attacks, privacy attacks, and data aggregation attacks [4].Since the complex attacks present in IoT-based WSN, the implementation of a security model to identify the attacks and control their impact becomes a serious concern.However, it is a challenging task to obtain security in IoT due to its inherent features and heterogeneous sensors.Many research works [5][6][7][8][9] have been presented to realize different security schemes in WSNs for IoT applications.The proposed security schemes should provide confidentiality, data integrity, and accuracy and should function against internal and external attacks.
In introducing security schemes in data transmission, the problems of WSN, such as limited energy, limited storage, and transmission cost, need to be concerned.Security in WSN can be attained by adding security keys to the transmitting data through encryption schemes and retrieving the original message at the receiver by removing the security key using decryption.The addition of security keys with data sensed at the sensor node increases the size of the message which, in turn, increases the transmission cost and energy consumption.Usually the BS in WSN maintains a database holding the details of sensor nodes.Along with this database, the security-related table has to be maintained by the BS for retrieving the data.Thus, the storage requirement of the network increases.These drawbacks can be overcome by reducing the number of data transmissions, transmission distance, or data size.When a node directly transmits its data to the BS, the transmission distance is more.Hence, it consumes more energy.To avoid this problem, the data from the sensor node can be transmitted through the aggregator to the BS.An aggregator is a device/node in the network that receives data from its neighboring node and transmits them to the BS or another aggregator.In addition, the aggregator avoids recurrent transmissions to BS and resource utilization.To reduce transmission cost and energy consumption several methods such as clustering methods, prediction-based methods, compressionbased methods, energy-efficient routing algorithms, etc. are presented in the literature.In IoT applications, the devices communicate the data between different users and the communication is centralized.Therefore, the security techniques should be more advanced as the conventional cryptography schemes do not provide better performance in IoT applications.In IoT applications, data integrity and data authentication issues are very severe as they are centralized networks.The cryptography schemes for IoT applications are presented in works [1,3,[10][11][12].Those papers do not give the expected performance.
When introducing security schemes, the network issues, such as energy, memory size, and transmission costs, must be considered.There is a need for low-cost secured data transmission schemes with reduced energy consumption.A secured data aggregation scheme with reduced data size and transmission cost and a route selection strategy to find the best routes for reducing the network's energy consumption is required.In IoT-based wireless networks, data gathering with limited energy consumption and good security is essentially needed nowadays.The network is energy limited as the sensor nodes are operated using battery power.The nodes in networks are vulnerable to several attacks and the proposed data transmission scheme should provide network security.Security is a main concern in data aggregation.The existing methods of secured data aggregation give protection against attacks; still, they suffer from issues such as energy, memory size, and transmission costs.
Blockchain technology is a prevailing tool for implementing trusted communications in a decentralized attitude.It is actually a digital cryptocurrency system demonstrated by Bitcoin core support technology, developed in 2008 [5].Its main advantage is decentralization, and it attains point-to-point transactions, coordination, and collaboration in distributed systems.It implements various means, such as data encryption, time stamping, distributed consensus, and economic incentives.Blockchain is mainly utilized to overcome the problems presented in centralized systems.Blockchain technology is growing fast due to the Bitcoin system that is getting popular.The popular applications of blockchain technology implementation are given as follows.In Ref. [6], a Smart contract application platform is presented that utilized blockchain for distributed computing and sharing software.Fromknecht et al. [7] presented a decentralized Public Key Infrastructure (PKI) which is based on blockchain technology.The authors developed a new Certcoin system.This PKI has the advantages of the Bitcoin and Namecoin systems and assures protection.In Ref. [8], a decentralized peer-to-peer cloud storage network is presented using MetaDisk [9] file storage application which is based on blockchain technology.In Ref. [9], decentralized IoT is presented for software stack, which uses Bitcoin blockchain.Blockchain technology is an emerging technology for cloud computing, and provides many advantages, such as an encrypted chain block structure for validating and storing data, distributed node consensus algorithm for updating data, and automated script code (smart contract) for handling data.Thus, the integration of Blockchain technology with IoT can provide better security, intelligence, and big data storage.For providing security in the wireless network, blockchainbased encryption system is employed in this paper.Here, a secured data aggregation scheme with compression technique and blockchain encryption added routing is presented.
The existing methods of secured data aggregation give protection against attacks; still, they suffer from issues such as energy, memory size, and transmission costs.The devices in the network transmit data to the base station/server in the network through gateways.The data transmitted by the device are added with a hash key generated using a spider web-based dynamic key (SWDK) generation process.Then compression-based data aggregation is utilized to reduce the data size and sequentially the transmission cost.The security-added compressed data are transmitted using blockchain encryption routing and optimized neural network (NN).The proposed routing scheme effectively chooses the best routes for transmitting data securely and with less energy consumption.The simulation results prove that the proposed work gives reduced transmission cost and energy consumption compared with the existing works.The network throughput increases due to the sharing of security keys, network latency, and packet dropping, which are reduced in the proposed work.
The devices in the network read the data and the sensed data are added with a security key generated using a spider web-based dynamic key (SWDK) generation process and ciphertext is formed.This message is then applied with a Principal Component Analysis (PCA) compression scheme before transmitting to the aggregator.Similarly, the aggregator receives compressed ciphertext messages from several nodes and aggregates the message.The aggregated data are forwarded to the BS directly or through other aggregating devices.While forwarding the aggregated data, a blockchain-based encryption scheme is employed to provide security.Then the route selection process is performed optimally using the neural network.
Thus, the proposed method prevents data loss and data integrity issues caused by malicious nodes.It also provides data confidentiality at each stage of transmission; sensing device to aggregating device, and aggregator to the BS/server.The security key and hash function used in the encryption method is verified at the receiver side/user and the receiver identifies whether the received data are obtained from the authorized nodes.Thus, the data received from the malicious nodes are neglected.In addition, the unauthorized receivers/users cannot retrieve the transmitted data as they fail to access the data due to nonmatching security keys.The utilization of compression helps to reduce data size, hence the transmission cost and energy consumption are reduced.At the BS, the decryption process is performed to obtain the data and then the decompression process is applied to obtain the original data.

LITERATURE SURVEY
In the literature numerous works related to IoT-based WSN applications have been presented.The energy conservation-based routing mechanisms for IoT applications have been presented in Refs.[13][14][15][16][17].The authors employed some routing algorithms with data aggregation and data compression methods.In those works, the security concerns in data transmission have not been discussed.Consequently in works [1,[5][6][7][8][9], the securityadded routing protocols for data transmission are presented.Various types of secure routing and energy conservation mechanisms are presented in those papers.
In Ref. [10], sensing-based data gathering is presented which gives energy efficiency.It also employs dictionary learning for manipulating different sensor data.The proposed data aggregation method gives less transmission cost than the conventional compressive scheme.Early Message Ahead Join Adaptive Data Aggregation (E-ADA) method is presented in Ref. [18].Energy consumption and lifetime in WSN can be optimized by using an advance notification scheme.The transmission of an early message is faster than other data.This scheme is used to increase the probability of data aggregation.Then a Delay-optimized Convergence Routing is presented by combining the advance notification scheme and convergence routings.The duty cycle of sensors is dynamically changed to reduce transmission latency.In Ref. [11], the energy-efficient LEACH (EE-LEACH) algorithm is presented using the effective data ensemble technique and optimal clustering approach.The cluster head is selected to reduce energy consumption and resource utilization.For routing, higher energy nodes are selected for forwarding the data.This method gives improves packet delivery ratio performance and network lifetime.Zhang et al. [12] presented novel ring-based in-network data aggregation for WSN.In this aggregation scheme the network is divided into rings and the data aggregation is performed from one ring to another ring.In this work, unicasts multiple aggregated packet copies are used to help to increase reliability.But several unicast packet copies increase energy consumption.If fewer unicast packet copies are used, less transmission reliability is obtained.Hence, the authors presented a fuzzy logic scheme to dynamically adjust the number of unicast packets to achieve better transmission reliability.In work [19], a cluster-based data aggregation scheme is presented to increase the network lifetime.Mobile elements are used as CH nodes in IoT.Thus, the cluster-based data aggregation scheme increases network lifetime.
In Ref. [20], the air pollution monitoring application using WSN is designed.The data transmission in this application is done by allotting a unique identifier (id) to each sensor node.The main sensor node checks this id when the server receives the transmitted data.This scheme helps to ensure data integrity.However, the data can be altered while sending from the sensor node to the server.Therefore, it is essentially required to introduce cryptographic methods to add more security.In the paper [21], the method for preventing denial of service (DoS) attacks is presented.The timestamp-based method and clustering method are employed in the work.The timestamp from one sensor node to another node is computed and the clustering of nodes is done.If the timestamp is larger than the time limit, it can be detected that malicious nodes produced some attacks.Then the transmission is stopped.This method does not use any cryptography technique.In Ref. [22], a secure routing method is proposed which used a double guarantee method to identify the aggressive nodes.Thus, data security is introduced.Haseeb et al. [23] presented IoT-based WSN system for smart agriculture applications.The sensor nodes measure data and form a set of cluster heads based on several criteria.The signal-to-noise ratio (SNR) parameter is measured to obtain reliable data transmission.The transmission in this application is realized through single-hop transmission and the security aspect is attained through symmetric data encryption using recurrence of the linear congruential generator.In Ref. [13], a healthcare IoT application with WSN is designed where the data in the network are shared with the FoG server.An aggregator node in the network transmits the data to the FoG served through several intermediate aggregator nodes.The FoG server receives the aggregated data and stores it in the local space.Then the data are updated on the cloud server.The authors also employ compression algorithms to reduce the transmission cost.In Ref. [1], an IoT-based WSN system is designed for intrusion avoidance.The network used an energy-efficient and secure routing (ESR) algorithm.The network creates a cluster of nodes based on node energy and other features.The security and reliability features are obtained using Shamir's secret-sharing scheme.The proposed security method is a light-weight scheme that avoids intrusions occurred by malicious nodes.
In Ref. [14], an adaptable, secure compressive sensingbased data collection method is presented for distributed wireless networks, which provides better security and improved efficiency.Also, it reduces communication costs.The adaptive method includes a public key cryptosystem and a compressive sensing scheme presented in Ref. [15].In this method, encryption operations are performed using arithmetic functions.In addition, the decryption process has been made easier at the node and the BS can carry out decryption complexities.Zhang et al. [16] presented a Multi-functional secure Data Aggregation scheme (MODA) which performs raw data encoding and multifunctional data fusion.It employs a homomorphic cryptosystem for establishing end-to-end security in the network.Two additional data aggregation methods based on randomly selected encryption and compression have been presented in the work.These methods can reduce communication costs and energy depletion.
A secure privacy-preserving data aggregation model (SPPDA) is presented in Ref. [17] and implemented for wearable sensing devices.It assures privacy at aggregator and sink nodes.The data are divided into two segments using a slicing mechanism.The data are transmitted to two different neighboring cluster heads (CHs) and forwarded to the next CH nodes until the data are transmitted to the sink.This work employs a system to detect malicious nodes using leaf nodes and intermediaries.If the message of an intermediary node is constantly passing through the path and the final data were not validated at the receiver node, then it is considered that the intermediary node is malicious.In Ref. [24], a secure data aggregation method using encryption is presented.In data aggregation method it uses a pair-wise method and data encryption is performed using a lightweight encryption algorithm.The main drawback is the device data are transmitted to the aggregator without a compression scheme which leads to increased communication costs.
Li et al. [25] presented a multi-layer secure IoT using blockchain which splits the network into a multilevel decentralized network and blockchain encryption is applied at each level.In Ref. [26], a block-chain-based model is presented and the model is altered for making it suitable for IoT devices.The performance of this scheme depends on the distributed nature of the blockchain and its security features.In work [27], a data-gathering system for WSN is presented using the blockchain method.This work does not consider data integrity, data security, and data reliability in data transmission.However, encryption schemes are not employed.In blockchainbased methods, the data integrity feature is achieved to a better extent.Nevertheless, data security or privacy is not provided.The content stored in the chain can be accessed by any user presenting in the network.Therefore, a blockchain-based data preserving should be used along with encryption techniques to achieve data security and privacy.Dorri et al. [28] presented the lightweight blockchain-based scheme for IoT.This work reduces data overhead compared to the conventional method.In Ref. [29], a privacy-preserving scheme using a blockchain scheme is presented for IoT-based WSN.Data security is achieved by using the attribute-based encryption (ABE) method.ABE is a simple encryption method that can be used for security and access control.Kumar et al. [3] presented a trust-aware localized routing scheme and a dynamic encryption scheme for WSN.
In a short period, several ML algorithms [30] and approaches are launched to quickly analyze huge data measurements and boost the productivity of the IoT.Similar to humans, machines can recognize trends from a variety of sources in a variety of datasets and make suitable judgments based on their analysis thanks to particular ML techniques such as decision trees, clustering, and neural and Bayesian networks.
To increase dependability and cooperative communication in smart cities, a fault-tolerant supervised routing (Trust-FTSR) architecture for trust management in the IoT network has been developed.For a dependable and efficient network structure, each node assesses the actions of its neighbors and develops direct trust [31].A faulttolerant relaying mechanism is additionally provided by utilizing supervised machine learning without adding any extra overheads.
The above-declared existing methods of secured data aggregation give protection against attacks; still, they suffer from issues such as energy, memory size, and transmission costs.
Each node in the network trust measure is identified for each adjacent node based on the node's participation in data transmission and the number of successful transmissions.The security is realized using the blockchain encryption method and different encryption keys are used for different classes of data.The data are divided into blocks and a blockchain is formed.Then the data are transmitted to the BS.This scheme provides better security and network performance.

Cryptography
In many data transmission schemes, a cryptography scheme is enormously used for implementing security.Cryptography schemes have three algorithms.
1. Key generation (KeyGen) 2. Encryption (Enc) 3. Decryption (Dec) In cryptography public keys and private keys are used which are denoted as PK and SK, respectively.PK is used for encryption and SK is used for decryption.Homomorphic cryptography is a system where it can perform operations over the cipher text of the original text without the details of a decryption key.

Blockchain Encryption
Blockchain is a powerful technology to solve trusted communications in a decentralized method.Blockchain is a cryptocurrency system represented by a Bitcoin support scheme [5].It is a distributed account in the form of a list of blocks.Blockchain is actually developed for storing transaction details in cryptocurrency.It provides reliable currency transfer among untrusted users.Blockchain technology employs several tools such as data encryption, economic incentives, and time stamping.In a cryptocurrency system the data such as payer, transaction date and time, beneficiary, etc., are stored in the record.These datasets are known as blocks and each block is uploaded to the server.These blocks can be accessed by any customer without any trouble.Hence, there is an essential need to add security keys to the data block.A hash function generated by Secure Hash Algorithm (SHA)-256 [32] can be used for the purpose.The hash function is an irreversible algorithm and the hash key can be computed from the source data, but the reverse process of computing the key from the user side cannot be done.When a new block is inserted in the blockchain, the hash key is computed as done in the previous block.The key is stored along with the data in the new block.If an attacker tries to catch the information, the difference between the hash key and the data presents [33].
The difference exists as the hash key of a new block is calculated in association with the key of the previous block.It makes the attackers challenging to discover the hash keys, and finally, security is achieved.The blockchain structure is represented in Figure 1.This technology can be utilized in solving high-cost problems with inefficient and insecure data storage.The utilization of blockchain technology is increased in very recent years due to the fast growth of Bitcoin.In IoT applications, the use of blockchain technology is introduced in some works to improve security and big data management [3,[10][11][12]18].Those works exhibit favorable benefits in data security.

Data Aggregation
In IoT applications, data aggregation plays an imperative role since the data sensed by the nodes are typically heterogeneous and the network consumes more energy to transmit the data.Hence, the data aggregation process is employed to reduce energy consumption.But the heterogeneous nature of sensed data makes the data aggregation process difficult.Therefore, data modeling and data compression techniques can be used.The dataset X = {x 1 , x 2 , . . ., x N } is considered and data aggregation for this set is given as y = F(x) = F(x 1 , x 2 , . . ., x N ) such that y X, where X = x i .* represents the data size.y and F(x) denote statistical results and the data aggregation function, respectively.The sensor data are compressed before transmission and then sent to the aggregation node.The aggregated data are applied to the encryption method and then transmitted to the BS.

PROPOSED WORK
In this work, the compression technique, a blockchain encryption-added routing scheme, is presented.For adding security to the network, the observed data of the devices are added with the security key generated using the spider web-based dynamic key (SWDK) generation process.This process introduces security in the system and the data size is increased which, in turn, increases data transmission cost.To reduce data size, the compression scheme using PCA is utilized before transmitting data to the aggregator.Then the compressed cipher text message is sent from several devices to the aggregator.The aggregated message is applied with a blockchain-based encryption scheme to further improve security.Afterward, the routes for transmitting data from the aggregator to the BS are selected optimally using the neural network and Bacterial foraging optimization algorithm (BFA) [34].
A secured protocol on sensor nodes to offer authentication on each node should be implemented so that only authenticated nodes can access data was the primary goal of this research project.By lowering the expense of risk and security concerns on the network, and communicating with one another, the Algorithm for Wireless Secure Communication (ASCW) is afforded key management with acceptable key length [35].The outcomes of this "hello" text count can be used to experimentally verify the proposed security data.

System/Network Model
In IoT applications, the devices are interconnected through wireless links and connected to the BS.The BS uploads the data to the internet and the users can access the data.The system model is illustrated in Figure 2(a) and the complete blocks of the proposed SWDKbased secured model are depicted in Figure 2(b).This overall block is explained individually in the upcoming sections.
A set of IoT devices installed for certain applications such as smart cities, smart homes, agricultural monitoring, healthcare applications, or any other applications is considered.The sensor devices of IoT can be taken as nodes of the network.Let us consider the N number of nodes in the network and the L number of links.Then the nodes with higher residual energy are selected as aggregators.It is assumed that the number of aggregators is M and M ∈ N .Thus, a network is modeled as a connected

Spider Web-based Dynamic Key Generation
The observed data of the IoT device are added with the encryption key for security purposes.The generation of the security key is explained in this section.A spider webbased dynamic key (SWDK) is produced by designing a spider web constructor unit.The non-uniform spider web is constructed by placing radial lines and spiral lines.The spaces between the lines are fixed and unequal on the web and the displacement distance between the lines is entered according to the user's choice.For retrieving the key, the parameters of the spider web constructor (SWC) unit must be known.The SWC unit works similarly to the behavior of a spider in building an orb web structure.A dynamic spider web construction is developed using non-uniformly spaced radial lines and spiral lines.As the initial development, the sticky silk thread is discharged by the spider to stick on the walls.Then the spider searches for another location for connecting the thread and starts to form baselines in the form of a "Y" shape.Then a supporting structure in a triangular shape is formed.Then the radial lines and spiral lines are formed within the frame.However, in the development of the dynamic web the formation of the "Y" shape is not performed.In dynamic web construction, the user will provide the details of radial line length and angular displacement from the positive side of the X-axis.The radial lines are started from the reference point of the frame.
The angular displacement ad from the reference axis is given by the user and the increment in angular displacement for the next radial line is denoted as ad and given based on user choice.The number of radial lines to be used in the web depends on the values given for variables ad and ad.Similarly the security key is developed according to those values.While receiving the data at the aggregator, the key should be known for retrieving the transmitted data.
As seen earlier, the angular displacement from the reference point for the first radial line is ad and the increment in angle is ad, the consecutive radial line is drawn with the angular displacement of ad + (ad + ad).Also the calculations for determining displacement angle values for different quadrants are made.The construction of radial lines is made until the 360°region of the circular portion is covered.The angular displacements of the radial lines are fixed with non-uniform values, whereas the radius is set equal for all lines.Following the radial The construction of spiral lines starts with setting the initial distance d init from the reference point.Then the spider moves from the reference point up to the distance d init .The incremental distance over the radial lines when forming spiral lines is denoted as d and it is set by the user.The spiral line is drawn in the anti-clockwise direction.Thus, the spider movement for constructing spiral lines of the web is performed based on the distance d init and d.The distance to which the spider travels when moving from one radial line to another radial line is computed as The radial lines and spider lines of the spider orb web are shown in Figure 4.
From the constructed orb web, the security keys are taken from the intersection points of spiral lines and radial lines.The keys are framed by padding the numerical values of intersection points.After creating the security key generated using the SWC unit, the data are added to the key and transmitted by the device.Since the addition of a security key increases the data size, the compression process is employed to reduce the size and transmission cost.
The proposed security scheme does not deal with the generation of random numbers.Therefore, the attacker cannot easily retrieve the key.

Compression-based Secured Data Aggregation
Data transmission in the IoT WSN is performed in two stages in the work.The data measured at a node n is denoted as X n .Subsequently, a cipher text message X n is created by taking the XOR operation between data X n and a security key K n .The security key for adding ciphertext data is obtained using the SWC unit.Then ciphertext data X n is compressed (denoted as CX n ) and the compressed message is received at the aggregator from all devices connected with it.The security key generation using SWDK generator is performed at the sensor device of the IoT system and the aggregator unit of the IoT.The SWDK security key generated at the aggregator and the sensing device will be identical if the values of input variables such as ad, ad, d init , and d given at the SWC unit of the sensor node and aggregator are the same.The key exchange mechanism is performed between the aggregator and the sensor node as explained below.The aggregator generates the SWDK key K n (AG) and sends it to the sensor node.Even though the transmitted key K n (AG) is obtained by the attacker node, it cannot retrieve the key since the user input parameters of the SWC unit are unknown to the attacker.

Pseudo-code: Encryption of
The ciphertext message is compressed using a linear compression function [14].
The encrypted data X n is mapped into a compressed form CX n from a higher-dimensional space into a lowerdimensional space.Here c is the compression factor which is computed as the ratio of the length of X n and CX n .The decompressed data as X n can be recovered using the decompression function.
The decompression process is performed at the BS using the function given in (5).
If devices 1, 2, 5, 6, i, n send data to the aggregator, the messages represented as X 1 , X 2 , X 5 , X 6 , X i and X n are measured by the respective devices.The compressed ciphertext messages for these data are generated and denoted as {CX 1 , CX 2 , CX 5 , CX 6 , CX i , CX n }.
Adding to this, the aggregator receives ciphertext messages from another aggregator which is represented as CX AN .The ciphertext message received at the aggregator contains the message sensed by n and security key K n .Subsequently, the aggregator computes the key K n for received CX n and compares it with the key of the received message.If the keys match, the aggregator accepts the message.Then after checking all messages received from various nodes, the aggregator collects all messages CX 1 ||CX 2 ||CX 5 ||CX 6 ||CX i ||CX n which can be represented as CX.A graphical illustration of this aggregation process is represented in Figure 5.

Block Chain Encryption for the Secure Data Transmission Scheme
Compressed data are transmitted from the aggregator to the BS.During this transmission, blockchain encryption is presented as depicted in Figure 6.In the blockchain, the data are stored in a block along with a dedicated hash value.In the blockchain scheme, a user cannot perform any change on a block without getting permission from In each block of the blockchain, it contains data, a security key and a pointer value.The block with data and security key is added to the chain.The blocks are allocated with the signature that is established with the receiving node.Each block contains a pointer to the former block.A block of data in its encrypted format is added to the previous blocks having the data records.Thus, a chain of blocks (blockchain) is formed that shares data among different users.The data received at the aggregator is stored in the blockchain database before transmitting to the BS.For storing the data in the blockchain, the data are separated into blocks and for each block, the security key is added to encrypt the data.Based on the data type class, the different security key is selected from the list.The attackers fail to retrieve the original data without knowing the key.The use of data-aware encryption helps to use different types of keys based on the data type.Thus, the more significant data are provided with extensive security keys.In addition, the key size can be altered.For less significant data, the key size with fewer bits can be assigned.The key size can be dynamically varied based on some factors such as the significance of data, exposure of data to the attacks, and compromising ability.Thus, for the data requiring less security, a small size of security keys can be assigned.This mechanism helps to reduce the data size.
A data CX at the aggregator are divided into blocks.
The data in the blocks can be represented as b 1 (CX), b 2 (CX), . . ., b j (CX) where j denotes the number of blocks.The data blocks are classified and denoted with their classes as Cb 1 , Cb 2 , . . ., Cb n .Then the security keys selected according to the class of data are added and the data block is now represented as Cb 1 _K(C), Cb 2 _K(C), . . ., Cb n _K(C).The final data with the pointer to the previous block and the hash code in the blockchain are represented as FD 1 , FD 2 , . . ., FD n .Final data FD i consists of Cb i , K, P, H where K, H and P denote security key, hash code and pointer, respectively.FD i data are stored in the block and the BS receives this blockchain containing a series of data FD 1 , FD 2 , . . ., FD n .
The data of the aggregator A 1 are represented as CX(A 1 ) and they are transmitted to the next hop aggregator node A 2 .The number of packets in data CX(A 1 ) and CX(A 2 ) can be represented as m and n, respectively.At the initial processes, only m number of packets is transmitted to the next hop aggregator.After transmitting m number of packets, the transfer message is sent to the token contract.The transfer message consists of several transmitted packets, next hop aggregator, device ID, route address and timestamp.Then the message on the token contract is verified and the n number of packets is transmitted to the next hop aggregator.On the arrival of confirming message, the token verifies the number of packets.This token transaction process is performed using the authenticated server with the blockchain network.The unauthorized token transactions are avoided and not registered in the block chain network.The blockchain-based data transmission scheme provides a secured transmission process for IoT networks.
The overall procedure involved in the newly proposed SWDK-based data security technique is described in Pseudo-code representation below.i. for i = 1:N // every sensors ii.K n = K n ; iii.X n (i) = CX n ⊕ K n ; //retrieve original data iv.end for g. end if 9. end procedure 4.5 Data Receiving at the BS BS interprets the hash code and checks the code to decrypt the message to get back the actual data from the block.Then, the block is checked with the previous block number and the finishing of the chain.Decrypted data blocks are merged to retrieve the original message received at the AN.The hash code is verified and if the received hash code is equal to the hash code sent with the block, the data are taken.Then the data are decompressed using Equation ( 4) and then decryption is done to get the original message individually.The security key shared with the BS is taken and XOR operation is performed between CX n and the shared key K n .Subsequently this process is performed as a loop operation from count 1 to N for retrieving the data from all nodes involved in transmission.

SIMULATION RESULTS AND ANALYSIS
A heterogeneous network with 50 × 50 sensor nodes is deployed and simulated in MATLAB software.The nodes sense different types of data and transmit it to the BS through ANs.The IoT devices of the application are taken as the sensor nodes and a network is formed.The network is simulated with the proposed data aggregation and transmission methods.The security scheme, compression algorithms, the blockchain-secured storage scheme and the homomorphic encryption process are implemented.The simulation results are checked and compared with the existing methods.Energy consumption, transmission cost, storage cost, network throughput, packet drop ratio, and transmission ratio parameters are evaluated.The proposed work is compared with the existing literature works such as EHDA [13], TDFS [3], and energy-efficient secure IoT [23].The simulation results are illustrated as follows.
Figure 7 represents the storage cost observed for the proposed transmission scheme.The analysis is made by choosing different security key sizes as 32-bits, 48-bits, and 64-bits.The number of selected ANs also varied in the result analysis.The storage cost is computed by multiplying the number of keys with the key size.The below graph shows that the increased key size obviously increases the storage cost.But the use of a larger size encryption key ensures that the node cannot be easily compromised by the attacker.Therefore, the use of a larger size key is always recommended.However, it increases the storage cost.From the figure it is inferred that when the ANs in the network are more, the storage cost is high.The reason behind this is the number of ANs increases the number of transmissions from AN to BS.Since the proposed work uses security at two stages, the utilization of security keys in transmissions increases.Therefore, the storage cost increases with more ANs.
Figure 8 shows the effect of compression ratio on storage cost.The number of ANs is changed and the results are analyzed.When the number of ANs is more in the network, the storage cost increases, as shown in Figure 7.But it is necessary to use more ANs for obtaining better accuracy.Therefore, an effective way to reduce storage costs even under the use of more ANs is to reduce data size.Thus, when a compression algorithm is used in transmission, the data size is reduced.As a result, less storage is consumed.When the compression ratio is increased, the data size can be reduced considerably.
The performance of the compression algorithm is evaluated for different key sizes.For providing excellent security, the key size should be large.However, it increases the data size and the application of a compression scheme helps to reduce data size.This can be observed in Figure 9.When compression is not applied there is a massive difference in storage cost for the utilization of 32-bit size key and 64-bit size key.The application of compression substantially reduces the storage and the difference is very less as provided in the graph for an 80% compression  ratio.The effect of the various ANs with and without compression is also depicted in Figure 10.
Transmission cost is another parameter used to evaluate the performance of the system.For transmitting more packets, the transmission cost is high.When a large size key is used in encryption, the data size increases and hence the transmission cost.The application of compression reduces transmission costs by reducing the data size.In addition, the compression is applied at the sensor node only, not at the ANs.So, the more ANs increase the transmission cost.Still, the use of large ANs ensures that all the sensed data are transmitted without missing.
When the number of transmissions and data size increases, the energy consumption of the network also rises.Energy consumption is an important parameter  for validating energy-efficient transmission schemes.The energy consumption parameter is compared with EHDA [13], TDFS [3], and energy-efficient secure IoT [23].In Ref. [3], the trust-aware scheme and blockchain encryption security are presented.In that work, the security keys are employed in each block and the data size is increased.Therefore, the energy consumption for transmitting large-size data is more.In the paper [23], the clustered-based WSN is used which uses an energyefficient algorithm to reduce energy consumption.In the proposed work, the security keys are used at two stages of transmission.Still the use of a compression algorithm reduces the data size, thereby reducing energy consumption.Furthermore, the data-aware blockchain encryption scheme selects the keys based on the data type.With this mechanism keys with less size can be used for the data with fewer security factors.For the proposed work, if compression is not used, the energy consumption is more, as shown in Figure 11.In the utilization of security key sharing in encryption and decryption, the method provides secured connectivity throughout the network, which provides stable network connectivity, and, therefore, the network latency is less.The graph showing network latency analysis is given in Figure 13.The utilization of ANs assures that all data are forwarded to the BS.Hence, more ANs help improve network throughput.The comparison of network throughput for different methods is depicted in Figure 14.
An example from the ASCW concept [35], the SWDKbased data security model is also verified and the test bench parameters are considered similarly.The experimental analysis of our model considers the computation  of key generation for sensor nodes, which provides outcomes approximately equivalent to that of the previous approach.The graphical and tabular displays of the information gathered while viewing the interaction between the SN1 and SN2 sensor nodes.If the "hello" text transfers from SN1 to SN2, then the count is added as 1.Likewise, nine "hello" messages are required to communicate between two nodes of the same type via a vigorous node.
In Table 1, the count for the "hello" message sent to various types of network nodes is tabulated.It also demonstrates that when the number of nodes is odd, the count will be low.Similarly, the number of "hello" message sent is higher, when it is even.Also, Figure 15 displays graphically the number of "hello" messages sent for various sensor nodes.
The reason for this is that while pairs of nodes have already been established in the network when an even number of nodes talks with one another, pairs of odd numbers of nodes may occasionally exchange pointless "hello" messages.The second experimental finding was the total number of packets sent during the communication between two nodes of the same type.The total amount of packets sent on nodes during the connection is shown in Table 2 and Figure 16.Every time SN1 and SN2 need to connect, SN1 must assist them; extra-packets can be transmitted while authenticating the nodes and establishing the pairwise keys needed for inter-node communication.
To compare the newly implemented SWDK-based security scheme with the state-of-the-art protocols, the security analysis based on the aforementioned parameters has been carried out.

CONCLUSIONS
Secure data aggregation in IoT-based WSN is significantly important.The complete processing systems of data collection, aggregation, encryption, routing, and decryption are described.Also in this work, key generation using SWDK and compression-based secure data aggregation are presented in the encryption module.Furthermore, data-aware block chain-based encryption and decryption methods are applied to provide additional security, while transmitting data from the aggregator to BS.The data-aware encryption helps to use different types of keys based on the data type.The more significant data are provided with strong security keys.The addition of a security key with sensed data and aggregated data prevents unauthorized users from accessing the data.Thus, the attackers fail to retrieve the original data without knowing the key.The performance of the network is validated by analyzing the transmission cost, storage cost, energy consumption packet drop ratio, network latency, and throughput parameters.The simulation and implementation results prove that the proposed scheme contributes to improved performance compared with the existing works.

DISCLOSURE STATEMENT
No potential conflict of interest was reported by the author(s).

Figure 1 :
Figure 1: Structure of the blockchain scheme

Figure 2 :Figure 3 :
Figure 2: (a) System model illustration.(b) Complete secure model of the Proposed IoT system

Figure 4 :
Figure 4: Construction of Spider orb web

Secure Data 1 .
Start 2. Data at node X n .3. The cipher text message X n 4. Data are encrypted using XOR operation with the key K n : X n = X n ⊕ K n 5. Compressed cipher text CX n 6. end

Figure 5 :
Figure 5: Compressed secure data aggregation from the sensor node to the aggregator

Figure 6 :
Figure 6: Blockchain encryption and data transmission from the aggregator to BS

Figure 7 :
Figure 7: Storage cost for different key sizes and the number of ANs

Figure 8 :
Figure 8: Effect of compression on storage cost

Figure 9 :
Figure 9: Effect of compression ratio for different sizes of keys

Figure 10 :
Figure 10: Impact of compression on a varying number of ANs

Figure 11 :
Figure 11: Energy consumption vs network size

Figure 12 :
Figure 12: Comparison of Packet drop ratio for different methods

Figure 13 :
Figure 13: Comparison of network latency for different methods

Figure 14 :
Figure 14: Comparison of network throughput

Figure 15 :
Figure 15: "Hello" message count for the proposed concept

Figure 16 :
Comparison of the number of network packets sent on nodes