# Grouping Sensors for the Key Distribution of Implicit Certificates in Wireless Sensor Networks
## 3 The Proposed Methods
Only the owner is aware of the storage locations of the partitions, and to access them, one must know the server's password (the password for accessing the server and not the data password). Notably, all partitions are required to recover the original data. Figure 2 illustrates the concept of data partitions. To recover the original data, the partitions are multiplied as presented in Equation (3). Thus, these pieces can be stored randomly on different network servers. \[x^{k}+a_{k-1}x^{k-1}+a_{k-2}x^{k-2}+\ldots+a_{1}x+d=0, \tag{1}\]  
\[(x-r_{1})(x-r_{2})(x-r_{3})\ldots(x-r_{k})\equiv 0\text{mod}p \tag{2}\]  
\[d=r_{1}\bullet r_{2}\bullet\bullet r_{k}\text{mod}p. \tag{3}\]  
Figure 2: Framework of the key partitioning and distribution. The BS delineates the production of key partitions. It randomly generates a key \(d\) and a large prime \(p\). For \(N\) sensor nodes, BS randomly generates \(N\)-1 integers (i.e., \(r_{1}\), \(r_{2}\),..., and \(r_{N\text{-}1}\)) smaller than \(p\) and uses them to perform an inverse multiplication operation. Then, the \(k\)th key partition can be obtained from Equation (4). Finally, the BS distributes the \(N\) key partitions to the corresponding \(N\) nodes. Each node receives one key partition. \[r_{k}=d\bullet(r_{1}\bullet r_{2}\bullet\dots\bullet r_{k-1})^{-1}\text{mod}p \tag{4}\]  
The key is arranged in the network. We employed the group key management approach as described in the previous section to improve the network scalability and reduce the memory space. In the network grouping phase, our tree network is further divided into several subtrees. Each subtree represents a group, and all nodes in a group use a shared group key to protect their in group communications. We propose two intuitive strategies, TDG and BUG, to divide a network into groups, with \(MN\_G\) being the maximum group size. In TDG, a breadth-first search starts from BS (Figure 3). If the number of nodes joining the group equals the maximum number of group members, the search stops, and the group is completed. The node with the lowest depth in a group is delegated as the root of the group, and the search restarts from the deepest node to its child node. The above process continues until all sensor nodes are assigned to a group, and all groups can connect with other groups via a shared node. Considering the tree topology in Figure 4 as an example, we assume a maximum number of group members of six. With TDG, the entire network can be divided into eight groups. In BUG, the search starts from the deepest node to its parent node (Figure 5). If the number of nodes joining the group is smaller than \(MN\_G\), other child nodes of parent node y are searched for and added to the group. If the parent node y has no child nodes, it will conduct the breadth-first search from its parent node to find other child nodes. When the number of group sizes equals \(MN\_G\), the search stops, and the group is completed. The  
Figure 3: Pseudocode of the top-down grouping (TDG) algorithm. node with the lowest depth is delegated as the root of the group, and the search restarts from its parent node to create another group. This process continues until all sensor nodes are assigned to a group, and all groups can connect with other groups via a shared node. Similarly to the previous example, with BUG, the whole network can be divided into nine groups, and the grouping results are shown in Figure 6.  
To integrate the aggregation and encryption functions more effectively, we propose an alternative grouping algorithm, ABG (Figure 7). The breadth- and left-first searches start from BS to its child node \(x\). If the number of nodes added to the group is smaller than \(MN\_G\), it continues searching for other child nodes of node \(x\). When the aggregator is met, the search is targeted at other child nodes, which are non-aggregators. If the number of nodes added to the group is smaller than \(MN\_G\), the search stops, and the group is completed.