# An Efficient Framework for Secure Communication in Internet of Drone Networks Using Deep Computing
## 3 Materials and Methods
### System Model and Problem Formulation
#### 3.1.6 Protocol Phases
```
**Algorithm 3** User Authentication
```
Input: UserID, AuthRequest = {reqID, timestamp, nonce, signature} Output: Encrypted challenge token or authentication failure
1: if CurrentTime()-timestamp > TimeWindow then
2: return AuthFailure(\"Request expired\")
3: end if
4: userPK \(\leftarrow\) UserRegistry.getPK(UserID)
5: if not VerifyECC(userPK, signature, {reqID, timestamp, nonce}) then
6: return AuthFailure(\"Invalid signature\")
7: end if
8: profile \(\leftarrow\) BehaviorDB.getProfile(UserID)
9: lstmModel \(\leftarrow\) profile.LSTM
10: rfModel \(\leftarrow\) profile.RF
11: challenge \(\leftarrow\) GenerateUserBehaviorChallenge(profile)
12: challengeToken \(\leftarrow\) EncryptECC(userPK, {challenge, nonce + 1})
13: return challengeToken
```
**Algorithm 4** Verify User Response  
Explanation:  
User Authentication--After receiving an authentication request from a user, the system verifies the freshness of the request first to avoid replay attacks. The system then authenticates the digital signature based on the user's stored public key. In case it is valid, the system obtains the behavior models of the user and produces a dynamic behavioral challenge (for example, typing sequence or interface interaction task). The challenge is encrypted and dispatched to the user to produce genuine-time behavior to be checked subsequently. ```
UserID, Response = {challenge, responseData, signature} is the input. Output: AuthFailure or AuthSuccess with session key
1: UserPK \(\leftarrow\) UserRegistry.getPK (UserID)
2: If VerifyECC(userPK, signature, {challenge, responseData}) is not present, then
3: return AuthFailure(\"Invalid response\")
4: terminate if
5: Extract Behavior Features (responseData)\(\leftarrow\) currentBehavior
6: behaviorSeq \(\leftarrow\) FormatBehaviorAsSequence(currentBehavior)
7: predictedSeq \(\leftarrow\) lstmModel.Forward(behaviorSeq)
8: SequenceLoss(predictedSeq, behaviorSeq[1:])\(\leftarrow\) loss
9: lstmScore \(\leftarrow\) exp(\(-\)loss)
10: FormatBehaviorAsFeatureVector(currentBehavior)\(\leftarrow\) rfVector
11: classProbs \(\leftarrow\) rfModel.PredictProbabilities(rfVector)
12: rfAnomaly \(\leftarrow\) 1 \(-\) classProbs[1]
13: behaviorScore \(\leftarrow\) 0.6 \(\times\) lstmScore + 0.4 \(\times\) (1 \(-\) rfAnomaly)
14: if behaviorScore is less than behavior threshold, then
15: Log(UserID, \"Behavior anomaly\", behaviorScore)
16: AuthFailure(\"Behavior anomaly detected\") is returned. 17: terminate if
```
18:lstmModel.Update(learningRate = 0.01, behaviorSeq)
19:rfModel.Update(rfVector, isPositive = TRUE)
20:BehaviorDB.update(UserID, currentBehavior, lstmModel, rfModel)
21:GenerateRandomKey(128) \(\leftarrow\)sessionKey
22:returnAuthSuccess, encryptedKey
23:encryptedKey \(\leftarrow\)EncryptECC(userPK, sessionKey)
```
**Algorithm 5**Verify Drone Response

Verify User Response--Once the user reacts to the challenge, the system checks the signature of the response and extracts the features of the behavior. The LSTM model processes sequential patterns of behavior and computes confidence based on the accuracy of the prediction. Concurrently, RF model calculates the probability that the behavior is a legitimate user's. These values are blended together to generate the final authentication score. When the score goes over a predetermined value, the models are refreshed with the new behavior data to facilitate adaptive learning and a secure session key is produced.