# Two-Level-Composite-Hashing Facilitating Highly Efficient Anonymous IoT and D2D Authentication
## 3 The Proposed Schemes
### The S-Assist D2D Anonymous Authentication
#### 3.3.2 The S-Assist-Once-A-While D2S2D Anonymous Authentication and Direct D2D Authentication  
This S-assist-once-a-while D2S2D anonymous authentication facilitates two devices run several direct D2D anonymous authentication sessions, which do not require the involvement of servers after they have completed one S-assist-once-a-while D2S2D authentication via the help of a server. Two devices (say \(D_{i}\) and \(D_{\vec{i}}\)) first run the S-assist-once-a-while D2S2D anonymous authentication to establish the shared key \(K_{tmp,j,\vec{i}}\) and to establish their level-2 seed-pseudonym vectors (as specified in Figure 1b,c); after that, they can run \(w2\) instances of the direct D2D anonymous authentication. Figure 4: S-assist-always D2D anonymous authentication flow. Figure 5 shows the flow of the S-assist-once-a-while D2S2D anonymous authentication. In this instance, we took two devices (say \(D_{i}\) and \(D_{\overline{i}}\)) as the example to demonstrate how the protocol works. The details are described as follows. Step 1. \(D_{i}\to S\): \(PN\), \(ID_{S}\), \(Req\)  
\(D_{i}\) executes PN_Seed_Update(\(N_{i}\)) to generate the pseudonym \(PN\) and updates \(N_{i}\); \(D_{i}\) chooses \(x\in_{R}Z_{q}^{*}\), and calculates \(X=xP\) and \(Req=Enc_{K_{i}}\left(D_{\overline{i}},PN,X\right)\) for \(S\) to decrypt the request to derive the identity \(D_{\overline{i}}\). Step 2. \(S\to D_{\overline{i}}^{*}\): \(ID_{S}\), \(PN_{i}\), \(PN_{i}\), \(R1\), \(E_{2}\), \(Res2\), \(E_{3}\), \(Res3\)  
\(S\) first launches PV_Update(\(PN\), \(Req\)) to identify the identity of the device, gets the secret key \(K_{i}\), and decrypts/verifies \(Req\). If the verification succeeds, then it updates \(PV_{i}=\left\{PN_{i,k+1},\ldots,PN_{i,k+1+w1}\right\}\). \(S\) also calculates \(D_{i}^{\prime}s\) level-2 seed \(N_{i,\overline{i}}=\)\(h_{1}\left(PN_{i,k},D_{i},K_{i}\right)\), which will be used in the direct D2D anonymous authentication. \(D_{i}^{\prime}s\) level-2 seed-pseudonym vector is depicted in Figure 10.  
\(S\) then chooses a random challenge R1, computes the temporary secret key \(K_{tmp,j,\overline{i}}=h_{1}\left(\text{``}Server^{\prime},ID_{S},PN,D_{ \overline{i}},K_{i},R1\right)\) for \(D_{i}\) and \(D_{\overline{i}}\), and prepares the encryption \(E_{2}=Enc_{K_{\overline{i}}}\left(D_{i},K_{tmp,j,\overline{i}},N_{i,\overline{i }},X\right)\) and \(Res2=Mac\left(K_{\overline{i}},E_{2},R1\right)\) for \(D_{\overline{i}}\). Figure 5: S-assist-once-a-while D2S2D anonymous authentication. \(S\) locates \(D_{l}^{\prime}s\) active \(PN\) (say \(PN_{i,\overline{j}}\)), updates \(D_{l}^{\prime}s\) level-1 pseudonym vectors, and activates \(D_{l}^{\prime}s\) level-2 seed \(N_{\overline{i},i}=h_{1}\big{(}PN_{i,\overline{j},\overline{k}},D_{\overline{i} },K_{\overline{j}}\big{)}\); \(D_{l}^{\prime}s\) level-2 seed-pseudonym vector is depicted in Figure 1c. \(S\) prepares \(E_{3}=Enc_{K_{l}}\big{(}D_{\overline{i}},K_{tmp,\overline{i},\overline{j}},N _{\overline{i},\overline{j}}\big{)}\) and \(Res3=Mac(K_{i},PN,PN_{i,\overline{k}},\ ID_{S},E_{3},\)  
1.. It finally sends the data specified in Step 2 to \(D_{\overline{i}}\): Step 3. \(D_{\overline{i}}\to D_{l}\): \(ID_{S},PN,\ PN_{i,\overline{k},\overline{k}},R1,E_{3},Res3,Res4,Y\)  
\(D_{\overline{i}}\) decrypts \(E_{2}\), and gets \(K_{tmp,i,\overline{j}}\) and \(N_{i,\overline{j}}\). It validates \(Res2\); if the validation succeeds, then it updates \(D_{\overline{i}}\)\(s\) level-1 seed and pseudonym vectors. It also uses \(N_{i,\overline{j}}\) to activate \(D_{i}^{\prime}s\) level-2 seed-pseudonym vector (as specified in Figure 1b). It chooses \(y\in_{R}Z_{q}^{*}\) and prepares \(Y=yP\) and \(Res4=Mac\Big{(}K_{tmp,i,\overline{j}},E_{3},Y\Big{)}\). It computes the session key \(K_{sens}=h_{1}(\"D2D\",ID_{S},PN_{i,\overline{k}},K_{tmp,i,\overline{j}},xyP)\), and sends the data specified in Step 3 to \(D_{i}\): Step 4.