TY - JOUR AU - Pina, Alberto Bonastre AB - Introduction Wireless sensor networks (WSNs) are multi-hop self-organizing network systems that consists of many low-cost wireless sensor nodes (SNs) connected through wireless communications. The purpose lies in supportively perceiving, collecting, and processing the information of predefined variables in a monitoring area and transmitting it to a base station (BS). As a significant part of the Internet of Things (IoT), WSNs play an important role in many applications, such as medical and health related-treatment, national defense, environmental monitoring, and smart homes. In most cases, the SNs are operated by a battery and cannot be recharged. Moreover, the SNs may be positioned in hard-to-reach or inaccessible environments and are anticipated to stay operating for several months or years. Therefore, mechanisms to reduce the energy consumption of these nodes and maximize the network life cycle have lately attracted the attention of many researchers [1]. In addition, most of WSNs are defenseless against security threats and pose several security challenges [2]. Therefore, security in WSNs and IoT is a crucial and not easy problem [3]. All security mechanisms require certain resources for their implementation, such as code space, data memory, and energy to provide power to sensor, but these resources are very limited in small wireless sensors [4]. One type of security technology is a blockchain (BC). The security of blockchain systems is vital for potential users [5]. BCs have attracted researchers’ attention, as they believe that this technology will bring about extraordinary changes and opportunities in the world of industries. BCs are seen as a very robust technology for resolving trusted communications in a decentralized manner. This technology was introduced in 2008 by Nakamoto [6], and has been circulated by the encryption postal group. The basic power of BC is decentralized, allowing direct transactions point-to-point. It is possible to use this approach in distributed systems, since trust is not required for nodes to perform transactions, because a third party is no longer needed in a blockchain [7]. The definition of blockchain is a chain of valid transaction blocks, wherein each one contains the hash of a previous block in blockchain. After verifying the transaction, it is broadcasted to network and added to each blockchain copy. A blockchain is fundamentally a decentralized, distributed, shared, and immutable database ledger that stores registry of assets and transactions across a peer-to-peer (P2P) network [8]. Clearly, the advantages of BC technology can be listed as follows [9]: Security: Neither node nor anyone else, except transmitter and receiver can have access to data transmitted via BC. Removal of intermediaries: The peer-to-peer nature of BC requires no intermediaries. Immutability: Nothing on the BC can change, and any confirmed transaction cannot be altered. Permanence: A public BC acts as a public ledger. If the BC remains active, data will be accessible. Speed: According to [10], transactions are quicker than centrally controlled ledger. because Blockchain removes any third-party intervention between transactions and removes mistake and make system efficient and faster. Generally, a block contains a timestamp, key data, previous and current block hash, and a set of transactions, which is a piece of data representing an operation that some users want to carry out. Fig 1 illustrates the structure of block. When executing the transaction, it is hashed into a code and then broadcasted to each node. Since thousands of transaction records can be contained in block of each node, the BC uses the Merkle tree function to generate final hash value, which is also the root of the Merkle tree. This final hash value will be recorded in the block head the hash of the current block, with the Merkle tree function, computing resources, and thus the data transmission can be greatly minimized [11]. Blockchain provides authentication, confidentiality, and integrity through its distributed ledger technology. The distributed ledger is a shared database that is maintained by a network of computers. Each computer in the network stores a copy of the ledger, which is updated whenever a transaction occurs. This ensures that all copies of the ledger are identical and up to date. The authentication process in blockchain is based on digital signatures and cryptographic hashes. Digital signatures are used to verify the identity of the sender and receiver of a transaction, while cryptographic hashes are used to ensure that the data stored in the blockchain has not been tampered with or altered in any way. The confidentiality of data stored on the blockchain is ensured through encryption. All data stored on the blockchain is encrypted using public-key cryptography, which makes it impossible for anyone other than those with access to the private key to view or modify it. Finally, blockchain provides integrity by ensuring that all transactions are immutable and cannot be reversed or modified once they have been added to the chain. This ensures that all transactions are valid and trustworthy, as any attempt to alter them would be immediately detected by other nodes in the network [12]. Download: PPT PowerPoint slide PNG larger image TIFF original image Fig 1. Blockchain structure. https://doi.org/10.1371/journal.pone.0285924.g001 Adopting a energy-intensive and computationally intensive Blockchain technology across all participating nodes of the wireless sensor network to maintain data integrity and privacy will not be easy, as sensor nodes have critical constraint that must be addressed. Most researchers have agreed that WSN nodes/IoT nodes have 3 major limitations, as follows: battery capacity, computing hardware [13,14], and memory. This will create complexity in achieving security features in such systems. Hence, they would not be fast enough to carry data securely in real-time [15,16]. The above-mentioned points represent the challenges faced by WSNs in general, and during the BC technology implementation process in particular. From an initial point of view, the main cause of power consumption is the process of transmitting and receiving data; hence, the greater the volume of data, the higher the power consumption, because the transmission and reception time will be longer. In addition, the longer the distance between transmitter and receiver, the higher consumption. Moreover, data processing is also an important factor in energy consumption. Data processing includes the following: Creation block Mining (obtaining a consensus) Hash generation Creation of encryption keys Encryption process and using complicated algorithms Therefore, the first solution to save energy is to minimize the size of transmitted data by compressing the data. Developments in data compression algorithms have become indispensable in multimedia and communication applications. As is known, there are two main types of compression algorithms: lossless compression and lossy compression. Lossless compression is used for applications that require an exact reconstruction of original data, while lossy compression is used when user can tolerate some differences between the original and reconstructed representations of data. Due to the limitation of memory and processor speed, many compression algorithms are unsuitable for embedded real-time environments, mainly on the SN [17,18] due to the size of the algorithms; for example, the size of bzip2 is 219 KB and the size of LZO is 220 KB [19]. Therefore, to overcome these problems, energy-saving compression technologies have become a requirement [20,21] being imperative to design an algorithm capable of low-complexity and small-scale data compression for sensor networks [19]. Compressive sensing (CS) is a recently introduced simultaneous data sensing and compression mechanism that performs by sampling randomly at a sub-Nyquist rate. In this situation, the sample time signals can be totally recovered when they are adequately sparsely dispersed in the frequency domain [22]. In addition, from the information security point of view, compressed sensing has received much attention due to the fact that compressed sensing can be regarded as a cryptosystem to attain simultaneous sampling, compression, and encryption when maintaining the secret measurement matrix [23]. This way, CS can provide secrecy if the sensing matrix is changed for each measurement [24]. Thus, this type of cryptosystem can be compared with a One Time Pad system as the private key to encrypt and then decrypt a message is used only once time. In this work, it is aimed to substitute the sequence of random sampling by a deterministic chaotic sequence, as the latter mimics or approximates randomness in only few steps. This effective approach to semi-random sampling across chaotic sequences first emerged in the study by [25]. Besides that, the mathematical theory of chaos can help us in this work. A chaos system is a nonlinear system governed by deterministic equations that has an unstable structure, so that its output acts randomly in only a few steps under particular initial conditions and control parameters [26]. Due to the many intrinsic properties of chaos, such as sensitivity to initial conditions, broadband and orthogonality, and the fact that chaotic signals can be created by low power, low cost, and small area electronic circuits, the use of chaos in communication and engineering has gained a great deal of attention [27–29]. Furthermore, since chaos is just a deterministic equation [26], it is possible to implement chaos on hardware very cheaply. This is because the integration center is able to generate a deterministically transmitted chaotic sequence when the parameters of chaos are known, whereas with random sampling, unstandardized sampling time instants should be sent to the integration center with the time of arrival data [26]. Chaos-based hardware can be employed to optimize system performance by providing a variety of efficient methods to process data. This is because chaotic systems are able to process data faster than traditional methods, leading to improved performance. In addition, increased security by implementing chaos in hardware can help protect against malicious attacks by making it more difficult for attackers to reverse. This is because chaotic systems are highly unpredictable and difficult to model. Finally, reduced cost implementing the chaos in hardware can reduce the cost of a system by eliminating the need for expensive components such as processors and memory chips. This is because chaotic systems require fewer components, which can lead to cost savings [30,31]. So, CS by chaos achieves a cryptosystem simultaneous to data compression. The chaotic system parameters are used as secret key in constructing measurement matrix and masking matrix [32,33]. Therefore, this works studies the reduction of energy consumption of WSNs while ensuring security thanks to blockchain technology. This solution is based on a dedicated circuit design that works on the basis of chaos theory’s principle of the compressive sensing to generate a hash value, data compression and data encryption. The use of hardware-implemented chaotic operations for hash computation is well suited. It provides the recommended statistical properties of the generated random numbers using deterministic formulas, resulting in reduced hardware complexity while preserving reliability compared to probabilistic methods for hardware random numbers generation. In addition, fixed-point hardware is possible when using deterministic formulas, which means further reduction in hardware complexity [34]. As a result, there is no longer necessary to add an algorithm to encrypt data which consumes a lot of resources in terms of time and energy. To demonstrate the advantages of our hardware approach, we will measure and compare the power consumption and WSN lifetime with respect a WSN provided with traditional blockchain functionality without our dedicated circuit. Moreover, the results will also be compared to a WSN with blockchain implementation and CS techniques implemented in software. The rest of the paper is organized as follows. Section 2 contains the state-of-the-art of research focused on solutions for minimizing energy consumption in WSN with blockchain. Section 3 presents the proposed system and implementation of the dedicated circuit using a field-programmable gate array FPGA. Section 4 presents the experiments and results. Finally, Section 5 contains the conclusions and future work. State of the art This section reviews the most relevant research that has provided solutions to minimize energy consumption in BC implementations for WSNs and presents the most important aspects that researchers have achieved in this field. In [35], a secure framework is presented using a smart contract (Ethereum) to choose a cluster-head (CH), which can be combined with the blockchain model for mapping a cluster head. They obtained low energy consumption results when compared to existing WSN network approaches. In addition, they ensured that the data were securely transferred from the sensor node (SN) to sink by cluster-head and integrity of the decentralized database. This model was divided WSN nodes into clusters, each with a number of nodes, one of them being a master node that receives a large amount of data. The remaining nodes in the network (cluster) perform several tasks at the same time. One of them is to send the same information to the master node and mine it directly on the blockchain. The master node, on the other hand, oversees the authenticity of the obtained data by comparing it to the data stored on the blockchain. These researchers provided a new vision of security by utilizing many of the benefits of the blockchain in order to avoid most of possible security problems. In the encryption process, the researchers used public and the private key. The main drawback of this process is the high energy consumption in encrypting and decrypting. Also, the process of verifying transactions occurs in the master node and other nodes do not interfere. This represents one of the issues faced by wireless networks that would result in traffic congestion. In [36], the use of Blockchain technology was proposed to defend against malicious attacks in IoT networks to transfer wireless energy using the consensus algorithm. The authors provided a lightweight consensus algorithm based on delegated proof-of-stake (DPoS), to provide substantial energy loss reduction with minimal operating overhead. To design this system, they proposed a new distributed and secure wireless power transfer architecture that included two planes, including energy plane and blockchain plane. In blockchain plane, the devices static energy transmitters acts as miners and responsible for managing blockchain instead of establishing blockchain in the entire network, so that the energy-constrained smart devices had less overhead. The results obtained from their proposal includes energy loss reduction, due to the choice of high-power transmitters to manage the blockchain, which resulted in the time taken for the specified power transmitters to reach consensus being shorter. Furthermore, the probability of a transaction confirmation failure among the specified power transmitters was less. This confirmed the potential energy security gains in terms of energy loss using the DPoS-based blockchain. The researchers presented a strategy to reduce power loss due to the different traffic flows, but the size of the data still presents a power consumption concern, but the amount of data still presents a power consumption concern. After each round of the consensus process, the reward method is adopted. This can encourage some nodes to hold the bids while other nodes do not. In [37], the red deer algorithm (RDA)-based clustering technique was presented with blockchain—enabled secured data transmission, which was named RDAC-BC. The RDAC- blockchain technique was first initialized, and then the derived fitness function was used to create clusters. The fitness function in the RDAC-BC model was only based on the capacity, power density, node density, distance to nearby nodes, and distance to the sink. Following the completion of the cluster-head election process, a blockchain -based encrypted communication process was initiated. The experimental validation of the RDAC- blockchain technique was evaluated in a number of ways, and the findings were compared to the established methods. This technique performed better energy efficiency, obtained minimum energy consumption, and exhibited a higher network lifetime when compared to other algorithms, such as the genetic algorithm, and Ant-Lion optimization (ALO) and Grey-Wolf optimization (GWO) algorithms. Energy consumption remained huge due to the large volume of energy consumption in the data transmission and reception processes, as well as in processing. This represented a load on the processor of the node, which in turn also resulted in the nodes consuming more energy. In [38], a proposal to combine blockchain technology with a multiple-collaborative base stations to increase the energy efficiency of WSNs was presented. This proposal can be summarized as a energy-efficient clustering approach based on blockchain technology for WSN networks. In this model, each base station maintained a blockchain to provide consistency of the stored data and network lucidity. This allowed the user to access the status of the nodes that allow it. User could also verify data reliability when multiple base stations in network shared the same data using blockchain technology. All the messages sent between the nodes, users, and the base stations were considered as transactions. Although this proposal provided improved energy efficiency using the clustering approach, it did not provide a solution to reduce the power consumption caused by the volume of data transmitted. In addition, this approach suggested that a cluster key is generated for each group instead of creating keys for each node of the cluster. The generation of keys and hash by software required high power consumption. In [39], to minimize power consumption and enhance battery life, a load-balancing multi-hop (LBMH) routing and private communication blockchain platform was developed and tested using a constant bit rate. In this system, it was attempted to design a private blockchain in order to secure data. In this framework, the sink node was responsible for authenticating the participating sensors nodes and it stored the node ID, along with the anonymized blockchain node IDs. To ease the cluster-heads while retrieving the public keys it also stored all of the public keys of all of the participating SNs. All of the cluster-head updated the IDs and private keys of the blockchain to the sink. During the route discovery from the cluster-head of the source to the sink node, the sink stored the reverse route information to the source. Hence, the sink did not need to re-discover the route to the cluster-head again, as long as the routes remain valid. The researchers used a constant bit rate (CBR) mechanism to reduce power consumption, and the nodes used were divided into two types: cluster heads, and sensor nodes. Cluster heads have more energy than the second type. The researchers used the SHA256 algorithm, which is complex and therefore energy-intensive. This will represent a burden on the network. In [40], linear network coding (LNC) for WSNs was introduced with blockchain -powered IoT devices to increase the efficiency in terms of the number of live nodes, packet distribution ratio, and optimized residual energy. The architecture of the proposed model included the selection of an appropriate cluster head using K-means, encoding using the LNC, and security through the blockchain network. In this model, the gateway was responsible for data reception and forwarding to the blockchain network. The WSN network and gateway were connected through the base station. The sensor data were inserted into the blockchain network using the consensus mechanism. The application layer retrieved data from the blockchain network and performed the data analytics to initiate the appropriate actions in the applications of the smart cities. Researchers used the LNC encryption algorithm to increase the WSNs efficiency in terms of the live node number. In addition to the issue of data size in its transmission and the associated consumption of energy, the researchers have not addressed complexity challenges in the blockchain. In [41], a blockchain-based protocol was suggested for WSNs to achieve service immutability, availability, and network transparency by using a cooperative multiple-base–stations network to minimize the likelihood of network failure triggered by any attack on the BS and reduce energy consumption. It is attributed that most of the energy is lost in transmitting data to base station. This research presents solutions to reduce energy consumption in sensor networks with blockchain technology. These solutions consist of proposing protocols to balance energy consumption between network nodes and this research suggested using cluster heads with special specifications to extend the network lifetime. In this proposal, the encryption process is accompanied by high energy consumption and computing load. In addition, there is a high energy consumption due to the exchange of keys in the encryption process and in the software generation of the hash. Finally, data transmission still costs high energy consumption. Table 1 compares the approaches according to their objective, the mechanism for achieving it and the security methods. Download: PPT PowerPoint slide PNG larger image TIFF original image Table 1. Comparison of the proposed survey models. https://doi.org/10.1371/journal.pone.0285924.t001 To conclude this section, it is worth noting that none of the previous studies offer improvements in data volume reduction or the blockchain complexity in hash creation, which are one of the most important challenges for energy consumption. None of the studies evaluated the benefits of hardware compression and lightweight encryption improvements. These techniques could bring new opportunities for the application of blockchain in resource-constrained systems. Proposed system In this section, the dedicated circuit to provide a solution when implementing a blockchain in a WSN is described. This circuit will be in responsible for performing data compression and security functions (blockchain related functions) to reduce the load on node processors and reduce energy consumption. The compression process uses signal compression technique with chaos to select samples, considering encryption at the same time, while the authentication operations include generating the hash. Operation of the Blockchain-WSN with the dedicated circuit This subsection describes the basic operation of the blockchain-WSN on which we will evaluate the feasibility of our proposal, i.e whether our circuit makes possible to use BC technology in WSN. So, the designed circuit will be included in each of its nodes to obtain the results. Basically, the WSN architecture follows the well-established proposals in this area. This way, it follows a structure based on clusters, with cluster heads and sensor nodes. Several routing protocols can be used [42], especially those that generate less complexity and save energy. In this sense, it is suggested a protocol such as Leach to select cluster heads dynamically [43–45], as shown in Fig 2. This routing protocol was selected for our evaluation. Download: PPT PowerPoint slide PNG larger image TIFF original image Fig 2. Network topology [44]. https://doi.org/10.1371/journal.pone.0285924.g002 The blockchain paradigm on the WSN network is proposed as a communication procedure among cluster heads, as well as between cluster heads and the base station in a WSN. Data from sensor nodes is sent encrypted and compressed to the cluster head which will add it to the blockchain. As explained in [44], when nodes join the network or when changes are proposed to present blockchain frameworks in order to establish the blockchain P2P network, the topology building is connected to peer discovery and neighbor selection. The node randomly selects a number between 0 and 1 during the cluster creation stage. Then it compares this number to the threshold value t(n), and if the number is smaller than t(n), it advances to the cluster head position for this round. Otherwise, it becomes a common node. The cluster-heads CHs create a list of the associated sensor IDs to begin data collection. The sensor nodes send the data compressed and encrypted to the cluster-head using the compressive sensing. When the cluster-head receives this compressed and encrypted data it waits until it collects all the values from its associated nodes and then builds a block of at most 1000 bits to reduce the processing load in cluster-head and reduce the time to send and receive data. If the number of associated nodes of CH is N, the cluster head waits until it receives the N readings, one from each node in its domain. If the cluster-head receives N readings, it assumes that the data is ready to form a block, as all associated nodes have already sent their data. However, if one or more of nodes fails to send its reading for any reason, the cluster head will form a block after a specific waiting time. If the data (block) are sent by another CH, it is transmitted without any other operation because this block has already been generated previously, as shown in Fig 3. Download: PPT PowerPoint slide PNG larger image TIFF original image Fig 3. Flowchart of the data flowing into the network. https://doi.org/10.1371/journal.pone.0285924.g003 The block information will not be considered as reliable unless the majority of the network partners decide its authenticity. In the authentication process, a considerable group of the network members have to recognize the current hash of the block and the previous hash keys, which were included in the block. Each block contains data and initial parameters used in the chaos equation to generate the hash. If the network nodes agree by majority (50%+1) it means that the block is authentic and will be added to chain. That happens when cluster-heads exchange acceptance/rejection messages among each other. Each node in the network has its own ledger to store the authentic blocks. Hence, each node is able to check if the current block has the necessary information about the previous circulating blocks in the network. Inserting a block in the network is like a bid that the network member has to make, as this bid has to wait for the decision of other members to accept or reject it. The cluster head bids a new block of information, and the well-known consensus algorithm Proof Of Stake (POS) is used for authenticity [46]. To prevent bids from overlapping, the base station creates a schedule of bids sent by the cluster-heads and works according to the principle of First Come First Serve (FCFS) instead of the mechanism of traditional POS. The consensus algorithm is applied to the consensus depending upon the proposed authentication criteria. To select the CH that creates a new block, CHs send offers to BS. Here, BS creates a schedule of bids sent by CHs and works according to the principle of FCFS. This is to ensure equality among cluster headers for creating a new block and to avoid the control imposed by some nodes in creating blocks. The consensus algorithm is applied on a consensus basis according to the proposed authentication criteria. After creating a bids table in Bs, the Bs send a request for all CHs to listen to the CH that wins a bid, which sends its block for other CHs to validate the block. The cluster head, which creates a new block, will send it to all cluster-head node neighbors. Each cluster head node transmits the new block to all of the Sensor nodes in its cluster. As a result of the second stage, the current version of the blockchain will be stored on all of the nodes. This is because each node is allowed to be a cluster-head in other rounds. Blockchain security is based on two phases. The first comprises encryption phase, based on compressed sensor. The second comprises transaction authenticity. In the authentication phase, as shown in Figs 4 and 5, the dedicated circuit generates a hash value, and it is also responsible for authenticating the new block. Fig 4 shows that when Sensor node senses the data, the circuit creates a chaotic sequence, depending on the parameters, to start the sampling process to simultaneously compress and encrypt data. Upon receiving the compressed and encrypted data, the Tx block is generated by cluster-head, produces the chaotic hash code from the dedicated circuit, and then transmits the control parameters within the new block, as shown in Fig 4. Download: PPT PowerPoint slide PNG larger image TIFF original image Fig 4. Security system model: Hash creation and block generation. https://doi.org/10.1371/journal.pone.0285924.g004 Download: PPT PowerPoint slide PNG larger image TIFF original image Fig 5. Security system model: Authentication process. https://doi.org/10.1371/journal.pone.0285924.g005 In the receiver, the hash value is generated again by entering the message and the control parameters that are explained in more detail in the next section. L, α, and X0 are sent within the block to the dedicated circuit to generate again the hash value as in [47], and the resulting hash value is compared with the current hash value. Hence, the parameters are entered into the dedicated circuit, the chaos sequence is generated again, and the hash is obtained to determine block authenticity. In addition, the hash value of the previous block, which was included in the current block, enables the other nodes to determine the source authenticity by comparing the ‘previous’ hash with their own ledgers. If both tests are passed, then the node will vote to accept the current block. If a node accepts a certain block after the authenticity process mentioned above, it will add it the chain stored in its ledger. Therefore, it will be considered as a ‘previous’ block in the next round. Once accepted by the block, it will be added to the blockchain in the ledger of each node, as shown in Fig 5. Circuit design and implementation In this section, the two main function of the dedicated circuit are presented: the signal compression and the hardware-implemented algorithms for encryption and hash generation. Signal compression The first function of the designed circuit is to compress the data based on the chaos theory for sampling. CS requires random sampling. Usually, uniform, Gaussian, or Bernoulli distributions are used. However, generating these random sensing matrices is complicated and requires high memory storage [48]. An alternative and less complicated way to generate these sensing matrices is to use chaos, which is generated using a deterministic approach with a few parameters that can be controlled by the sending and receiving parties. Reduced complexity is essential in WSNs with limited resources. In addition, the use of chaos introduces a level of security due to the sensitivity of chaos to its parameters. The control parameters consist of three values: length of the chaotic sequence L, α, and the initial value X0. They control the determination of the outputs of the chaotic system by certain initial states of these parameters. These chaotic equations are created through a simple chaos system, comprising the logistical map determined by Eq (1). (1) The sampling rate is reduced based on the chaotic sequence of the original signal by matching the sequence numbers resulting from the chaotic map and the signal indicator to determine which samples should be sent as a compressed signal according to the following Algorithm 1:  Algorithm 1. Signal compression using chaotic logistic map.  Input: Input L, α, b, d, sos, v[], x[0]  Output: Y (compressed data)   1: for i = 1: L-1   2: x[i] ← α x[i-1] *(1-x[i-1])   3: end for   4: for i = 0: L − 1   5: x[i] ← b* (x[i]+d)   6: end for   7: i = 0   8: while (i