# A New Blockchain-Based Multi-Level Location Secure Sharing Scheme
## 4 Our Proposed Scheme
### Our Proposed Scheme
#### 4.2.2 Location Record
\(LD_{n}\) can translate \(Z_{n}^{p}\) into the geographic coordinate by \(Translate^{-1}()\), which is the inverse function of \(Translate()\) in line 2. In order to prevent users from cheating by sending fake locations, many location-proof schemes [42; 43; 44; 45; 46] have been proposed. They focus on using BlueTooth or Wi-Fi technology to verify the authenticity of the user's location point. Here, we can use the location-proof schemes to ensure the authenticity of \(VE\) in \(Udrec_{LD}^{p}\). ```
0: The geographic coordinate of \(LP\): \(G^{p}\); The virtual location point of \(LP\): \(Z_{0}\); The secret key for p-th location update: \(k_{ud}^{p}\);
0: Bool variaable: \(Accept_{LP_{n}}\);
1:\(LP\) execute:
2:\(P^{p}=(x^{p},y^{p})\leftarrow Translate(G^{p})\);
3:\(\Delta x^{p}\gets P^{p}.x^{p}-Z_{0}.x_{0}\);
4:\(\Delta y^{p}\gets P^{p}.y^{p}-Z_{0}.y_{0}\);
5:\(VE\gets E(k_{ud}^{p},\Delta x^{p}||\Delta y^{p})\);
6:\(k_{ud}^{p+1}\leftarrow Hash(k_{ud}^{p}||Timestamp)\);
7:\(KeyHash\gets Hash(k_{ud}^{p+1})\);
8:\(Inf_{0 ud}\gets p||VE||KeyHash||Timestamp\);
9:\(Udrec_{LP}^{p}\gets PK_{LP}||Info_{ud}||Sig_{LP}\);
10:\(LP\) broadcasts \(Udrec_{LP}^{p}\) to all Miners;
11:\(LP_{n}\) execute:
12:initialize\(Accept_{LP_{n}}\leftarrow False\);
13:\(\Delta x^{p}||\Delta y^{p}\gets D(k_{ud}^{p},Udrec_{LP}^{p}.VE^{p})\);
14:\(Z_{n}^{p}\gets Udare(Z_{n},(\Delta x^{p},\Delta y^{p}))\);
15:\(k_{ud}^{p+1}=Hash(k_{ud}^{p}||Udrec_{LP}^{p}.Timestamp)\);
16:if\(Hash(k_{ud}^{p+1})=Udrec_{LP}^{p}.KeyHash\)then
17:\(Accept_{LP_{n}}\leftarrow\) Ture
18:endif
19:return\(Accept_{LP_{n}}\);
```

**Algorithm 5** Location update: pseudocode for computing location update record and updating location

### License Record

As mentioned above, to enable \(LD\)s with different access levels to obtain user location information with different precisions, we designed a smart contract to implement attribute-based access control. In this section, we illustrate how the smart contract \(SC\) implements attribute-based access control and records the license. We test \(SC\) on Remix Solidity IDE, a browser-based IDE that is frequently used to develop Ethereum smart contracts. As shown in Figure 4, the work of \(SC\) here is mainly composed of two parts. (1) \(LP\) and \(LD\), respectively, call \(SC\) to record \(LP\)'s policy and \(LD\)'s public attribute. If \(LP\) has a high-security requirement, \(LP\) can also record \(LD\)'s public key as the public attribute and corresponding access level in the policy. However, this will reduce the efficiency of access control and increase the gas consumption of the smart contract. (2) \(LD\) calls \(SC\) for \(LP\)'s location, where the input is the address (public-key) of \(LP\). \(SC\) judges \(LD\)'s level ID according to \(LP\)'s policy and \(LD\)'s public attribute, then records the license into the blockchain. In addition, \(LP\)s are allowed to call \(SC\) to modify the policy to change the access level of \(LD\)s. Note that if the policy is modified, \(LP\) must re-execute the initialization phase and location record phase for security before updating location, and \(LD\) also needs to obtain and verify the new virtual location data and the new secret key. The smart contract is publicly deployed in the blockchain by the initiator of the system. One can verify the authenticity of the license by checking which smart contract records it. We simulate the process that \(LP\) and \(LD\), respectively, call \(SC\) to record the policy and the public attributes, as shown in Figure 5. The policy indicates the access level of a certain type or specific \(LD\) to \(LP\)'s location. We also simulate the process by which the \(LD\)s call \(SC\) for \(LP\)'s location; the recorded license is shown in Figure 6.

There is still an unsolved problem of how to ensure the authenticity of \(LD\)'s recorded public attribute. Our approach is that \(LD\)s are required to provide relevant proof to an authority who is authorized by the system.