# A New Blockchain-Based Multi-Level Location Secure Sharing Scheme
## 4 Our Proposed Scheme
### Our Proposed Scheme
#### 4.2.2 Location Record
In lines 5-7, \(Fnode\) sends the \(Info^{F}_{n}\) containing the ciphertext of the virtual location data \(Z_{n}\) and the verification data \(NODE_{n}\) to \(LD_{n}\). \(NODE_{n}\) is a set of the intermediate nodes in the Merkle tree, which is the verification data of data (\(n||Z^{{}^{\prime}}_{n}\)), as introduced in Section 3.2. In lines 9-10, after checking the license, \(LD_{m}\) sends the ciphertext of the secret key \(k^{p}_{ud}\) to \(LD_{n}\), \(p\) indicates that \(LP\) has updated its location for \(p-1\) times at this time. We describe how to update the secret key in Section 4.2.4. In lines 13-14, \(LD_{n}\) decrypts \(Loc_{n}\) of \(Info^{F}_{n}\) from \(Fnode\) and \(Info^{m}_{n}\) from \(LD_{m}\), obtains the virtual location area \(Z^{{}^{\prime}}_{n}\) and the secret key \(k^{p}_{ud}\). In lines 15-16, \(LD_{n}\) generates the leaf node \(node^{\prime}_{n}\), then uses \(node^{\prime}_{n}\) and \(NODE_{n}\) of \(Info^{F}_{n}\) to generate the root node \(root^{\prime}\) of \(VerMer\), \(MerRoot()\) denotes the function to generate the root node of a Merkle tree using two leaf nodes and a set of necessary intermediate nodes. In lines 17, \(LD_{n}\) verifies \(Z_{n}\) by checking whether \(root^{{}^{\prime}}\) is equal to the \(VerMer_{root}\) in \(Record_{LP}\). In lines 18-23, \(LD_{n}\) verifies \(k^{p^{\prime}}_{ud}\) by checking whether its hash value is equal to the \(KeyHash\) in \(Record_{LP}\) or in \(Udrec^{p}_{LP}\). \(Udrec^{p}_{LP}\) is generated and recorded into the blockchain in location update phase, which is illustrated in Section 4.2.4. ```
13:for\(i=0\); \(i\leq N\); \(i++\)do
14:\(node_{i}\leftarrow Hash(i||Z^{{}^{\prime}}_{i})\);
15:endfor
16:\(VerMer^{\prime}\gets MER(node^{\prime}_{0},node^{\prime}_{1}\),..., \(node^{\prime}_{N})\);
17:if\(VerMer^{\prime}_{root}=Record_{LP}.Info_{Re}.VerMer_{root}\)and\(Z^{{}^{\prime}}\) meets the condition (1) and (2) then
18:\(Accept_{Fnode}\leftarrow True\);
19:endif
20:return\(Accept_{Fnode}\);
21:LD execute:
22:initialize\(Accept_{LD}\leftarrow False\);
23:\(k^{1^{\prime}}_{ud}\gets Dec(SK_{LD},Info_{LD})\)
24:if\(Hash(k^{1^{\prime}}_{ud})=Record_{LP}.Info_{Re}.KeyHash\)then
25:\(Accept_{LD}\leftarrow True\);
26:endif
27:return\(Accept_{LD}\);
```

**Algorithm 4**_Cont._

#### 4.2.4. Location Update

In the location update phase, \(LP\) generates the location update record \(Udrec^{p}_{LP}\) and records it into the blockchain. \(LD\) that has obtained the virtual location data and the secret key \(k^{p}_{ud}\) can use \(Udrec^{p}_{LP}\) to update \(LP\)'s location; the details are shown in Algorithm 5. In line 2 of Algorithm 5, \(LP\) translates the geographic coordinate \(G^{p}\), usually expressed in terms of latitude and longitude, into the Cartesian coordinate, where \(p\) indicates that \(LP\) has updated its location for \(p-1\) times at this time. In lines 3-5, \(LP\) generates and encrypts the offset values \(\Delta x^{k}\) and \(\Delta y^{k}\), \(E()\) denotes the symmetric encryption function. In line 6, \(LP\) generates the hash value of \((k^{p}_{ud}||Timestamp)\) as the secret key \(k^{p+1}_{ud}\) for the next location update. \(LP\) broadcasts the location update record \(Udrec^{p}_{LP}\) containing the ciphertext of the offset values and the hash value of \(k^{p+1}_{ud}\) to the \(Miners\). \(Miners\) verify \(Record_{LP}\) by \(LP\)'s digital signature \(Sig_{LP}\), then record it into the blockchain. In lines 13-14, \(LD_{n}\) decrypts the ciphertext \(VE^{k}\) in the record \(Udrec_{LD}^{p}\), and updates \(Z_{n}\) with the vector \((\Delta x^{k},\Delta y^{k})\), \(D()\) and \(Udarea()\) denote the symmetric decryption function and the function to translate location data \(Z_{n}\) using a vector, respectively. In lines 15-17, \(LD\) generates \(k_{ud}^{p+1}\) and verifies it by checking whether the hash value of it is equal to \(KeyHash\) in \(Udrec_{LD}^{p}\). Finally, \(LD_{n}\) can confirm that \(LP\) is located in \(Z_{n}^{p}\).