# Policy-Based Smart Contracts Management for IoT Privacy Preservation
## 3 Proposed Method: Policy-Based Smart Contract Management for IoT Privacy Preservation
### Smart Contract Management Policies  
In our proposed model, a \"policy\" refers to a user-defined set of preferences that control shared data, access control, and privacy settings. This allows users to set their privacy preferences through policies, which, in turn, trigger smart contracts automatically based on predefined conditions. Our model leverages policies to empower users to manage their privacy preferences, enabling dynamic adjustments to data-sharing preferences. In this section, we detail the privacy policies that express the user's preferences and purposes, which are used to manage the predefined smart contracts. A privacy policy is represented by a set of privacy terms determining the private data and their purposes. The private data represent the different types of data from IoT devices tagged by the user as private. The purpose defines how private data could be used. For instance, users might want to share their blood glucose data only with their physician during a predetermined time slot via a secure channel. Formally, the user's privacy model can be formulated as follows:  
* A privacy policy is represented by the set of private data and their purposes as expressed by the user. We define \(\text{PT}=<\mu_{pd},\mu_{pr}>\) as privacy terms linking the private data pd and their purpose pr. * Private data \(\mu_{pd}\) are defined by the tuple (id,n, ty, cr), where id is the identifier of the IoT device (it could be any representation uniquely representing the IoT device such as its address), n is the name of the IoT device, ty is the data type, and cr is the criticality degree of the collected data used to prioritize the smart contracts when sending them to the blockchain network. The criticality degree may be assigned the value 1 (normal), 2 (precritical), or 3 (critical). * A purpose \(\mu_{pr}\) is defined by the tuple (tr, e, ti), where tr is the action identifying the purpose, e is the entity performing the purpose, and ti is an interval in which e must perform the action tr. Similar to a privacy policy, a preference is described by a set of predicates used to determine the time of triggering a smart contract, what type of data will be collected, and whether they want a private channel with the physician or not. We define a preference as \(\text{Fp}=(ts,<id>,pc,th)\), where \(ts\) is the time to trigger a smart contract, \(\text{<id>}\) is a set of privacy policies ids linked with the preference \(\text{Fp}\), pc is a boolean variable determining if the transaction must reserve a private channel or not, and th is the threshold defined by the user and involved parties, used to initiate the smart contract if the predetermined threshold is met. **Example: Patient health monitoring. ** We will apply the proposed model using the same scenario described in Section 3.3. We distinguished two policies, which are the policy of glucose (\(\mp_{\text{gplcy}}\)) value sensed by the IoT device and the policy of user claims (\(\mp_{\text{gplcy}}\)). We also considered two preferences: preference for triggering urgent smart contracts (\(\mp_{\text{gplcy1}}\)), and preference for triggering claims smart contracts (\(\mp_{\text{fplcy2}}\)). Table 2 maps the different policy variables with the user's preferences and purposes regarding glucose IoT device policy. The corresponding glucose-related policies were specified as presented below:  
\[\mp_{\text{gplcy}}=<\mu_{pd1},\mu_{pr1}> \tag{1}\]  
\[\mu_{pd1}=(\text{GlucoseMeasure}01,\text{CGM-002},\text{340 mmol/L},\text{2}) \tag{2}\]  
\[\mu_{pr1}=(\text{purpose-CGM002},\text{Samsung-A225G},\text{[0,5 min]}) \tag{3}\]  
\[\mp_{\text{fplcy1}}=([0,6,12,18],\mu_{\text{GlucoseMeasure}01},\text{false}, \text{300 mmol/L}) \tag{4}\]  
Similarly, Table 3 maps the different policy variables with the user's preferences and purposes regarding the user's claim policy.