# DSVN: A Flexible and Secure Data-Sharing Model for VANET Based on Blockchain
## 4 System Design  
### System Flow  
The description of the symbols and abbreviations appearing in this paper are shown in Table 1.  
Figure 3: The key encryption key tree.  
As shown in Figure 4, the system has the following five main phases:  
1. System initialization: RSU inputs \(\lambda\) and \(U\) as parameters and invokes the initialization contract. The contract will execute algorithm 1 to generate \(PK\), \(MSK\), \(DPK\), and \(DSK\), and record them in the genesis block of CBN;
2. User registration: VDO (or DU) sends the registration request containing the user \(id\) and user attribute set \(S\) to RSU. Then, RSU verifies the authenticity and validity of the registration information and then invokes the user registration contract. The contract reads the \(PK\), \(MSK\) and \(DPK\) from CBN block and executes algorithm 2 to generate \(SK_{id}\), \(kek\), \(USK\) and \(KEK\). \(id\) and \(S\) are written to the block of CBN. Finally, RSU returns \(SK_{id}\) and \(kek\) to VDO as the result of successful registration;
3. Data upload: VDO uploads Data to IPFS via RSU. IPFS returns the retrieval code to the RSU. Then RSU generates M corresponding to the retrieval code and returns it to VDO as the result of data upload. VDO receives \(M\) and invokes algorithm 3 to generate the attribute-weighted access tree \(T^{*}\), and then invokes algorithm 4 to generate \(CT\). VDO sends \(CT\), \(G\) to RSU to invoke the data upload contract. The contract executes algorithm 5 to generate \(CT^{\prime}\), \(Hdr\) and writes the relevant information into the block of CBN. Finally, RSU broadcasts \(CT^{\prime}\) to DUs;
4. Data access: data user DU sends \(SK_{id}\) and \(CT^{\prime}\) to RSU. RSU invokes the data access contract. If DU satisfies the data access condition, the contract will execute algorithm 6 to calculate and get \(PDCT\) and send it to DU. Otherwise, the execution of the contract will be terminated by the execution failure of algorithm 6. Then, DU executes algorithm 7 to calculate \(\overline{\text{M}}\) and return it to RSU. After receiving \(\overline{\text{M}}\), RSU will read the data retrieval code and connect IPFS to download data. Finally, DU successfully accesses data;
5. User attribute revocation: RSU invokes the user attribute revocation contract with revoked user \(id\) and \(att\) as input. The contract calls algorithm 8 to update \(DPK\), \(DSK\) and outputs the updated \(KEK\). Then, contract reads the encrypted ciphertext \(CT^{\prime}\) associated with the user \(id\) in the CBN block and calls algorithm 9. The algorithm 9 updates \(Hdr\) and \(CT^{\prime}\), and writes the updated \(CT*\) on the new block in CBN. Finally, RSU broadcasts the updated \(CT*\) to DUs.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Symbols** & **Description** \\ \hline \(\lambda\) & Safety parameters \\ \(U\),\(S\) & System attribute set and user attribute set \\ \(PK\), \(MSK\) & System public key and private key \\ \(DPK\), \(DSK\) & Data public key and private key \\ \(id\), \(SK_{id}\) & User id and key \\ \(USK\) & Global parameters for user access \\ \(kek\) & Attribute Encryption Information \\ \(KEK\) & User attribute group encryption information \\ \(M\) & Data address information \\ \(T\),\(T^{*}\) & Access tree \\ \(CT\) & Pre-encrypted ciphertext \\ \(G_{x}\) & The attribute groups of attribute \(x\) \\ \(CT^{\prime}\), \(CT*\) & Encrypted ciphertext \\ \(Hdr\) & Encryption header \\ \(PDCT\) & Pre-decrypted ciphertext \\ \(\overline{\text{M}}\) & The decrypted data address information \\ \hline \hline \end{tabular}
\end{table}
Table 1: Description of Symbols.