# A Blockchain-Based Privacy-Preserving and Fair Data Transaction Model in IoT
## 4 System Model
### Workflow
The MDLDP algorithm is as follows (Algorithm 1):  
```
0:\(D_{i}\), \(\varepsilon_{i}\), \(L_{i}\)
0:\(G_{i}\), \(\alpha_{i}\)
1: Create array _indice_[\(L_{i}\)] for storing the index of dataset \(L_{i}\);
2: Create array _indice_[\(G_{ij}\)] storing the index of the perturbed data in dataset \(G_{ij}\);
3:\(p_{i}=\exp\{\varepsilon_{i}\}/(\exp\{\varepsilon_{i}\}+d_{i}-1)\);
4:for\(j\) 1 to h by 1 // independent perturbations of the original dataset \(D_{i}\) h times
5:for\(z\) 1 to \(d_{i}\) by 1 // Randomly perturb each element in dataset \(D_{i}\) with probability \(1-p_{i}\)
6:if\(\text{rand}()<p_{i}\)
7:\(\xi_{ij}=\text{value}_{ij2}\); // \(\text{value}_{ij2}\) refers to the true value in \(D_{i}\), \(\xi_{ij2}\) is an element in \(G_{ij}\)
8:else
9:\(\xi_{ij2}=\text{rand}(D_{i})/\text{value}_{ij2}\);
10:end
11: Obtaining perturbed dataset \(G_{ij}\);
12:\(\alpha_{ij}=intersect\Big{(}indice\Big{[}G_{ij}\Big{]},indice[L_{i}]\Big{)}/l_{i}\); // Calculate degree of privacy protection \(\alpha_{ij}\) to evaluate the effectiveness of this perturbation
13:end
14: Take \(\alpha_{ij}\) the result of the largest perturbation as \(G_{i}\) and \(\alpha_{i}\);
15:return\(G_{i}\), \(\alpha_{i}\). ```  
**Algorithm 1** The MDLDP Algorithm  
Data transaction stage: Initially, the data provider \(P_{s}\) aggregates all data from providers (as in Process 3) and negotiates with data consumer \(P_{c}\) regarding fees and data sharing, primarily encompassing reward details. Following this, \(P_{c}\) and \(P_{s}\) generate their respective key pairs \((pk_{c},sk_{c})\) and \((pk_{s},sk_{s})\) using the public key \(APK\). \(P_{c}\) generates his true signature \(\sigma_{i}\) based on \(Sign(pp,sk_{c},m)\). \(P_{c}\) then produces a verifiable encrypted signature \(\sigma_{c}^{VES}\) using \(VESSign(sk_{c},m,APK)\) to sign the transaction agreement. Anyone can validate the validity of the signature via the arbitrator's provided public key \(APK\). But without the help of the \(P_{c}\) or the arbitration committee, it is impossible to extract the true signature \(\sigma_{i}\). Once the agreement is signed and validated, \(P_{s}\) delivers the perturbed data set \(G=\sum_{i=1}^{n}G_{i}\) to \(P_{c}\). After confirming the \(G\) dataset, \(P_{s}\) decrypts the encrypted signature \(\sigma_{c}^{VES}\) using its private key \(sk_{c}\) and extracts the true signature \(\sigma_{i}\) to validate the agreement and complete the transaction (as in Process 5). Arbitration stage: If \(P_{c}\) acts deceitfully during the transaction, refusing to decrypt the encrypted signature \(\sigma_{c}^{VES}\) to extract the true signature \(\sigma_{i}\) to complete the agreement, i.e., paying compensation. Data providers \(P_{s}\) can seek assistance from arbitration committees. any \(t\) members within the arbitration committee can utilize Equation (3) to reconstruct the arbitration private key \(ASK\) (as in Process 6). Based on the characteristics of verifiable encrypted signature technology, the private key \(ASK\) can directly extract the true signature \(\sigma_{i}\) of data consumer \(P_{c}\) from the encrypted signature \(\sigma_{c}^{VES}\) (as in Process 7). Forcing data consumer \(P_{c}\) to execute agreements to pay compensation. Dishonest trading behavior will result in the confiscation of margin as compensation for honest traders and arbitrators.