# A TEE-Based Federated Privacy Protection Method: Proposal and Implementation
## 3 Method Introduction
### Introduction of the Privacy Protection Model  
In Section 3.1, the basic idea of privacy protection has been shown. In this section, we first formally describe the capabilities of Intel SGX and then build a privacy enhancement method for federated learning based on it. The trusted application e is defined as Formula (5). The trusted application e includes the corresponding initialization program code and configuration. The program code includes data and source code. The configuration includes the program startup point, memory access range, and access control information. \[ \begin{split} e:=<init_{e}, config_{e}>\\ init_{e}:=<code,code_{sha256},data,data\_sha256>\\ config_{e}:=<entropy,vrange,acl>\end{split}  \tag{5}\]  
In Equation (5), \(code\_sha256\) and \(data\_sha256\) represent the SHA256 hash values of code and data, which are used for integrity verification when starting the Enclave, and establishing the trusted startup chain; \(entropy\) represents the entry function of the trusted application; \(orange\) represents the memory range of the trusted application; \(acl\) represents the access control list of the current trusted application. Suppose \(\sigma_{i}:\rightarrow\sigma_{i+1}\) represents the state set of trusted application \(e\) in state \(\sigma\), which comprises the program counter, virtual memory state, stack state, register state, and so on. We set \(I_{e}(\sigma),O_{e}(\sigma)\) as the input and output of \(e\). Then, the formal representation of the execution process is \(\sigma_{i}:\rightarrow\sigma_{i+1}\). Trusted metrics ensure that the Enclave starts correctly. We set \(\mu(e)\) as the metric value of the trusted application \(e\). If two Enclaves have the same metric value, the same execution state and output must be generated for the same input. There are two statements:  
Statement 1: For two Enclaves, after completing the credible measurement, if they have the same measurement values and inputs, their outputs and internal states must be the same. The formal description is as shown in Equation (6). \[ \begin{split}(1)\text{Preconditions}:&\forall \sigma_{1},\sigma_{2}\cdot init_{e_{1}}(E_{e_{1}}(\sigma_{1}))\wedge init_{e_{ 2}}(E_{e_{2}}(\sigma_{2}))\\ (2)\text{Result}:&\mu(e_{1})=\mu(e_{2})\Leftrightarrow E _{e_{1}}(\sigma_{1})=E_{e_{2}}(\sigma_{2})\end{split}  \tag{6}\]  
Statement 2: Further, if two Enclaves have the same initial states, which means that they must have the same metric values (see Equation (7)), they enter the Enclave the same number of times, and for each time they enter the Enclave, they are given the same inputs. As a result, they will reach the same Enclave states after each time they enter the Enclave, and finally gain the same outputs. The process is expressed as follows:  
\[ \begin{split}(1)\text{Preconditions}:&\forall \pi_{1},\pi_{2}.E_{e_{1}}(\pi_{1}[0])=E_{e_{2}}(\pi_{2}[0])\\ &\forall i.(curr(\pi_{1}[i])=e_{1})\Leftrightarrow(curr(\pi_{2}[ i])=e_{2})\\ &\forall i.(curr(\pi_{1}[i])=e_{1})\Rightarrow I_{e_{1}}(\pi_{1}[ i])=I_{e_{2}}(\pi_{2}[i])\\ (2)\text{Result}:&\forall i.E_{e_{1}}(\pi_{1}[i])=E_{ e_{2}}(\pi_{2}[i])\wedge O_{e_{1}}(\pi_{1}[i])=O_{e_{2}}(\pi_{2}[i])\end{split}  \tag{7}\]  
where \(curr(\sigma)=e\) represents the platform state when the current Enclave is in state \(\sigma\), and \(\pi\) represents a series of state sequences. Integrity is for the Enclave, which means that during the execution process, the attacker can only affect the input but cannot tamper with the execution instruction sequence. The formal description is as shown in Equation (8). \[ \begin{split}(1)\text{Preconditions}:&\forall\pi_{1},\pi_{2 }.E_{e_{1}}(\pi_{1}[0])=E_{e_{2}}(\pi_{2}[0])\\ &\forall i.(curr(\pi_{1}[i])=e)\Leftrightarrow(curr(\pi_{2}[i])=e) \\ &\forall i.(curr(\pi_{1}[i])=e)\Rightarrow I_{e}(\pi_{1}[i])=I_{e}( \pi_{2}[i])\\ (2)\text{Result}:&\forall i.E_{e}(\pi_{1}[i])=E_{e}( \pi_{2}[i])\wedge O_{e}(\pi_{1}[i])=O_{e}(\pi_{2}[i])\end{split}  \tag{8}\]  
Confidentiality is an essential feature of protecting data privacy.