# Public Key-Based Authentication and En-Route Filtering Scheme in Wireless Sensor Networks
## 4 The Proposed Scheme
### Report Generation
However, all these malicious behaviors will be detected by the other cluster nodes. Step 3. Each participating node \(v_{IDj}\) uses \(X(R)\) to generate \(e=ENC(X(R)\), \(C)\) and \(d=H(e\mid V)\), where \(H\) is a hash function (SHA-1 for example), \(\mid\mid\) denotes concatenation, and the \(ENC\) denotes a symmetric-key encryption algorithm (AES, DEA, and RC5 for example). Subsequent to that, \(v_{IDj}\) computes its share of the cluster signature (partial signature) \(\sigma_{j}=x_{j}|d+k_{j}\) and sends it to \(v_{IDi}\). Note that during the report generation phase, each cluster node will listen to and temporarily store the information sent by the other cluster nodes, which will be used to identify malicious behaviors. Step 4. When \(v_{IDi}\) detects a partial signature \(\sigma_{j}\), which is not from any of the \(t\) participating nodes, it will drop that \(\sigma_{j}\) immediately. Otherwise, \(v_{IDi}\) should verify \(\sigma_{j}\) and drop the incorrect one in time. The authors have designed a verification scheme as follows:  
1. Compute \(\sigma_{j}P\) (i.e., \(\sigma_{j}P=(x_{j}|d+k_{j})P=x_{j}|dP+k_{j}P\));
2. Compute \(x_{j}|dP+k_{j}P\) by using \(x_{j}P\) stored locally and \(k_{j}P\) received from \(v_{IDj}\) in Step 1;
3. Compare the results in 1 and 2. When the result in 1 is equal to that in 2, \(\sigma_{j}\) is considered to be correct, otherwise \(\sigma_{j}\) is considered to be incorrect. When \(v_{IDi}\) gets \(t\) correct partial signatures, go to Step 6. Otherwise, go to Step 5. Step 5. Suppose that there are \(z\) (\(1\leq z<t\)) participating nodes to be substituted because they provided incorrect \(\sigma_{j}\), or they did not provide \(k_{j}P\) or \(\sigma_{j}\). Then, what will substitute the \(z\) nodes to participate in report generation? The authors have designed a substitution scheme as follows. First, \(v_{IDi}\) broadcasts a substitution message SUBMSG, embedded with \(ID_{i}\), the reason code \(rd\) (\(rcd\) is \(0\) if the \(z\) participating nodes will be substituted due to failure to provide \(k_{j}P\), or \(1\) if the \(z\) participating nodes will be substituted because they did not provide their partial signatures or provided incorrect partial signatures), \(z\), and the IDs of the \(z\) participating nodes to be substituted. When a cluster node receives the SUBMSG message, it executes Algorithm 1 to process the message. Then, \(v_{IDi}\) deducts \(0.2\) from the trust value of each participating node \(v_{IDm}\) to be substituted. When \(TV_{IDm}\) falls below \(T_{\texttt{\tiny{T}}{\texttt{\tiny{T}}}}\) and the number of ALARM messages for \(v_{IDm}\) (denoted as \(NA_{IDm}\)) is lower than \(Nc/2\), \(v_{IDi}\) will broadcast an ALARM message (embedded with \(ID_{i}\) and \(ID_{m}\)) for \(v_{IDm}\) to inform other cluster nodes that \(v_{IDm}\) is suspicious. \(v_{IDi}\), and each cluster node that hears the ALARM message, executes Algorithm 2 to process the ALARM message. When the number of trusted non-participating cluster nodes is less than \(z\), which means there are not enough trusted participating nodes to cosion the report, then \(v_{IDi}\) will set \(Fail\_flag=true\), cancel the timer \(TRG\), and stop generating the signed report. Otherwise, the \(z\) trusted non-participating nodes whose IDs are closer to \(hv\) than the others will be selected to participate in report generation. When a new participating node does not send \(k_{j}P\) to \(v_{IDi}\), \(v_{IDi}\) performs the substitution scheme again. Otherwise, after receiving all the \(k_{j}P\) from all the \(z\) new participating nodes, \(v_{IDi}\) recomputes \(R=kP=\sum\limits_{j=1}^{t}k_{j}P\) and broadcasts \(X(R)\) to the current participating nodes. Then, each current participating node recomputes its partial signature \(\sigma_{j}\) and sends it to Following reception of a new partial signature from a current participating node, \(v_{IDi}\) verifies it.