Efficient and Secure Key Distribution Protocol for Wireless Sensor Networks

Modern wireless sensor networks have adopted the IEEE 802.15.4 standard. This standard defines the first two layers, the physical and medium access control layers; determines the radio wave used for communication; and defines the 128-bit advanced encryption standard (AES-128) for encrypting and validating the transmitted data. However, the standard does not specify how to manage, store, or distribute the encryption keys. Many solutions have been proposed to address this problem, but the majority are impractical in resource-constrained devices such as wireless sensor nodes or cause degradation of other metrics. Therefore, we propose an efficient and secure key distribution protocol that is simple, practical, and feasible to implement on resource-constrained wireless sensor nodes. We conduct simulations and hardware implementations to analyze our work and compare it to existing solutions based on different metrics such as energy consumption, storage overhead, key connectivity, replay attack, man-in-the-middle attack, and resiliency to node capture attack. Our findings show that the proposed protocol is secure and more efficient than other solutions.


Introduction
A wireless sensor network (WSN) is a network composed of resource-constrained devices with the ability to perform sensing and wireless communications, which are called wireless sensor nodes. Due to the low cost and flexibility of WSNs, they are employed in a variety of applications such as agriculture, the environment, health, home and commercial automation, the military and transportation [1][2][3][4][5][6][7][8][9][10][11] and have recently become a promising technology for Internet of Things (IoT) applications [12][13][14][15]. Modern WSNs adopt the IEEE 802.15.4 standard, which specifies the physical layer and the medium access control (MAC) layer for low-rate wireless personal area networks (LR-WPANs). The standarad also determines the radio frequency used for communication and provides four security services: access control, confidentially, integrity and replay protection. The MAC layer handles security for the IEEE 802.15.4 standard and defines the 128-bit advanced encryption standard (AES-128) for encrypting and validating transmitted data. Unfortunately, the standard does not specify how to manage, store, or distribute encryption keys [16]. Many solutions have been proposed to address this problem, but the majority are impractical in resource-constrained devices such as wireless sensor nodes or cause degradation of other metrics.
In this work, we propose an efficient and secure key distribution protocol for WSNs. We utilized the existing cryptographic primitives to design a protocol that is simple, practical and feasible to implement on resource-constrained devices such as wireless sensor nodes. This work extends our preliminary work introduced in [17] by improving its efficiency and security. The contributions of our work can be summarized as follows.

•
We introduce a comprehensive classification for the main key distribution and key establishment schemes in WSNs. We classify the schemes into traditional key distribution schemes, including private-key-based schemes and public-key-based schemes, and quantum-based key distribution schemes, including those based on entanglement swapping and teleportation. • We propose an efficient and secure key distribution protocol that is simple, practical and feasible to implement on resource-constrained devices such as wireless sensor nodes. Because data communication is responsible for most of a node's energy consumption [18], the proposed protocol utilizes the existing cryptographic primitives and leverages asymmetric encryption to achieve key distribution and node authentication in one step and using only one frame to avoid communication overhead. Moreover, the implementation of the proposed protocol adopts the following techniques: a fast modular exponentiation algorithm (described in Appendix A.4) and a short public exponent. These techniques speed up the node's data computation, resulting in lower energy consumption. • We analyze and compare the proposed protocol against different types of schemes using various metrics, including energy consumption, key connectivity, storage overhead, man-in-the-middle attack, replay attack and resiliency to node capture attack. Our methodology (described in Appendix A.1) combines simulations, hardware implementations and practical models to calculate both the energy consumption of sensor nodes and the energy consumption caused by wireless channel effects. • We visualize and analyze the key connectivity and the impact of node capture attack using a graph. We model a WSN as a graph and then implement the proposed protocol and the corresponding schemes on the graph to investigate their key connectivity and the impact of node capture attack on the key connectivity.

•
We conduct a formal verification using an automatic cryptographic protocol verifier, ProVerif. We utilize ProVerif to prove the security and soundness of the proposed protocol in formal models. We verify the reachability and secrecy, correspondence assertions (authentication) and observational equivalences.
The remainder of this paper is organized as follows: The next section introduces a classification for WSN key distribution schemes and work related to the proposed protocol. Section 3 describes the proposed protocol. Section 4 presents our findings and analyses. Section 5 describes the formal verification of our proposed protocol, and Section 6 concludes the paper.

Related Work
Key distribution schemes in WSNs have been comprehensively studied in the literature. The authors of [19][20][21][22] provided detailed surveys. However, in this study, we present a comprehensive overview of the existing key distribution and key establishment schemes in WSNs, which we classify into two domains. The first domain includes traditional key-based distribution schemes, which can be further classified into private-key-based and public-key-based schemes. Private-key-based schemes can be subcategorized into grid-based, polynomial-based and probabilistic schemes. Public-key-based key distribution schemes can be subcategorized based on an integer factorization problem (IFP) or on a discrete logarithm problem (DLP). The second domain includes quantum-based key distribution schemes, which can be further classified into entanglement-swapping-based and teleportation-based schemes. Figure 1 depicts this classification hierarchy, and Table 1 defines our evaluation metrics. Grid-based schemes address a WSN of size n as an √ n · √ n matrix or grid. In this subcategory, each node in the WSN is assigned to a unique intersection (i, j) in the grid [23][24][25]. An early example was called Peer Intermediaries for Key Establishment in Sensor Networks (PIKE) [26]. PIKE represents a sensor network of size n by an √ n · √ n matrix and uses some sensor nodes as trusted intermediaries for key distribution. Each sensor has an ID in the form of (x, y) based on its position in the matrix. Moreover, each node is loaded with a pairwise secret key shared only with each node in the two sets: Keys are deployed such that in any pair A and B, at least one node C exists that shares a pairwise key with both A and B. However, this approach suffers from key dependency because one inoperable or missing node would impact the network connectivity. Additionally, the search process for intermediary nodes consumes a large amount of energy because it involves sending many frames to other sensor nodes searching for a node that shares a pairwise key. Moreover, this approach requires each sensor node to store 2 √ n − 1 keys.

Efficiency
Energy consumption The amount of energy consumed during the key distribution/key establishment process.

Storage overhead
The memory required to store keys or keys materials.

Key connectivity
The percentage of available links in a WSN, calculated as the number of secured links divided by the total links.

Replay attack
The ability of an adversary to replay any of the corresponding frames. Man-in-the-middle attack The ability of an adversary to impersonate any sensor node or sink node.
Resiliency to node capture attack The impact percentage of a node capture attack on WSN key connectivity, calculated as the number of compromised links over the number of secured links.
Polynomial-based schemes depend on storing polynomials on wireless sensor nodes that are used for key generation. In [27], this process was described as a threshold scheme (R, K). The threshold is a shared security scheme that divides a message into K parts, where R is the minimum number of parts required to reconstruct the original message. The author of [28], proposed a sharing security scheme that used a polynomial equation in a finite field to construct a threshold scheme. In this scheme, an arbitrary polynomial of degree R − 1 was generated in the following form: where p is a public prime number that is greater than the coefficients, m is the message, and a and b are randomly chosen coefficients. Many other forms of polynomial-based key distribution schemes have been proposed [29][30][31][32][33][34]. In [35], the authors proposed a polynomial-based key management scheme consisting of three phases. In the first phase, sensor nodes discover the neighboring nodes and elect a cluster head (CH). In the second phase, when a sensor node wants to acquire a secure communication channel through the base station (BS), it sends a registration request. The third phase generates a triple key. Subsequently, when a sensor node wants to communicate with the CH and BS, the key is calculated based on a given polynomial and coefficients in a finite group. In this approach, sensor nodes consume large amounts of energy during the discovery and cluster-electing phases. Additionally, key connectivity is affected by node capture attacks.
Probabilistic-based schemes rely on the probability of two sensor nodes sharing a common key to establish a communication link. In [36], the authors proposed a probabilistic key-based management protocol. This scheme consists of three phases: key predistribution, shared-key discovery and path-key establishment. During the key predistribution phase, a large pool of keys p and their identifiers are generated. Then, a random set of keys k and their identifiers are drawn out of the key pool p to form a key ring for each sensor node based on the following formula: where P key is the probability of two nodes sharing a common key. Next, the key rings are loaded into each of the sensor node memories, and the key identifiers are saved on a trusted controller node along with the associated sensor identifiers. In the shared-key discovery phase, two sensor nodes can discover a shared key by broadcasting a list of their key rings. Additionally, the two sensor nodes can hide the key sharing patterns by broadcasting a list, li = {α||Eki(α)||i = 1, ..., k}, for every key on the key ring, where α is a challenge. The ability of the receiver to decrypt Eki(α) will reveal the challenge α and then establish a shared key with the sender. In the path-key establishment phase, a path key is assigned to each pair of sensor nodes that do not share a key but are connected to other sensor nodes at the end of the shared-key discovery phase. However, this approach consumes large amounts of energy because finding a common key between two sensor nodes requires broadcasting many frames. Additionally, storing the key ring requires large amounts of memory, especially when the probability of sensor nodes sharing a common key is certain. Public-key-based schemes are another class of the traditional key distribution schemes in WSNs. Practical public-key-based schemes depend on two major families of problems: IFPs such as the Rivest-Shamir-Adleman (RSA) cryptosystem and DLPs such as Diffie-Hellman key exchange (DHKE) and elliptic curve Diffie-Hellman (ECDH). The authors of [37] discussed using public infrastructure such as RSA to improve the security of WSNs. The study considered the WSN topology as a set of wirelessly connected sensor nodes that report collected data to the base station. However, wireless sensor nodes are resource-constrained devices, and a straightforward implementation of IFP or DLP without appropriate modifications is energy and memory intensive. In [38], the authors proposed a public-key-based key distribution scheme using ECDH. The scheme consists of two phases: a predeployment phase and a postdeployment phase. In the predeployment phase, sensor nodes are configured with elliptic curve (EC) parameters and the basepoint G. Then, α n is generated to calculate P n = α n G for all n nodes. Next, α n is stored in each corresponding node, and all P n are stored in the sink node. In the postdeployment phase, the sink creates a new secret key b and calculates its public key Q = bG. The public key is then broadcast to all sensor nodes. Each sensor node calculates a new key k n = α n Q, whereas the sink calculates a new key k n = bP n . The downside of this approach is that each node must store all the EC parameters such as the field over which the curve is defined, the α and b values that defined the curve and the generator point G.
Quantum-based schemes rely on the laws of physics and require special hardware. Nevertheless, many authors have proposed solutions. For example, entanglement swapping was adopted in [39]. This scheme utilizes a third party, called a base station, to perform entanglement swapping among sensor nodes. Each sensor node shares n qubits with the base station, and the base station shares m qubits with each sensor node. When two sensor nodes x and y are separately entangled with the base station, the base station performs entanglement swapping, allowing sensor node x and sensor node y to become entangled. As another example, the authors of [40] proposed a scheme that includes Einstein-Podolsky-Rosen (EPR)-pair distribution and quantum authentication. This scheme allows a sensor node to teleport quantum information to any other sensor node in the network. The entanglement-swapping-based and teleportation-based schemes rely on quantum cryptography, which has been proven in prior literature to be secure unless the laws of physics have been defeated. However, these schemes require entangled qubits to function, and applying entangled qubits in resource-constrained devices such as WSNs is not yet practical with existing technology.

Proposed Protocol
The proposed protocol includes four phases: a pre-deployment phase, a key distribution phase, a post-key distribution phase, and a key refreshment phase. Table 2 presents the notations used to describe the proposed protocol.

Notation
Description

Pre-Deployment Phase
Pre-deployment Phase Steps = AK nodes Sink node := AK sink and Sensor nodes := AK nodes Sensor node i := K local i and Sink node := K local i The pre-deployment phase of the protocol consists of five offline steps. The first step is the generation of an asymmetric key pair {K P , K R } ←− RSA gen , where RSA gen is the RSA key generation algorithm. In the second step, K P is defined as a sink node key, AK sink , and K R is defined as the key for the sensor nodes, AK nodes . In the third step, AK sink is loaded into the sink node, and AK nodes is loaded into the sensor nodes. The fourth step involves the generation of a random local key for each sensor node as follows:K local i R ← − key gen {0, 1} 128 , where key gen {0, 1} 128 is a random key generation algorithm with a key space of {0, 1} 128 ; the key space is a uniform distribution such that ∀K local i ∈ {0, 1} 128 , and the probability of each key is P K local i = 1 |{0,1} 128 | . In the fifth step, K local i is loaded into the corresponding sensor node i and into the sink nodes.

Key Distribution Phase Steps
Sink node: After deploying the sensor nodes, the sink node generates a random complementary key K compl ←− Ran gen {0, 1} 128 , computes its hash value Tag ←− H(K compl ), and calculates a timestamp T. The sink node then encrypts these values using its asymmetric key AK sink . After this task is complete, the sink node sends the cipher to neighboring sensor nodes as follows: . These neighbors forward the cipher to their neighbors in a multihop fashion until all of the sensor nodes have received the cipher Because each sensor node is loaded with the asymmetric key AK nodes in the pre-deployment phase, a sensor node i can decrypt the cipher as follows: and verifies the timestamp f veri f y (T) based on a predefined threshold. If the timestamp exceeds the threshold, the sensor node i rejects the cipher.
Otherwise, the sensor node i hashes the complementary key Tag ←− H K compl and compares it with the received hash f compare (Tag, Tag ) to ensure it has not received a modified complementary key K compl . If a mismatch is found, the sensor node i rejects the cipher; otherwise, the sensor node i produces its unique key by XORing the complementary key and its local key as follows:

Post-key Distribution Phase Steps
Sensor nodes: Sensor data D, Node i identity Id i , and Timestamp T After establishing the key distribution phase, the sensor nodes have already produced their unique keys. Therefore, when sensor node i wants to transmit data D to the sink node, it uses its unique key K unique i to encrypt the data D, its identity Id i , and a timestamp T; then, it concatenates the cipher with another copy of its identity Id i and sends both to the sink node. This process is described as follows: , where ⊥ is a probabilistic encryption algorithm. Because this study is concerned with key distribution, the sensor node i can use any secure probabilistic encryption algorithm. When the sink node receives the following cipher it uses the concatenated node Id i to find the corresponding K unique i as follows: F : Id i → K unique i . Then, the sink node decrypts the cipher and compares the identities f compare (Id, Id ), to ensure that the appropriate K unique i is used and that the cipher is received from an authorized node. If a match is found, the sink node verifies the timestamp T, f veri f y (T), based on a predefined threshold. When T is less than or equal to the threshold, the sink node accepts the sensor data D; otherwise, it rejects the sensor data D.

Key Refreshment Phase Steps
Sink node: In the key refreshment phase, the sink node generates a new random complementary key K compl new ←− Ran gen {0, 1} 128 , computes its hash value Tag ←− H(K compl new ), and calculates a timestamp T. The sink node then encrypts these values using its asymmetric key AK sink and sends the cipher to the neighboring sensor nodes as follows: . These neighbors forward the cipher to their neighbors in a multihop fashion until all of the sensor nodes have received the cipher recv ⇐ == = C ←− E AK sink K compl new || Tag ←− H(K compl new ) || T . Because the sensor nodes are loaded with the asymmetric key AK nodes in the pre-deployment phase, a sensor node i can decrypt the cipher as follows: P ←− D AK nodes C ←− E AK sink K compl new || Tag ←− H(K compl new ) || T and verifies the timestamp f veri f y (T), based on a predefined threshold. If T exceeds the threshold, the sensor node i rejects the cipher; otherwise, the node hashes the new complementary key Tag ←− H K compl new and compares it with the received hash f compare (Tag, Tag ) to ensure it has not received a modified new complementary key K compl new . If a mismatch is found, the sensor node i rejects the cipher; otherwise, it produces its new unique key by XORing the new complementary key and its local key as follows:

Findings and Analyses
In this section, we analyze the efficiency and security of the proposed protocol in comparison to the schemes proposed in [26,[35][36][37]. These analyses are based on the metrics presented in Table 1. Table 3 compares the energy consumption required by the proposed protocol and the corresponding schemes to perform a key distribution/establishment process between two nodes.

Energy Consumption
(Because some schemes perform key distribution and others conduct key establishment, we refer to both terms as the "key distribution/establishment process."). The experimental design and parameters are described in Appendix A.1.
The first part of the table includes eight rows to quantify the energy consumed by the nodes' transceivers. The first row, "Th.N.F.Tx," represents the theoretical number of frames sent by a node's transmitter when performing a key distribution/establishment process without modeling wireless channel effects. The second row, "Av.N.F.Tx," shows the average number of frames sent after modeling the wireless channel effects. The third row, "N.F.Rx," shows the number of frames that a node's receiver receives during the key distribution/establishment process. If a scheme involves exchanged frames for node discovery or clustering before the key distribution/establishment process, the fourth row, "N.F.ND.C," represents the number of those frames. The fifth row, "T.Tx," shows the time the node's transmitter requires to send the frames. The sixth row, "T.Rx," shows the time the node's receiver requires to receive the frames. The seventh row, "E.TPO," shows the energy consumed by the transmitter power output (TPO). The eighth row, "E.TRX," shows the total energy consumed by the nodes' transceivers.
The second part of the table quantifies the energy consumption of the nodes' microcontrollers and includes eight rows. The first row, "S.C.K," represents the search complexity for finding a common key, where n is the number of nodes, P is the key pool size, and P C is the probability that two nodes share a key. The next six rows show the time a node's microcontroller requires to perform the various operations required to complete the key distribution/establishment process. The "T.MA.K" row shows the time a node's microcontroller requires to find a common key; "T.MA.X" is the time a node's microcontroller requires to perform an XOR operation; "T.MA.H" is the time a node's microcontroller requires to perform a hashing operation; "T.MA.E" is the time a node's microcontroller requires for encryption; and "T.MA.D" is the time a node's microcontroller requires for decryption. When a scheme involves polynomial evaluation, "T.MA.P.E" is the time a node's microcontroller requires for polynomial evaluation. The eighth row, "E.MA," shows the total energy consumed by the nodes' microcontrollers.
The last part of the table, "T.C.E," shows the total energy consumption of the proposed protocol and the corresponding schemes.
As shown in Table 3, the nodes' transceivers consume the lowest amount of energy in the proposed protocol, followed by scheme [37], at 2.75 mJ and 4.15 mJ, respectively; whereas, the nodes' transceivers consume the largest amount of energy in scheme [35], followed by scheme [36] and scheme [26], at 295.77 mJ, 150.37 mJ, and 46.02 mJ, respectively.
In contrast, the nodes' microcontrollers consume the lowest amount of energy in scheme [26], followed by scheme [36] and scheme [35], at 0.15 mJ, 1.29 mJ, and 27.50 mJ, respectively, and the largest amount of energy consumed is in the proposed protocol, followed by scheme [37], at 38.35 mJ and 38.23 mJ, respectively.
However, the total energy consumption in the proposed protocol is 41.10 mJ, which is the lowest relative to the total energy consumed by each of the corresponding schemes. This result is intuitive because the proposed protocol is designed to perform key distribution based on efficient data computation rather than data communication. The parameters that contribute to the energy consumption of nodes' microcontroller.  Table 4 illustrates the key storage overhead of the proposed protocol and the corresponding schemes. In the pre-deployment phase of the proposed protocol, each sensor node stores two keys, AK nodes and K local . Then, in the key distribution phase, each sensor node prepares its unique key, K unique . Therefore, the proposed protocol has the lowest key storage overhead for each sensor node compared to the corresponding schemes. The logarithmic graph presented in Figure 2 shows the magnitude of the key storage overhead as the number of sensor nodes increases. The graph clearly shows that the proposed protocol is advantageous because it requires the fewest keys compared to other schemes. Table 4. Key Storage overhead for each scheme.

Scheme Key Storage Overhead
The proposed protocol 3 Scheme [26] 2 · √ n − 1 Scheme [35] 6 Scheme [36] −P · log(1 − P c ) 1 Scheme [37] n n represents the number of nodes. 1 The key pool size p is equal to the number of sensor nodes multiplied by 10, and P c is equal to 0.99%.

Key Connectivity
To evaluate the key connectivity in each scheme, we model the entire WSN with a graph in which the vertices represent wireless sensor nodes and the edges represent links. Therefore, Figure 3a shows a random deployment of 200 nodes over an area of 1000 ft · 1000 ft. In Figure 3b, the black links indicate the wireless signal range of the nodes' transceivers without applying either the proposed protocol or the corresponding schemes. The wireless signal range is based on the nodes' transceiver modules (described in Appendix A.1). Figure 4 shows the implementation of the proposed protocol and the corresponding schemes on the WSN shown in Figure 3b. However, when two sensor nodes share a common key or key material within the same wireless range, the black links are converted to green links. In contrast, the red links indicate nodes that do not share a common key or any key materials. This modeling shows the key connectivity of each scheme, which can be defined as follows: The key connectivity (%) = Secured links Total number o f links × 100, (5) where the term "Secured links" includes any link between two nodes that share a common key or key materials, and "Total number o f links" counts all links in the WSN. Figure 4a,c,e show that the key connectivity is certain because nodes in these schemes are designed to have either a shared common key or key materials that lead to 100% key connectivity. In contrast, the key connectivities in Figure 4b,d reach only 87% and 99%, respectively.    [26]; (c) Scheme [35]; (d) Scheme [36] ; (e) scheme [37].

Replay Attack
In a replay attack, an adversary captures a copy of exchanged frames to resend them later to the receiver for a deceptive purpose. The goal is for the receiver to believe that the resent messages are new messages; however, the receiver receives old information. This type of attack cannot be performed against the proposed protocol because a timestamp T is employed as a countermeasure in all three on-line phases: key distribution, post-key distribution and key refreshment. In the key distribution and key refreshment phases, the timestamp T is appended to each complementary key sent to the sensor nodes: In the post-key-distribution phase , each sensor node appends a timestamp T to each frame sent to the sink node.
This timestamp allows the sink node to validate whether the received data are replayed data. However, none of the corresponding schemes implement a countermeasure against replay attacks.

Man-in-the-Middle Attack
During a man-in-the-middle attack, an adversary secretly intercepts frames from the sender and likely modifies them. Then, the adversary resends the frames to the receiver. This process occurs without the knowledge of the sender and receiver; therefore, both parties assume that they are communicating directly with one another. However, the proposed protocol is secure against man-in-the-middle attacks because in the pre-deployment phase, an asymmetric key pair is generated, renamed AK sink and AK nodes , and loaded into the sink node, and the sensor nodes, respectively. Thus, during the key distribution and key refreshment phases, when the sink node encrypts the complementary key with AK sink : Only the sensor nodes are able to decrypt the cipher because they already possess one key of the asymmetric key pair.
Additionally, in the post-key distribution phase, each sensor node encrypts data with its unique key that is only in the possession of the sensor node and the sink node.
Therefore, an adversary cannot impersonate either the sink node or any sensor node in the proposed protocol. Scheme [37] is vulnerable to man-in-the-middle attacks; however, the other compared schemes are not subjected to this type of attack.

Node Capture Attack
To investigate the resilience of the proposed protocol and the corresponding schemes against node capture attacks, node capture attacks must be launched on the key connectivity of each scheme. Therefore, as shown in Figure 5, we mount node capture attacks on the key connectivity of each scheme presented in Figure 4. Thus, Figure 5 shows each scheme's resilience against node capture attacks. The impact of a node capture attack can be defined as follows: The impact o f a node capture attack on a WSN (%) = Compromised links Total number o f secured links × 100, (6) where "Compromised links" indicates the number of links that are compromised after a random number of sensor nodes have been captured, and "Total number o f secured links" counts any link between two nodes that share a common key or key materials. However, each scheme has a different design; thus, for fairness, we assume the following: 1. An adversary is able to physically capture 5% of the sensor nodes randomly (i.e., 10 sensor nodes in the example network). 2. Because capturing the sink node will compromise any given WSN, in Assumption 1, node capture does not include the sink node. 3. Capturing a sensor node reveals all the data that node contains. For example, if the captured sensor node contains data that reveal information about other nodes' common keys or keys materials, those keys are also compromised.
In Figure 5a, the key connectivity of the proposed protocol does not change after 10 sensor nodes are captured, which indicates that the proposed protocol is secure against node capture attacks. However, the key connectivities of the networks in Figure 5b,c are decreased by 51% and 75%, respectively (assuming the network in Figure 5c has 4 clusters and that some of the compromised nodes are located in 3 different clusters). The key connectivity in Figure 5d is only slightly affected, decreasing by only 6%. In contrast, the network in Figure 5e is heavily impacted, and the key connectivity is decreased by 100%. (c) Scheme [35]; (d) Scheme [36] ; (e) Scheme [37].

Formal Verification
To formally prove the security and soundness of the proposed protocol, we utilize ProVerif, an automatic cryptographic protocol verifier. ProVerif is a powerful tool for automatically analyzing the security of cryptographic protocols and verifying them in a formal model.
In this section, we present the verification results pertaining to reachability and secrecy, correspondence assertions (authentication), and observational equivalences.

Reachability and Secrecy
ProVerif provides proof of reachability and secrecy properties by investigating the reachability of a term x by an adversary A. Based on the results, the secrecy of x can be assessed with respect to the modeled protocol. In the proposed protocol, we test whether sensor data "sensorData" are available to A. Figure 6 shows the complete verification result. The result concludes, "RESULT not attacker(sensorData[ ]) is true", meaning that "sensorData" is unreachable, and an attack cannot be conducted against the protocol successfully.

Correspondence Assertions
In ProVerif, authentication can be modeled using a sequence of events defined as correspondence assertions. We apply a sequence of events to verify the authentication of the sink node and the complementary key to the sensor nodes and the authentication of the sensor nodes and encrypted data to the sink node. Figure 7 shows the complete verification result. The verification confirmes that the proposed protocol achieves successful authentication.

Observational Equivalence
In applied π-calculus terminology, two processes p 1 and p 2 have observational equivalence (p 1 ≈ p 2 ) when they are indistinguishable through observation. ProVerif can prove observational equivalence such as strong secrecy, in which an adversary A cannot distinguish when a cipher changes. We leverage this feature to prove that the proposed protocol is semantically secure and that the A cannot learn anything from the cipher. Figure 8 shows the complete verification result. The analysis showes that the sensor data "sensorData" in the proposed protocol are observationally equivalent and that the A cannot distinguish when they change because the data are encrypted by a probabilistic algorithm, as described in the post-key distribution phase.

Conclusions
In this work, we propose a practical key distribution protocol that can be implemented above the IEEE 802.15.4 standard to secure the wireless communication of resource-constrained sensor nodes. We utilized existing cryptographic primitives to design a protocol that maintains a tradeoff between efficiency and security. We conducted simulation, hardware implementations, and modeling to compare the proposed protocol to the existing solutions. Moreover, we conducted formal verifications to prove the soundness and the security of our proposed protocol. The proposed protocol provides low energy and memory consumption, certain key connectivity, and security against: replay attack, man-in-the-middle attack, and node capture attack. The overall results show that the proposed protocol is more efficient and secure than the corresponding schemes.
Future work includes examining more advanced methods to enhance the energy consumption of the proposed protocol. For example, using more efficient algorithms to perform data computation. Furthermore, investigating additional types of attacks against the proposed protocol to increase its security. Funding: This research was funded by the University of Bridgeport for financial funding to publish this research.

Acknowledgments:
The authors acknowledge the reviewers for their valuable comments that have improved this paper to appear in its current form.

Conflicts of Interest:
The authors declare no conflict of interest.

Appendix A. Methodology
Appendix A. 1

. Experiment Design and Parameters
The experimental design includes two parts: simulation and hardware implementation. In the first part, we utilize the OPNET Modeler to design a model for a wireless sensor node and then used this model to conduct simulations for a network of 200 wireless sensor nodes, as shown in Figure A1. Our sensor node model calculates the energy consumption of a node's transceiver, including both the TPO and the energy consumption caused by wireless channel effects, based on the models described in Appendix A.2 and Appendix A.3, respectively.
In the second part, because the energy consumption by a node's microcontroller cannot be simulated, we implement the proposed protocol and the compared schemes on a real microcontroller and measure the time these schemes require to perform key distribution/establishment processes. Then, we calculate the energy consumption of the node's microcontroller based on the model described in Appendix A.2.
Moreover, in this experiment, the transceiver parameters of our sensor node model are based on XBee transceiver S1 [41], and the microcontroller used in the implementation is an Atmega328p [42] (clocked at 16 MHz). The following table shows these parameters.  The energy consumption of a wireless sensor node is the total amount of energy consumed by the node's transceiver, microcontroller, and sensors, as indicated in Equation (A1). Because our research considers key distribution security and efficiency regardless of the network's application, we ignore the energy consumed by the sensors because that consumption is based on sensor applications regardless of the underlying key distribution/establishment algorithm. Thus, in this paper, the energy consumption of a wireless sensor node is calculated by Equation (A2): The energy consumption is generally calculated by Equation (A3): where Power(W) is calculated by Equation (A4): Based on Equation (A3), we calculate the energy consumption of nodes' transceivers and microcontrollers. The following subsections describe these calculations.
Appendix A.2.1. Energy Consumption of the Transceiver The energy consumption of a node's transceiver E transceiver , given in Equation (A2), is the energy consumed by the node's transmitter E Tx and its receiver E Rx . However, the energy consumption of the node's transmitter E Tx is the total energy consumed by the TPO E Tx TPO and the transmitter electronics E Tx elec , which can be found by the following equation: where the energy consumed by E Tx TPO is found by Equation (A6): where Tx power output is the TPO, and it depends on the transceiver module (described in Appendix A.1). Tx time is the time that a node's transmitter takes to send one frame and is found by Equation (A7): where Fr Size is the frame size, and Tx DR is the data rate of the transmitter. The transmitter data rate depends on the transceiver module (described in Appendix A.1). The energy consumed by the transmitter electronics E Tx elec can be calculated as follows: E Tx elec = Tx time · (Tx elec current · Tx elec voltage ) + (MA Tx current · MA Tx voltage ) , where Tx time is found as shown in Equation (A7). Tx elec current and Tx elec voltage are the respective current and voltage required by the transmitter's electronics, and MA Tx current and MA Tx voltage are the respective current and voltage required by a node's microcontroller to run the transmitter. The energy consumption of the node's receiver E Rx can be calculated as follows: where Rx time is the time that a node's receiver requires to receive one frame, which can be found by Equation (A10). Rx current and Rx voltage are the respective current and voltage required by a node's receiver, and MA Rx current and MA Rx voltage are the respective current and voltage required by a node's microcontroller to run the receiver.
where Fr Size is the frame size, and Rx DR is the data rate of the receiver. The receiver's data rate depends on the transceiver module (described in Appendix A.1).

Appendix A.2.2. Energy Consumption of the Microcontroller
The energy consumption of a node's microcontroller, E microcontroller , presented in Equation (A2), represents the energy consumed by a node's microcontroller, E MA , and can be found using the following equation: MA Time operate is the time required by the microcontroller to execute the core algorithm of a key distribution/establishment process. MA current and MA voltage are the respective current and voltage required by the microcontroller.

Appendix A.3. Modeling Wireless Channel Effects
When our sensor node model receives a frame, it calculates the received power P Rx of the frame as follows: where P Tx is the transmitter power, G Tx is the transmitter antenna gain, G Rx is the receiver antenna gain, and P Loss is the path loss in free space, which can be found by the following equation: where λ is the wavelength, and D is the distance. If the received power is less than the receiver sensitivity, our model discards the frame because the receiver is unable to decode it. However, if the received power is greater than or equal to the receiver's sensitivity, our model calculates the noise in each frame caused by interference from other frames and then calculates the signal-to-noise ratio (SNR) based on Equation (A14): SNR = 10 log 10 P Rx N Intern .
Then, our model calculates the bit error rate (BER) in the received frame, which is calculated based on the chosen modulation curve and the SNR. Finally, it calculates the percentage of errors in the received frame by the following equation: where F size is the frame size. If the percentage of errors in the received frame F Errors exceeds a specified threshold, the model discards the frame.

Appendix A.4. Fast Modular Exponentiation Algorithm
The proposed protocol relies on modular exponentiation in the key distribution phase. The running time for an ordinary modular exponentiation algorithm is exponential with the magnitude of the exponent e (linear complexity); thus the algorithm is not a practical. To make the proposed protocol practical in resource-constrained nodes, we utilized the square-and-multiply algorithm, Algorithm A1, which has a polynomial running time in the length of e (logarithmic complexity).