# 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
\begin{table}
\begin{tabular}{l l l} \hline
**Variable** & **Mapping** & **Value** \\ \hline \(id\) & Identifier of the glucose sensor & GlucoseMeasure01 \\ \(n\) & Name of the glucose sensor & CGM-002 \\ \(ty\) & Blood glucose level & 340 mmol/L \\ \(cr\) & Criticality of the sensed blood sugar level & 2 \\ \(tr\) & Triggering glucose smart contracts & purpose-CGM002 \\ \(e\) & Mobile phone device & Samsung-A225G \\ \(ts\) & Every 6 h, the smart contract is triggered & [0,6,12,18] \\ \(ti\) & Time interval to send the smart contract & \(ts\) + 5 min \\ \(th\) & Threshold, when reached, the smart contract must be sent & 300 mmol/L \\  & immediately & false \\ \(pc\) & The need is for a fast transaction, so the transaction will be & false \\  & sent without reserving a private channel, and, therefore, & any physician could inspect the transaction and respond \\  & immediately & \\ \hline \end{tabular}
\end{table} 
Table 2: Mapping of the user’s privacy and preferences regarding glucose data. Then, the following claim-related policies were defined:  
\[\mp_{\text{cplcy}}=<\mu_{pd2},\mu_{p\prime 2}> \tag{5}\]  
\[\mu_{pd2}=(\text{C-001,NAN, \"FGBN\", 1}) \tag{6}\]  
\[\mu_{p\prime 2}=(\text{purpose-C001, Samsung-A225G, [0,5 min]}) \tag{7}\]  
\[\mp_{\text{fplcy2}}=(0,\text{PrivateClaim001, true, NAN}) \tag{8}\]  
These predefined policies (\(\mp_{\text{gplcy}}\), \(\mp_{\text{cplcy}}\),\(\mp_{\text{fplcy1}}\),\(\mp_{\text{fplcy2}}\)) were used by Algorithm 1 to manage smart contracts. ```
0:\(id,n,ty,cr,tr,e,ts,ti,th,pc,register,claim\) if\(ty\geq th\)then  Trigger Urgent smart Contract (id, n, ty, cr, e, false) \(\triangleright\) Urgent smart contract without booking private channel elseif(ty \(<th\)&& ts in [0,6,12,18])then  Trigger Routine smart Contract (id, n, ty, cr, e, false) \(\triangleright\) Routine smart contract without booking private channel \(timeStamp=[ts,ts+5 min]\) endif if (\(claim==true\)&& pc \(==true\))then  Trigger Claim smart Contract (id, n, ty, cr, e, true) \(\triangleright\) Claim smart contract communicated in private channel elseif(\(claim==true\)&& pc \(==false\))then  Trigger Claim smart Contract (id, n, ty, cr, e, false) \(\triangleright\) Claim smart contract communicated without booking private channel endif if\(register==true\)then  Trigger Register smart Contract() \(\triangleright\) Register smart contract endif
```  
**Algorithm 1** Smart contract management  
Algorithm 1 manages different types of smart contracts based on input parameters from the IoT devices or the user and conditions according the user preferences. It primarily focuses on triggering smart contracts related to claims, registration, and routine/urgent actions. **Parameters:** \begin{table}
\begin{tabular}{l l l} \hline
**Variable** & **Mapping** & **Value** \\ \hline \(id\) & Identifier of the user claim & C-001 \\ \(n\) & Name of the sensor & NAN \\ \(ty\) & Claim body & the bathroom during \\ \(cr\) & Criticality of the claim & 1 \\ \(tr\) & Triggering claim smart contracts & purpose-C-001 \\ \(e\) & Mobile phone device & Sumsung-A225G \\ \(ts\) & Immediate triggering of the smart contract & 0 (Immediate) \\ \(ti\) & Time interval to send the smart contract & \(ts+5\min\) \\ \(th\) & Threshold when reached, the smart contract must be sent & NAN \\  & immediately \\ \(pc\) & The need is for a private channel so only their physician & true \\  & could inspect the transaction and respond to them & \\ \hline \end{tabular}
\end{table} 
Table 3: Mapping of the user’s privacy and preferences regarding their claims. The different parameters are explained in Tables 2 and 3. The _register_ and _claim_ parameters are provided by the user to initiate the register and claim smart contracts, respectively. These smart contracts are not automatically triggered but require explicit user action to execute. **Logic Flow:**  
* **Threshold Check**: If _ty_ (blood glucose level) is greater than or equal to the threshold _th_, an urgent smart contract is triggered without booking a private channel.