## 3 The Proposed SP-IoUAV Model
### Privacy-Preserving Ensemble
#### 3.2.3 Secure Multi-Party Computation (SMC)  
SMC is a fundamental cryptographic technique used in our proposed model to ensure data privacy and security. The IDS we provide enables multiple UAVs to collaborate on encrypted data in one solution.  
As part of the SMC process, data are encrypted before they are shared with other participants. UAVs hold secret keys that encrypt their data before sharing these data asencrypted inputs with other UAVs. Since the actual computations take place on encrypted data, no UAV is able to access plain text data held by other participants.  
Let UAV\({}_{i}\) represent a UAV, and \(D_{i}\) be its encrypted dataset. Each UAV computes a function \(f_{i}\) on its encrypted data:  
\[E_{i}=\text{Encrypt}(D_{i},\text{key}_{i}) \tag{6}\]  
where \(\text{Encrypt}(\cdot)\) denotes the encryption function using the UAV's secret key \(\text{key}_{i}\), and \(E_{i}\) is the encrypted dataset shared with other UAVs.  
After receiving the encrypted inputs \(E_{i}\) from all UAVs, the collaborative computation is performed using secure cryptographic protocols. The result is an encrypted output that contains the collective insights from all UAVs without exposing any individual UAV's data.  
The secure computation can be represented as:  
\[E_{\text{out}}=\text{Compute}(E_{1},E_{2},\dots,E_{n}) \tag{7}\]  
where \(\text{Compute}(\cdot)\) denotes the secure computation function, and \(E_{\text{out}}\) is the encrypted output shared with all UAVs.  
By utilizing advanced cryptographic protocols like secure multi-party computation, the proposed model enables UAVs to collaboratively train machine learning models and collectively detect anomalies without the need to disclose raw data to other entities. This privacy-preserving mechanism enhances the overall security of UAV operations in a smart city environment and strengthens the resilience of the IDS against potential attacks.  
SMC plays a pivotal role in the collective decision-making process, allowing UAVs to share insights from their individual data sets without compromising data privacy. This collaborative approach facilitates the detection of sophisticated security threats that may span across multiple UAVs and ensures that the system operates effectively in real-time, adapting to evolving security challenges within the Internet of Unmanned Aerial Vehicles (IoUV) ecosystem.  
Algorithm 3 clearly describes the functionality of SCM in our proposed model.  
```
Data: Encrypted dataset \(E_{i}\) from UAV \(i\) Result: Encrypted output \(E_{\text{out}}\)
1 Input: Receive encrypted datasets \(E_{i}\) from all UAVs;
2 Initialize: Set \(E_{\text{out}}\) to empty encrypted data;
3 forachUAV \(i\) in the networkdo
4 Perform secure computation on \(E_{i}\) using cryptographic protocols (see Equation (6));
5 Aggregate: Add the result of secure computation to \(E_{\text{out}}\) (see Equation (7));
6
7 end for
8 Output: Encrypted output \(E_{\text{out}}\);
```  
**Algorithm 3** Secure Multi-party Computation Algorithm  
The secure multi-party computation algorithm facilitates data exchange and collaborative computations using encrypted datasets, producing the encrypted collective output \(E_{\text{out}}\). This method enables collective learning without revealing individual UAVs' data, ensuring data privacy within the privacy-preserving ensemble. Real-time updates of the ensemble models with new data further enhance the IDS's effectiveness in dynamic environments, enabling robust threat detection and prevention.